-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
95 lines (83 loc) · 2.65 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Spiral globe</title>
<style>
body {
background-color: black;
}
#c {
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
width: 768px;
height: 768px;
}
</style>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-101273659-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<canvas id="c"></canvas>
<script>
// from https://www.dwitter.net/d/683
const c = document.getElementById("c");
const x = c.getContext("2d");
const S = a => Math.sin(a);
const C = a => Math.cos(a);
const T = a => Math.tan(a);
const R = () => {}; // ToDo
const HALF_PI = Math.PI / 2;
let w = 768;
const hw = w >>> 1;
const r = .80 * hw | 0;
console.info(hw, r);
c.width = w;
c.height = w;
x.fillStyle = x.strokeStyle = "#5b70ff";
x.lineWidth = 3;
x.shadowBlur = 50;
x.translate(0, hw - r);
function update(t) {
t /= 2000; // slow it down
// const pd = t % r;
x.clearRect(0, -hw+r, w, w);
const lstep = S(t * 2) * 0.05 + 0.08;
const step = Math.PI / 500;
let px, py;
for (let lambda = 0, phi = -HALF_PI; phi < HALF_PI; lambda += lstep, phi += step) {
const cx = C(phi) * S(lambda-t) * (r + r * 0.08 * Math.random()) + w / 2;
const cy = (C(t) * S(phi) - S(t) * C(phi) * C(lambda-t)) * r + r;
if (px !== undefined) {
const color = 360 * (phi + HALF_PI) / Math.PI | 0;
x.beginPath();
x.moveTo(px, py);
x.lineTo(cx, cy);
x.shadowColor = x.strokeStyle = `hsl(${color}, 100%, 50%)`; // S(t) * + 180
x.lineTo(cx, cy);
x.stroke();
}
px = cx;
py = cy;
}
// x.beginPath();
// x.ellipse(
// C(-HALF_PI) * S(-t) * r + w / 2,
// (C(t) * S(-HALF_PI) - S(t) * C(-HALF_PI) * C(-t)) * r + r,
// 8, 8, 0, 0, Math.PI * 2
// );
// x.fill();
requestAnimationFrame(update);
}
requestAnimationFrame(update);
</script>
</body>
</html>