If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Course: Unlisted resources area > Unit 2

Lesson 1: ProcessingJS documentation

draw()

If you define a function called draw in your code, then that function will get called repeatedly, about 60 times per second. This is typically used for creating animations, in combination with incrementing variables that affect the shapes drawn. To re-paint the entire canvas for each frame, use the background() command. Otherwise, new shapes will be drawn on top of the previous canvas.
Note: The default frame rate can be changed with the frameRate() function.

Want to join the conversation?

No posts yet.