I'm doing a practice project in Pyzo, and I've been having some issues with turtle.tracer().
When n =/= 0 or 1, I run into an issue where the objects on screen start to flicker.
import turtle
sketcher = turtle.Turtle()
canvas = turtle.Screen()
sketcher.speed(0)
sketcher.hideturtle()
def drawPinwheelAnimation(length):
sketcher.setheading(90)
backwardLength = length
lengthChange = 1
while(True):
canvas.tracer(36)
drawPinwheel(0, 0, length, backwardLength)
drawPinwheel(3*length, 0, length, backwardLength)
drawPinwheel(0, 3*length, length, backwardLength)
drawPinwheel(-3*length, 0, length, backwardLength)
drawPinwheel(0, -3*length, length, backwardLength)
canvas.update()
backwardLength += lengthChange
if(backwardLength == (1.5*length) or backwardLength == (0.5*length)):
lengthChange *= -1
sketcher.clear()
def drawSwingingPinwheel(xPos, yPos, initialLength):
while(True):
drawPinwheel(xPos, yPos, forwardLength, backwardLength)
backwardLength += lengthChange
if(backwardLength == (1.5*initialLength) or backwardLength == (0.5*initialLength)):
lengthChange *= -1
sketcher.clear()
def drawPinwheel(xPos, yPos, fdLength, bkLength):
sketcher.penup()
sketcher.setpos(xPos, yPos)
sketcher.pendown()
for side in range(12):
sketcher.fd(fdLength)
sketcher.bk(bkLength)
sketcher.rt(30)
drawPinwheelAnimation(50)
turtle.mainloop()
When n = 1, there is no flicker, but it also means that the animation goes at the basic speed anyways, so it has no effect. When n = 0, there is no flicker. However, it's far too fast for my purposes. I tried changing the "delay" value, but to no avail:
canvas.tracer(0, 1000) #Changing the second value to 1000 has no notable difference.
drawPinwheel(0, 0, length, backwardLength)
drawPinwheel(3*length, 0, length, backwardLength)
drawPinwheel(0, 3*length, length, backwardLength)
drawPinwheel(-3*length, 0, length, backwardLength)
drawPinwheel(0, -3*length, length, backwardLength)
canvas.update()
I'm pretty stuck at this point. There might be a pretty obvious solution I'm missing, I'm not sure.
Thanks!