canvas教程

HTML5 Canvas编写五彩连珠(2):画图(2)

字号+ 作者:H5之家 来源:H5之家 2015-10-04 16:33 我要评论( )

[javascript] clearBubble: function (x, y) { var px = this.startX + this.cellWidth * x - this.cellWidth + 0.5; var py = this.startY + this.cellWidth * y - this.cellWidth + 0.5; ctx.beginPath(); ctx.cl

[javascript]
clearBubble: function (x, y) { var px = this.startX + this.cellWidth * x - this.cellWidth + 0.5; var py = this.startY + this.cellWidth * y - this.cellWidth + 0.5; ctx.beginPath(); ctx.clearRect(px, py, this.cellWidth - 1, this.cellWidth - 1); ctx.stroke(); } 

 clearBubble: function (x, y) { var px = this.startX + this.cellWidth * x - this.cellWidth + 0.5; var py = this.startY + this.cellWidth * y - this.cellWidth + 0.5; ctx.beginPath(); ctx.clearRect(px, py, this.cellWidth - 1, this.cellWidth - 1); ctx.stroke(); }
 ok,是不是很霸气? o(∩_∩)o 哈哈,不过在获取泡泡的位置时是不是很纠结,为什么画泡泡是 width/2 而擦除要加0.5?
画圆是从中心点开始画,所以要去掉半径,而擦数不能擦掉我们的棋盘线,所以要偏移0.5 。

  

\




摘自  君之?
 

转载请注明来源:HTML5 Canvas编写五彩连珠(2):画图

标签:PHP ,CSS数据库 ,优化

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • kphp框架分享:html5知识学习之html5中的canvas元素的简单介绍。

    kphp框架分享:html5知识学习之html5中的canvas元素的简单介绍。

    2017-04-28 17:02

  • 传智播客PHP培训 韩顺平 PHP视频教程 Ajax技术 课堂源代码.zip

    传智播客PHP培训 韩顺平 PHP视频教程 Ajax技术 课堂源代码.zip

    2017-04-26 16:00

  • 传智播客PHP培训 韩忠康 PHP视频教程 Mysql 第34讲 备份还原.wmv

    传智播客PHP培训 韩忠康 PHP视频教程 Mysql 第34讲 备份还原.wmv

    2017-04-24 11:01

  • 基于thinkphp5开发的通用版restful接口框架

    基于thinkphp5开发的通用版restful接口框架

    2017-04-22 14:00

网友点评
A