课程表

微信小程序框架

微信小程序组件

微信小程序API

微信小程序开放接口

微信小程序工具

微信小程序设计规范

工具箱
速查手册

小程序API 开始一个路径

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

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

beginPath


定义

开始创建一个路径,需要调用fill或者stroke才会使用路径进行填充或描边。

Tip: 在最开始的时候相当于调用了一次 beginPath()

Tip: 同一个路径内的多次setFillStyle()setStrokeStyle()setLineWidth()等设置,以最后一次设置为准。

例子

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