canvasContext.createCircularGradient
解释:创建一个圆形的渐变颜色。
参数:
参数名 | 类型 | 说明 |
---|---|---|
x | Number | 圆心的 x 坐标 |
y | Number | 圆心的 y 坐标 |
r | Number | 圆的半径 |
示例:
- const ctx = swan.createCanvasContext('myCanvas');
// Create circular gradient
const grd = ctx.createCircularGradient(75, 50, 50);
grd.addColorStop(0, 'red');
grd.addColorStop(1, 'blue');
// Fill with gradient
ctx.setFillStyle(grd);
ctx.fillRect(30, 30, 150, 80);
ctx.draw();