Massive Scale

Posted: October 6, 2009

Now that you know how to use the power of the for loop to make Processing repeat the execution of some code, your project for the week is to explore the concept and impact of massive scale.

This means you should have hundreds or thousands of things being drawn on the screen every time draw() is called.

Note that performance will become a problem at some point and you must deal with that as a programmer. Experiment. You may choose to use classes or not in this project.

We’ll share our explorations in class on Friday, October 9.

int blocksize;

 void setup() {
   size(460,200);
   blocksize = 20;
   noStroke();
 }

 void draw() {
   for(int y=0; y<height; y+=blocksize) {
     for(int x=0; x<width; x+=blocksize) {
       fill(random(0,64),random(128,223),random(223), 30);
       rect(x,y,blocksize,blocksize);
     }
   }
   int specialX = mouseX - (mouseX % blocksize);
   int specialY = mouseY - (mouseY % blocksize);
   fill(255);
   rect(specialX, specialY, blocksize, blocksize);
 }