Examples Translate

Translate

The translate() function moves the origin of the coordinate system to the specified location.

The push() and pop() functions save and restore the coordinate system and various other drawing settings, such as the fill color.

Note that in this example, we draw the shapes (rectangle and circle) each time in a different coordinate system.

Translate: Revised by Darren Kessner. Edited and maintained by p5.js Contributors and Processing Foundation. Licensed under CC BY-NC-SA 4.0.

You can find the code history of these examples here: 2023 code, pre-2023 code. You can suggest improvements by contributing to the current website!