创新互联小程序教程:微信小程序API绘图beginPath(开始一个路径)

疆括仕网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

创新互联小程序教程:微信小程序API绘图beginPath(开始一个路径)

绘图接口和方法

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

绘图接口和方法


本文标题:创新互联小程序教程:微信小程序API绘图beginPath(开始一个路径)
新闻来源:https://tyhkzb.com/article/cojsogo.html
在线咨询
服务热线
服务热线:028-86922220
TOP