A fractal is a never-ending pattern. Fractals are infinitely complex patterns that are self-similar across different scales. They are created by repeating a simple process over and over in an ongoing feedback loop. Driven by recursion, fractals are images of dynamic systems – the pictures of Chaos.
In this article, we will draw a colorful Y fractal tree using a recursive technique in Python.
turtle: turtle library enables users to draw picture or shapes using commands, providing them with a virtual canvas. turtle comes with Python’s Standard Library. It needs a version of Python with Tk support, as it uses tkinter for the graphics.
- fd(x) : draw the cursor forward by x pixels.
- rt(x), lt(x) : rotates the facing direction of the cursor by x degrees to the right and left respectively.
- colormode(): to change the colour mode to rgb.
- pencolor(r, g, b): to set the colour of the turtle pen.
- speed(): to set the speed of the turtle.
- We start by drawing a single ‘Y’ shape for the base(level 1) tree. Then both the branches of the ‘Y’ serve as the base of other two ‘Y’s(level 2).
- This process is repeated recursively and size of the Y decreases as level increases.
- Colouring of the tree is done level wise: darkest in the base level to lightest in the topmost.
In the implementation below, we will draw a tree of size 80 and level 7.
- Python | Plotting Fibonacci spiral fractal using Turtle
- Star fractal printing using Turtle in Python
- Fractal using Spirograph in Python
- Julia fractal in Python
- Fractal Trees in Python
- Mandelbrot Fractal Set visualization in Python
- turtle.forward() method in Python-Turtle
- turtle.setpos() and turtle.goto() functions in Python
- Draw tree using Turtle module in Python
- Draw Circle in Python using Turtle
- Python - Hilbert Curve using turtle
- Create a simple Animation using Turtle in Python
- Python - Write "GFG" using Turtle Graphics
- How to make Indian Flag using Turtle - Python
- How to make Triangle in Python Turtle using onscreenclick?
- Create digital clock using Python-Turtle
- Draw Cube and Cuboid in Python using Turtle
- Draw Shape inside Shape in Python Using Turtle
- Draw Colored Solid Cube using Turtle in Python
- Colored Flower by circles using Turtle in Python