The CanvasRenderingContext2D
interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a <canvas>
element. It is used for drawing shapes, text, images, and other objects.
See the interface's properties and methods in the sidebar and below. The Canvas tutorial has more explanation, examples, and resources, as well.
Basic example
To get a CanvasRenderingContext2D
instance, you must first have an HTML <canvas>
element to work with:
<canvas id="my-house" width="300" height="300"></canvas>
To get the canvas' 2D rendering context, call getContext()
on the <canvas>
element, supplying '2d'
as the argument:
const canvas = document.getElementById('my-house');
const ctx = canvas.getContext('2d');
With the context in hand, you can draw anything you like. This code draws a house:
// Set line width
ctx.lineWidth = 10;
// Wall
ctx.strokeRect(75, 140, 150, 110);
// Door
ctx.fillRect(130, 190, 40, 60);
// Roof
ctx.beginPath();
ctx.moveTo(50, 140);
ctx.lineTo(150, 60);
ctx.lineTo(250, 140);
ctx.closePath();
ctx.stroke();
The resulting drawing looks like this:
Reference
Drawing rectangles
There are three methods that immediately draw rectangles to the canvas.
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 draw 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
,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 aCanvasPattern
.
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 current sub-path to the specified (x, y) coordinates with a straight line.
CanvasRenderingContext2D.bezierCurveTo()
- Adds a cubic Bézier curve to the current path.
CanvasRenderingContext2D.quadraticCurveTo()
- Adds a quadratic Bézier curve to the current path.
CanvasRenderingContext2D.arc()
- Adds a circular arc to the current path.
CanvasRenderingContext2D.arcTo()
- Adds an arc to the current path with the given control points and radius, connected to the previous point by a straight line.
CanvasRenderingContext2D.ellipse()
- Adds an elliptical arc to the current path.
CanvasRenderingContext2D.rect()
- Creates a path for a rectangle at ' position (x, y) with a size that is determined by width and height.
Drawing paths
CanvasRenderingContext2D.fill()
- Fills the current sub-paths with the current fill style.
CanvasRenderingContext2D.stroke()
- Strokes the current sub-paths 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.getTransform()
- Retrieves the current transformation matrix being applied to the context.
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 benull
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.
Filters
- '
CanvasRenderingContext2D.filter
- Applies a CSS or SVG filter to the canvas, e.g., to change its brightness or bluriness.
Non-standard APIs
Blink and WebKit
Most of these APIs are deprecated and were removed shortly after Chrome 36.
- ' '
CanvasRenderingContext2D.clearShadow()
- Removes all shadow settings like
CanvasRenderingContext2D.shadowColor
andCanvasRenderingContext2D.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
andCanvasRenderingContext2D.shadowBlur
instead. - ' '
CanvasRenderingContext2D.webkitLineDash
- Use
CanvasRenderingContext2D.getLineDash()
andCanvasRenderingContext2D.setLineDash()
instead. - ' '
CanvasRenderingContext2D.webkitLineDashOffset
- Use
CanvasRenderingContext2D.lineDashOffset
instead. - ' '
CanvasRenderingContext2D.webkitImageSmoothingEnabled
- Use
CanvasRenderingContext2D.imageSmoothingEnabled
instead.
Blink only
- '
CanvasRenderingContext2D.isContextLost()
- Inspired by the same
WebGLRenderingContext
method it returnstrue
if the Canvas context has been lost, orfalse
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()
orCanvasRenderingContext2D.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
ornonzero
(default).
Specifications
Specification | Status | Comment |
HTML Living StandardThe definition of 'CanvasRenderingContext2D' in that specification. | Living Standard |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
CanvasRenderingContext2D
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support 9 |
Opera
Full support 9 |
Safari
Full support 2 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
Chrome Full support Yes Full support Yes Disabled' This feature is behind the |
Edge Full support ≤79 Full support ≤79 Disabled' From version ≤79: this feature is behind the |
Firefox Full support 30 Full support 30 Disabled' From version 30: this feature is behind the |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android Full support 30 Full support 30 Disabled' From version 30: this feature is behind the |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No | |
arc
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support 9 |
Opera
Full support 11.6 |
Safari
Full support 3 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 12 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
arcTo
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support 9 |
Opera
Full support 11.6 |
Safari
Full support 2 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 12 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
beginPath
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
bezierCurveTo
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support 9 |
Opera
Full support 11.6 |
Safari
Full support 2 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 12 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
canvas
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
Chrome Full support Yes Full support Yes Disabled' This feature is behind the |
Edge Full support ≤79 Full support ≤79 Disabled' From version ≤79: this feature is behind the |
Firefox Full support 38 Full support 38 Disabled' From version 38: this feature is behind the |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android Full support 38 Full support 38 Disabled' From version 38: this feature is behind the |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No | |
clearRect
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
clip
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
closePath
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support 9 |
Opera
Full support 11.6 |
Safari
Full support 2 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 12 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
createImageData
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 2 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
createLinearGradient
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
createPattern
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
createRadialGradient
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
Chrome Full support Yes Full support Yes Disabled' This feature is behind the |
Edge
Full support ≤18 |
Firefox No support No No support No Notes' See bug 928150. Firefox also supports the experimental and prefixed properties mozCurrentTransform and mozCurrentTransformInverse which set or get the current (inverse) transformation matrix. |
IE
No support No |
Opera
No support No |
Safari No support No No support No Notes' See webkitbug(174278). |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No | |
Chrome Full support Yes Full support Yes Disabled' This feature is behind the |
Edge Full support ≤79 Full support ≤79 Disabled' From version ≤79: this feature is behind the |
Firefox
No support No |
IE
No support No |
Opera
No support No |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes | |
drawFocusIfNeeded
|
Chrome
Full support Yes |
Edge
Full support 14 |
Firefox Full support 32 Full support 32 Full support 29 Disabled' From version 29: this feature is behind the Alternate Name' Uses the non-standard name: |
IE
No support No |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android Full support 32 Full support 32 Full support 29 Disabled' From version 29: this feature is behind the Alternate Name' Uses the non-standard name: |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
drawImage
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support 9 |
Opera
Full support 9 |
Safari
Full support 2 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
Chrome
No support No |
Edge
No support No |
Firefox
Full support 41 |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
Full support 41 |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No | |
Chrome
No support No |
Edge
No support No |
Firefox
Full support 1.5 |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
Full support 4 |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No | |
Chrome
Full support 31 |
Edge
Full support 13 |
Firefox
Full support 48 |
IE
No support No |
Opera
Full support 18 |
Safari
Full support 9 |
WebView Android
Full support 4.4.3 |
Chrome Android
Full support 31 |
Firefox Android
Full support 48 |
Opera Android
Full support 18 |
Safari iOS
Full support 9 |
Samsung Internet Android
Full support 2.0 | |
fill
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
fillRect
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support 9 |
Opera
Full support 9 |
Safari
Full support 2 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
fillStyle
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
fillText
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 3.5 |
IE
Full support 9 |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
Chrome
Full support 52 |
Edge
Full support 79 |
Firefox Full support 49 Full support 49 No support 35 — 48 Disabled' From version 35 until version 48 (exclusive): this feature is behind the |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
Full support 52 |
Chrome Android
Full support 52 |
Firefox Android Full support 49 Full support 49 No support 35 — 48 Disabled' From version 35 until version 48 (exclusive): this feature is behind the |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
Full support 6.0 | |
font
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 3.5 |
IE
Full support 9 |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
getImageData
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox Full support 2 Full support 2 Notes' Since Firefox 5, |
IE
Full support 9 |
Opera
Full support 9.5 |
Safari
Full support 4 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android Full support 4 Full support 4 Notes' Since Firefox 5, |
Opera Android
Full support 10.1 |
Safari iOS
Full support 3.2 |
Samsung Internet Android
Full support 1.0 |
getLineDash
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 27 |
IE
Full support 11 |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 27 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
getTransform
|
Chrome
Full support 68 |
Edge
Full support 79 |
Firefox
Full support 70 |
IE
No support No |
Opera
Full support 55 |
Safari
Full support 11 |
WebView Android
Full support 68 |
Chrome Android
Full support 68 |
Firefox Android
No support No |
Opera Android
Full support 48 |
Safari iOS
Full support 11 |
Samsung Internet Android
Full support 10.0 |
globalAlpha
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
globalCompositeOperation
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support 9 |
Opera
Full support 9 |
Safari
Full support 2 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
Chrome Full support 30 Full support 30 No support ? — 30 Prefixed' Implemented with the vendor prefix: webkit |
Edge
Full support 15 |
Firefox Full support 51 Full support 51 No support ? — 51 Prefixed' Implemented with the vendor prefix: moz |
IE Full support Yes Full support Yes Prefixed' Implemented with the vendor prefix: ms |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support 4.4 |
Chrome Android
Full support Yes |
Firefox Android Full support 51 Full support 51 No support ? — 51 Prefixed' Implemented with the vendor prefix: moz |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes | |
Chrome
Full support 54 |
Edge
Full support ≤79 |
Firefox
No support No |
IE
? |
Opera
Full support 41 |
Safari
Full support Yes |
WebView Android
Full support 54 |
Chrome Android
Full support 54 |
Firefox Android
No support No |
Opera Android
Full support 41 |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support 6.0 | |
isPointInPath
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 2 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
isPointInStroke
|
Chrome
Full support Yes |
Edge
Full support 79 |
Firefox Full support 20 Full support 20 No support 19 — 20 Prefixed' Implemented with the vendor prefix: moz |
IE
No support No |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android Full support 20 Full support 20 No support 19 — 20 Prefixed' Implemented with the vendor prefix: moz |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
lineCap
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
lineDashOffset
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox Full support 27 Full support 27 Full support 7 Alternate Name' Uses the non-standard name: |
IE
Full support 11 |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android Full support 27 Full support 27 Full support 7 Alternate Name' Uses the non-standard name: |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
lineJoin
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
lineTo
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support 9 |
Opera
Full support 11.6 |
Safari
Full support 2 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 12 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
lineWidth
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
measureText
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 2 |
IE
Full support 9 |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
miterLimit
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
moveTo
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support 9 |
Opera
Full support 11.6 |
Safari
Full support 2 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 12 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
putImageData
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 2 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
quadraticCurveTo
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support 9 |
Opera
Full support 11.6 |
Safari
Full support 3 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 12 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
rect
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support 9 |
Opera
Full support 11.6 |
Safari
Full support 2 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 12 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
Chrome Full support Yes Full support Yes Disabled' This feature is behind the |
Edge Full support 79 Full support 79 Disabled' From version 79: this feature is behind the |
Firefox Full support 30 Full support 30 Disabled' From version 30: this feature is behind the |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android Full support 30 Full support 30 Disabled' From version 30: this feature is behind the |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
No support No | |
Chrome
Full support 31 |
Edge
Full support 79 |
Firefox
Full support 36 |
IE
No support No |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 36 |
Opera Android
No support No |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes | |
restore
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
rotate
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
save
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
scale
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
Chrome Full support Yes Full support Yes Disabled' This feature is behind the |
Edge Full support ≤79 Full support ≤79 Disabled' From version ≤79: this feature is behind the |
Firefox
No support No |
IE
No support No |
Opera
Full support Yes |
Safari
No support No |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
Full support Yes | |
setLineDash
|
Chrome
Full support 23 |
Edge
Full support 12 |
Firefox
Full support 27 |
IE
Full support 11 |
Opera
Full support 15 |
Safari
Full support 6.1 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 25 |
Firefox Android
Full support 27 |
Opera Android
Full support 14 |
Safari iOS
Full support 7 |
Samsung Internet Android
Full support 1.5 |
setTransform
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 3 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
shadowBlur
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
shadowColor
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
shadowOffsetX
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
shadowOffsetY
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
stroke
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
strokeRect
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
strokeStyle
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
strokeText
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 3.5 |
IE
Full support 9 |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support Yes |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
textAlign
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 3.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
textBaseline
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 3.5 |
IE
Full support 9 |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
transform
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 3 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
translate
|
Chrome
Full support Yes |
Edge
Full support 12 |
Firefox
Full support 1.5 |
IE
Full support Yes |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.'
- Experimental. Expect behavior to change in the future.
- Non-standard. Expect poor cross-browser support.'
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.'
- Deprecated. Not for use in new websites.
- See implementation notes.'
- See implementation notes.
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
- Uses a non-standard name.'
- Uses a non-standard name.
- Requires a vendor prefix or different name for use.'
- Requires a vendor prefix or different name for use.
See also
CanvasRenderingContext2D by Mozilla Contributors is licensed under CC-BY-SA 2.5.