<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="1500" height="1500" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var g = 300;
var x = 0;
var y = 0;
var line = 300;
const intervalID = setInterval(myCallback, 300);
function myCallback(){
ctx.moveTo(g,g);
ctx.lineTo(x+line, y-line);
ctx.moveTo(g,g);
ctx.lineTo(x-line, y+line);
g = g + 5;
ctx.stroke();
}
</script>
</body>
</html>
|