Draw a small rectangle, scale five times, and draw the same rectangle again:
JavaScript:
The scale method scales the drawings, bigger or smaller.
You can scale the width or the height or both, by using the two parameters
If you scale both width and height two times (2,2) all drawings, from now on, will be twice as wide and twice as high as you specify
Also, the positioning will be scaled. If you scale (2,2), drawings will be positioned twice as far from the left, and top, of the canvas.
| JavaScript syntax: | context.scale(x,y); |
|---|
![]()
The scale method is supported in all major browsers.
| Parameter | Values | Description | Play it |
|---|---|---|---|
| x | width | The scaling of the the width. 1= no scaling, 0.5= half the size,2= twice the size etc. | Play it » |
| y | height | The scaling of the the height. 1= no scaling, 0.5= half the size,2= twice the size etc. | 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 |
|---|
| XML Editor - Free Trial! |
| 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 |
|---|