137-3385-8848(同微信)

微信小程序API绘图closePath,关闭小程序路径

2022-04-21 管理员

 

canvasContext.closePath


定义

关闭一个路径

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

 

更多微信小程序开发教程,可以关注。
上一篇:微信小程序moveTo把路径移动到画布中的指定点,用stroke()方法来画线条
下一篇:微信小程序API绘图beginPath,开始小程序路径
相关资讯 Releva ntnews
解决方案 Solutions
相关热点 Hot spot
郑州做排名中正确使用关键词优化的方法
  1. 我们的优势
  2. 我们的实力
  3. 选择我们的理由
咨询电话(微信同号)

137-3385-8848(同微信)

豫ICP备16014343号-1

Copyright © 2017-2022 版权所有 酷微科技 Rights Reserved

电话咨询 在线咨询 服务项目 SEO优化