W3cubDocs

/DOM

CanvasRenderingContext2D

The CanvasRenderingContext2D interface is used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a <canvas> element.

To get an instance CanvasRenderingContext2D, call getContext() on a canvas element, supplying 2d as the argument:

var canvas = document.getElementById('myCanvas'); // in your HTML this element appears as <canvas id="myCanvas"></canvas>
var ctx = canvas.getContext('2d');

Once you have the 2D rendering context for a canvas, you can draw within it. For example:

ctx.fillStyle = 'rgb(200,0,0)'; // sets the color to fill in the rectangle with
ctx.fillRect(10, 10, 55, 50);   // draws the rectangle at position 10, 10 with a width of 55 and a height of 50

See the properties and methods in the sidebar and below. The canvas tutorial has more information, examples, and resources as well.

Drawing rectangles

There are three methods that immediately draw rectangles to the bitmap.

CanvasRenderingContext2D.clearRect()
Sets all pixels in the rectangle defined by starting point (x, y) and size (width, height) to transparent black, erasing any previously drawn content.
CanvasRenderingContext2D.fillRect()
Draws a filled rectangle at (x, y) position whose size is determined by width and height.
CanvasRenderingContext2D.strokeRect()
Paints a rectangle which has a starting point at (x, y) and has a w width and an h height onto the canvas, using the current stroke style.

Drawing text

The following methods are provided for drawing text. See also the TextMetrics object for text properties.

CanvasRenderingContext2D.fillText()
Draws (fills) a given text at the given (x,y) position.
CanvasRenderingContext2D.strokeText()
Draws (strokes) a given text at the given (x, y) position.
CanvasRenderingContext2D.measureText()
Returns a TextMetrics object.

Line styles

The following methods and properties control how lines are drawn.

CanvasRenderingContext2D.lineWidth
Width of lines. Default 1.0
CanvasRenderingContext2D.lineCap
Type of endings on the end of lines. Possible values: butt (default), round, square.
CanvasRenderingContext2D.lineJoin
Defines the type of corners where two lines meet. Possible values: round, bevel, miter (default).
CanvasRenderingContext2D.miterLimit
Miter limit ratio. Default 10.
CanvasRenderingContext2D.getLineDash()
Returns the current line dash pattern array containing an even number of non-negative numbers.
CanvasRenderingContext2D.setLineDash()
Sets the current line dash pattern.
CanvasRenderingContext2D.lineDashOffset
Specifies where to start a dash array on a line.

Text styles

The following properties control how text is laid out.

CanvasRenderingContext2D.font
Font setting. Default value 10px sans-serif.
CanvasRenderingContext2D.textAlign
Text alignment setting. Possible values: start (default), end, left, right or center.
CanvasRenderingContext2D.textBaseline
Baseline alignment setting. Possible values: top, hanging, middle, alphabetic (default), ideographic, bottom.
CanvasRenderingContext2D.direction
Directionality. Possible values: ltr, rtl, inherit (default).

Fill and stroke styles

Fill styling is used for colors and styles inside shapes and stroke styling is used for the lines around shapes.

CanvasRenderingContext2D.fillStyle
Color or style to use inside shapes. Default #000 (black).
CanvasRenderingContext2D.strokeStyle
Color or style to use for the lines around shapes. Default #000 (black).

Gradients and patterns

CanvasRenderingContext2D.createLinearGradient()
Creates a linear gradient along the line given by the coordinates represented by the parameters.
CanvasRenderingContext2D.createRadialGradient()
Creates a radial gradient given by the coordinates of the two circles represented by the parameters.
CanvasRenderingContext2D.createPattern()
Creates a pattern using the specified image (a CanvasImageSource). It repeats the source in the directions specified by the repetition argument. This method returns a CanvasPattern.

Shadows

CanvasRenderingContext2D.shadowBlur
Specifies the blurring effect. Default 0
CanvasRenderingContext2D.shadowColor
Color of the shadow. Default fully-transparent black.
CanvasRenderingContext2D.shadowOffsetX
Horizontal distance the shadow will be offset. Default 0.
CanvasRenderingContext2D.shadowOffsetY
Vertical distance the shadow will be offset. Default 0.

Paths

The following methods can be used to manipulate paths of objects.

CanvasRenderingContext2D.beginPath()
Starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path.
CanvasRenderingContext2D.closePath()
Causes the point of the pen to move back to the start of the current sub-path. It tries to draw a straight line from the current point to the start. If the shape has already been closed or has only one point, this function does nothing.
CanvasRenderingContext2D.moveTo()
Moves the starting point of a new sub-path to the (x, y) coordinates.
CanvasRenderingContext2D.lineTo()
Connects the last point in the subpath to the x, y coordinates with a straight line.
CanvasRenderingContext2D.bezierCurveTo()
Adds a cubic Bézier curve to the path. It requires three points. The first two points are control points and the third one is the end point. The starting point is the last point in the current path, which can be changed using moveTo() before creating the Bézier curve.
CanvasRenderingContext2D.quadraticCurveTo()
Adds a quadratic Bézier curve to the current path.
CanvasRenderingContext2D.arc()
Adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending at endAngle going in the given direction by anticlockwise (defaulting to clockwise).
CanvasRenderingContext2D.arcTo()
Adds an arc to the path with the given control points and radius, connected to the previous point by a straight line.
CanvasRenderingContext2D.ellipse()
Adds an ellipse to the path which is centered at (x, y) position with the radii radiusX and radiusY starting at startAngle and ending at endAngle going in the given direction by anticlockwise (defaulting to clockwise).
CanvasRenderingContext2D.rect()
Creates a path for a rectangle atposition (x, y) with a size that is determined by width and height.

Drawing paths

CanvasRenderingContext2D.fill()
Fills the subpaths with the current fill style.
CanvasRenderingContext2D.stroke()
Strokes the subpaths with the current stroke style.
CanvasRenderingContext2D.drawFocusIfNeeded()
If a given element is focused, this method draws a focus ring around the current path.
CanvasRenderingContext2D.scrollPathIntoView()
Scrolls the current path or a given path into the view.
CanvasRenderingContext2D.clip()
Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the clipping path only. For an example, see Clipping paths in the Canvas tutorial.
CanvasRenderingContext2D.isPointInPath()
Reports whether or not the specified point is contained in the current path.
CanvasRenderingContext2D.isPointInStroke()
Reports whether or not the specified point is inside the area contained by the stroking of a path.

Transformations

Objects in the CanvasRenderingContext2D rendering context have a current transformation matrix and methods to manipulate it. The transformation matrix is applied when creating the current default path, painting text, shapes and Path2D objects. The methods listed below remain for historical and compatibility reasons as SVGMatrix objects are used in most parts of the API nowadays and will be used in the future instead.

CanvasRenderingContext2D.currentTransform
Current transformation matrix (SVGMatrix object).
CanvasRenderingContext2D.rotate()
Adds a rotation to the transformation matrix. The angle argument represents a clockwise rotation angle and is expressed in radians.
CanvasRenderingContext2D.scale()
Adds a scaling transformation to the canvas units by x horizontally and by y vertically.
CanvasRenderingContext2D.translate()
Adds a translation transformation by moving the canvas and its origin x horzontally and y vertically on the grid.
CanvasRenderingContext2D.transform()
Multiplies the current transformation matrix with the matrix described by its arguments.
CanvasRenderingContext2D.setTransform()
Resets the current transform to the identity matrix, and then invokes the transform() method with the same arguments.
CanvasRenderingContext2D.resetTransform()
Resets the current transform by the identity matrix.

Compositing

CanvasRenderingContext2D.globalAlpha
Alpha value that is applied to shapes and images before they are composited onto the canvas. Default 1.0 (opaque).
CanvasRenderingContext2D.globalCompositeOperation
With globalAlpha applied this sets how shapes and images are drawn onto the existing bitmap.

Drawing images

CanvasRenderingContext2D.drawImage()
Draws the specified image. This method is available in multiple formats, providing a great deal of flexibility in its use.

Pixel manipulation

See also the ImageData object.

CanvasRenderingContext2D.createImageData()
Creates a new, blank ImageData object with the specified dimensions. All of the pixels in the new object are transparent black.
CanvasRenderingContext2D.getImageData()
Returns an ImageData object representing the underlying pixel data for the area of the canvas denoted by the rectangle which starts at (sx, sy) and has an sw width and sh height.
CanvasRenderingContext2D.putImageData()
Paints data from the given ImageData object onto the bitmap. If a dirty rectangle is provided, only the pixels from that rectangle are painted.

Image smoothing

CanvasRenderingContext2D.imageSmoothingEnabled
Image smoothing mode; if disabled, images will not be smoothed if scaled.
CanvasRenderingContext2D.imageSmoothingQuality
Allows you to set the quality of image smoothing.

The canvas state

The CanvasRenderingContext2D rendering context contains a variety of drawing style states (attributes for line styles, fill styles, shadow styles, text styles). The following methods help you to work with that state:

CanvasRenderingContext2D.save()
Saves the current drawing style state using a stack so you can revert any change you make to it using restore().
CanvasRenderingContext2D.restore()
Restores the drawing style state to the last element on the 'state stack' saved by save().
CanvasRenderingContext2D.canvas
A read-only back-reference to the HTMLCanvasElement. Might be null if it is not associated with a <canvas> element.

Hit regions

CanvasRenderingContext2D.addHitRegion()
Adds a hit region to the canvas.
CanvasRenderingContext2D.removeHitRegion()
Removes the hit region with the specified id from the canvas.
CanvasRenderingContext2D.clearHitRegions()
Removes all hit regions from the canvas.

Experimental APIs

CanvasRenderingContext2D.filter
Applies a CSS and SVG filter to the Canvas, e.g. to change the brightness or blur the canvas.

Non-standard APIs

Most of these APIs are deprecated and were removed shortly after Chrome 36.

CanvasRenderingContext2D.clearShadow()
Removes all shadow settings like CanvasRenderingContext2D.shadowColor and CanvasRenderingContext2D.shadowBlur.
CanvasRenderingContext2D.drawImageFromRect()
This is redundant with an equivalent overload of drawImage.
CanvasRenderingContext2D.setAlpha()
Use CanvasRenderingContext2D.globalAlpha instead.
CanvasRenderingContext2D.setCompositeOperation()
Use CanvasRenderingContext2D.globalCompositeOperation instead.
CanvasRenderingContext2D.setLineWidth()
Use CanvasRenderingContext2D.lineWidth instead.
CanvasRenderingContext2D.setLineJoin()
Use CanvasRenderingContext2D.lineJoin instead.
CanvasRenderingContext2D.setLineCap()
Use CanvasRenderingContext2D.lineCap instead.
CanvasRenderingContext2D.setMiterLimit()
Use CanvasRenderingContext2D.miterLimit instead.
CanvasRenderingContext2D.setStrokeColor()
Use CanvasRenderingContext2D.strokeStyle instead.
CanvasRenderingContext2D.setFillColor()
Use CanvasRenderingContext2D.fillStyle instead.
CanvasRenderingContext2D.setShadow()
Use CanvasRenderingContext2D.shadowColor and CanvasRenderingContext2D.shadowBlur instead.
CanvasRenderingContext2D.webkitLineDash
Use CanvasRenderingContext2D.getLineDash() and CanvasRenderingContext2D.setLineDash() instead.
CanvasRenderingContext2D.webkitLineDashOffset
Use CanvasRenderingContext2D.lineDashOffset instead.
CanvasRenderingContext2D.webkitImageSmoothingEnabled
Use CanvasRenderingContext2D.imageSmoothingEnabled instead.
CanvasRenderingContext2D.isContextLost()
Inspired by the same WebGLRenderingContext method it returns true if the Canvas context has been lost, or false if not.

WebKit only

CanvasRenderingContext2D.webkitBackingStorePixelRatio
The backing store size in relation to the canvas element. See High DPI Canvas.
CanvasRenderingContext2D.webkitGetImageDataHD
Intended for HD backing stores, but removed from canvas specifications.
CanvasRenderingContext2D.webkitPutImageDataHD
Intended for HD backing stores, but removed from canvas specifications.

Gecko only

Prefixed APIs

CanvasRenderingContext2D.mozCurrentTransform
Sets or gets the current transformation matrix, see CanvasRenderingContext2D.currentTransform.
CanvasRenderingContext2D.mozCurrentTransformInverse
Sets or gets the current inversed transformation matrix.
CanvasRenderingContext2D.mozImageSmoothingEnabled
See CanvasRenderingContext2D.imageSmoothingEnabled.
CanvasRenderingContext2D.mozTextStyle
Introduced in in Gecko 1.9, deprecated in favor of the CanvasRenderingContext2D.font property.
CanvasRenderingContext2D.mozDrawText()
This method was introduced in Gecko 1.9 and is removed starting with Gecko 7.0. Use CanvasRenderingContext2D.strokeText() or CanvasRenderingContext2D.fillText() instead.
CanvasRenderingContext2D.mozMeasureText()
This method was introduced in Gecko 1.9 and is unimplemented starting with Gecko 7.0. Use CanvasRenderingContext2D.measureText() instead.
CanvasRenderingContext2D.mozPathText()
This method was introduced in Gecko 1.9 and is removed starting with Gecko 7.0.
CanvasRenderingContext2D.mozTextAlongPath()
This method was introduced in Gecko 1.9 and is removed starting with Gecko 7.0.

Internal APIs (chrome-context only)

CanvasRenderingContext2D.drawWindow()
Renders a region of a window into the canvas. The contents of the window's viewport are rendered, ignoring viewport clipping and scrolling.
CanvasRenderingContext2D.demote()
This causes a context that is currently using a hardware-accelerated backend to fallback to a software one. All state should be preserved.

Internet Explorer

CanvasRenderingContext2D.msFillRule
The fill rule to use. This must be one of evenodd or nonzero (default).

Specifications

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 1 Yes 1.5 9 9 2
canvas Yes 12 Yes Yes Yes Yes
currentTransform Yes
Disabled
Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Yes No
No
See bug 928150. Firefox also supports the experimental and prefixed properties mozCurrentTransform and mozCurrentTransformInverse which set or get the current (inverse) transformation matrix.
No No No
No
See webkitbug(174278).
direction Yes
Disabled
Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
? No No No Yes
fillStyle Yes 12 Yes Yes Yes Yes
filter 52 ? 49
49
35 — 48
Disabled
Disabled From version 35 until version 48 (exclusive): this feature is behind the canvas.filters.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
No No No
font Yes 12 3.5 9 Yes Yes
globalAlpha Yes 12 Yes Yes Yes Yes
globalCompositeOperation Yes 12 Yes Yes Yes Yes
imageSmoothingEnabled 30
30
? — 30
Prefixed
Prefixed Implemented with the vendor prefix: webkit
15 51
51
? — 51
Prefixed
Prefixed Implemented with the vendor prefix: moz
Yes
Prefixed
Yes
Prefixed
Prefixed Implemented with the vendor prefix: ms
? ?
imageSmoothingQuality 54 ? No ? 41 Yes
lineCap Yes 12 Yes Yes Yes Yes
lineDashOffset Yes 12 27
27
7
Uses the non-standard name: mozDashOffset
11 Yes Yes
lineJoin Yes 12 Yes Yes Yes Yes
lineWidth Yes 12 Yes Yes Yes Yes
miterLimit Yes 12 Yes Yes Yes Yes
shadowBlur Yes 12 Yes Yes Yes Yes
shadowColor Yes 12 Yes Yes Yes Yes
shadowOffsetX Yes 12 Yes Yes Yes Yes
shadowOffsetY Yes 12 Yes Yes Yes Yes
strokeStyle Yes 12 Yes Yes Yes Yes
textAlign Yes 12 3.5 Yes Yes Yes
textBaseline Yes 12 3.5 9 Yes Yes
addHitRegion Yes
Disabled
Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
? 30
Disabled
30
Disabled
Disabled From version 30: this feature is behind the canvas.hitregions.enabled preference. To change preferences in Firefox, visit about:config.
No No No
arc Yes 12 Yes Yes Yes Yes
arcTo Yes 12 Yes Yes Yes Yes
beginPath Yes 12 Yes Yes Yes Yes
bezierCurveTo Yes 12 Yes Yes Yes Yes
clearHitRegions Yes
Disabled
Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
? 38
Disabled
38
Disabled
Disabled From version 38: this feature is behind the canvas.hitregions.enabled preference. To change preferences in Firefox, visit about:config.
No No No
clearRect Yes 12 Yes Yes Yes Yes
clip Yes 12 Yes Yes Yes Yes
closePath Yes 12 Yes Yes Yes Yes
createImageData Yes 12 Yes Yes Yes Yes
createLinearGradient Yes 12 Yes Yes Yes Yes
createPattern Yes 12 Yes Yes Yes Yes
createRadialGradient Yes 12 Yes Yes Yes Yes
drawFocusIfNeeded Yes ? 32
32
29
Disabled
Disabled From version 29: this feature is behind the canvas.focusring.enabled preference. To change preferences in Firefox, visit about:config.
28
Uses the non-standard name: drawSystemFocusRing
No Yes Yes
drawImage Yes 12 Yes Yes Yes Yes
drawWidgetAsOnScreen No No 41 No No No
drawWindow No No Yes No No No
ellipse 31 13 48 No 18 9
fill Yes 12 Yes Yes Yes Yes
fillRect Yes 12 Yes Yes Yes Yes
fillText Yes 12 3.5 9 Yes Yes
getImageData Yes 12 Yes
Yes
5
getImageData now correctly accepts rectangles that extend beyond the bounds of the canvas; pixels outside the canvas are returned as transparent black and now also returns at least one pixel's worth of image data if a rectangle smaller than one pixel is specified.
Yes Yes Yes
getLineDash Yes 12 27 11 Yes Yes
isPointInPath Yes 12 Yes Yes Yes Yes
isPointInStroke Yes No Yes No Yes Yes
lineTo Yes 12 Yes Yes Yes Yes
measureText Yes 12 Yes 9 Yes Yes
moveTo Yes 12 Yes Yes Yes Yes
putImageData Yes 12 Yes Yes Yes Yes
quadraticCurveTo Yes 12 Yes Yes Yes Yes
rect Yes 12 Yes Yes Yes Yes
removeHitRegion Yes
Disabled
Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
? 30
Disabled
30
Disabled
Disabled From version 30: this feature is behind the canvas.hitregions.enabled preference. To change preferences in Firefox, visit about:config.
Yes Yes Yes
resetTransform 31 ? 36 No No No
restore Yes 12 Yes Yes Yes Yes
rotate Yes 12 Yes Yes Yes Yes
save Yes 12 Yes Yes Yes Yes
scale Yes 12 Yes Yes Yes Yes
scrollPathIntoView Yes
Disabled
Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
? No No Yes No
setLineDash Yes 12 27 11 Yes Yes
setTransform Yes 12 Yes Yes Yes Yes
stroke Yes 12 Yes Yes Yes Yes
strokeRect Yes 12 Yes Yes Yes Yes
strokeText Yes 12 3.5 9 Yes Yes
transform Yes 12 Yes Yes Yes Yes
translate Yes 12 Yes Yes Yes Yes
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support Yes Yes Yes ? ? ? Yes
canvas Yes Yes Yes Yes Yes Yes Yes
currentTransform No No Yes No No No No
direction Yes Yes ? No No Yes Yes
fillStyle Yes Yes Yes Yes Yes Yes Yes
filter 52 52 ? 49
49
35 — 48
Disabled
Disabled From version 35 until version 48 (exclusive): this feature is behind the canvas.filters.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
No No 6.0
font Yes Yes Yes 4 Yes Yes Yes
globalAlpha Yes Yes Yes Yes Yes Yes Yes
globalCompositeOperation Yes Yes Yes Yes Yes Yes Yes
imageSmoothingEnabled 4.4 ? Yes 51
51
? — 51
Prefixed
Prefixed Implemented with the vendor prefix: moz
? ? ?
imageSmoothingQuality 54 54 ? No 41 Yes 6.0
lineCap Yes Yes Yes Yes Yes Yes Yes
lineDashOffset Yes Yes Yes 27
27
7
Uses the non-standard name: mozDashOffset
Yes Yes Yes
lineJoin Yes Yes Yes Yes Yes Yes Yes
lineWidth Yes Yes Yes Yes Yes Yes Yes
miterLimit Yes Yes Yes Yes Yes Yes Yes
shadowBlur Yes Yes Yes Yes Yes Yes Yes
shadowColor Yes Yes Yes Yes Yes Yes Yes
shadowOffsetX Yes Yes Yes Yes Yes Yes Yes
shadowOffsetY Yes Yes Yes Yes Yes Yes Yes
strokeStyle Yes Yes Yes Yes Yes Yes Yes
textAlign Yes Yes Yes 4 Yes Yes Yes
textBaseline Yes Yes Yes 4 Yes Yes Yes
addHitRegion No No ? 30
Disabled
30
Disabled
Disabled From version 30: this feature is behind the canvas.hitregions.enabled preference. To change preferences in Firefox, visit about:config.
No No No
arc Yes Yes Yes Yes Yes Yes Yes
arcTo Yes Yes Yes Yes Yes Yes Yes
beginPath Yes Yes Yes Yes Yes Yes Yes
bezierCurveTo Yes Yes Yes Yes Yes Yes Yes
clearHitRegions No No ? 38
Disabled
38
Disabled
Disabled From version 38: this feature is behind the canvas.hitregions.enabled preference. To change preferences in Firefox, visit about:config.
No No No
clearRect Yes Yes Yes Yes Yes Yes Yes
clip Yes Yes Yes Yes Yes Yes Yes
closePath Yes Yes Yes Yes Yes Yes Yes
createImageData Yes Yes Yes Yes Yes Yes Yes
createLinearGradient Yes Yes Yes Yes Yes Yes Yes
createPattern Yes Yes Yes Yes Yes Yes Yes
createRadialGradient Yes Yes Yes Yes Yes Yes Yes
drawFocusIfNeeded Yes Yes ? 32
32
29
Disabled
Disabled From version 29: this feature is behind the canvas.focusring.enabled preference. To change preferences in Firefox, visit about:config.
28
Uses the non-standard name: drawSystemFocusRing
Yes Yes Yes
drawImage Yes Yes Yes Yes Yes Yes Yes
drawWidgetAsOnScreen No No No 41 No No No
drawWindow No No No Yes No No No
ellipse No Yes Yes Yes No Yes Yes
fill Yes Yes Yes Yes Yes Yes Yes
fillRect Yes Yes Yes Yes Yes Yes Yes
fillText Yes Yes Yes 4 Yes Yes Yes
getImageData Yes Yes Yes Yes
Yes
5
getImageData now correctly accepts rectangles that extend beyond the bounds of the canvas; pixels outside the canvas are returned as transparent black and now also returns at least one pixel's worth of image data if a rectangle smaller than one pixel is specified.
Yes Yes Yes
getLineDash Yes Yes Yes 27 Yes Yes Yes
isPointInPath Yes Yes Yes Yes Yes Yes Yes
isPointInStroke Yes Yes Yes Yes Yes Yes Yes
lineTo Yes Yes Yes Yes Yes Yes Yes
measureText Yes Yes Yes Yes Yes Yes Yes
moveTo Yes Yes Yes Yes Yes Yes Yes
putImageData Yes Yes Yes Yes Yes Yes Yes
quadraticCurveTo Yes Yes Yes Yes Yes Yes Yes
rect Yes Yes Yes Yes Yes Yes Yes
removeHitRegion No No ? 30
Disabled
30
Disabled
Disabled From version 30: this feature is behind the canvas.hitregions.enabled preference. To change preferences in Firefox, visit about:config.
Yes Yes No
resetTransform No No ? 36 No No No
restore Yes Yes Yes Yes Yes Yes Yes
rotate Yes Yes Yes Yes Yes Yes Yes
save Yes Yes Yes Yes Yes Yes Yes
scale Yes Yes Yes Yes Yes Yes Yes
scrollPathIntoView Yes Yes ? No No No Yes
setLineDash Yes Yes Yes No Yes Yes Yes
setTransform Yes Yes Yes Yes Yes Yes Yes
stroke Yes Yes Yes Yes Yes Yes Yes
strokeRect Yes Yes Yes Yes Yes Yes Yes
strokeText Yes Yes Yes Yes Yes Yes Yes
transform Yes Yes Yes Yes Yes Yes Yes
translate Yes Yes Yes Yes Yes Yes Yes

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D