Draw Pythagoras Fractal

Draw the Pythagoras tree (Bosman 1942) - recursive squares + Pythagorean theorem. Angle 30-60°, gradient mode. Free, offline, client-side, instant, secure.

Renders the Pythagoras tree (Albert E. Bosman, 1942): every node splits into two child squares with sides cos(θ) and sin(θ) times the parent's side. The Pythagorean identity cos²(θ) + sin²(θ) = 1 makes the child areas add up to the parent's area.

How to Use Draw Pythagoras Fractal

  1. Set iterations (1-12). Total squares = 2ᴺ⁺¹ − 1: iter 10 = 2,047; iter 12 = 8,191. (An earlier version of this tool's code dropped the leaf generation and produced half that - fixed now.)
  2. Pick the branching angle (30°-60°). 45° is symmetric. Angles far from 45° make the tree visibly self-overlap.
  3. Pick render mode. Gradient (the default) shades each square by its recursion depth; solid uses the trunk color throughout; outline shows just the polygon edges.
  4. Pick trunk and leaf colors. A toast warns if the two colors are too close in luminance for the gradient to be readable.
  5. Pick canvas size and background. Transparent background is useful when exporting for overlay use.
  6. Click Draw Tree or press Ctrl/Cmd + Enter. Iter 11+ shows a non-blocking time estimate toast - no modal interrupts you.
  7. Copy or download the PNG; the filename includes the iteration count and angle.

Frequently Asked Questions

What is the Pythagoras tree?

The Pythagoras tree is a plane fractal first described by the Dutch mathematics teacher Albert E. Bosman in his 1942 book “Het wondere onderzoekingsveld der vlakke meetkunde” (The Wondrous Field of Investigation of Plane Geometry). He drew it by hand. The construction: start with a square (the trunk). On top of the square, erect a right triangle. The two non-hypotenuse sides of the triangle become the sides of two new squares – and the same procedure is applied to each new square recursively.

How is the Pythagorean theorem involved?

If the branching angle is θ, the two child squares have sides cos(θ) and sin(θ) times the parent side. So the sum of their areas is cos²(θ) + sin²(θ) = 1 times the parent area – exactly the parent’s area. The total covered area is therefore conserved at every level: the tree always has the same total area as a single unit square, no matter how deep you go.

How many squares does iteration N produce?

2 to the (N+1) minus 1. The tree is a binary recursion: 1 trunk at level 0, 2 children at level 1, 4 at level 2, …, 2 to the N at level N. The geometric series sums to 2 to the (N+1) minus 1. Iter 10 = 2,047. Iter 12 = 8,191. An older version of this tool’s code accidentally skipped the leaf generation (returned before pushing the last layer) so it produced 2 to the N minus 1 instead – half the correct count. That bug is fixed; the stats line shows the real number.

What is the fractal dimension?

By the Pythagorean identity, the IFS (similarity) dimension is exactly 2.0 for every branching angle, not just 45°. Solve the Moran equation cos(θ) to the d plus sin(θ) to the d equals 1: at d = 2 we get cos²+sin² = 1, which holds for any θ. However, at angles far from 45° the tree self-overlaps, so the box-counting dimension of the actually visible figure dips below 2. The classical “the Pythagoras tree fills 2D space” statement strictly applies in the IFS sense; in the rendered image, only 45° has a non-overlapping tree that genuinely covers a finite area exactly.

What does the gradient mode show?

Each square’s recursion depth – from 0 at the trunk to N at the leaves – is mapped to a color interpolated linearly between the trunk color and the leaf color. So the trunk takes the trunk color, the topmost leaves take the leaf color, and intermediate generations sit on a smooth gradient between them. It is the easiest way to see how many recursion levels are actually rendered.

Why do small angles look “wind-swept”?

At θ small, cos(θ) is close to 1 and sin(θ) is close to 0 – one child square is almost as big as the parent and the other is tiny. The tree grows mostly in one direction, and the small branches are barely visible. At θ close to 90° the same thing happens in mirror. At 45° both children are size √2/2 ≈ 0.707 of the parent and the tree is symmetric.

Why does the tree look like real foliage?

Real plants use very similar recursive branching – each node splits into two (or more) sub-branches at a roughly constant angle. The Pythagoras tree at 45° doesn’t look exactly like a maple, but the structural similarity is strong, which is why it appears in biology textbooks alongside L-system plant models. It is one of the canonical examples of “fractal in nature”.

Is anything sent to a server?

No. The tool loads three static files (HTML, CSS, JS) and then runs entirely in your browser – recursion, drawing, PNG export, clipboard copy. You can disconnect from the internet after the page loads. No analytics, no tracking, no cookies.

Is this tool free?

Yes – free, unlimited, no signup, no watermark. Use the PNGs in lectures, papers, blog posts, or art freely. Attribution to is appreciated but not required.