Rotate a rectangle 20 degrees:
JavaScript:
The rotate method rotates the canvas.
The rotation is done in an angle from the canvas' position 0,0:
The rotate method takes one parameter, radians.
The parameter decides the degree of the rotation by using radians.
To calculate from degrees to radians, use this formula: degrees*PI/180
20 degrees: 20*PI/180=0.35
The rotation will only affect drawings made AFTER the rotation is done.
| JavaScript syntax: | context.rotate(angle); |
|---|
![]()
The rotate method is supported in all major browsers.
| Parameter | Values | Description | Play it |
|---|---|---|---|
| angle | angle | Rotates the canvas to the given angle | Play it » |
| WEB HOSTING |
|---|
| Best Web Hosting |
| PHP MySQL Hosting |
| Best Hosting Coupons |
| UK Reseller Hosting |
| Cloud Hosting |
| Top Web Hosting |
| $3.98 Unlimited Hosting |
| Premium Website Design |
| WEB BUILDING |
|---|
| Download XML Editor |
| FREE Website BUILDER |
| Best Website Templates Top CSS Templates |
| CREATE HTML Websites |
| EASY WEBSITE BUILDER |
| W3SCHOOLS EXAMS |
|---|
|
Get Certified in: HTML, CSS, JavaScript, XML, PHP, and ASP |
| W3SCHOOLS BOOKS |
|---|
|
New Books: HTML, CSS JavaScript, and Ajax |
| STATISTICS |
|---|
|
Browser Statistics Browser OS Browser Display |
| SHARE THIS PAGE |
|---|