This example demonstrates the use of loop() and noLoop() to pause and resume the animation.
Clicking the mouse toggles the animation loop. If the animation loop is stopped, the user can press any key to advance one frame. Note: the user must click to set the focus on the canvas for key presses to be registered.
Advancing a single frame is accomplished by calling the redraw() function, which results in a single call to the draw() function.
Animation with Events by p5.js Contributors and the Processing Foundation is licensed under CC BY-NC-SA 4.0.