微信小程序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 nfc-nfcb标签

微信小程序api 音频-暂停播放

微信小程序 小程序使用abnormalconfirm

微信小程序 页面

微信小程序 插件服务微信同声传译

微信小程序 即时配送接口(商家查看)-相关接口和事件

微信小程序 用户信息-unionid机制说明

微信小程序api 录音-停止录音

微信小程序 运力方使用oncheckbusiness

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




打赏

取消

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

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

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

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

评论

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