Py5Shape.rotate_z()

Rotates the shape around the z-axis the amount specified by the angle parameter.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
def setup():
    py5.size(100, 100, py5.P3D)
    global s
    s = py5.load_shape("bot.svg")


def draw():
    py5.background(204)
    py5.scale(0.2)
    py5.shape(s, py5.width//2, py5.height//2)


def mouse_pressed():
    # rotate the shape around the z-axis each time the mouse is pressed
    s.rotate_z(0.1)

Description

Rotates the shape around the z-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted from degrees to radians with the radians() method.

Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Subsequent calls to the method accumulates the effect. For example, calling rotate_z(HALF_PI) and then rotate_z(HALF_PI) is the same as rotate_z(PI). This transformation is applied directly to the shape, it’s not refreshed each time draw() is run.

This method requires a 3D renderer. You need to use P3D as a third parameter for the size() function as shown in the example.

Underlying Java method: PShape.rotateZ

Syntax

rotate_z(angle: float, /) -> None

Parameters

  • angle: float - angle of rotation specified in radians

Updated on September 11, 2021 16:51:34pm UTC