Facebook
From zzb, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 108
  1. background(200);
  2. size(300,300);
  3. IntList inventory;
  4. inventory = new IntList();
  5. inventory.append(23);
  6. inventory.append(6);
  7. inventory.append(33);
  8. inventory.append(12);
  9. inventory.append(41);
  10. inventory.append(4);
  11. inventory.append(5);
  12. inventory.append(35);
  13. inventory.append(15);
  14. inventory.append(22);
  15. int sum=0;
  16. stroke(130);
  17. for(int i=0; i<=10; i++){
  18.   line(width/30+i*7*width/75,height/30,width/30+i*7*width/75,29*height/30);
  19.   line(width/30,height/30+i*7*height/75,29*width/30,height/30+i*7*height/75);
  20. }
  21. stroke(0);
  22. for(int count=0; count<10; count++){
  23.   int leng=inventory.get(count);
  24.   sum=sum+leng;
  25.   fill(30,60+10*count,30);
  26.   rect(width/30,height/30+count*7*height/75,leng*width/45,7*height/75);
  27.   noFill();
  28. }
  29.  
  30. float mean = sum/10;
  31. line(width/30,height/60,width/30,59*height/60);
  32. line(width/60,29*height/30,59*width/60,29*height/30);
  33. stroke(255,0,0);
  34. strokeWeight(3);
  35. line(width/30+(mean*width/45),height/30,width/30+(mean*width/45),29*height/30);
  36.  
  37. save("assignment2.png");