-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtunnel.html
More file actions
131 lines (112 loc) · 3.53 KB
/
tunnel.html
File metadata and controls
131 lines (112 loc) · 3.53 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tunnel Vision</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background-color: black;
font-family: Arial, sans-serif;
}
/* Spinner shape layout with rotation animation */
.spinner {
position: fixed;
overflow: hidden;
display: block; /* Always visible */
}
.spinner.top-left { top: 0; left: 0; width: 50%; height: 50%; transform: rotate(-30deg); animation: spin-cc 0.1s ease-in-out infinite; }
.spinner.top-right { top: 0; right: 0; width: 50%; height: 50%; transform: rotate(30deg); animation: spin-cc 0.1s ease-in-out infinite; }
.spinner.bottom-left { bottom: 0; left: 0; width: 50%; height: 50%; transform: rotate(30deg); animation: spin-cc 0.1s ease-in-out infinite; }
.spinner.bottom-right { bottom: 0; right: 0; width: 50%; height: 50%; transform: rotate(-30deg); animation: spin-cc 0.1s ease-in-out infinite; }
.spinner.center-middle {
top: 25%;
left: 25%;
width: 50%;
height: 50%;
transform: translate(50%, 50%) rotate(-30deg);
animation: spin-ccw 0.1s ease-in-out infinite;
}
@keyframes spin-cc {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
@keyframes spin-ccw {
from { transform: rotate(360deg); }
to { transform: rotate(0deg); }
}
canvas {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<!-- Fidget spinner layout with five canvases -->
<div class="spinner top-left"><canvas id="canvas1"></canvas></div>
<div class="spinner top-right"><canvas id="canvas2"></canvas></div>
<div class="spinner bottom-left"><canvas id="canvas3"></canvas></div>
<div class="spinner bottom-right"><canvas id="canvas4"></canvas></div>
<div class="spinner center-middle"><canvas id="canvas5"></canvas></div>
<script>
const canvasElements = [
document.getElementById('canvas1'),
document.getElementById('canvas2'),
document.getElementById('canvas3'),
document.getElementById('canvas4'),
document.getElementById('canvas5')
];
let scale = 1;
let scaleIncrement = 0.01;
function getRandomColor() {
const r = Math.floor(Math.random() * 256);
const g = Math.floor(Math.random() * 256);
const b = Math.floor(Math.random() * 256);
return `rgb(${r}, ${g}, ${b})`;
}
function setupCanvas(canvas) {
const ctx = canvas.getContext('2d');
canvas.width = canvas.clientWidth;
canvas.height = canvas.clientHeight;
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
function fibonacci(n) {
let fibSequence = [0, 1];
for (let i = 2; i < n; i++) {
fibSequence.push(fibSequence[i - 1] + fibSequence[i - 2]);
}
return fibSequence;
}
function drawFibonacciSpiral() {
const fibNumbers = fibonacci(20);
let angle = 0;
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.save();
ctx.translate(centerX, centerY);
ctx.scale(scale, scale);
for (let i = 2; i < fibNumbers.length; i++) {
let radius = fibNumbers[i] * 10;
ctx.beginPath();
ctx.arc(0, 0, radius, angle, 360);
ctx.lineWidth = 3;
ctx.strokeStyle = getRandomColor();
ctx.stroke();
angle += Math.PI / 2;
}
ctx.restore();
scale += scaleIncrement;
if (scale > 3 || scale < 1) scaleIncrement *= -1;
}
function animate() {
drawFibonacciSpiral();
requestAnimationFrame(animate);
}
animate();
}
canvasElements.forEach(canvas => setupCanvas(canvas));
</script>
</body>
</html>