diff --git a/art/fractalTree-maggieClaireBelle/index.js b/art/fractalTree-maggieClaireBelle/index.js new file mode 100644 index 000000000..41ee4e723 --- /dev/null +++ b/art/fractalTree-maggieClaireBelle/index.js @@ -0,0 +1,33 @@ +// Fractal trees by Maggie, Claire and Belle + +const t = createTurtle(); + +const MAX_ITERATION = randInRange(7, 10) +const START_ANGLE = 90 +const ANGLE_CHANGE = randInRange(10, 20) +const BRANCH_LEN = randInRange(20, 30) +const START_POS = [62.5, 30] + +function recurse(prevBranchEnd, angle, branchLen, iteration) { + if (iteration > MAX_ITERATION) { + return + } + + // Left branch from a node + t.jump(prevBranchEnd) + t.setAngle(angle + ANGLE_CHANGE) + t.forward(branchLen) + + recurse(t.end, angle + ANGLE_CHANGE, branchLen * 2/3, iteration + 1) + + // Right branch from a node + t.jump(prevBranchEnd) + t.setAngle(angle - ANGLE_CHANGE) + t.forward(branchLen) + + recurse(t.end, angle - ANGLE_CHANGE, branchLen * 2/3, iteration + 1) +} + +recurse(START_POS, START_ANGLE, BRANCH_LEN, 1) + +drawTurtles([t]) \ No newline at end of file diff --git a/art/fractalTree-maggieClaireBelle/snapshots/0.png b/art/fractalTree-maggieClaireBelle/snapshots/0.png new file mode 100644 index 000000000..2501209f6 Binary files /dev/null and b/art/fractalTree-maggieClaireBelle/snapshots/0.png differ diff --git a/art/fractalTree-maggieClaireBelle/snapshots/1.png b/art/fractalTree-maggieClaireBelle/snapshots/1.png new file mode 100644 index 000000000..31bd43459 Binary files /dev/null and b/art/fractalTree-maggieClaireBelle/snapshots/1.png differ diff --git a/art/fractalTree-maggieClaireBelle/snapshots/2.png b/art/fractalTree-maggieClaireBelle/snapshots/2.png new file mode 100644 index 000000000..fc80bb7ae Binary files /dev/null and b/art/fractalTree-maggieClaireBelle/snapshots/2.png differ