/** * A hypnotic rectangle. * *

Elie Zananiri
* CART 253, Winter 2008

*/ void setup() { size(400, 400); rectMode(CENTER); noStroke(); noLoop(); } void draw() { boolean mode = true; for (float i=1.0; i > 0; i -= 0.05) { hypnoRect(i, mode); mode = !mode; } } void hypnoRect(float ratio, boolean mode) { // draw the middle rectangle fill(mode?0:255); rect(width/2, height/2, width*ratio, height*ratio); // draw the corner rectangles fill(mode?255:0); rect(width*1/4, height*1/4, width*ratio/2, height*ratio/2); rect(width*1/4, height*3/4, width*ratio/2, height*ratio/2); rect(width*3/4, height*3/4, width*ratio/2, height*ratio/2); rect(width*3/4, height*1/4, width*ratio/2, height*ratio/2); }