<!doctype html>
<html>
<head>
<title>canvasExample</title>
<meta charset='utf-8' />
</head>
<body onload="setInterval('myfunc()', 10)" >
<canvas height='700' width='700' id='example'></canvas>
<script>
let s = 0;
const canvas = document.querySelector('#example');
const ctx = canvas.getContext('2d');
ctx.fillStyle = '#' + Math.floor(Math.random()*16777215).toString(16);
function myfunc(){
let narray = [];
for (let q = 0 ;q <10;q++){
narray.push(Math.floor(Math.random() * 300));
}
ctx.clearRect(0,0,700,700);
for (let q = 0 ;q <10;q++){
for (let i = 0; i < 700; i+=100){
ctx.fillRect(0,0,narray[q]+s,i)
}
}
s = s + 1;
}
</script>
</body>
</html>
|