//////////////////////////////////////////////////////// float c_x = 0, c_y = 0, f = sqrt(2) / 2 , ln, r, sw = 5.0; int deep = 10; //////////////////////////////////////////////////////// void setup() { size(700, 512); strokeCap(ROUND); frameRate(30); count = 0; } //////////////////////////////////////////////////////// void draw() { count++; dTime = sin(count%628 / 30.0)*5; background(175, 55, 25); noStroke(); fill(255, 115, 0); ellipse(width * 0.7, height - height / 4, height, height); fill(45, 5, 0, 25); rect(0, height - 45, width, height - 15); fill(45, 5, 0); rect(0, height - 15, width, height); fill(255, 100, 0); stroke(45, 5, 0); pstX = 100.0 * mouseX / width; pstY = 100.0 * mouseY / height; c_x += (radians(3.6 * pstX + dTime) - c_x) / 20; c_y += (radians(3.6 * pstY + dTime) - c_y) / 20; //c_x = (radians(3.6 * pstX + dTime)); //c_y = (radians(3.6 * pstY + dTime)); ln = height * 0.618; dy = 0; text("% X = "+pstX, 10, dy+=10); text("% Y = "+pstY, 10, dy+=10); text("frame rate = "+frameRate, 10, dy+=10); text("count = "+dTime, 10, dy+=10); translate(width * 0.5, height / 1.5); strokeWeight(sw); line(0, 0, 0, ln); branch(ln / 2, deep); branchDot(ln / 2, deep); //branch2(ln / 2, deep); //branchDot2(ln / 2, deep); } //////////////////////////////////////////////////////// void branch(float l,int n) { l *= f; n -= 1; if (n > 0) { pushMatrix(); rotate(c_x); strokeWeight(sw * (0.2 + 0.8 * l / ln)); line(0, 0, 0, -l); translate(0, -l); branch(l, n); popMatrix(); pushMatrix(); rotate(c_x - c_y); strokeWeight(sw * (0.2 + 0.8 * l / ln)); line(0, 0, 0, -l); translate(0, -l); branch(l, n); popMatrix(); } } //////////////////////////////////////////////////////// void branchDot(float l,int n) { l *= f; n -= 1; float r = l / 3; if ((r > 2) && (n > 0)) { strokeWeight(sw * (0.2 + 0.8 * l / ln)); ellipse(0, 0, r, r); pushMatrix(); rotate(c_x); translate(0, -l); branchDot(l, n); popMatrix(); pushMatrix(); rotate(c_x - c_y); translate(0, -l); branchDot(l, n); popMatrix(); } } //////////////////////////////////////////////////////// void branch2(float l,int n) { l *= f; n -= 1; if (n > 0) { pushMatrix(); rotate(-c_x); strokeWeight(sw * (0.2 + 0.8 * l / ln)); line(0, 0, 0, -l); translate(0, -l); branch2(l, n); popMatrix(); pushMatrix(); rotate(c_x - c_y); strokeWeight(sw * (0.2 + 0.8 * l / ln)); line(0, 0, 0, -l); translate(0, -l); branch2(l, n); popMatrix(); } } //////////////////////////////////////////////////////// void branchDot2(float l,int n) { l *= f; n -= 1; float r = l / 3; if ((r > 2) && (n > 0)) { strokeWeight(sw * (0.2 + 0.8 * l / ln)); ellipse(0, 0, r, r); pushMatrix(); rotate(-c_x); translate(0, -l); branchDot2(l, n); popMatrix(); pushMatrix(); rotate(c_x - c_y); translate(0, -l); branchDot2(l, n); popMatrix(); } }