微信小程序API绘图createCircularGradient,创建微信小程序圆形渐变

发布时间:2023-07-19 21:01:39 作者:andrel 阅读量:4994

 


canvasContext.createCircularGradient


定义

创建一个圆形的渐变颜色。

Tip: 起点在圆心,终点在圆环。

Tip: 需要使用addColorStop()来指定渐变点,至少要两个。

参数

参数 类型 定义
x Number 圆心的x坐标
y Number 圆心的y坐标
r Number 圆的半径

例子

const ctx = wx.createCanvasContext('myCanvas')

// Create circular gradient
const grd = ctx.createCircularGradient(75, 50, 50)
grd.addColorStop(0, 'red')
grd.addColorStop(1, 'white')

// Fill with gradient
ctx.setFillStyle(grd)
ctx.fillRect(10, 10, 150, 80)
ctx.draw()

 

更多微信小程序开发教程,可以关注多程序。
***本网站图片,文字之类版权申明,因为网站可以由注册用户自行上传图片或文字,本网站无法鉴别所上传图片或文字的知识版权,如果侵犯,请及时通知我们,本网站将在第一时间及时删除。

我要评论

秒制作
Catfish(鲶鱼) Blog V 4.7.3