Here is an example for the html5 moving circle with a tutorial explaining the code and how to do it. The code under the gplv3 license is so clearly free.
https://www.youtube.com/watch?v=6j4Y14TEO6s
Fragment in focus ctx.strokeStyle = 'rgb (255,0,0)'; ctx.lineWidth = 10;
ctx.beginPath(); ctx.arc(x, y, radius, 0, Math.PI * 2, false); ctx.closePath(); ctx.stroke();
Another example is the following, where it shows an animated perspective of the same, if that is what you are looking for.
https://www.youtube.com/watch?v=eKDeKFFZDNo
The trick is to break the animation at some point and thus the shot is in focus in the code redraw section.
if (!ctx.isPointInPath(300,500)) { x = x + 1; y = y + 2; ctx.strokeStyle = colorToHex(getRandom(255),getRandom(255),getRandom(255)); ctx.lineWidth = 10; ctx.beginPath(); ctx.arc(x, y, radius, 0, Math.PI * 2, false); ctx.closePath(); ctx.stroke(); }
source share