How do I draw a recursive Sierpiński arrowhead curve using turtle graphics in python on Visual Studio Code?
-
Hi I am trying to draw a recursive Sierpiński arrowhead curve using turtle graphics in python on Visual Studio Code. I can get the basic shape just fine but I can't seem to make it rotate correctly to form the sierpinski triangle. Here's my code:
from turtle import *
def arrowhead(level, length):
if level == 1:
rt(-60)
fd(length)
rt(60)
fd(length)
rt(60) #Basic shape for level 1
else:
arrowhead(level-1, length/2)
rt(60)
for i in range(3):
arrowhead(level-1, length/2)
lt(-60)
for i in range(3):
arrowhead(level-1, length/2)
rt(-60)
arrowhead(level-1, length/2)
lt(60)
arrowhead(level-1, length/2)arrowhead(4, 400)
-
Hi I am trying to draw a recursive Sierpiński arrowhead curve using turtle graphics in python on Visual Studio Code. I can get the basic shape just fine but I can't seem to make it rotate correctly to form the sierpinski triangle. Here's my code:
from turtle import *
def arrowhead(level, length):
if level == 1:
rt(-60)
fd(length)
rt(60)
fd(length)
rt(60) #Basic shape for level 1
else:
arrowhead(level-1, length/2)
rt(60)
for i in range(3):
arrowhead(level-1, length/2)
lt(-60)
for i in range(3):
arrowhead(level-1, length/2)
rt(-60)
arrowhead(level-1, length/2)
lt(60)
arrowhead(level-1, length/2)arrowhead(4, 400)