Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- size(800, 800); // Canvas size
- rectMode(CORNER); // Jerome: not necessary, CORNER is the default for rectangles
- noStroke(); // Jerome: this tells Processing not to draw lines or edges
- noLoop(); // Jerome: so you really want the program to run only once?
- frameRate(1); // Jerome: not necessary after having used noLoop() to have the sketch run only once
- randomSeed(minute()+second()); // Jerome: not necessary either
- }
- void draw() {
- background(120); // Clear the screen to grey
- //25 squares
- int num = 5; //select 25 squares each frame
- int gap=(int) random(1, 20); //select a random gap between each square
- //calculate the size of each square for the giving nomber of square and gap between them
- float cellsize = ( width - (num + 1) * gap ) / (float)num;
- //print out the size of each square
- println("cellsize = " + cellsize);
- //calculate shadows offset
- float offsetX = cellsize/10.0 + (int) random (1, 2);
- float offsetY = cellsize/10.0 + (int) random (1, 2);
- for (int i=0; i<num; i++) {
- for (int j=0; j<num; j++) {
- fill(100, 100); //shadow color
- rect(gap * (i+1) + cellsize * i + offsetX, gap * (j+1) + cellsize * j + offsetY, cellsize, cellsize);
- } // Jerome: you had forgotten this one, you also need to close a previous { with a corresponding }
- } // Jerome: you had forgotten this one, you also need to close a previous { with a corresponding }
- } // Jerome: you had forgotten this one, you also need to close a previous { with a corresponding }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement