HTML5 Draw Canvas - 计算点击次数

时间:2014-02-18 12:22:21

标签: javascript html5 canvas

我在图像上有一个HTML5绘制画布,允许用户在图像上绘制点:

JAVASCRIPT

var sketcher = null;
var brush = null;

$(document).ready(function(e) {

  brush = new Image();
  brush.src = 'assets/brush2.png';
  brush.onload = function(){
    sketcher = new Sketcher( "sketch", brush );
  }

 });

HTML

<canvas id="sketch" width="1024" height="687" />
<canvas id="draw"/>

<div class="id1462-Main-Window"><img src="images/1462_Main_Window.jpg"
 width="1024"height="687" alt=""/>

我正在尝试添加一个功能,当用户在画布区域中单击/绘制一个点时,计数器会逐步增加+1。

<p id="counter_text"><span>0</span></p>

1 个答案:

答案 0 :(得分:0)

$(function(){
      canvas.addEventListener('click', function() { 
          $("#counter_text").val($("#counter_text").val() += 1);
      }, false);
});