0
如何將黑色填充的第一個元素移動到鼠標光標?或者只是如何將它移到我在事件處理程序中的位置?如何移動畫布元素?
的Javascript:
var drawing = document.getElementById('canvas');
var ctx = drawing.getContext('2d');
ctx.fillStyle = 'black';
ctx.fillRect(188, 50, 200, 100);
ctx.fillStyle = 'yellow';
ctx.fillRect(0, 0, 200, 100);
document.onmousemove = function(e) {
/* How to move rectangle here? */
}
http://jsfiddle.net/9545qbo4/1/
在此先感謝。
好的,謝謝! – qwerty 2014-08-31 11:07:49