Ptranslate
processing
Specifies an amount to displace objects within the display window. The x parameter specifies left/right translation, the y parameter specifies up/down translation.
Transformations are cumulative and apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling 50 0 Ptranslate and then 20 0 Ptranslate is the same as 70 0 Ptranslate. This function can be further controlled by using PpushMatrix
and PpopMatrix
.
Link to original Processing doc
Ptranslate is available since version 1.0.0.
See also
Signatures
Examples
// @preview image
<%
//draw smiley macro
'centerY' STORE
'centerX' STORE
'CENTER' PellipseMode
$centerX $centerY 30 30 Pellipse
0 Pfill
$centerX 7 - $centerY 5 - 5 8 Pellipse
$centerX 7 + $centerY 5 - 5 8 Pellipse
PnoFill
$centerX $centerY 22 22 0.5 1.5 Parc
%> 'drawsmiley' STORE
200 200 '2D3' PGraphics
255 Pbackground
0 0 @drawsmiley //top left corner
40 0 @drawsmiley
100 100 Ptranslate
0 0 @drawsmiley
40 0 @drawsmiley
0 30 Ptranslate //try to invert this line with the next one
pi 4 / Protate
0 0 @drawsmiley
40 0 @drawsmiley
PresetMatrix
200 200 @drawsmiley //bottom right corner
Pencode