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