Skip to content

Instantly share code, notes, and snippets.

@cbhyphen
Last active February 15, 2022 05:27
Show Gist options
  • Select an option

  • Save cbhyphen/6e8a96808c58981d4beabc4abed2aa17 to your computer and use it in GitHub Desktop.

Select an option

Save cbhyphen/6e8a96808c58981d4beabc4abed2aa17 to your computer and use it in GitHub Desktop.
cesaro-fractal-turtle
#!/usr/bin/python
import turtle
def draw_cesaro_line(turtle, level, length):
if level == 0:
turtle.forward(length)
if level != 0:
draw_cesaro_line(turtle, level-1, length/4)
turtle.right(85)
draw_cesaro_line(turtle, level-1, length/4)
turtle.left(170)
draw_cesaro_line(turtle, level-1, length/4)
turtle.right(85)
draw_cesaro_line(turtle, level-1, length/4)
def draw_cesaro_fractal(turtle, level, length):
for i in range(4):
draw_cesaro_line(turtle, level, length)
turtle.right(90)
if __name__ == "__main__":
window = turtle.Screen()
window.bgcolor("black")
timmy = turtle.Turtle()
timmy.shape("turtle")
timmy.color("green")
timmy.fillcolor("red")
timmy.speed(0)
timmy.begin_fill()
draw_cesaro_fractal(timmy, 3, 2000)
timmy.end_fill()
window.exitonclick()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment