Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining

scale method

Scales the current context by the specified horizontal (x) and vertical (y) factors.

HTML Canvas 2D Context, Section 3Internet Explorer 9



object.scale(x, y);


x [in]

Type: number

The horizontal scaling factor, where 1 equals unity or 100% scale.

y [in]

Type: number

The vertical scaling factor.

Return value

This method does not return a value.

Standards information


When you create a CanvasRenderingContext2D object, it has a transformation matrix that identifies the current state. The ICanvasRenderingContext2D::scale method modifies the transformation by multiplying the matrix by the specified factor. For example, context.scale(1,.5) halves the vertical (or y-axis) values that are used in context and leaves the horizontal (or x-axis) values the same. Similarly, context.scale(2,2) doubles the size of the graphics.



Community Additions

© 2015 Microsoft