微信小程序API 绘图fill(对当前路径进行填充)


本文整理自网络,侵删。

绘图接口和方法

canvasContext.fill


定义

对当前路径中的内容进行填充。默认的填充色为黑色。

Tip: 如果当前路径没有闭合,fill()方法会将起点和终点进行连接,然后填充,详情见例一。

Tip:fill()填充的的路径是从beginPath()开始计算,但是不会将fillRect()包含进去,详情见例二。

例子

const ctx = wx.createCanvasContext('myCanvas')
ctx.moveTo(10, 10)
ctx.lineTo(100, 10)
ctx.lineTo(100, 100)
ctx.fill()
ctx.draw()


const ctx = wx.createCanvasContext('myCanvas')
// begin path
ctx.rect(10, 10, 100, 30)
ctx.setFillStyle('yellow')
ctx.fill()

// begin another path
ctx.beginPath()
ctx.rect(10, 40, 100, 30)

// only fill this rect, not in current path
ctx.setFillStyle('blue')
ctx.fillRect(10, 70, 100, 30)

ctx.rect(10, 100, 100, 30)

// it will fill current path
ctx.setFillStyle('red')
ctx.fill()
ctx.draw()


绘图接口和方法


标签:微信小程序

相关阅读 >>

微信小程序api 实时音视频-liveplayercontext实例

微信小程序api 绘图getactions(不推荐使用)

微信小程序 小程序使用onbindresultupdate

微信小程序 小程序使用addtip

微信小程序云开发服务端数据库api update

微信小程序框架逻辑层(app service)

微信小程序云开发控制台

微信小程序云开发 预付费

微信小程序api 网络

微信小程序开放数据 ad-custom

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




打赏

取消

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

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

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

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

评论

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