I am doing this script that will rotate the needle on the tachometer using a canvas. I am new to this canvas. This is my code:
function startup() { var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); var meter = new Image(); meter.src = 'background.png'; var pin = new Image(); pin.src = 'needle.png'; context.drawImage(meter,0,0); context.translate(275,297); for (var frm = 0; frm < 6000; frm++){ var r=frm/1000;
Here is the script action in action:
http://www.kingoslo.com/instruments/
The problem is that the red needle is not removed between each loop.
What I need to do is clear the canvas for the pin object between each cycle of the loop. How to do it?
Thanks.
Yours faithfully,
Marius
source share