> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.nrVT7J3DTiY/rev.297
 * 
 * authors: 
 *   Zach Denton

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



// This sketch builds on a prior work, "sphidron arms", created by Janos Erdos Jr. & [unnamed author]
// http://studio.sketchpad.cc/sp/pad/view/ro.9KvejRSsEh7K5/rev.1341

int t = 0;
int period = 500;
float H;
float R;

void setup() {     
    size(400, 400); 
}

void duplaspiral(float x1, float y1, float x2, float y2){
    final float d = dist(x1,y1,x2,y2), a = atan2(x1-x2,y1-y2);
    final float phi = 1.6180339887;
    final float A = 2.15, B=1;

    for(int radius = 0, d1 = d/phi, d1log=A*log(d1*B); radius < d1; radius+=1){
            float aa = a+A*log(radius*B)-d1log-PI;
            vertex(x1+sin(aa)*radius, y1+cos(aa)*radius);
    }

    for(int d1 = d-d/phi, d1log=A*log(d1*B), radius = d1; radius > 0; radius-=1){
            float aa = a+A*log(radius*B)-d1log;
            vertex(x2+sin(aa)*radius, y2+cos(aa)*radius);
    }
}
 
void arm(float x1, float y1, float x2, float y2, float rotation){
    pushMatrix();
    rotate(rotation);
    beginShape(POLYGON);
    duplaspiral(x1,y1,x2,y2);
    duplaspiral(x2,y2,x1,y1);
    endShape();  
    popMatrix();   
}
 
void draw() {
   background(280,112,132);
   
   stroke(255);
    
    noStroke();
    fill(44);
 //   arm(width/2, height/2, mouseX, mouseY);
    translate(width/2, height/2);
    
    if (t < period) {
        H = (t%period)*((TWO_PI/3)/period);
        R = 0;
    } else {
        H = TWO_PI/3;
        R = -(t%period)*(TWO_PI/period);
    }
    
    arm(sin(H)*100, cos(H)*100, sin(H+H)*100,cos(H+H)*100, R);
    fill(255);
    arm(sin(H+H)*100, cos(H+H)*100, sin(0)*100,cos(0)*100, R);

    fill(123);
    arm(sin(0)*100, cos(0)*100, sin(H)*100,cos(H)*100, R);

    t++;    
    
}