<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid
#d3d3d3;" >
</canvas>
<script>
let c = document.getElementById("myCanvas");
let ctx = c.getContext("2d");
let x = 0;
let y = 0;
let array_coordX = Array(100);
let array_coordY = Array(100);
let i = setInterval(function(){
for (let i = 0; i < 100;i++){
array_coordX[i] = Math.floor(Math.random()*300);
array_coordY[i] = Math.floor(Math.random()*300);
}
for (let i = 0; i < 100;i++){
ctx.fillRect(array_coordX[i],array_coordY[i],5, 5);
}
},100);
</script>
</body>
</html>
|