I thought what I was trying to do was simple! But I'm struggling. I've got this funky grid drawn, but i want to 'see' it be draw animating one line after the other, I' thought by using the timeout and animateframe that it would animate and draw each line in succession but it keeps just 'appearing' rather than animating, what am i missing?!
var fps = 15; var c = document.getElementById("box2009"); var ctx = c.getContext("2d"); draw(); function draw() { setTimeout(function () { ctx.strokeStyle = "rgb(0,0,0)"; requestAnimationFrame(draw); ctx.beginPath(); ctx.moveTo(100, 5); ctx.lineTo(289, 5); ctx.lineTo(289, 69); ctx.lineTo(100, 69); ctx.lineTo(100, 2); ctx.moveTo(5, 69); ctx.lineTo(100, 69); ctx.lineTo(100, 139); ctx.lineTo(5, 139); ctx.lineTo(5, 66); ctx.moveTo(289, 69); ctx.lineTo(289, 139); ctx.lineTo(192, 139); ctx.lineTo(192, 69); ctx.moveTo(100, 139); ctx.lineTo(192, 139); ctx.lineTo(192, 215); ctx.lineTo(100, 215); ctx.lineTo(100, 139); ctx.moveTo(289, 139); ctx.lineTo(406, 139); ctx.lineTo(406, 231); ctx.lineTo(289, 231); ctx.lineTo(289, 139); ctx.moveTo(406, 231); ctx.lineTo(513, 231); ctx.lineTo(513, 325); ctx.lineTo(406, 325); ctx.lineTo(406, 231); ctx.lineWidth = 5; ctx.stroke(); }, 1000 / fps); }