-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
416 lines (333 loc) · 10.8 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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>peterliu</title>
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
* {
cursor:-webkit-grab;
}
*:active {
cursor:-webkit-grabbing;
}
::-webkit-scrollbar {
width: 0 !important;
display: none;
}
@font-face {
font-family: "Chaparral";
src: url("./fonts/ChaparralPro-Regular.otf");
}
@font-face {
font-family: "Secondary";
src: url("./fonts/ChaparralPro-Italic.otf");
}
body {
/* background:url('assets/pattern.png');
*/ margin:0;
font-family:Chaparral;
color:#333;
user-select: none;
}
#map {
position:absolute;
top:0;
bottom:0;
width:100%;
}
.container{
max-width:940px;
margin:0 auto;
padding-top:50px;
height:100%;
overflow:scroll;
}
.secondary{
font-family:Secondary;
}
.section{
margin-top:30px;
width:33%;
float:left;
}
.work{
margin-top:10px;
}
.maroon {
color:maroon;
}
.big{
font-size:1.25em;
}
.bigger{
font-size:1.5em;
}
#title {
margin-top:30px;
}
.biggest{
font-size:2em;
}
.title{
font-size:3em;
color:maroon;
}
.weak {
opacity:0.75;
}
.weaker{
opacity:0.5;
}
.weakest{
opacity:0.3;
}
.bold {
font-weight:bold;
}
.lowercase {
text-transform:lowercase;
}
#lightbox{
background:rgba(0,0,0,0.8);
left:0px;
right:0px;
z-index:100;
top:0px;
bottom:0px;
height:100%;
overflow:hidden;
transition:all 0.25s;
}
#modal{
background:url('assets/pattern.png');
margin: 0 auto;
border-radius: 3px;
position: absolute;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
overflow: hidden;
}
.fl{
float:left;
}
.fr{
float:right;
}
.pad1{
padding:10px;
}
.pad2{
padding:20px;
}
.m3 {
margin:30px;
}
.hidden {
opacity: 0;
transform: scale(0.8);
pointer-events: none;
}
a {
color:maroon;
cursor:pointer;
}
.a{
}
a:hover,
.a:hover{
color:orangered;
}
.underline:hover {
text-decoration: underline;
}
#explainer{
width:360px;
height:100%;
overflow:scroll;
}
.wrapper {
position:absolute;
left:360px;
right:0px;
top:0px;
bottom:0px;
border-left:1px solid #ccc;
height:100%;
background:url('assets/pattern.png');
}
iframe{
width:100%;
height:100%;
border:none;
opacity:1;
transition:opacity 1s;
}
#drawCanvas {
display:none;
}
#canvas,
#drawCanvas {
width:100%;
top:0;
bottom:0;
position:absolute;
z-index: -99;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<canvas id="drawCanvas"></canvas>
<div class='container hidden'>
<input type="range" min="0" max="2.5" value="1" step='0.1' class="slider" style='float:right' onchange='state.amplitude = this.value'>
<div class='title'>peter liu</div>
<div class='secondary bigger weaker'>maps / interfaces / algorithms</div>
<div id='intro' class='biggest weak'>
<p>I'm a designer, engineer, and noodle enthusiast in Portland, OR. </p>
<p>I enjoy working across the stack to build prototypes and tools, especially around graphics, mapping, and data vis. Some relevant work:</p>
</div>
<div id='portfolio' class=''>
</div>
<div class='pad2 big' style='margin-top:0px; position:fixed; right:0; bottom:0'><span class='weak'>peterqliu at gmail</span> | <a target="_blank" href='./assets/resume.pdf'>cv</a> | <a target="_blank" href='https://github.com/peterqliu'>github</a></div>
</div>
<div id='lightbox' class='hidden'>
<div id='modal'>
<div id='explainer' class=''>
<div class='m3'>
<div id='close'>
<span class='bigger a weaker' style='transform:rotateZ(180deg)'>✕</span>
</div>
<div class='maroon biggest' id='title'></div>
<div class='big secondary weaker' id='subhed'></div>
<div id='blurb' class='weak'></div>
<div id='press' class='hidden big'>
<div class='bold'>Press</div>
<a target="_blank" id='pressLink'></a>
</div>
</div>
</div>
<div class='wrapper'>
<iframe src=''></iframe>
</div>
</div>
</div>
</body>
<script id="drawVert" type="x-shader/x-vertex">
precision mediump float;
attribute float a_index;
uniform sampler2D u_particles;
uniform float u_particles_res;
varying vec2 v_particle_pos;
void main() {
vec4 color = texture2D(u_particles, vec2(
fract(a_index / u_particles_res),
floor(a_index / u_particles_res) / u_particles_res));
// decode current particle position from the pixel's RGBA value
v_particle_pos = vec2(
color.r / 255.0 + color.b,
color.g / 255.0 + color.a);
gl_PointSize = 1.0;
gl_Position = vec4(2.0 * v_particle_pos.x - 1.0, 1.0 - 2.0 * v_particle_pos.y, 0, 1);
}
</script>
<script id="drawFrag" type="x-shader/x-fragment">
precision mediump float;
uniform sampler2D u_wind;
uniform vec2 u_wind_min;
uniform vec2 u_wind_max;
uniform sampler2D u_color_ramp;
varying vec2 v_particle_pos;
void main() {
vec2 velocity = mix(u_wind_min, u_wind_max, texture2D(u_wind, v_particle_pos).rg);
float speed_t = length(velocity) / length(u_wind_max);
// color ramp is encoded in a 16x16 texture
vec2 ramp_pos = vec2(
fract(16.0 * speed_t),
floor(16.0 * speed_t) / 16.0);
gl_FragColor = texture2D(u_color_ramp, ramp_pos);
}
</script>
<script id="quadVert" type="x-shader/x-vertex">
precision mediump float;
attribute vec2 a_pos;
varying vec2 v_tex_pos;
void main() {
v_tex_pos = a_pos;
gl_Position = vec4(1.0 - 2.0 * a_pos, 0, 1);
}
</script>
<script id="screenFrag" type="x-shader/x-fragment">
precision mediump float;
uniform sampler2D u_screen;
uniform float u_opacity;
varying vec2 v_tex_pos;
void main() {
vec4 color = texture2D(u_screen, 1.0 - v_tex_pos);
// a hack to guarantee opacity fade out even with a value close to 1.0
gl_FragColor = vec4(0.02+floor(255.0 * color * u_opacity) / 255.0);
}
</script>
<script id="updateFrag" type="x-shader/x-fragment">
precision highp float;
uniform sampler2D u_particles;
uniform sampler2D u_wind;
uniform vec2 u_wind_res;
uniform vec2 u_wind_min;
uniform vec2 u_wind_max;
uniform float u_rand_seed;
uniform float u_speed_factor;
uniform float u_drop_rate;
uniform float u_drop_rate_bump;
varying vec2 v_tex_pos;
// pseudo-random generator
const vec3 rand_constants = vec3(12.9898, 78.233, 4375.85453);
float rand(const vec2 co) {
float t = dot(rand_constants.xy, co);
return fract(sin(t) * (rand_constants.z + t));
}
// wind speed lookup; use manual bilinear filtering based on 4 adjacent pixels for smooth interpolation
vec2 lookup_wind(const vec2 uv) {
// return texture2D(u_wind, uv).rg; // lower-res hardware filtering
vec2 px = 1.0 / u_wind_res;
vec2 vc = (floor(uv * u_wind_res)) * px;
vec2 f = fract(uv * u_wind_res);
vec2 tl = texture2D(u_wind, vc).rg;
vec2 tr = texture2D(u_wind, vc + vec2(px.x, 0)).rg;
vec2 bl = texture2D(u_wind, vc + vec2(0, px.y)).rg;
vec2 br = texture2D(u_wind, vc + px).rg;
return mix(mix(tl, tr, f.x), mix(bl, br, f.x), f.y);
}
void main() {
vec4 color = texture2D(u_particles, v_tex_pos);
vec2 pos = vec2(
color.r / 255.0 + color.b,
color.g / 255.0 + color.a); // decode particle position from pixel RGBA
vec2 velocity = mix(u_wind_min, u_wind_max, lookup_wind(pos));
float speed_t = length(velocity) / length(u_wind_max);
// take EPSG:4236 distortion into account for calculating where the particle moved
float distortion = cos(radians(pos.y * 180.0 - 90.0));
vec2 offset = vec2(velocity.x, -velocity.y) * 0.0001 * u_speed_factor;
// update particle position, wrapping around the date line
pos = fract(1.0 + pos + offset);
// a random seed to use for the particle drop
vec2 seed = (pos + v_tex_pos) * u_rand_seed;
// drop rate is a chance a particle will restart at random position, to avoid degeneration
float drop_rate = u_drop_rate + speed_t * u_drop_rate_bump;
float drop = step(1.0 - drop_rate, rand(seed));
vec2 random_pos = vec2(
rand(seed + 1.3),
rand(seed + 2.1));
pos = mix(pos, random_pos, drop);
// encode the new particle position back into RGBA
gl_FragColor = vec4(
fract(pos * 255.0),
floor(pos * 255.0) / 255.0);
}
</script>
<script src='src/app.js'></script>
<script src='src/flow/wind-gl.js'></script>
<script src='src/flow/index.js'></script>
</html>