-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportal.html
159 lines (147 loc) · 4.26 KB
/
portal.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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html>
<html lang="en">
<head>
<title>O</title>
</head>
<body style="background-color: #000000">
<div class="centered" id="circle-spinner"></div>
</body>
</html>
<style>
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.rotate-wrapper {
position: absolute;
}
@keyframes momentum-a {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes momentum-b {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(-360deg);
}
}
.spinner {
box-sizing: border-box;
flex-grow: 0;
flex-shrink: 0;
position: absolute;
transform-origin: center center;
border-radius: 50%;
}
.spinner:hover {
border-style: solid;
}
</style>
<script src="jquery-3.5.1.min.js"></script>
<script>
let circle_num = 120;
// let circle_num = 6;
let period = 30;
let width = 3;
let size = (width + 1) * circle_num * 2;
$(document).ready(function() {
//let centered = $(".centered");
// centered.css("margin-top", (size / -2).toString() + "px");
// centered.css("margin-left", (size / -2).toString() + "px");
create_circle();
});
let create_circle = function() {
let circle_spinner = $("#circle-spinner");
circle_spinner.empty();
let i = 0;
while(i < circle_num) {
let indent = i / circle_num;
let radius = size * (1 - indent);
// let offset = (size * indent) / 2 - width;
let offset = radius / -2;
let duration = period * (1 - indent);
let color = (30 + 330 * indent) % 360;
let color_string = "hsl(" + color.toString() + ", 100%, 50%, " + (0.05 + indent * 0.9).toString() + ")";
// let rotate = i * 30 + Math.random() * 30 - 15;
let rotate = Math.random() * 360;
// while(rotate > 360) {
// rotate -= 360;
// }
let rotate_wrapper = $("<span />", {
class: "rotate-wrapper",
css: {
"transform": "rotate(" + rotate.toString() + "deg)",
"width": radius.toString() + "px",
"height": radius.toString() + "px",
"top": offset.toString() + "px",
"left": offset.toString() + "px",
},
});
let frame = $("<span />", {
class: "spinner",
css: {
"width": radius.toString() + "px",
"height": radius.toString() + "px",
// "top": offset.toString() + "px",
// "left": offset.toString() + "px",
"border": width.toString() + "px double rgb(0, 0, 0, 0)",
},
click: function() {
period *= 7 / 8;
reset_duration();
}
});
frame.css("border-top-color", color_string);
if([0, circle_num - 1].includes(i)) {
frame.css("border-style", "double");
frame.css("border-bottom-color", color_string);
}
else {
switch(Math.floor(Math.random() * 4) % 4) {
case 0:
frame.css("border-bottom-color", color_string);
break;
default:
break;
}
switch(Math.floor(Math.random() * 16) % 16) {
case 0:
frame.css("border-style", "solid");
break;
default:
break;
}
}
switch(Math.floor(Math.random() * 2) % 2) {
case 0:
frame.css("animation", "momentum-a " + duration.toString() + "s linear infinite");
break;
case 1:
frame.css("animation", "momentum-b " + duration.toString() + "s linear infinite");
break;
}
rotate_wrapper.append(frame);
circle_spinner.append(rotate_wrapper);
i += 1;
}
};
let reset_duration = function() {
console.log(period)
let frame_list = $("#circle-spinner").children().slice();
let i = 0;
while(i < circle_num) {
let indent = i / circle_num;
let duration = period * (1 - indent);
$(frame_list[i]).children().css("animation-duration", duration.toString() + "s");
i += 1;
}
}
</script>