Name

CanvasRenderingContext2D.rotate( ): rotate the coordinate system of the canvas

Synopsis

void rotate(floatangle)

Arguments

angle

The amount of rotation, in radians. Positive values result in clockwise rotation, and negative values result in counterclockwise rotation.

Description

This method alters the mapping between canvas coordinates and the pixels of the <canvas> element in the web browser so that any subsequent drawing appears rotated within the canvas by the specified angle. It does not rotate the <canvas> element itself. Note that the angle is specified in radians. To convert degrees to radians, multiply by Math.PI and divide by 180.

See Also

CanvasRenderingContext2D.scale( ), CanvasRenderingContext2D.translate( )

Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.