You are on page 1of 1

<html>

<body>
<canvasid="myCanvas" width="600" height="600"></canvas>
<scriptsrc='coords.js' type='text/javascript'></script>
<script>
letframe= 0;
letcanvas= document.getElementById('myCanvas');
letcontext= canvas.getContext('2d');
functionline(p1,p2) {
context.beginPath();
context.moveTo(p1.x,p1.y);
context.lineTo(p2.x,p2.y);
context.stroke();
}
functiondraw(){
context.clearRect(0,0,600,600);
letpoints=[];
for(letn=0;n<11;n++){
letpoint={
x: coords[fram*2*11+n*2],
y: 400-coords[fram*2*11+n*2+1]
};
points.push(point);
}
context.beginPath();
context.arc(points[2].x,points[2].y,30,0,2*Math.PI);
context.stroke();
line(points[0], points[1]);
line(points[1], points[3]);
line(points[3], points[4]);
line(points[0], points[5]);
line(points[5], points[6]);
line(points[1], points[7]);
line(points[7], points[8]);
line(points[0], points[9]);
line(points[9], points[10]);
frame++;
if(frame==226)
frame=0;
window.requestAnimationFrame(draw);
}
context.lineWidth=10;
context.lineCap ='round';
draw();
</script>
</body>
</html>

You might also like