Facebook
From Ruslanna, 2 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 88
  1. size(300,300);
  2. background(220);
  3.  
  4. int graphX = width/10;
  5. int graphY = height/10;
  6. int rectH = (height-2*graphY)/10;
  7. int factor = (width-2*graphX)/100;
  8.  
  9. int a = factor*50;
  10. int b = factor*75;
  11. int c = factor*48;
  12. int d = factor*39;
  13. int e = factor*82;
  14. int f = factor*55;
  15. int g = factor*65;
  16. int j = factor*33;
  17. int l = factor*77;
  18. int m = factor*100;
  19.  
  20. for(int i=graphX; i<(width-graphX);i=i+rectH){
  21.   for(int k=graphY;k<(height-graphY);k=k+rectH){
  22.     stroke(150);
  23.     fill(220);
  24.     rect(i,k,rectH,rectH);
  25.   }  
  26. }
  27.  
  28. stroke(0);
  29. strokeWeight(2);
  30. line(graphX,graphY/2,graphX,(height-graphY/2));
  31. line(graphX/2,(height-graphY),(width-graphX/2),(height-graphY));
  32.  
  33.  
  34. graphY = height-graphY-rectH;
  35. fill(0,0,220);
  36. rect(graphX,graphY,a,rectH);
  37. graphY = graphY-rectH;
  38. fill(0,0,210);
  39. rect(graphX,graphY,b,rectH);
  40. graphY = graphY-rectH;
  41. fill(0,0,200);
  42. rect(graphX,graphY,c,rectH);
  43. graphY = graphY-rectH;
  44. fill(0,0,180);
  45. rect(graphX,graphY,d,rectH);
  46. graphY = graphY-rectH;
  47. fill(0,0,160);
  48. rect(graphX,graphY,e,rectH);
  49. graphY = graphY-rectH;
  50. fill(0,0,140);
  51. rect(graphX,graphY,f,rectH);
  52. graphY = graphY-rectH;
  53. fill(0,0,120);
  54. rect(graphX,graphY,g,rectH);
  55. graphY = graphY-rectH;
  56. fill(0,0,100);
  57. rect(graphX,graphY,j,rectH);
  58. graphY = graphY-rectH;
  59. fill(0,0,85);
  60. rect(graphX,graphY,l,rectH);
  61. graphY = graphY-rectH;
  62. fill(0,0,60);
  63. rect(graphX,graphY,m,rectH);
  64.  
  65. float mean = (a+b+c+d+e+f+j+g+l+m)/10.0;
  66. float lineX = graphX + mean;
  67. stroke(240,0,0);
  68. line(lineX, graphY, lineX, (height-graphY));
  69. fill(220,0,0);
  70. text("mean = "+mean,width/2,(height-graphY/2));
  71.  
  72. save("assignment_2.png");