【发布时间】:2012-11-06 07:43:19
【问题描述】:
我在bodyonmousemove函数上使用这个脚本:
function lineDraw() {
// Get the context and the canvas:
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
// Clear the last canvas
context.clearRect(0, 0, canvas.width, canvas.height);
// Draw the line:
context.moveTo(0, 0);
context.lineTo(event.clientX, event.clientY);
context.stroke();
}
每次我移动鼠标时都应该清除画布并画一条新线,但它不能正常工作。 我试图在不使用 jQuery、鼠标侦听器或类似工具的情况下解决它。
【问题讨论】:
标签: javascript line draw onmousemove