Commit c7432542 authored by Kevin Dang's avatar Kevin Dang

added research on fractals

parent 738c9a37
float theta;
void setup() {
size(500, 500);
theta = 0.54342943;
}
void draw() {
background(255);
translate(width/2, height);
stroke(0);
branch(100);
println(theta);
}
void mousePressed() {
theta = random(0.3, 0.6);
}
void branch(float len) {
float strokeW = map(len, 2, 120, 1, 10);
strokeWeight(strokeW);
line(0, 0, 0, -len);
translate(0, -len);
len *= 0.66;
if (len > 2) { // this allows an exit point, so recursion doesn't continue to infinity
pushMatrix();
rotate(theta);
branch(len);
popMatrix();
pushMatrix();
rotate(-theta);
branch(len);
popMatrix();
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment