注册

微信小程序API绘图beginPath,开始小程序路径

2017-12-22
导读:绘图接口和方法 canvasContext.beginPath 定义 开始创建一个路径,需要调用fill或者stroke才会使用路径进行填充或描边。 Tip : 在最开始的时候相当于调用了一次 beginPath() 。 Tip : 同一个路径内...

 

canvasContext.beginPath


定义

开始创建一个路径,需要调用fill或者stroke才会使用路径进行填充或描边。

Tip: 在最开始的时候相当于调用了一次beginPath()

Tip: 同一个路径内的多次setFillStyle()setStrokeStyle()setLineWidth()等设置,以最后一次设置为准。

例子

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()

 

更多微信小程序开发教程,可以关注hi小程序。
重磅推荐:小程序开店目录

第一部分:小商店是什么

第二部分:如何开通一个小商店

第三部分:如何登录小商店

第四部分:开店任务常见问题

第五部分:小商店可以卖什么

第六部分:HiShop小程序特色功能

第七部分:小程序直播

第八部分:小程序收货/物流

第九部分:小程序怎么结算

第十部分:小程序客服

第十一部分:电商创业

第十二部分:小程序游戏开发