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 GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
CanvasGradient
addColorStop

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

参见