/

HTML / CSS / JavaScript Tutorial

JavaScript canvas2d object method: scale()

[this page | pdf | back links]

The scale() method of the JavaScript DOM object returned by the getContext("2d") method applied to the HTML <canvas> element scales the current drawing. It also scales future drawings and the positioning is also scaled. The parameters are scaling factors, so 1 means stay at 100% of previous size, 0.5 means adjust to 50% of previous size etc.

 

It has the following syntax with the following parameters:

 

context.scale(scalewidth,scaleheight)

 

Parameter

Required / Optional

Description

scalewidth

Required

Scaling factor applied to width

scaleheight

Required

Scale factor applied to height (

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile