Created
April 1, 2022 15:29
-
-
Save nknapp/ee8fe17c5aaae7a0caf54aa8c63aad44 to your computer and use it in GitHub Desktop.
fraktal-turtle
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 time | |
my_window = turtle.Screen() | |
# my_window.screensize(1000,1000) | |
my_window.bgcolor("white") # creates a graphics window | |
# my_window.setworldcoordinates(0,0, 1000,1000) | |
my_window.delay(0) | |
my_window.tracer(100,200) | |
my_pen = turtle.Turtle() | |
lightness = 1 | |
colors = ["LightBlue", "orange", "DarkOliveGreen1","LightBlue4", "DarkRed","DarkOliveGreen", "Black"] | |
maxDepth = 7 | |
minLength = 1 | |
pensizeFactor = 2 | |
lineDivisionFactor = 3 | |
initialLength = minLength * pow(lineDivisionFactor, maxDepth-1) * pensizeFactor | |
for depth in range(maxDepth): | |
lightness = lightness - 0.2 | |
my_pen.color(colors[depth]) | |
my_pen.penup() | |
my_pen.goto(-200,400) | |
my_pen.pendown() | |
commands = "FRFRFRFR" | |
length = initialLength | |
for i in range(depth): | |
length = length / lineDivisionFactor | |
commands = commands.replace("F","FRFLFLFRF") | |
print("length: " + str(length)) | |
my_pen.pensize(length / pensizeFactor) | |
my_pen.speed(0) | |
for command in commands: | |
if (command == "F"): | |
my_pen.forward(length) | |
elif (command == 'R'): | |
my_pen.right(90) | |
elif (command == 'L'): | |
my_pen.left(90) | |
my_window.update() | |
time.sleep(86400) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment