-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.html
More file actions
70 lines (60 loc) · 2.14 KB
/
app.html
File metadata and controls
70 lines (60 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>KREA Mouse Saati</title>
<style>
body { margin: 0; overflow: hidden; }
canvas { display: block; }
.coordinates { position: absolute; color: red; }
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let mouseX = canvas.width / 2;
let mouseY = canvas.height / 2;
let permanentCoordinates = [];
function drawClock(x, y) {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.beginPath();
ctx.arc(x, y, 50, 0, 2 * Math.PI);
ctx.stroke();
const now = new Date();
const seconds = now.getSeconds();
const minutes = now.getMinutes();
const hours = now.getHours();
drawHand(x, y, (seconds / 60) * 2 * Math.PI, 40, 'red');
drawHand(x, y, (minutes / 60) * 2 * Math.PI, 35, 'black');
drawHand(x, y, ((hours % 12) / 12) * 2 * Math.PI, 30, 'black');
permanentCoordinates.forEach(coord => {
ctx.fillText(`(${coord.x}, ${coord.y})`, coord.x, coord.y);
});
}
function drawHand(x, y, angle, length, color) {
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x + length * Math.cos(angle - Math.PI / 2), y + length * Math.sin(angle - Math.PI / 2));
ctx.strokeStyle = color;
ctx.stroke();
}
canvas.addEventListener('mousemove', (e) => {
mouseX = e.clientX;
mouseY = e.clientY;
});
canvas.addEventListener('click', (e) => {
permanentCoordinates.push({ x: e.clientX, y: e.clientY });
});
function animate() {
drawClock(mouseX, mouseY);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>