CanvasGradient
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
备注: 此特性在 Web Worker 中可用。
CanvasGradient
接口表示描述渐变的不透明对象。该接口通过 CanvasRenderingContext2D.createLinearGradient()
、CanvasRenderingContext2D.createConicGradient()
或 CanvasRenderingContext2D.createRadialGradient()
方法返回。
实例属性
不透明对象,没有暴露的属性。
实例方法
CanvasGradient.addColorStop()
-
添加一个由偏移(
offset
)和颜色(color
)定义的断点到渐变中。
规范
Specification |
---|
HTML # canvasgradient |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
CanvasGradient | ||||||||||||
addColorStop |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
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.
参见
CanvasRenderingContext2D
中的创建方法。<canvas>
元素及其相关接口HTMLCanvasElement
。