当前位置:K88软件开发文章中心编程全书微信小程序 → 文章内容

微信小程序API 绘图beginPath(开始一个路径)

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-15 15:00:41

由 ?﹏???ζ???﹏﹏? 创建,youj 最后一次修改 2016-12-24 绘图接口和方法canvasContext.beginPath定义开始创建一个路径,需要调用fill或者stroke才会使用路径进行填充或描边。Tip: 在最开始的时候相当于调用了一次beginPath()。Tip: 同一个路径内的多次setFillStyle()、setStrokeStyle()、setLineWidth()等设置,以最后一次设置为准。例子const ctx = wx.createCanvasContext('myCanvas')// begin pathctx.rect(10, 10, 100, 30)ctx.setFillStyle('yellow')ctx.fill()// begin another pathctx.beginPath()ctx.rect(10, 40, 100, 30)// only fill this rect, not in current pathctx.setFillStyle('blue')ctx.fillRect(10, 70, 100, 30)ctx.rect(10, 100, 100, 30)// it will fill current pathctx.setFillStyle('red')ctx.fill()ctx.draw()绘图接口和方法

微信小程序API 绘图beginPath(开始一个路径)