Chapter 02 - Lesson 04

Rotation and Scaling

Use angle and shrink ratio to control the tree silhouette.

Concept explanation

Rotation aims child branches left and right. Scaling makes each generation shorter. Together, angle and shrink ratio determine whether the tree is narrow, open, dense, or sparse.

Try it

Use angle and shrink ratio to control the tree silhouette.

Code fragment

rotate(angle);
branch(length * shrink, depth - 1);

What to observe

  • Small angles make a narrow tree.
  • Large shrink values crowd the canopy.
  • Small shrink values end the visible structure quickly.

Small challenge

Find one compact setting and one wide setting.