<!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";
ctx.clearRect(0,0,700,600);
let timer = setInterval(function() {
let randomColor = "#" + Math.floor(Math.random()*16777215).toString(16);
let x = Math.floor(Math.random()*300);
let y = Math.floor(Math.random()*200)+300;
const d = new Date();
ctx.clearRect(0,0,700,600);
ctx.fillStyle = randomColor;
let minutes = d.getMinutes();
if (minutes < 10) minutes = "0" + minutes;
ctx.fillText(d.getHours()+":"+minutes,x,y);
},500);
</script>
</body>
</html>
|