此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

CanvasGradient

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

备注: 此特性在 Web Worker 中可用。

CanvasGradient 接口表示描述渐变的不透明对象。该接口通过 CanvasRenderingContext2D.createLinearGradient()CanvasRenderingContext2D.createConicGradient()CanvasRenderingContext2D.createRadialGradient() 方法返回。

实例属性

不透明对象,没有暴露的属性。

实例方法

CanvasGradient.addColorStop()

添加一个由偏移(offset)和颜色(color)定义的断点到渐变中。

规范

Specification
HTML
# canvasgradient

浏览器兼容性

参见