FAQ
 
 
Cover  \ Exhibition  \ Learning  \ Reference  \ Download  \ Discourse   
      Language \ Environment \ Libraries \ Comparison
 
   
   
Abridged (A-Z) \ Complete (A-Z)  
   
  Reference for Processing (BETA) version 91+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.  
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. Further control over applying the transformation is acheived with 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: Fri Jul 15 16:36:16 PDT 2005
 
 








Creative Commons License
 
  Processing is an open project initiated by Ben Fry and Casey Reas  
  © Info