Rotates the coordinate system about the z-axis in WebGL mode.
The parameter, angle, is the amount to rotate. For example, calling rotateZ(1) rotates the coordinate system about the z-axis by 1 radian. rotateZ() interprets angle values using the current angleMode().
By default, transformations accumulate. For example, calling rotateZ(1) twice has the same effect as calling rotateZ(2) once. The push() and pop() functions can be used to isolate transformations within distinct drawing groups.
Note: Transformations are reset at the beginning of the draw loop. Calling rotateZ(1) inside the draw() function won't cause shapes to spin.
rotateZ() can also be used in shaders with p5.strands. Inside a shader callback, it takes a transform created with transform3D() as its first parameter, as in rotateZ(myTransform, PI / 4). Instead of turning the coordinate system, it returns a new transform with the turn added on and leaves the one passed in untouched, so the result has to be assigned back. This does the same thing as calling rotate() on a 3D transform. Angles are always in radians inside a shader. The finished transform is applied to a position with transformPoint(). See its reference for a more in-depth explanation of how that works. The following example turns each instance of a bar a little more than the one before it.
Examples
Syntax
rotateZ(angle)
rotateZ(transform, angle)