Reference for Processing version 1.2. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.





PShape s;

void setup() {
  s = loadShape("bot.svg");

void draw() {

void mousePressed() {
  // Move the shape 10 pixels right each time the mouse is pressed
  s.translate(10, 0);  
Description Specifies an amount to displace the shape. The x parameter specifies left/right translation, the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. Subsequent calls to the method accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.

Using this method with the z parameter requires using the P3D or OPENGL parameter in combination with size.
sh.translate(x, y);
sh.translate(x, y, z);
sh PShape: any variable of type PShape
x int or float: left/right translation
y int or float: up/down translation
z int or float: forward/back translation
Returns none
Usage Web & Application
Updated on June 14, 2010 12:05:29pm EDT

Creative Commons License