Chapter 7. Motion

Like a flip book, animation on screen is created by drawing an image, then drawing a slightly different image, then another, and so on. The illusion of fluid motion is created by persistence of vision. When a set of similar images is presented at a fast enough rate, our brains translate these images into motion.

To create smooth motion, Processing tries to run the code inside draw() at 60 frames each second. To confirm the frame rate, run this program and watch the values print to the Console. The frameRate variable keeps track of the program’s speed.

void draw() {

The frameRate() function changes the speed at which the program runs. To see the result, ...

Get Getting Started with Processing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.