triangles
@author
int LOOP = 200;
float radius = 70;
void setup(){
size(500, 500);
stroke(200);
strokeWeight(3);
fill(204, 204, 0);
}
void draw(){
background(0, 0, 30);
translate(width / 2.0, height / 2.0);
for(int i = 0; i < 3; i++){
pushMatrix();
float angle = radians(120 * i);
rotate(angle);
translate(radius * cos(radians(-30)), radius * sin(radians(-30)));
rotate(map(calcQuad(float(frameCount % LOOP) / LOOP), 0, 1.0, 0, radians(240)));
float edge = radius * sqrt(3);
triangle(0, 0, -edge / 2, -edge * sqrt(3) / 2, -edge, 0);
popMatrix();
}
}
float calcQuad(float v){
if(v < 0.5){
return 2.0 * v * v;
} else {
return -2.0 * (v - 1.0) * (v - 1.0) + 1.0;
}
}