The CanvasGradient
interface represents an opaque object describing a gradient. It is returned by the methods CanvasRenderingContext2D.createLinearGradient()
or CanvasRenderingContext2D.createRadialGradient()
.
It can be used as a fillStyle
or strokeStyle
.
As an opaque object, there is no exposed property.
There is no inherited method.
CanvasGradient.addColorStop()
offset
and a color
, to the gradient. If the offset is not between 0
and 1
, inclusive, an INDEX_SIZE_ERR
is raised; if the color can't be parsed as a CSS <color>
, a SYNTAX_ERR
is raised.Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'CanvasGradient' in that specification. | Living Standard |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 4 | Yes | 3.6
|
9 | 9 | 3.1 |
addColorStop |
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 | ? | 18 | Yes | 4 | 10.0 | 3.2 | Yes |
addColorStop |
? | Yes | Yes | Yes | Yes | Yes | Yes |
CanvasRenderingContext2D
.<canvas>
element and its associated interface, HTMLCanvasElement
.
© 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/CanvasGradient