a port of the Processing Visualization Language
Name

translate()

Examples
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().
Syntax
translate(x, y);

translate(x, y, z);
Parameters
x int or float: left/right translation
y int or float: up/down translation
z int or float: forward/back translation
Usage Web & Application
Related rotateX()
rotateY()
rotateZ()
rotate()
scale()
pushMatrix()
popMatrix()

This reference is licensed under the CC BY-NC-SA 2.0 license:

Creative Commons License
Fork me on GitHub