Facebook
From Alvaro ValiƱo, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 70
  1. size(500,500);
  2.  
  3. int W = width;
  4. int H = height;
  5.  
  6.  
  7. // variables
  8. int n_circles = 5;
  9. int x_amp = W  / n_circles;
  10. int y_amp = H / n_circles;
  11. int c = 0;
  12. int n = 1;
  13. int t = 1;
  14.  
  15. // Grid
  16. for(int g_y = y_amp/2 ; g_y <= H  - y_amp/2 ; g_y = g_y + y_amp){
  17.   for(int g_x = x_amp/2 ;g_x <= W - ((x_amp/2) * t); g_x = g_x + x_amp){
  18.     if(c % 2 ==0){
  19.       fill(0,0,175);
  20.     } else{
  21.       fill(175,0,0);};
  22.     ellipse(g_x,g_y,x_amp,y_amp);
  23.     fill(0);
  24.     textSize(16);
  25.     textAlign(CENTER);
  26.     text(n, g_x, g_y);
  27.     n = n + 1;
  28.   }
  29.   c = c + 1;
  30.   t = t + 2;
  31. }
  32.  
  33.  
  34. save("Assignment4_part2.png");
  35.