# HTML canvas rotate() Method

• Last Updated : 05 Jan, 2023

The HTML canvas rotate() Method is used to rotate the drawing by given angle. Note that the rotation will only work on those canvas that made after the rotation was done. Syntax:

`context.rotate(angle)`

Parameter Values:

• angle: It store the rotation angle in radian. If the angle is give in form of degree then it convert into radian by using formula degree*Math.PI/180.

Example 1:

## html

 ```<``html``>` `<``head``>``    ``<``title``>``        ``HTML canvas rotate() Method``    ````` `<``body``>``<``center``>``<``h1` `style="color:green">GeeksforGeeks``    ``<``canvas` `id="GFG" width="500"``            ``height="300" style="border:2px solid gray;">``        ``` `    ``<``script``>``        ``var geeks = document.getElementById("GFG");``        ``var contex = geeks.getContext("2d");``        ``contex.strokeRect(100, 50, 150, 100);``        ``contex.rotate(30 * Math.PI / 180);``        ``contex.strokeRect(100, 50, 150, 100);``    ``````` `                        `

Output: Example 2:

## html

 ```<``html``>` `<``head``>``    ``<``title``>``        ``HTML canvas rotate() Method``    ````` `<``body``>``<``center``>``<``h1` `style="color:green">GeeksforGeeks``    ``<``canvas` `id="GFG" width="500"``            ``height="300" style="border:2px solid gray;">``` `    ``<``script``>``        ``var geeks = document.getElementById("GFG");``        ``var contex = geeks.getContext("2d");``        ``contex.rect(100, 100, 150, 100);//actual rectangle``        ``contex.stroke();``        ` `        ``contex.rotate((-20) * Math.PI / 180);``        ``contex.rect(100, 100, 150, 100);//rotate rectangle``        ``contex.stroke();``    ``````` `                                     `

Output: Supported Browsers: