RosettaCodeData/Task/Fractal-tree/Processing/fractal-tree-1.processing

22 lines
443 B
Plaintext

void setup() {
size(600, 600);
background(0);
stroke(255);
drawTree(300, 550, 9);
}
void drawTree(float x, float y, int depth) {
float forkAngle = radians(20);
float baseLen = 10.0;
if (depth > 0) {
pushMatrix();
translate(x, y - baseLen * depth);
line(0, baseLen * depth, 0, 0);
rotate(forkAngle);
drawTree(0, 0, depth - 1);
rotate(2 * -forkAngle);
drawTree(0, 0, depth - 1);
popMatrix();
}
}