Lesson 38 of 51 · Fractals
Koch Snowflake
The Koch snowflake is a classic fractal curve.
Python
from turtle import *
bgcolor("black")
color("cyan")
pensize(1)
speed(0)
def koch(length, depth):
if depth == 0:
forward(length)
return
koch(length / 3, depth - 1)
left(60)
koch(length / 3, depth - 1)
right(120)
koch(length / 3, depth - 1)
left(60)
koch(length / 3, depth - 1)
penup()
goto(-150, 80)
pendown()
for i in range(3):
koch(300, 4)
right(120)
done()Output

1
The Rule
Each line segment is replaced by 4 smaller segments forming a bump.