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

发布时间:2023-07-20 07:34:10 作者:Starsinthesky 阅读量:8722

 

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

 

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

我要评论

秒制作
Catfish(鲶鱼) Blog V 4.7.3