Skip to content

Instantly share code, notes, and snippets.

@horstjens
Created November 7, 2018 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save horstjens/053a8b67a9bc3e5cb93d022231852ea2 to your computer and use it in GitHub Desktop.
Save horstjens/053a8b67a9bc3e5cb93d022231852ea2 to your computer and use it in GitHub Desktop.
recursive tree with turtle graphic
import turtle
import random
#rekursive tree
def branch(length=50, angle=30, factor=0.5, stops=2):
if length < 5:
return
turtle.fd(length)
turtle.left(angle)
branch(length * factor)
turtle.right(2*angle)
branch(length * factor)
turtle.left(angle)
turtle.fd(-length)
turtle.goto(0,-400)
turtle.clear()
turtle.left(90)
branch(400)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment