<!DOCTYPE html>
<title>start here</title>
<meta charset=utf-8>
<style>
body,html,main,#canvas {
margin: 0;
padding: 0;
}
html, body { width: 100%; height: 100%; }
canvas { display: block; }
</style>
<main>
<canvas id=canvas width=400 height=600></canvas>
</main>
<script>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
update();
}
function update() {
const now = new Date();
const hours = now.getMinutes();
const mins = now.getSeconds();
console.log(hours, mins);
if (mins == 0) {
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
ctx.fillStyle = 'green';
ctx.fillRect(
hours * canvas.width / 60 * Math.sin(mins),
mins * canvas.height / 60,
canvas.width, 1);
ctx.fillStyle = 'purple';
ctx.fillRect(
mins * canvas.width / 60,
hours * canvas.height / 60 * Math.cos(mins),
1, canvas.height);
}
var updateID = window.setInterval(update, 1000);
window.addEventListener('resize', resizeCanvas, false);
resizeCanvas();
</script>