Windmill animation , The process is as follows :1) Draw windmill shape A,2) Erase windmill shape A,3) Draw windmill shape B,4) Erase windmill shape B... and so on

In operation , use clear() The effect of erasing windmill shape is not good , The screen will flash , So take a flexible approach , Draw again with the background color to achieve the visual erasure effect , Namely :

1) Draw windmill shape A,2) Drawing windmill shape with background color A,3) Draw windmill shape B,4) Drawing windmill shape with background color B... and so on
import turtle turtle.pensize(2) turtle.hideturtle() windSpeed = 2 radius = 50
def windmill(c): turtle.pencolor(c) turtle.tracer(False)
# Hide drawing process , No animation , Only the finished picture can be drawn , Use it later update() Direct drawing for i in range(4):
turtle.forward(2*radius) turtle.right(90) turtle.circle(-radius,180) while
True: windmill('black') turtle.update() # Refresh the picture windmill('white')
# Redraw the windmill with white background here , To clear the previous black track , The screen clearing function is not used turtle.right(windSpeed) turtle.done()
 

Technology