java - Processing mapping always out of bounds -


i'm trying make graph in processing, keep getting "arrayindexoutofbounds" error. having hard time understanding concept of map() syntax, clear me? i'm not sure every number supposed stand within map(x,y,z,a,b);

string[] name = {   "1st:",   "5th:",   "10th:",   "15th:",   "20th:",   "25th:",   "30th:" };  int[] temperature = {   81,   82,   84,   85,   87,   88,   90 };   void setup(){   size(200,200); }  void draw(){   int x=0;   for(int i=0;i<10;i++){      if(mousex>x && mousex<=x+40){       fill(255,40,40);     }else{       fill(50);     }      float h = map(temperature[i], 0, 100, 0, 200);      rect(x+4,height-h,32,h);      x+=40;   }  } 

your arrays have 7 elements, iterate 10 times.

for(int i=0;i<10;i++){   ...   float h = map(temperature[i], 0, 100, 0, 200);  } 

either fill arrays additional 3 elements, or better: instead of number 10 should use i < temperature.length() condition in for-loop.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -