This activity will help you learn how to create simple animations
using for
loops, how to display them, how to save the
images to a folder, and then create an MP4 file. You will also explore using drawing elements to create animations. (See the Drawing
Shapes activity and the Introduction to Pictures
reading for a refresher on the drawing functions.)
moveBox
moves a red box across a
horizontal line at the top of a yellow background. Run the code cell
that tests the moveBox
function. Discuss what happens with
your peers or an instructor or TA.
moveBox
that takes the row number
and the color for the box as parameters rather than constants.
The function should replace row 10 and 'red' with the values from
the parameters.
savePicsToJPGS
takes a list of images, a path
to a folder on your Google drive, and the name to be used for the images. It then saves each
image from the list into the specified folder, numbering them as it saves them.
Boxes
on your Google drive.
moveBox
function so that you will now save the
images that get created in the moveBox
function to a folder on your Drive.
The path of the new folder you created on your Google drive gets saved
into the boxPath
variable, and then the
savePicsToJPGS
function
will save all of those images into your folder.
jpg
files and write them to an
mp4
file. The function
convertPicsToMP4
will do this for us. Uncomment this
line of code and then run the Code cell.
mp4
is there.
moveBox
functionand add one or two lines of code.
(Just add another filled rectangle to the canvas inside the
for
loop.)
movingRectangles
that is in the
notebook represents a more mathematically complicated way to
get the boxes moving. One box moves down the canvas in a circular
motion, while the other just moves down the diagonal of the canvas.
Test it to see how it works.
tickerTape
function that is in the
notebook moves a text across a horizontal
line. This should be similar to moving a box, except drawing text on
the image instead of rectangles.