/* "Seed Wind Blossom" small version Rob Weinberg 3/14/08 spindrift.org */ int numSpinBoxes = 15; SpinBox mySpin[] = new SpinBox[numSpinBoxes]; color spinFill = color (255, 255, 255); int colorSeed = 100; void setup (){ size(500,300); frameRate(125); background(0); //colorMode(HSB, 255); //create SpinBox instances but do not draw them yet for (int i=0; i < mySpin.length; i++){ //try variations on the spinFactor //determines angle of rotation each fan with respect to its neighbors int spinFactor = 15*i; mySpin[i] = new SpinBox ( 85+20*i, 100+7*i, 6, 120, spinFactor ); } } void draw(){ noStroke(); //The second number in "fill" determines amount of ghosting fill (0,14); rect(0,0,500,300); colorMode (HSB, 300); // //Draw all of the the instances // //Send a rush of color through if (int(random(5)) == 4){ colorSeed += int(random(-10,10)); //tweak hue if (colorSeed > 260) { // leave room for random increment below colorSeed = 260; } if (colorSeed <40) { // leave room for random increment below colorSeed = 40; } } //Rotate and decide fill color (if any) on all spinBoxes for (int i=0; i < mySpin.length; i++){ spinFill = color (colorSeed + i*6, 150, 200); mySpin[i].spinMe(); } } class SpinBox { int x; int y; int xwid; int ywid; int spinAngle; //constructor - does not draw anything yet SpinBox (int x, int y, int xwid, int ywid, int spinAngle) { //x and y will only be used in "translate" this.x = x; this.y = y; this.xwid = xwid; this.ywid = ywid; //initial angle of rotation - will increment this later this.spinAngle = spinAngle; } //translate, rotate, and draw the instance void spinMe (){ colorMode (HSB, 300); fill(spinFill, 80); //Increase the angle of rotation this.spinAngle++; //Don't increment forever if (this.spinAngle == 300){ this.spinAngle = 0; } //bring back standard matrix pushMatrix(); translate(this.x, this.y); //draw this instance with incremented angle of rotation rotate(PI/(150)*this.spinAngle); //draw the instance rect (0-this.xwid/2, 0-this.ywid/2, this.xwid*mouseX/120 + 2, this.ywid*mouseY/120 + 2); //return matrix as you found it popMatrix(); } }