I am just starting with the canvas. I have done this:
http://www.kingoslo.com/instruments/
The arrow for the tachometer is depicted on canvas. Now I'm trying to make an animation to rotate it around the input of the tachometer (and not myself). This is what I wrote so far:
<script type="text/javascript">
var img = new Image();
function init(){
img.src = 'background.png';
setTimeout(draw,4000);
}
function draw() {
var ctx = document.getElementById('canvas').getContext('2d');
img.onload = function(){
ctx.drawImage(img,0,0);
ctx.beginPath();
ctx.moveTo(247,308);
ctx.bezierCurveTo(51, 408, 51, 410, 51, 411);
ctx.bezierCurveTo(53, 413, 52, 412, 249, 313);
ctx.fillStyle = "red";
ctx.fill();
}
}
</script>
I have no idea how to proceed. Also, is there documentation anywhere where this happens?
Thank.
Regards,
Marius
source
share