Python recursion , Sierpinski triangle with color at each depth
- by ???? ???
import turtle
w=turtle.Screen()
def Tri(t, order, size):
if order==0:
t.forward(size)
t.left(120)
t.forward(size)
t.left(120)
t.forward(size)
t.left(120)
else:
t.pencolor('red')
Tri(t, order-1, size/2, color-1)
t.fd(size/2)
t.pencolor('blue')
Tri(t, order-1, size/2, color-1)
t.fd(size/2)
t.lt(120)
t.fd(size)
t.lt(120)
t.fd(size/2)
t.lt(120)
t.pencolor('green')
Tri(t, order-1, size/2,color-1)
t.rt(120)
t.fd(size/2)
t.lt(120)
can anyone help with this problem ?
i want to a sierpinski triangle that have color at specific depth
like this
http://openbookproject.net/thinkcs/python/english3e/_images/sierpinski_color.png
i dont know how to make the the triangle color change at specific depth