-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
284 lines (260 loc) · 7.49 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Numenera Character Idea Generator</title>
<link href="https://fonts.googleapis.com/css?family=Cinzel+Decorative:400,700" rel="stylesheet">
<style>
body {
font-family: 'Cinzel Decorative', cursive;
font-size: 16px;
text-align: center;
padding: 0;
margin: 0;
color: #7F135C;
background: #FEFEFE;
height: 100%;
}
#container {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: stretch;
min-height: calc(100% - 2rem);
padding: 1rem;
}
h1, h2 {
margin: 0;
padding: 0;
line-height: 1.2;
}
h1 {
font-size: 2rem;
font-weight: normal;
}
h2 {
font-size: 1.5rem;
}
button {
outline: 0;
border: 0;
display: block;
font-family: 'Cinzel Decorative', cursive;
padding: 0.5rem;
font-size: 1.5rem;
font-weight: bold;
line-height: 1;
background: #7F135C;
color: #FEFEFE;
cursor: pointer;
transition: all 200ms ease;
box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.1);
}
button:hover {
background: #A10E72;
box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.3);
}
button:active {
background: #4F0F3B;
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.5);
}
@media(min-width: 600px) {
h1 {
font-size: 3rem;
margin: 3rem 0;
}
h2 {
font-size: 2rem;
}
button {
width: 200px;
font-size: 2rem;
padding: 1rem;
}
#container {
align-items: center;
justify-content: center;
padding: 4rem;
min-height: calc(100% - 8rem);
}
}
</style>
</head>
<body>
<div id="container">
<h2>Your character is:</h2>
<h1 id="title">Generating...</h1>
<button onclick="startSpin()">Retry</button>
</div>
<script>
const types = [
'Arkus',
'Delve',
'Glaive',
'Jack',
'Nano',
'Wright',
]
const desc = [
'Adaptable',
'Articulate',
'Beneficient',
'Cheerful',
'Civic',
'Clever',
'Committed',
'Confident',
'Cultured',
'Curious',
'Earnest',
'Empirical',
'Exacting',
'Forward-Thinking',
'Graceful',
'Gregarious',
'Heroic',
'Imaginative',
'Industrious',
'Intelligent',
'Intimidating',
'Intuitive',
'Irrepressible',
'Lawful',
'Learned',
'Loyal',
'Meddlesome',
'Mystical / Mechanical',
'Nurturing',
'Obsessive',
'Optimistic',
'Organized',
'Passionate',
'Perserving',
'Prepared',
'Protective',
'Relentless',
'Risk-Taking',
'Rugged',
'Serene',
'Stealthy',
'Strong',
'Strong-Willed',
'Swift',
'Tough',
'Vicious',
]
const focus = [
'Absorbs Energy',
'Acts Without Consequence',
'Adjures the Leviathan',
'Augments Flesh With Grafts',
'Battles Automatons',
'Bears a Halo of Fire',
'Brandishes an Exotic Shield',
'Breaks Down Walls',
'Builds Tomorrow',
'Commands Mental Powers',
'Controls Beasts',
'Controls Gravity',
'Crafts Illusions',
'Dances With Dark Matter',
'Defends the Gate',
'Defends the Weak',
'Descends From Nobility',
'Emerged From the Obelisk',
'Employs Magnetism',
'Entertains',
'Exists Partially Out of Phase',
'Explores Dark Places',
'Explores Yesterday',
'Fights With a Horde',
'Fights With Panache',
'Focuses Mind Over Matter',
'Fuses Flesh and Steel',
'Fuses Mind and Machine',
'Howls at the Moon',
'Hunts',
'Hunts Abhumans',
'Imparts Wisdom',
'Leads',
'Learns From Adversity',
'Lives in the Wilderness',
'Masters Defense',
'Masters Weaponry',
'Metes Out Justice',
'Moves Like a Cat',
'Murders',
'Needs No Weapons',
'Never Says Die',
'Possesses a Shard of the Sun',
'Radiates Vitality',
'Rages',
'Rides the Lightning',
'Sees Beyond',
'Shepherds the Community',
'Shreds the Walls of the World',
'Speaks With a Silver Tongue',
'Talks to Machines',
'Thunders',
'Touches the Sky',
'Wears a Sheen of Ice',
'Wields Power With Precision',
'Wields Two Weapons at Once',
'Wields Words Like Weapons',
'Works Miracles',
'Works the Back Alleys',
]
const title = document.getElementById('title')
function generate () {
let rand = new Uint32Array(3)
window.crypto.getRandomValues(rand)
return [
types[rand[0] % types.length],
desc[rand[1] % desc.length],
focus[rand[2] % focus.length],
]
}
let test = [0, 0, 0, 0, 0, 0]
let rand = new Uint32Array(1)
for (let i = 0; i < 100000; i++) {
window.crypto.getRandomValues(rand)
test[rand[0]]++
}
function fill () {
const char = generate()
let start = char[1].match(/^[aeiou].+/i) ? 'An' : 'A'
title.innerHTML = `${start} <strong>${char[1]} ${char[0]}</strong> who<br><strong>${char[2]}</strong>`
}
let spins = 0
const numSpins = 40
let startTime
let lastSpin
function startSpin() {
spins = 0
window.requestAnimationFrame(spin)
}
function spin (t) {
if (spins == 0) {
startTime = t
lastSpin = t
spins++
window.requestAnimationFrame(spin)
return
}
const _spins = Math.pow(spins / numSpins, 4)
if (t > lastSpin + _spins * 100) {
fill()
title.style.opacity = _spins
spins++
lastSpin = t
}
if (spins >= numSpins) {
return
}
window.requestAnimationFrame(spin)
}
window.onload = startSpin
</script>
</body>
</html>