Compiled with Processing (www.proce55ing.org)
Rick Companje (www.companje.nl)
October 1st, 2005
int xMax, xMin, yMax, yMin, xCenter, yCenter;
int x=0,y=0;
int xr=1,yr=1;
float rMin,rMax,r,rr=.1;
void setup() {
framerate(20);
size(200,200);
xMin = -width/2; xCenter = 0; xMax = width/2;
yMin = -height/2; yCenter = 0; yMax = height/2;
rMin = 4*PI; rMax = 12*PI; r=rMin;
}
void draw() {
background(100);
translate(xMax,yMax);
stroke(50);
line(xMin,0,xMax,0);
line(0,yMin,0,yMax);
spiral(0,0,getMouseX(),getMouseY(),r);
x+=xr; y+=yr; r+=rr;
if (r>rMax || r<rMin) rr=-rr;
if (x>xMax || x<xMin) xr=-xr;
if (y>yMax || y<yMin) yr=-yr;
}
int getMouseX() { return mouseX-width/2; }
int getMouseY() { return mouseY-height/2; }
void mouseMoved() { r=rMax; }
void spiral(float xc,float yc,float xm,float ym,float rmax) {
float x,y,xp=0,yp=0;
float d=dist(xc,yc,xm,ym);
float r=atan2(ym, xm) + rmax;
while (r>0) {
x=-sin(r-HALF_PI)*(r/rmax)*d + xc;
y= cos(r-HALF_PI)*(r/rmax)*d + yc;
stroke(255-255*(r/rmax));
line(0,0,x,y);
stroke(255);
line(x,y,xp,yp);
xp=x;
yp=y;
r-=.02;
}
}
