Advertisement
salahzar

rappresenta grafico

Apr 24th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string simpleEncode(list values, float min, float max)
  2. {
  3.     string text = "";
  4.     float range = 244 / (min - max);//4 * 61
  5.     integer index = -llGetListLength(values);
  6.  
  7.     do
  8.     {
  9.         integer type = llGetListEntryType(values, index);
  10.         if(type == TYPE_FLOAT || type == TYPE_INTEGER)
  11.             text = llGetSubString(llIntegerToBase64((integer)(range * (min - llList2Float(values, index)))), 4, 4) + text;
  12.         else
  13.             text = "_" + text;
  14.  
  15.         ++index;
  16.     }
  17.     while (index);
  18.  
  19.     return text;
  20. }
  21.  
  22. string cleanup(float value)
  23. {
  24.     string str = (string)value;
  25.     if(value >= 10.0)
  26.         return llGetSubString(str, 0, -8);
  27.  
  28.     integer i = -1;
  29.     while(llGetSubString(str, i, i) == "0")
  30.         --i;
  31.  
  32.     if(llGetSubString(str, i, i) == ".")
  33.         --i;
  34.  
  35.     return llGetSubString(str, 0, i);
  36. }
  37.  
  38. string chartUrl(list values, list captions, integer yDivisions)
  39. {
  40.     integer min = llFloor(llListStatistics(LIST_STAT_MIN, values));
  41.     integer max = llCeil(llListStatistics(LIST_STAT_MAX, values));
  42.  
  43.     string url = "http://chart.apis.google.com/chart"
  44.                + "?chs=200x125"
  45.                + "&chd=s:" + simpleEncode(values, min, max)
  46.                + "&cht=lc"
  47.                + "&chxt=x,y"
  48.                + "&chxl=0:";
  49.  
  50.     integer index = -llGetListLength(captions);
  51.     do
  52.     {
  53.         url += "|" + llEscapeURL(llList2String(captions, index));
  54.         ++index;
  55.     }
  56.     while (index);
  57.  
  58.     url += "|1:";
  59.     ++yDivisions;
  60.     float range = max - min;
  61.  
  62.     index = 1;
  63.     do
  64.     {
  65.         url += "|" + cleanup(((index * range) / yDivisions) + min);
  66.         ++index;
  67.     }
  68.     while (index <= yDivisions);
  69.  
  70.     return url;
  71. }
  72.  
  73. default
  74. {
  75.     state_entry()
  76.     {
  77.        
  78.         string url=
  79.             chartUrl([8,8,3,2,1,5,3,2,2,3,1,4,6,3,4,7,5,6,5,5,4,5,5,6,4], ["4AM", "4PM", "4AM"], 0);
  80.  string URLTexture=osSetDynamicTextureURL("", "image" ,url  , "", 600 );
  81.    
  82.     }
  83.  
  84.     touch_start(integer total_number)
  85.     {
  86.         llSay(PUBLIC_CHANNEL,
  87.             chartUrl([8,8,3,2,1,5,3,2,2,3,1,4,6,3,4,7,5,6,5,5,4,5,5,6,4], ["4AM", "4PM", "4AM"], 0));
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement