4.1. Fractal Trees

Watch this video about using recursion to draw fractal trees.

Don’t worry about building each version of the tree block! The first couple of draw tree blocks are just showing off what we want to happen and why solving the problem without recursion is going to be hard. Just watch the first 15 minutes or so of the video.

You will want to make your own copy of the tree of ( ) levels with ( ) size that is near the end of the video.


Any time you modify the recursive tree block, make sure your turns cancel each other out. If you do not cancel out the turns, the sprite will go all over the place.

This is good:

Left 15
Left 15
Right 30 (30 total left, 30 total right)

So is this:

Left 40
Right 60
Left 20 (60 total left, 60 total right)

This is not:

Left 20
Right 40 (end up turning right 20 more than left!)

Checkpoint Exercises

Quad Branch:

Modify the recursive tree recipe to make something with 4 short branches.


Leaning Tree:

Modify the recursive tree recipe to make something that leans to the side.