Pythagoras tree generator

World's simplest math tool

Free online Pythagoras tree fractal generator. Just press a button and you'll get a Pythagoras fractal. There are no ads, popups or nonsense, just an awesome Pythagorean tree generator. Press a button – get a tree. Created by mathematicians for mathematicians.

Generate a Regular TreeAngle of rotation at each
level stays the same.

Generate a Coniferous TreeLeft and right rectangles change
rotation angle at each level.

Generate a Semi-coniferous TreeLeft and right rectangles change
rotation angle every two levels.

Generate an Alternating TreeLeft and right rectangles change
rotation angle every time.

Generate a Per-Level Random TreeRandom rotation angle is selected
for each level.

Generate a Totally Random TreeRandom rotation angle is selected
for all rectangles.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

Iterations, Size, and Tilt

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

Pythagoras Tree Colors

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Pythagoras tree generator toolWhat is a pythagoras tree generator?

This tool draws the Pythagoras tree fractal. The Pythagoras tree is created as follows - take a rectangle (or a square), then adjacent to its top side draw two more rectangles at an angle so that the sides of all three rectangles form a right-angled triangle. If this triangle is isosceles, then the tree will grow symmetrically in both directions. If the triangle's base angles are different, then the Pythagorean tree will be tilted to the side of the smallest angle. In this tool, you can set the tilt angle and see how the Pythagorean tree evolves with each step of iteration. You can colorize the branches, add a contour line around each branch, and set the background color. You can also set the distance that the tree will be drawn from the frame. Additionally, you can generate coniferous tree type, semi-coniferous tree type, and alternating tree type. Once you have generated the tree that you like, you can resize it to your desired dimensions by entering width and height in pixels. Mathabulous!

Pythagoras tree generator examplesClick to use

Symmetrical Pythagorean Tree

This example generates a symmetric Pythagoras tree using twelve generations. It uses a square as the base figure. The outlines of recursively drawn squares are not visible here because it's set to zero. The fractal uses only two colors – black for the background and blue for the tree. Notice that as the branches twist, overlap and intersect, this fractal starts to look very similar to Levy C curve.

Required options

These options will be used automatically if you select this example.

Generate a Regular TreeAngle of rotation at each
level stays the same.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Regular Tree from Rectangles

In this example, we set the width of the initial rectangle to 100 pixels and height to 400 pixels. This base figure has a ratio of 4:1 and as a result, we grow a Pythagorean tree that's thin and tall. The rotation angle is 40 degrees, which makes the tree tilt to the right.

Required options

These options will be used automatically if you select this example.

Generate a Regular TreeAngle of rotation at each
level stays the same.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Coniferous Pythagorean Tree

In this example, we draw a coniferous Pythagoras tree. In this type of tree, the angle of rotation alternates at every level. On the first level, the left square rotates 60 degrees, and on the second level, the right square rotates 60 degrees, and so on. We set the rectangular shape of the image (800x1000px) and generate 15 iterations, without using a border around squares.

Required options

These options will be used automatically if you select this example.

Generate a Coniferous TreeLeft and right rectangles change
rotation angle at each level.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Semi-Coniferous Pythagorean Tree

This example draws a semi-coniferous type of tree. This type alternates the rotation angle every two levels. On the first and second levels, the left square rotates by 50 degrees, and on the third and fourth by 90-50 = 40 degrees. The angles change up to the 11th iteration level this way.

Required options

These options will be used automatically if you select this example.

Generate a Semi-coniferous TreeLeft and right rectangles change
rotation angle every two levels.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Realistic Pythagorean Tree

In this example, we generate a tree that looks very realistic, like you see in nature. This is achieved by selecting semi-coniferous tree type option (where alpha and beta angles swap every two levels), setting alpha angle to 34 degrees (beta is automatically set to 56 degrees), and using a non-square base rectangle. The height of each rectangle is 3 times greater than its width. This aspect ratio makes this Pythagoras tree look very realistic and all branches bend very smoothly. We also chose to use two colors here and used 15 iterative levels.

Required options

These options will be used automatically if you select this example.

Generate a Semi-coniferous TreeLeft and right rectangles change
rotation angle every two levels.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Alternating Pythagorean Tree

This example draws an alternating type of tree. In this case, every pair of squares exchange base corner angles. Here we set the rotation angle to 58 degrees, which then turns to 32 degrees for the next pair of squares, then to 58 again, then 32, and so on. Also, in this example, we used an interesting combination of colors for the tree – we use the same color for the background and squares, and another for the contour. As a result we get a transparent-looking tree.

Required options

These options will be used automatically if you select this example.

Generate an Alternating TreeLeft and right rectangles change
rotation angle every time.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Extraordinary Pythagorean Tree

Believe or not, this is also a Pythagorean tree. You've got to agree that it has a very unusual appearance. The reason it's so weird is that the width of each rectangle is 5 times greater than its height. It's drawn using alternating-angles method with the initial rotation angle of 50 degrees. It uses white fill color for rectangles, crimson for background and dark red color for the contour.

Required options

These options will be used automatically if you select this example.

Generate an Alternating TreeLeft and right rectangles change
rotation angle every time.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Randomize Rotation Angles on Every Tree Level

In this example, we introduce some randomness in our Pythagoras trees. This example generates a Pythagoras tree that uses a random angle for every tree level. Note that one angle is randomly selected for every recursion level and it doesn't change on that level. For example, on the fifth level all triangles will have the same angle but fourth and sixth levels will have different angles. Every time you click on the example, you'll get something new because of randomization. Also you can just press the Draw a Pythagoras Tree button to get a new, random Pythagoras tree.

Required options

These options will be used automatically if you select this example.

Generate a Per-Level Random TreeRandom rotation angle is selected
for each level.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Randomize all Rotation Angles

This example uses a different tree randomization method. Here the rotation angles are randomly selected for each pair of squares. The branches each time tilt in different directions, creating a chaotic tree shape.

Required options

These options will be used automatically if you select this example.

Generate a Totally Random TreeRandom rotation angle is selected
for all rectangles.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Symmetrize Pythagoras Tree

This example uses the additional symmetrize function. This function gradually increases (or decreases) the angle to 45°. In our example, the tree starts at 10° and we generate 10 iterations of the tree. To achieve symmetry this angle has to be increased to 45°. To do it, at every iteration the angle increases by 3.5°. We can quickly calculate that by generating 10 levels we get 3.5° * 10 = 35° plus initial 10° makes it 45°.

Required options

These options will be used automatically if you select this example.

Generate a Coniferous TreeLeft and right rectangles change
rotation angle at each level.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Tilted Pythagoras Tree

In this example the angle of rotation of the left square is 30 degrees and right is 60 degrees. As a result left and right squares have different sizes and the whole tree is tilted to the left side. We also stretched the image horizontally by setting its size to 700x600px and set a black outline for squares with thickness of 2px.

Required options

These options will be used automatically if you select this example.

Generate a Regular TreeAngle of rotation at each
level stays the same.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Random Rectangles

This example turns on the randomize rectangle sizes function. It does the obvious thing – the size of each rectangle gets randomized. Note that only height can be randomized because width is automatically computed so that every pair of rectangles formed a right triangle. In our case, the height is a random number from 1 to 200 (because we set base rectangle's height to 200). This is example is similar to the first example where we're drawing a regular Pythagorean tree with a base angle of 45 degrees but symmetry is lost here because of height randomization.

Required options

These options will be used automatically if you select this example.

Generate a Regular TreeAngle of rotation at each
level stays the same.

Generate a Symmetrized TreeAt each level the rotation angle
increases or decreases so that
it reaches 45 degrees in the last iteration.

Randomize Rectangle SizesSize of each rectangle is chosen
arbitrarily.

IterationsHow many times to recursively
draw tree branches?

WidthTree width.

HeightTree height.

Base WidthBase rectangle width.

Base HeightBase rectangle height.

AngleAngle of rotation of the left
rectangle.

Line WidthTree branches outline thickness.

PaddingSpace between the frame and
the Pythagoras tree.

Select DirectionStarting direction of movement.

BackgroundPythagoras tree background
color.

Internal colorFill color for rectangles.

Line colorColor of the contour of the
rectangles.

Pro tipsMaster online math tools

You can pass options to this tool using their codes as query arguments and it will automatically compute output. To get the code of an option, just hover over its icon. Here's how to type it in your browser's address bar. Click to try!

We're Browserling — a friendly and fun cross-browser testing company powered by alien technology. At Browserling we love to make developers' lives easier, so we created this collection of online math tools. Unlike many other tools, we made our tools free, without ads, and with the simplest possible user interface. Our online math tools are actually powered by our programming tools that we created over the last couple of years. Check them out!

Secret message

If you love our tools, then we love you, too! Use coupon code MATHTOOLLING to get a discount at Browserling.

Privacy Policywe don't log data!

All conversions and calculations are done in your browser using JavaScript. We don't send a single bit about your input data to our servers. There is no server-side processing at all. We use Google Analytics and StatCounter for site usage analytics. Your IP address is saved on our web server, but it's not associated with any personally identifiable information. We don't use cookies and don't store session information in cookies. We use your browser's local storage to save tools' input. It stays on your computer.

Terms of Servicethe legal stuff

By using Online Math Tools you agree to our Terms of Service. TLDR: You don't need an account to use our tools. All tools are free of charge and you can use them as much as you want. You can't do illegal or shady things with our tools. We may block your access to tools, if we find out you're doing something bad. We're not liable for your actions and we offer no warranty. We may revise our terms at any time.