-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathindex.html
More file actions
211 lines (189 loc) · 5.38 KB
/
index.html
File metadata and controls
211 lines (189 loc) · 5.38 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
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
<!DOCTYPE html>
<head>
<title>r/place</title>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
!function() {
"use strict";
var scripts = [
'scripts/lib/f.js',
'scripts/lib/pf.js',
'scripts/lib/dom.js',
'scripts/lib/kbd.js',
// 'scripts/lib/gl-matrix.js',
'scripts/lib/min-matrix.js',
'scripts/base/EventEmitter.js',
'scripts/base/Defer.js',
'scripts/base/Loader.js',
'scripts/base/Timer.js',
'scripts/base/Bit.js',
'scripts/Bar.js',
'scripts/Viewport.js',
'scripts/main.js'
]
var styles = [
'styles/main.css',
'styles/place.css'
]
var first = document.getElementsByTagName('script')[0]
function add_script(src, callback) {
var elem = document.createElement('script')
elem.type = 'text/javascript'
elem.src = src
elem.onload = callback
first.parentNode.insertBefore(elem, first)
}
function add_style(href) {
var elem = document.createElement('link')
elem.rel = 'stylesheet'
elem.href = href
elem.type = 'text/css'
first.parentNode.insertBefore(elem, first)
}
window.loadAssets = function(scripts, styles) {
var _scripts = scripts.slice()
, _styles = styles.slice()
!function run_scripts() {
_scripts.length && add_script(_scripts.shift(), run_scripts)
}()
while(_styles.length) add_style(_styles.shift())
}
loadAssets(scripts, styles)
}()
</script>
</head>
<body>
<div class="viewport absmid">
<canvas class="place"></div>
<!--
<div class="point cp"></div>
<div class="point tl"></div>
<div class="point tr"></div>
<div class="point bl"></div>
<div class="point br"></div>
-->
</div>
<div class="controls">
<div class="seek-field field">
<span class="label">time:</span>
<span class="value">0</span>
<div class="seek bar">
<div class="seek pending">...loading</div>
<div class="cursor"></div>
</div>
</div>
<div class="rate-field field">
<span class="label">rate:</span>
<span class="value">0</span>
<div class="rate bar">
<div class="cursor"></div>
</div>
</div>
<div class="zoom pane">
<canvas width="28" height="28" class="hand button zoom-in"></canvas>
<canvas width="28" height="28" class="hand button zoom-out"></canvas>
<canvas width="28" height="28" class="hand button zoom-fit"></canvas>
</div>
</div>
<div id="bscrn" class="fullscreen absmid">
<style>
.absmid {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: auto;
}
.fullscreen {
background-color: white;
}
.loading {
width: 100px;
height: 2px;
padding: 1px;
border: 1px solid #000;
outline: 2px solid white;
background: white;
}
.progress {
width: 0px;
height: 2px;
background-color: #000;
}
.logo {
image-rendering: optimizeSpeed;
image-rendering: -moz-crisp-edges;
image-rendering: -o-crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: pixelated;
image-rendering: optimize-contrast;
-ms-interpolation-mode: nearest-neighbor;
transform: scale(2);
bottom: 36px;
}
</style>
<canvas id="boot" class="logo absmid" width="1000" height="1000"></canvas>
<div class="loading absmid">
<div id="bprog" class="progress"></div>
</div>
</div>
<script>
!function() {
var ctx = boot.getContext('2d'), cw = boot.width = 128, ch = boot.height = 128
var raw = 'DShDXnmUODc2UWyHITxWcYumxquQdVo/QEFcd5KRmZiXlntgRUZHYn1MS0plgJucnaGgn4RpTk9Qa4U='
var img = atob(raw).split('').map(n => n.charCodeAt(0)), imgw = 27, imgh = 8, len = imgw * imgh
var { PI, sin, cos, exp, pow, random } = Math, c = (x, a, b) => x < a ? a : x > b ? b : x
for(var i = len -1; i >= 0; i--) img.push(img.splice(random() * len |0, 1))
var nd = x => 1 / (pow(PI * 2, 1/2) * (exp(2 * pow((x * 2 - 1) * 1.5, 2))))
var ndp = 1000, ndt = [], sum = 0, t = 0, image = new Set, pix = ctx.createImageData(cw, ch);
for(var i = 0; i < ndp; i++) { sum += nd(i / ndp) * (1 / ndp); ndt.push(sum) }
for(var ky = 1 / sum, i = 0; i < ndp; i++) ndt[i] *= ky;
var nds=x=>ndn(x* ndp), ndv=x=>ndt[c(x|0,0,ndp-1)], ndn=x=>(x%1)*(ndv(x+1)-ndv(x))+ndv(x)
window.bootProgress = function(value, a) {
t = isFinite(value) ? c(value, 0, 1) : 0
}
function loop() {
if (t < 1) requestAnimationFrame(loop)
for(var i = (1 - t + 0.1) * 10; i >= 0; i--) {
var r = nds(c(random() + 0.1, 0, 1)) * ((1 - t) * 24 + 8)
var a = random() * PI * 2
var x = cos(a) * r + cw/2 |0
var y = sin(a) * r + ch/2 |0
var p = x + y * cw
pix.data[p * 4 + 3] = 255
image.add(p)
}
var array = [...image]
for(var i = (t * 0.4 + 0.4) * 10; i >= 0; i--) {
var p = array.splice(random() * array.length |0, 1)
pix.data[p * 4 + 3] = 0
image.delete(p)
}
for(var i = (t * 0.5) * 10; i >= 0; i--) {
var v = random() * imgw * imgh |0
var ix = v % imgw
var iy = v / imgw |0
var x = cw/2 - imgw/2 + ix |0
var y = ch/2 - imgh/2 + iy |0
var p = x + y * cw
pix.data[p * 4 + 3] = 0
image.delete(p)
}
for(var i = (t + 0.2) * 6; i >= 0; i--) {
var v = img[random() * img.length |0]
var x = cw/2 - imgw/2 + v % imgw |0
var y = ch/2 - imgh/2 + v / imgw |0
var p = x + y * cw
pix.data[p * 4 + 3] = 255
image.add(p)
}
ctx.putImageData(pix, 0, 0)
bprog.style.width = (t * 100 |0) +'%'
bscrn.style.display = t === 1 ? 'none' : 'block'
}
loop()
}()
</script>
</body>