Search⌘ K
AI Features

Rotation

Explore how to rotate user coordinates in Pycairo to manipulate shape orientation. Understand rotating around the origin and about a specific point using translation and rotation commands to control drawing alignment.

We'll cover the following...

Rotating user space

Rotation turns the user coordinate system, through a fixed angle about the origin. We can use this to draw shapes at different orientations, without changing the drawing code.

We use the rotate method of the Context to perform the rotation:

ctx.rotate(math.pi/6)
ctx.rectangle(300, 200, 200, 100)

After rotating by pi/6 ...