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
和
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>
,
SYNTAX_ERR
被引发。
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'CanvasGradient' in that specification. |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
CanvasGradient
|
Chrome 4 | Edge 12 |
Firefox
3.6
|
IE 9 | Opera 9 | Safari 3.1 | WebView Android Yes | Chrome Android 18 | Firefox Android 4 | Opera Android 10.1 | Safari iOS 3.2 | Samsung Internet Android 1.0 |
addColorStop
|
Chrome Yes | Edge 12 | Firefox 3.6 | IE Yes | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android 4 | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
见实现注意事项。
CanvasRenderingContext2D
.
<canvas>
element and its associated interface,
HTMLCanvasElement
.