> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.qOav9vxS73F/rev.1544
 * 
 * authors: 
 *   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/ 
 */ 



var radius = 90;

var c1 = color(23,32,12),  c2=color(112,202,123);


void setup(){
    size(470,470);
    noStroke();
    }

void hexagon(){
    
    beginShape();
    for(int i = 0; i < 6; i++){
        duplaspiral(sin(i*PI/3)*radius, cos(i*PI/3)*radius, sin((i+1)*PI/3)*radius, cos((i+1)*PI/3)*radius );
        //vertex( sin(i * PI/3)*radius, cos(i*PI/3)*radius);    
    }
    endShape(CLOSE);
}

void hetHatszog(){

    ///hexagon();

    fill(c1);
    translate(radius*1.74,0);
    hexagon();

    fill(c2);
    translate(radius*-0.87, 1.50*radius);
    hexagon();

    fill(c1);
    translate(-1.74*radius,0);
    hexagon();

    fill(c2);

    translate(-0.86*radius,-1.50*radius);
    hexagon();

    fill(c1);

    translate(0.86*radius,-1.50*radius);
    hexagon();

    fill(c2);

    translate(radius*1.74,0);
    hexagon();

}


void draw(){
    background(255);

    noFill();
    
    
    fill(134,112,121);

    translate(width/2, height/2);
    rotate(mouseX/100);

    hetHatszog();
}

{
    add(1,2);
    add(4,5);
}

int add(int a, float b){
    if(a==0)
        return b;
    else
        return add(a-1,b+1);
}

void mouseMoved(){
    radius = radius + mouseY - pmouseY;
}

void mouseClicked(){
    
    c2=c1;
    
    c1=color(random(255), random(255), random(255));
    
    //stroke(color(random(255), random(255), random(255)));
    }

//hátemmi???
// ez egy korabbi kiserlet (a het hatszog), most megprobaljuk kicsit altalanositani.

// vonal

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 = 2; //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);
    }
}