Fractal tree

Fractal tree
Fractal Tree

The tree that you saw first on index page was made with turtle. Turtle is a graphical module that comes built in with python programming language. Below is the source code for the tree.


import turtle

hr = turtle.Turtle()
hr.color("white", "white")

ts = turtle.getscreen()
ts.bgcolor("black")

hr.left(90)
hr.speed(1500)

def tree(i):
    if i < 4:
        return
    else:
        hr.forward(i)
        hr.left(30)
        tree(3 * i/4)
        hr.right(60)
        tree(3 * i/4)
        hr.left(30)
        hr.backward(i)
tree(100)
turtle.done()

view raw

I was going through my old notebooks, and found a turtle code in it, then modified it a bit.


Made with <3 by samiuljoy

rss | about | go to top