One way to do it is to clone the turtle inside mvmt()
, so you have an independent one that you can fill without interfering with the filling of the outer one.
To make that work recursively, you have to pass the current turtle as a parameter to mvmt()
.
That's what I changed your code to:
#!/usr/bin/env python
from __future__ import division
import colorsys
import turtle
def mvmt(original, length):
if length >= 10:
fraction = length / 3
h, s, v = colorsys.rgb_to_hsv(*original.fillcolor())
clone = original.clone()
clone.fillcolor(colorsys.hsv_to_rgb(h + 1/6, s, v))
clone.begin_fill()
mvmt(clone, fraction)
clone.right(60)
mvmt(clone, fraction)
clone.left(120)
mvmt(clone, fraction)
clone.right(60)
mvmt(clone, fraction)
clone.end_fill()
original.forward(length)
def whole(length = 300):
voldemort = turtle.Turtle()
voldemort.speed(0)
voldemort.hideturtle()
voldemort.penup()
voldemort.goto(-200,-255)
voldemort.pendown()
voldemort.fillcolor((1.0, 0.5, 0.5))
voldemort.begin_fill()
mvmt(voldemort, length)
voldemort.left(60)
mvmt(voldemort, length)
voldemort.left(60)
mvmt(voldemort, length)
voldemort.left(60)
mvmt(voldemort, length)
voldemort.left(60)
mvmt(voldemort, length)
voldemort.left(60)
mvmt(voldemort, length)
voldemort.end_fill()
turtle.delay(0)
turtle.speed(0)
whole()
turtle.exitonclick()