//@ http://scriptdemo.blogspot.com float myAngle, myScale, myAlpha0, myAlpha; float shiftX, shiftY; int rr,gg,bb; // to control the shape of spiral float minScale, dAngle, coefScale; boolean isLine=false; boolean isColor=true; void setup() { size(500,500); shiftX=width/2; shiftY=height/2; myAngle=0; myScale=1.0; minScale=0.01; coefScale=0.99; myAlpha0=8; dAngle=PI/50; noStroke(); background(255); frameRate(30); smooth(); } void draw() { while(myScale>minScale) { pushMatrix(); myAngle=myAngle+dAngle; myScale=myScale*coefScale; translate(shiftX,shiftY); rotate(myAngle); scale(myScale); if (isColor) { rr=ceil(255*sin(myAngle)); gg=ceil(255*cos(myAngle)); if (rr<=0) rr=rr+255; if (gg<=0) gg+=255; bb=(rr+gg)%256; } else { rr=10; gg=10; bb=10; if (isLine) myAlpha0=max(myAlpha0,20); } myAlpha=min(myAlpha0*(ceil(myAngle/TWO_PI)),255); if (isLine) { stroke(rr,gg,bb,myAlpha); noFill(); line(-1*shiftX,shiftY,shiftX,shiftY); } else { noStroke(); fill(bb,gg,rr,myAlpha); rect(-1*shiftX,shiftY,width,height); } popMatrix(); } } void mouseClicked() { isLine=!isLine; myAlpha=myAlpha0; myScale=1; myAngle=random(-PI,PI); background(255); } void mouseDragged() { isColor=!isColor; myAlpha=myAlpha0; myScale=1; myAngle=random(-PI,PI); background(255); } |
Friday, August 19, 2011
[Processing] spiral demo using Processing
Labels:
graphic,
Processing,
script,
spiral
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment