translate() \ Language (API) \ Processing 1.0
Author: Casey Reas & Ben Fry
Description: Processing is an electronic sketchbook for developing ideas. It is a context for learning fundamentals of computer programming within the context of the electronic arts.
Keywords: Processing, Processing, Interactive Media, Electronic Arts, Programming, Java, Ben Fry, Casey Reas

Reference for Processing version 1.5. 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.

Name | ### translate()
Examples |
    translate(30, 20);
    rect(0, 0, 55, 55);
    // 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);
    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
Returns | None
Usage | Web & Application
Related | rotate() rotateX() rotateY() rotateZ() scale() pushMatrix() popMatrix()

Updated on August 30, 2010 04:29:39pm EDT