Scale, Translate, Rotate
- Karla G
- 28 mar 2015
- 1 Min. de lectura
ROTATE
"The rotate() function rotates the coordinate system so that shapes can be drawn to the screen at an angle. It has one parameter that sets the amount of the rotation as an angle: rotate(angle);" (Casey Reas, Ben Fry.)
SCALE
"The scale() functions magnifies the coordinate system so that shapes are drawn larger. It has one or two parameters to set the amount of increase or decrease: scale(size); scale(xsize, ysize);" (Casey Reas, Ben Fry.)
TRANSLATE
"The translate() function moves the origin from the upper-left corner of the screen to another location. It has two parameters- the first is the x-coordintate offset, and the second is the y-coordinate offser. The calues of the parameters are added to aany shapes after the function is run." (Casey Reas, Ben Fry.)
How to use them:
A normal box:
noFill();
stroke(255,255,255);
box(10);

A rotated box:
noFill();
rotate(3*PI/4);
stroke(255,255,255);
box(10);

A normal sphere:
noFill();
scale(1,2);
stroke(255,255,255);
sphere(10);

A scaled sphere:
noFill();
scale(1,2);
stroke(255,255,255);
sphere(10);

A normal box:
noFill();
stroke(255,255,255);
box(10);

A translated box:
noFill();
stroke(255,255,255);
translate(10,30);
box(10);

References:
Casey Reas, Ben Fry. (2014). Processing: A Programming Handbook for Visual Designers and Artists. United States: MIT Press, 2014.
Comments