Rotates the shape the amount specified by the angle parameter.


 1def setup():
 2    global s
 3    s = py5.load_shape("bot.svg")
 6def draw():
 7    py5.background(204)
 8    py5.scale(0.2)
 9    py5.shape(s, py5.width//2, py5.height//2)
12def mouse_pressed():
13    # rotate the shape each time the mouse is pressed
14    s.rotate(0.1)


Rotates the shape 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. Transformations apply to everything that happens after and subsequent calls to the method accumulates the effect. For example, calling rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI). This transformation is applied directly to the shape, it’s not refreshed each time draw() is run.

Underlying Processing method: PShape.rotate


rotate(angle: float, /) -> None
rotate(angle: float, v0: float, v1: float, v2: float, /) -> None


  • angle: float - angle of rotation specified in radians

  • v0: float - x-coordinate of vector to rotate around

  • v1: float - y-coordinate of vector to rotate around

  • v2: float - z-coordinate of vector to rotate around

Updated on November 12, 2021 11:30:58am UTC