/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.NYrzpzg65G1/rev.1244
*
* authors:
* erdely daniel
*
* Janos Erdos Jr.
* dani
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
boolean looping = true;
void setup() {
size(600, 600);
}
void spiral(){
final float ratio = 0.9, delta = 0.1;
float angle = 0.01*mouseX, radius = 120;
stroke(255);
strokeWeight(1);
while(radius > 2){
line(
sin(angle)*radius,
cos(angle)*radius,
sin(angle+delta)*radius*ratio,
cos(angle+delta)*radius*ratio
);
angle += delta;
radius *= ratio;
}
}
void spiral12(){
pushMatrix();
for(int i = 0; i < 12; i++){
spiral();
rotate(-PI/6); // 90 fokkal balra.
}
popMatrix();
}
void felspiral(float radius){
// final float ratio = 0.9, delta = 0.241 ;
//final float ratio = 0.95, delta = 0.053 ;
final float ratio = 0.95, delta = 0.11 ;
float angle = -PI/2;
stroke(255);
strokeWeight(1);
while(radius > 4){
line(
sin(angle)*radius,
cos(angle)*radius,
sin(angle+delta)*radius*ratio,
cos(angle+delta)*radius*ratio
);
angle += delta;
radius *= ratio;
}
}
void duplaspiral(float x1, float y1, float x2, float y2){
float d = dist(x1,y1,x2,y2);
float a = atan2(y1-y2, x1-x2);
final float phi = 1.6180339887;
pushMatrix();
translate(x1,y1);
//felspiral(d);
rotate(a);
felspiral(d/phi);
popMatrix();
pushMatrix();
translate(x2,y2);
rotate(PI+a);
felspiral(d-d/phi);
popMatrix();
}
void draw() {
background(180,12,32);
stroke(255,62);
line(mouseX,mouseY,width/2,height/2);
stroke(255);
translate(width/2, height/2);
rotate(atan2(height/2-mouseY,width/2-mouseX));
float d = mouseX/2;
hatszog(d);
translate(d,0);
hatszog(d);
translate(-d-d,0);
hatszog(d);
translate(d/2, sqrt(3)/2*d);
hatszog(d);
translate(d, 0);
hatszog(d);
translate(0, -sqrt(3)*d);
hatszog(d);
}
void hatszog(float r){
for(int i = 0; i < 6; i++){
rotate(PI/3);
duplaspiral(0,0,r,0);
duplaspiral(r,0, 0, 0);
}
}
void mousePressed(){
if(looping)
noLoop();
else loop();
looping=!looping;
}