微信小程序API 绘图createLinearGradient(创建线性渐变)


本文整理自网络,侵删。

绘图接口和方法


canvasContext.createLinearGradient


定义

创建一个线性的渐变颜色。

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

参数

参数类型定义
x0Number起点的x坐标
y0Number起点的y坐标
x1Number终点的x坐标
y1Number终点的y坐标

例子

const ctx = wx.createCanvasContext('myCanvas')

// Create linear gradient
const grd = ctx.createLinearGradient(0, 0, 200, 0)
grd.addColorStop(0, 'red')
grd.addColorStop(1, 'white')

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


绘图接口和方法


标签:微信小程序

相关阅读 >>

微信小程序api 图片-全屏预览图片

微信小程序api tabbar

微信小程序云开发 代金券

微信小程序api 菜单

微信小程序 运力方使用onmockupdateorder

微信小程序 查询欠费用户列表

sdk数据库 command查询数组操作符

微信小程序云开发存储

微信小程序 运力方使用previewtemplate

微信小程序api绘图中创建三次方贝塞尔曲线路径

更多相关阅读请进入《微信小程序》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...