-
Notifications
You must be signed in to change notification settings - Fork 47
/
index.html
414 lines (330 loc) · 11.1 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
<!doctype>
<html>
<head>
<!-- TRANSLATE: 'title' -->
<title>Fireflies</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta charset="utf-8">
<meta name="viewport" content="width=640">
<link rel="icon" type="image/png" href="favicon.png">
<!-- TRANSLATE: 'name' and 'description' -->
<meta itemprop="name" content="Fireflies">
<meta itemprop="description" content="a small simulation of small fireflies">
<meta itemprop="image" content="http://ncase.me/fireflies/social/thumbnail.png">
<!-- TRANSLATE: 'twitter:title' and 'twitter:description' -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@ncasenmare">
<meta name="twitter:title" content="Fireflies">
<meta name="twitter:description" content="a small simulation of small fireflies">
<meta name="twitter:creator" content="@ncasenmare">
<meta name="twitter:image" content="http://ncase.me/fireflies/social/thumbnail.png">
<!-- TRANSLATE: 'og:title' and 'og:description' -->
<meta property="og:title" content="Fireflies">
<meta property="og:type" content="website">
<meta property="og:url" content="http://ncase.me/fireflies/">
<meta property="og:image" content="http://ncase.me/fireflies/social/thumbnail.png">
<meta property="og:description" content="a small simulation of small fireflies">
<!-- Styles -->
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="css/widgets.css">
</head>
<body>
<!-- The firefly simulation -->
<div id="game"></div>
<!-- The WORDS! -->
<div id="words">
<h1>“Fireflies”</h1>
<p>
Like Christmas lights gently floating in midair,
fireflies always add a little bit of magic to the forests they live in.
</p>
<div style="overflow:hidden;">
<img src="ui/chaos.png" width="150" style="float: left;"/>
<div style="width: 185px; float: right;">
<span style="font-size:1.6em; line-height:1.1em;">CLICK & DRAG</span>
<br>
to create some
<br>
firefly chaos →
</div>
</div>
<p>
But some firefly species add even <em>more</em> magic.
In Southeast Asia, if you go out to the riverbank deep in the night,
you'll be treated to this stunning lightshow – courtesy of the Thailand firefly:
</p>
<iframe width="350" height="197" src="https://www.youtube-nocookie.com/embed/ZGvtnE1Wy6U?rel=0&start=64" frameborder="0" allowfullscreen></iframe>
<p>
A whole mangrove forest, lighting up all at once,
plunging into darkness, then lighting up all again – in near-perfect synchrony.
How do thousands of fireflies coordinate with each other?
Who is the conductor of this silent symphony?
</p>
<p>
This was a mystery for nearly a century, and in 1992,
a team of US scientists set out to solve it.
Sadly, but not surprisingly, the press mocked them –
<em>“Govt. Blows Your Tax $$ to Study Fireflies in Borneo:
Not a Bright Idea!”</em> read one tabloid.
Undeterred, the scientists pressed on, cameras and calculators in hand.
</p>
<p>
So, how <em>do</em> thousands of fireflies pick a leader to follow,
a maestro to keep their flashing in time?
The answer, the scientists found, is simple:
</p>
<p>
They don't.
</p>
<p>
Each firefly has its <em>own</em> individual internal clock,
and every time the clock “strikes twelve”, it flashes.
</p>
<p>
<img src="ui/clock.png" width="350"/>
</p>
<p>
And instead of synchronizing their clocks to a central leader,
each firefly does the following:
</p>
<p>
Step 1: when you see a nearby firefly flash,
nudge your clock a little bit forward.
</p>
<p>
<img src="ui/nudge.png" width="350"/>
</p>
<p>
Step 2: that's it.
</p>
<p>
Can such a small, short-ranged interaction really cause an
entire forest-ful of fireflies to flash in synchronous harmony?
Only one way to find out...
</p>
<hr/>
<!-- TRANSLATE: 'label', 'label-on', and 'label-off' -->
<widget type="toggle"
id="neighborNudgeRule"
background="#000" color="#fff"
background-on="#FEE27F" color-on="#000"
label="Nudge thy neighbor:<br>(click to turn on→)"
label-on="ON" label-off="OFF">
</widget>
<hr/>
<p>
Wait. Watch carefully.
</p>
<p>
What do you see?
</p>
<p>
At first, not much.
The fireflies still seem to be flashing without pattern.
</p>
<p>
But after a while, you may notice small “patches” of fireflies firing together –
but these individual “patches” are still out of sync.
</p>
<p>
After a bit longer, you start seeing fireflies performing a “wave”,
like excited fans in the stands during a baseball game.
</p>
<p>
Finally, all but a few fireflies are flashing together –
and eventually, even these laggards join in the collective dance.
</p>
<p>
What's more amazing? If you disrupt these fireflies by causing some chaos...
</p>
<div style="overflow:hidden;">
<img src="ui/chaos.png" width="150" style="float: left;"/>
<div style="width: 185px; float: right;">
<span style="font-size:1.6em; line-height:1.1em;">CLICK & DRAG</span>
<br>
to mess up these
<br>
fireflies, again →
</div>
</div>
<p>
...yes, it may cause them to divide for a moment, but slowly and surely,
they shall collect themselves again, and flash as one.
</p>
<p>
Here's a few more buttons & sliders you can use,
to play around with these virtual fireflies:
</p>
<hr/>
<!-- TRANSLATE: 'label', 'label-min', and 'label-max' -->
<widget type="slider"
id="numFireflies"
background="#FEE27F" color="#fff"
min=10 max=500 step=1
label="Number of fireflies:"
label-min="10" label-max="500">
</widget>
<!-- TRANSLATE: 'label', 'label-on', and 'label-off' -->
<widget type="toggle"
id="showClocks"
background="#000" color="#fff"
background-on="#FEE27F" color-on="#000"
label="Show clocks:"
label-on="ON" label-off="OFF">
</widget>
<!-- TRANSLATE: 'label', 'label-min', and 'label-max' -->
<widget type="slider"
id="clockSpeed"
background="#FEE27F" color="#fff"
min="0.2" max="2" step="0.05"
label="Fireflies' clock speed:"
label-min="slow" label-max="fast">
</widget>
<!-- TRANSLATE: 'label', 'label-on', and 'label-off' -->
<widget type="toggle"
id="neighborNudgeRule"
background="#000" color="#fff"
background-on="#FEE27F" color-on="#000"
label="Nudge thy neighbor:"
label-on="ON" label-off="OFF">
</widget>
<!-- TRANSLATE: 'label', 'label-min', and 'label-max' -->
<widget type="slider"
id="nudgeAmount"
background="#FEE27F" color="#fff"
min="0.01" max="0.10" step="0.001"
label="How much to nudge clock forward:"
label-min="a bit" label-max="a lot">
</widget>
<!-- TRANSLATE: 'label', 'label-min', and 'label-max' -->
<widget type="slider"
id="neighborRadius"
background="#FEE27F" color="#fff"
min=50 max=500 step=10
label="How close neighbor must be:"
label-min="nearby" label-max="faraway">
</widget>
<!-- TRANSLATE: 'label' -->
<widget type="button"
id="resetFireflies"
background="#000" color="#fff"
background-hover="#FEE27F" color-hover="#000"
label="reset fireflies">
</widget>
<!-- TRANSLATE: 'label' -->
<widget type="button"
id="resetEverything"
background="#000" color="#fff"
background-hover="#FEE27F" color-hover="#000"
label="reset everything">
</widget>
<hr/>
<p>
And that's the secret behind our fireflies' magic trick:
</p>
<div style="overflow:hidden; text-align:center">
<img src="ui/emergence.png" width="350" style="margin-bottom:25px"/>
<div style="width:170px; float:left;">
<span style="font-size:33px; line-height:10px">small-scale</span><br><span style="font-size:27px">interactions</span>
</div>
<div style="width:10px; float:left; position:relative; left:-5px; top:7px">→</div>
<div style="width:170px; float:left;">
<span style="font-size:33px; line-height:10px">large-scale</span><br><span style="font-size:27px">organization</span>
</div>
</div>
<p>
As it turns out, fireflies aren't the only things that
synchronize themselves from the bottom up.
Your neurons create brain waves.
Your heart's pacemaker cells fire in sync.
<a target="_blank" href="https://www.youtube.com/watch?v=5v5eBf2KwF8">
Even a bunch of lifeless metronomes on a wobbly platform will start to march together.</a>
On top of all that, understanding self-synchrony has helped us build better
lasers, computers, and communications technology!
</p>
<p>
And to think, the mathematics of self-synchronizing systems was discovered
in part by a few scientists who just really loved fireflies.
Looks like calling their project <em>“Not a Bright Idea”</em> was not a bright idea.
</p>
<p>
. . .
</p>
<p>
You float along, softly, in silence,
occasionally punctuating the darkness with a small dot of bright light.
By yourself, there's not much to see.
</p>
<p>
But whenever you shine, you inspire those close to you to shine too,
a little bit sooner than they otherwise would have.
And those close to you, in turn, inspire those close to <em>them</em>.
</p>
<p>
And so on, and so on.
</p>
<p>
First, a few small groups start flashing together.
Then, a wave of light sweeps across the swarm.
Finally, you're all dazzling together,
a brilliant beacon, all in harmony, in tandem – in synchrony.
</p>
<p>
What small-scale interaction will you make today, little firefly?
</p>
<hr class="footer"/>
<div id="credits">
<p>
Inspired by Steven Strogatz's book,<br>
<a href="http://www.powells.com/book/sync-how-order-emerges-from-chaos-in-the-universe-nature-daily-life-9780786887217" target="_blank">
SYNC: How Order Emerges From Chaos In the Universe, Nature, and Daily Life
</a>
</p>
<p>
Created by
<a href="http://ncase.me/" target="_blank">Nicky Case</a>,
with the love & support of my patrons
<a href="credits" target="_blank">(see them all here)</a>
</p>
<p>
“Fireflies” is open source, dedicated to the public domain.
<a href="https://github.com/ncase/fireflies" target="_blank">(Get the code on Github!)</a>
</p>
<p>
<a href="https://www.patreon.com/ncase" target="_blank">
<span id="patreon" >support me on patreon <3</span>
</a>
</p>
<p> </p>
<p>
share with your swarm:<br>
<!-- TRANSLATE: 'text' -->
<sharing text="Fireflies, and what they can teach us about, well, everything. An interactive simulation:"
link="http://ncase.me/fireflies/"></sharing>
</p>
<p style="margin-top:45px">
fan-translations:<br>
<a href="http://ncase.me/fireflies-zh/">中文 (chinese)</a><br>
<a href="http://ncase.me/fireflies-pt-br/">português (brazilian portuguese)</a><br>
<a href="http://ncase.me/fireflies-fr/">français (french)</a><br>
<a href="http://ncase.me/fireflies-de/">deutsch (german)</a><br>
<a href="http://ncase.me/fireflies-tr/">türkçe (turkish)</a><br>
<a href="https://alxliv.github.io/fireflies/">pусский (russian)</a><br>
<a href="https://taleinat.github.io/fireflies/">עברית (hebrew)</a><br>
<a href="https://gepito.github.io/fireflies-hu/">magyar (hungarian)</a>
</p>
</div>
</div>
</body>
</html>
<!-- Library code -->
<script src="js/pixi.min.js"></script>
<script src="js/howler.js"></script>
<script src="js/minpubsub.src.js"></script>
<script src="js/helpers.js"></script>
<script src="js/Mouse.js"></script>
<script src="js/widgets.js"></script>
<script src="js/sharing.js"></script>
<!-- Main code -->
<script src="js/index.js?v=2"></script>