Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int num, gap; // declare the variables as global variables
- float cellsize_X, cellsize_Y, offsetX, offsetY; // declare the variables as global variables
- void setup() {
- size (600, 600);
- // rectMode(CORNER); > not necessary, it's the default
- noStroke();
- randomSeed(hour() + minute() + second() + millis()); // that's an interesting way to create the random seed! :)
- 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)
- gap = 0; // idem
- cellsize_Y = ( height - (num +1) * gap ) / (float) num;
- cellsize_X = ( width - (num +1) * gap ) / (float) num;
- offsetX = cellsize_X/16.0;
- offset = cellsize_Y/16.0;
- }
- void draw() {
- background (255);
- for (int i=0; i<num; i++) {
- for (int j=0; j<num; j++) { // you had i<num here! That's why you didn't see any rectangles!
- fill (255, 57, 57, 180); // do not need a value higher than 255 as a value here
- rect(gap * (i+1) + cellsize_X * i, gap * (j+1) + cellsize_Y * j, cellsize_X, cellsize_Y);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement