I have tried with some code, but it's not working fine.
var canvas=document.getElementById('can');
ctx=canvas.getContext('2d');
canvas.width=1200;
canvas.height=750;
for (var x = 100; x <=900; x+=10) {
linedraw(x);
}
function linedraw(n) {
setTimeout(function(){
ctx.moveTo(n,100);
ctx.lineTo(n+20,100);
ctx.stroke();
},1000 * 5);
}
<canvas id="can" style="background-color: gray"></canvas>
Here you go
var canvas=document.getElementById('can');
ctx=canvas.getContext('2d');
canvas.width=1200;
canvas.height=750;
for (var x = 100; x <=900; x+=10) {
linedraw(x);
}
function linedraw(n) {
setTimeout(function(){
ctx.moveTo(n,100);
ctx.lineTo(n+20,100);
ctx.stroke();
},5000/900*n); // change here
}
<canvas id="can" style="background-color: gray"></canvas>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With