微信小程序开发 专题
专题目录
您的位置:微信小程序开发 > 微信小程序开发专题 > 微信小程序API 绘图closePath(关闭一个路径)
微信小程序API 绘图closePath(关闭一个路径)
作者:--    发布时间:2019-11-20 21:09:40


定义

关闭一个路径

tip: 关闭路径会连接起点和终点。

tip: 如果关闭路径后没有调用fill()或者stroke()并开启了新的路径,那之前的路径将不会被渲染。

例子

const ctx = wx.createcanvascontext('mycanvas')
ctx.moveto(10, 10)
ctx.lineto(100, 10)
ctx.lineto(100, 100)
ctx.closepath()
ctx.stroke()
ctx.draw()


const ctx = wx.createcanvascontext('mycanvas')
// begin path
ctx.rect(10, 10, 100, 30)
ctx.closepath()

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


网站声明:
本站部分内容来自网络,如您发现本站内容
侵害到您的利益,请联系本站管理员处理。
联系站长
373515719@qq.com
关于本站:
编程参考手册