Lesson goal: Create an animated-GIF with programming

Previous: Not rolling a 7 or 11 | Home | Next: Make a point move

You've seen those animated GIFs (small, fast-loading videos) around the Internet, right? This lesson will allow you to make them using programming. Here's how.

If you made it through this lesson, you know how to plot things like points, lines and circles on the screen. An animation is just such drawing, but with the pixel drawn in different positions, across multiple frames, all played back in rapid succession. Got it?

Let's start by making a GIF animation that flashes the screen. We'll use some new functions to handle the animation, called gif_start(), gif_add_frame(), and gif_end(). gif_start() starts a new animated-GIF. gif_add_frame() takes what you've drawn and pushes it all out to a single frame in the GIF. gif_end() tells the code to end your GIF animation.

So, to make a GIF-animation, all you have to do is use gif_start() to start a new animation, draw a bunch of stuff to make your scene, add it to the movie with gif_add_frame(), then draw everything again, but in a slightly different position, then add it all as the next frame, again, using gif_add_frame(). When done, wrap it all up using gif_end().

In this first lesson, we'll learn how to clear a whole frame in your animation, using gif_cls().

Your GIF will play below. You may have to scroll down to see it.
gif_cls(color)
Move the mouse over a dotted box for more information.

Now you try. Make a flashing screen GIF!

Type your code here:


See your results here: