Is it possible to move an image inside a canvas element smoothly? this is what I'm trying:
if (a == 1) { // onmousedown
CX = event.clientX;
CY = event.clientY;
return;
} else if (a == 2) { // onmouseup
CimgX += event.clientX - CX;
CimgY += event.clientY - CY;
ctx[0].clearRect(0, 0, canvas[0].width, canvas[0].height);
ctx[0].drawImage(img, CimgX, CimgY);
but you can see that it won't work smoothly, it will just clear the canvas and draw the image in a new location, I tried onmousemove
and setInterval
but it didn't work. Any thoughts?