![]()
YOU LEARN HERE... |
how to create animated computer graphics. An animation consists of individual images that change only slightly and are displayed step by step one after the other. As the human eye can only capture around 25 images per second, the result is a smooth, jerk-free movement, just like a movie, if the image sequence is shown fast enough. You can draw the images with the Turtle or load them as image files |
EXAMPLE |
In your example, you program a rotating propeller. As the animated figure is used several times, it is advantageous to build the program modularly, i.e. to display the figures using functions. This makes your program clearer. Use the functions bogen(), blatt() and propeller() to draw a 3-bladed propeller.
Program: from gturtle import * def bogen(): repeat 45: forward(3) right(2) def blatt(): startPath() bogen() right(90) bogen() left(150) fillPath() def propeller(): repeat 3: blatt() right(120) makeTurtle() hideTurtle() setFillColor("blue") repeat: propeller() delay(40) right(4) clear()
Program: from gturtle import * def watchFace(): setPenColor("black") penUp() repeat 12: forward(110) dot(10) back(110) right(30) penDown() def hand(): setPenWidth(5) forward(90) back(90) makeTurtle() hideTurtle() watchFace() a = 0 while True: setHeading(a) setPenColor("red") hand() delay(300) setPenColor("white") hand() a += 30 |
REMEMBER... |
| In an animation, a figure is displayed for a short time in a repetition loop, then deleted and displayed again at a slightly different position. To delete the figure, use the clear() or clear(“color”) function if the background is not white. This deletes the entire window, but the turtle remains in its current position. Sometimes it is advantageous to only paint over the animated figure with the background color before drawing it at the new position. |
TO SOLVE BY YOURSELF |
|
|
|
![]()