Created
November 7, 2018 17:43
-
-
Save horstjens/053a8b67a9bc3e5cb93d022231852ea2 to your computer and use it in GitHub Desktop.
recursive tree with turtle graphic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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