我想在mouseover事件上调整大小并缓慢增长大小的canvas元素(如弧形)。我怎么能这样做?
答案 0 :(得分:0)
// Every time the mouse comes over the canvas the radius increases.
// you could even add a timer so that every time the mouse stays over
// the canvas the radius continues to increase constantly
can.addEventListener('mouseover', function(e) {
radius += 10;
ctx.clearRect(0,0,can.width, can.height);
ctx.beginPath();
ctx.arc(150, 150, radius, 0, Math.PI*.8, false);
ctx.stroke();
}, false);
鼠标悬停在画布上绘制的“对象”?你必须add object persistence and detection to the canvas。