Swirling Vortex
A swirling vortex exploring the golden mean, phi and the arrangement of almost all things that grow.
It’s interactive:
Clicking towards the left spaces the dots more closely, to the right, further apart. Click towards the top for smaller dots, towards the bottom for bigger. Each click toggles between expansion and compression. Easter egg: “c” toggles between black and white and a random color.
Here’s the sourcecode:
// Rotation of items at 137.5 degrees
// Golden Rectangle sized canvass naturally.
float phi=1.61725;
float dimX=600,dimY=dimX/phi;
float distance=3; // Spreading of the dots
float newx=dimX/2;
float newy=dimY/2;
int diameter=50; // Width of the outer dots.
float growth=1; // Speed of growth
int numSeeds=144 ; // number of seeds should be a fibonacci number.
float rot=0;
int i;
float direction=-1;
float spinAmt=1;
boolean randomColor=false; // Uses black and white by default.
color mColor=color(255,255,255);
void setup(){
size(int(dimX),int(dimY),JAVA2D);
smooth();
fill (mColor);
stroke(1,255);
placeSpots();
}
void placeSpots() {
fill (mColor);
for(i=1;i<numSeeds;i++){
rot+=radians(137.5);
newx=(i*distance*sin( rot));
newy=(i*distance*cos( rot));
ellipse(newx,newy,diameter*(i*.01),diameter*(i*.01));
}
}
void draw(){
fill(0,0,0,255);
// rect(0,0,dimX,dimY);
translate(dimX/2,dimY/2);
rotate(spinAmt);
rot=0;
spinAmt+=radians(137.5)*direction;
translate(dimX/2,dimY/2);
placeSpots();
}
int randomSign(){ //returns +1 or -1
float num = random(1);
if(num<.5)
return -1;
else
return 1;
}
void mouseMoved(){
distance=(mouseX/70)+1;
diameter=mouseY/2+5;
placeSpots();
//direction*=-1;
}
void keyPressed() {
if (key == 'c') {
// pressing c will toggle color and B&W
randomColor=!randomColor;
if (!randomColor){
mColor=color(255,255,255);
stroke(100,100,100,150);
}
else {
mColor=color(random(255),random(255),random(255));
stroke(100,100,100,150);
}
}
if (key == 's') {
// pressing s will take a picture. Won't work on JS version.
saveFrame("output##.png");
}
}
And a few cool looking images along the way.






Leave a Reply