Vary Your Tree

On this page, you will make experiment freely with the tree procedure to see how you can modify the appearance of the result.
tree with thick trunk a fifth random tree with random branch lengths and angles

BRIAN TO INVESTIGATE

Comments and request by Tim Matthies at Piazza about how to improve this page such as including animated gifs for each task.

Tim Matthies at Piazza requesting solutions for this gravity version but also for the rest of Unit 7,8.

  1. Experiment! Try varying your tree in the following ways:
    • Change the turn angle.
    • Change the scale factor.
    • Change the number of branches at each level.
    • Change the branching structure. For example, trees can have branches along the trunk tree with two branches at different locations along trunk and three branches at top or even a bent trunk tree with trunk bending to the right by 5 degrees at each place where branches emerge.
    • Brian thinks this is useless and confusing.
      When you use more complicated structures or bend the trunk, returning the sprite to its original position—maintaining state transparency—becomes more of a nuisance. Instead of undoing each move and turn step by step, you can record the starting position like this
      script variables(sprite state); set(sprite state) to (sprite pos and direction); set pen color to (brown)
      using a block like this
      sprite pos and direction{report(list{x position, y position, direction})}
      and build a return sprite to state block that returns the sprite to its original position.
      return sprite to state (sprite state)
  2. Change the pen thickness between levels, so that the trunk is really thick and the leaves are thin.
    tree with thick trunk
  3. Make a brown trunk and branches and green leaves.
    You do not have to get it exactly like the picture.
    realistic tree
  4. You might have found the green leaves harder to debug than the varying thickness. If so, what went wrong with drawing the leaves green? Why didn't the same problem come up for the thickness?
  1. Put some randomness in the choice of angles and/or scaling factors. Here are some examples:
    a random tree with random branch lengths and angles a second random tree with random branch lengths and angles a third random tree with random branch lengths and angles
    a fourth random tree with random branch lengths and angles a fifth random tree with random branch lengths and angles a sixth random tree with random branch lengths and angles
  2. Make a forest by planting varied trees randomly on the stage.
    forest of trees
  3. Search for images of fractals in nature.
  1. In nature, gravity affects how plants grow. Here is an example of the tree fractal that uses a gravity block to weigh down the branches roughly the way gravity would. This tree's branching structure looks like tree with trunk bending to the right by 5 degrees at each place where branches emerge. The image below shows what happens when we add gravity. Experiment with this idea or work on whatever alternative you find interesting and beautiful.
    Tree with gravity gravity(strength#){point in direction(direction+sin of (direction)*strength)}