/* "Seed Wind Blossom" large window version Rob Weinberg 3/14/08 spindrift.org */ int numSpinBoxes = 20; SpinBox mySpin[] = new SpinBox[numSpinBoxes]; color spinFill = color (255, 255, 255); boolean doRandomFills = false; int colorSeed = 100; void setup (){ size(820,700); frameRate(125); background(0); //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+30*i, 130+10*i, 6, 150, spinFactor ); } } void draw(){ noStroke(); //The second number in "fill" determines amount of ghosting fill (0,14); rect(0,0,820,700); colorMode (HSB, 300); // //Draw all of the the instances // //Send a rush of color through if (int(random(5)) == 4){ doRandomFills = true; 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; } println (colorSeed); } //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(); //draw this instance always to the same place //translate(this.x + mouseX/10, this.y + mouseY/10); 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(); } }