<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="700" height="600"
style="border:1px solid #d3d3d3;">
</canvas>
<script>
let counter = 0;
let canvas = document.getElementById("myCanvas");
let ctx = canvas.getContext("2d");
ctx.font = "75px Arial";
ctx.fillStyle = "red";
let timer = setInterval(function() {
ctx.clearRect(0,0,700,600);
let x = Math.floor(Math.random() * 300);
let y = Math.floor(Math.random() * 300)+150;
ctx.fillText(counter,x,y);
counter = counter +1;
}, 1000);
</script>
</body>
</html>
|