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.



example pic
translate(30, 20);
rect(0, 0, 55, 55);
example pic
// Translating in 3D requires P3D
// or OPENGL as a parameter to size()
size(100, 100, P3D);
translate(30, 20, -50);
rect(0, 0, 55, 55);
example pic
translate(30, 20);
rect(0, 0, 55, 55);
translate(14, 14);
rect(0, 0, 55, 55);
Description Specifies an amount to displace objects within the display window. 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. Using this function with the z parameter requires using the P3D or OPENGL parameter in combination with size as shown in the above example. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). If translate() is called within draw(), the transformation is reset when the loop begins again. This function can be further controlled by the pushMatrix() and popMatrix().
translate(x, y);
translate(x, y, z);
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
Related rotate()
Updated on June 14, 2010 12:05:29pm EDT

Creative Commons License