Advertisement
Home Open Editor ❯

HTML canvas rotate() Method

Example

let c = document.getElementById("myCanvas");
let ctx = c.getContext("2d");

ctx.rotate(25 * Math.PI / 125);
ctx.fillRect(50, 0, 100, 50);

Try this code ❯

Meaning

The rotate() method rotates the current drawing.


Standard Syntax

JavaScript syntax:

context.rotate(angle);


Advertisement

Parameter Values

Parameter Description
angle Specifies the rotation angle, in radians.
Home Open Editor ❯
Advertisement