Utility Macros

apply-matrix

pop-matrix

print-matrix

push-matrix

reset-matrix

rotate

rotate-x

rotate-y

rotate-z

scale

shear-x

shear-y

translate

apply-matrix

Arguments
[n00 n01 n02 n03 n10 n11 n12 n13 n20 n21 n22 n23 n30 n31 n32 n33][n00 n01 n02 n10 n11 n12]clj
Docstring
Multiplies the current matrix by the one specified through the
parameters. This is very slow because it will try to calculate the
inverse of the transform, so avoid it whenever possible. The
equivalent function in OpenGL is glMultMatrix().
Works only inside sketch functions?
Yes
Original Processing method
applyMatrix()

pop-matrix

Arguments
[]
Docstring
Pops the current transformation matrix off the matrix
stack. Understanding pushing and popping requires understanding the
concept of a matrix stack. The push-matrix fn saves the current
coordinate system to the stack and pop-matrix restores the prior
coordinate system. push-matrix and pop-matrix are used in conjuction
with the other transformation methods and may be embedded to control
the scope of the transformations.
Works only inside sketch functions?
Yes
Original Processing method
popMatrix()

push-matrix

Arguments
[]
Docstring
Pushes the current transformation matrix onto the matrix
stack. Understanding push-matrix and pop-matrix requires
understanding the concept of a matrix stack. The push-matrix
function saves the current coordinate system to the stack and
pop-matrix restores the prior coordinate system. push-matrix and
pop-matrix are used in conjuction with the other transformation
methods and may be embedded to control the scope of the
transformations.
Works only inside sketch functions?
Yes
Original Processing method
pushMatrix()

reset-matrix

Arguments
[]
Docstring
Replaces the current matrix with the identity matrix. The
equivalent function in OpenGL is glLoadIdentity()
Works only inside sketch functions?
Yes
Original Processing method
resetMatrix()

rotate

Arguments
[angle][angle vx vy vz]
Docstring
Rotates a shape the amount specified by the angle parameter. Angles
should be specified in radians (values from 0 to TWO-PI) or
converted to radians with the radians function.

Objects are always rotated around their relative position to the
origin and positive numbers rotate objects in a clockwise
direction. Transformations apply to everything that happens after
and subsequent calls to the function accumulates the effect. For
example, calling (rotate HALF-PI) and then (rotate HALF-PI) is the
same as (rotate PI). All tranformations are reset when draw begins
again.

Technically, rotate multiplies the current transformation matrix by
a rotation matrix. This function can be further controlled by the
push-matrix and pop-matrix.
Works only inside sketch functions?
Yes
Original Processing method
rotate()

rotate-x

Arguments
[angle]
Docstring
Rotates a shape around the x-axis the amount specified by the angle
parameter. Angles should be specified in radians (values from 0 to
(* PI 2)) or converted to radians with the radians function. Objects
are always rotated around their relative position to the origin and
positive numbers rotate objects in a counterclockwise
direction. Transformations apply to everything that happens after
and subsequent calls to the function accumulates the effect. For
example, calling (rotate-x HALF-PI) and then (rotate-x HALF-PI) is
the same as (rotate-x PI). If rotate-x is called within the draw fn,
the transformation is reset when the loop begins again. This
function requires either the :p3d or :opengl renderer.
Works only inside sketch functions?
Yes
Original Processing method
rotateX()

rotate-y

Arguments
[angle]
Docstring
Rotates a shape around the y-axis the amount specified by the angle
parameter. Angles should be specified in radians (values from 0
to (* PI 2)) or converted to radians with the radians function.
Objects are always rotated around their relative position to the
origin and positive numbers rotate objects in a counterclockwise
direction. Transformations apply to everything that happens after
and subsequent calls to the function accumulates the effect. For
example, calling (rotate-y HALF-PI) and then (rotate-y HALF-PI) is
the same as (rotate-y PI). If rotate-y is called within the draw fn,
the transformation is reset when the loop begins again. This
function requires either the :p3d or :opengl renderer.
Works only inside sketch functions?
Yes
Original Processing method
rotateY()

rotate-z

Arguments
[angle]
Docstring
Rotates a shape around the z-axis the amount specified by the angle
parameter. Angles should be specified in radians (values from 0
to (* PI 2)) or converted to radians with the radians function.
Objects are always rotated around their relative position to the
origin and positive numbers rotate objects in a counterclockwise
direction. Transformations apply to everything that happens after
and subsequent calls to the function accumulates the effect. For
example, calling (rotate-z HALF-PI) and then (rotate-z HALF-PI) is
the same as (rotate-z PI). If rotate-y is called within the draw fn,
the transformation is reset when the loop begins again. This
function requires either the :p3d or :opengl renderer.
Works only inside sketch functions?
Yes
Original Processing method
rotateZ()

scale

Arguments
[sx sy][sx sy sz][s]
Docstring
Increases or decreases the size of a shape by expanding and
contracting vertices. Objects always scale from their relative
origin to the coordinate system. Scale values are specified as
decimal percentages. For example, the function call (scale 2)
increases the dimension of a shape by 200%. Transformations apply to
everything that happens after and subsequent calls to the function
multiply the effect. For example, calling (scale 2) and then
(scale 1.5) is the same as (scale 3). If scale is called within
draw, the transformation is reset when the loop begins again. Using
this fuction with the z parameter requires specfying :p3d or :opengl
as the renderer. This function can be further controlled by
push-matrix and pop-matrix.
Works only inside sketch functions?
Yes
Original Processing method
scale()

shear-x

Arguments
[angle]
Docstring
Shears a shape around the x-axis the amount specified by the angle
parameter. Angles should be specified in radians (values from 0 to
PI*2) or converted to radians with the radians() function. Objects
are always sheared around their relative position to the origin and
positive numbers shear objects in a clockwise direction.
Transformations apply to everything that happens after and
subsequent calls to the function accumulates the effect. For
example, calling (shear-x (/ PI 2)) and then (shear-x (/ PI 2)) is
the same as (shear-x PI). If shear-x is called within the draw fn,
the transformation is reset when the loop begins again. This
function works in P2D or JAVA2D mode.

Technically, shear-x multiplies the current transformation matrix
by a rotation matrix. This function can be further controlled by the
push-matrix and pop-matrix fns.
Works only inside sketch functions?
Yes
Original Processing method
shearX()

shear-y

Arguments
[angle]
Docstring
Shears a shape around the y-axis the amount specified by the angle
parameter. Angles should be specified in radians (values from 0 to
PI*2) or converted to radians with the radians() function. Objects
are always sheared around their relative position to the origin and
positive numbers shear objects in a clockwise direction.
Transformations apply to everything that happens after and
subsequent calls to the function accumulates the effect. For
example, calling (shear-y (/ PI 2)) and then (shear-y (/ PI 2)) is
the same as (shear-y PI). If shear-y is called within the draw fn,
the transformation is reset when the loop begins again. This
function works in P2D or JAVA2D mode.

Technically, shear-y multiplies the current transformation matrix
by a rotation matrix. This function can be further controlled by the
push-matrix and pop-matrix fns.
Works only inside sketch functions?
Yes
Original Processing method
shearY()

translate

Arguments
[tx ty tz][tx ty][v]
Docstring
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.  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 push-matrix and pop-matrix.
Works only inside sketch functions?
Yes
Original Processing method
translate()