Last active
May 29, 2021 22:59
-
-
Save AugustoBarros/4477ef51d2474ed36a40b1c1986c5ad3 to your computer and use it in GitHub Desktop.
arvore fractal : D
This file contains hidden or 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
# https://www.simplifiedpython.net/python-turtle-module/ | |
import turtle as tu | |
import random # import random module | |
my_turtle = tu.Turtle() | |
my_turtle.screen.bgcolor('red') | |
my_turtle.left(90) | |
my_turtle.speed(20) | |
my_turtle.color('green') | |
my_turtle.pensize(5) | |
my_turtle.screen.title("My Fractal Tree") | |
def draw_fractal(blen): | |
# add these two lines | |
sfcolor = ["white", "blue", "purple", "grey", "magenta"] | |
my_turtle.color(random.choice(sfcolor)) | |
if(blen<10): | |
return | |
else: | |
my_turtle.forward(blen) | |
my_turtle.left(30) | |
draw_fractal(3*blen/4) | |
my_turtle.right(60) | |
draw_fractal(3*blen/4) | |
my_turtle.left(30) | |
my_turtle.backward(blen) | |
draw_fractal(80) | |
my_turtle = tu.done() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment