课程表

微信小程序框架

微信小程序组件

微信小程序API

微信小程序开放接口

微信小程序工具

微信小程序设计规范

工具箱
速查手册

小程序API 关闭一个路径

当前位置:免费教程 » 移动开发 » 微信小程序

微信小程序 canvas接口和方法绘图接口和方法

closePath


定义

关闭一个路径

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

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

例子

  1. const ctx = wx.createCanvasContext('myCanvas')
  2. ctx.moveTo(10, 10)
  3. ctx.lineTo(100, 10)
  4. ctx.lineTo(100, 100)
  5. ctx.closePath()
  6. ctx.stroke()
  7. ctx.draw()


  1. const ctx = wx.createCanvasContext('myCanvas')
  2. // begin path
  3. ctx.rect(10, 10, 100, 30)
  4. ctx.closePath()
  5. // begin another path
  6. ctx.beginPath()
  7. ctx.rect(10, 40, 100, 30)
  8. // only fill this rect, not in current path
  9. ctx.setFillStyle('blue')
  10. ctx.fillRect(10, 70, 100, 30)
  11. ctx.rect(10, 100, 100, 30)
  12. // it will fill current path
  13. ctx.setFillStyle('red')
  14. ctx.fill()
  15. ctx.draw()


微信小程序 canvas接口和方法绘图接口和方法

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号