Advertisement
xeromino

eyal

Aug 9th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. int num, gap;  // declare the variables as global variables
  2. float cellsize_X, cellsize_Y, offsetX, offsetY; // declare the variables as global variables
  3.  
  4. void setup() {
  5.   size (600, 600);
  6.   // rectMode(CORNER); > not necessary, it's the default
  7.   noStroke();
  8.   randomSeed(hour() + minute() + second() + millis()); // that's an interesting way to create the random seed! :)
  9.  
  10.   num = 25;  // no need for int(25) here! also, all these variables need only to be set once, not over and over again (also that works too in this case)
  11.   gap = 0; // idem
  12.  
  13.   cellsize_Y = ( height - (num +1) * gap ) / (float) num;
  14.   cellsize_X = ( width - (num +1) * gap ) / (float) num;
  15.  
  16.   offsetX = cellsize_X/16.0;
  17.   offset = cellsize_Y/16.0;
  18. }
  19.  
  20. void draw() {
  21.   background (255);
  22.  
  23.   for (int i=0; i<num; i++) {
  24.     for (int j=0; j<num; j++) { // you had i<num here! That's why you didn't see any rectangles!
  25.       fill (255, 57, 57, 180);  // do not need a value higher than 255 as a value here
  26.       rect(gap * (i+1) + cellsize_X * i, gap * (j+1) + cellsize_Y * j, cellsize_X, cellsize_Y);
  27.     }
  28.   }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement