@idle-screens/savers-classic 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-5EPTQV3C.js +965 -0
- package/dist/chunk-5EPTQV3C.js.map +1 -0
- package/dist/idle-worker.d.ts +2 -0
- package/dist/idle-worker.js +18 -0
- package/dist/idle-worker.js.map +1 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +2506 -1130
- package/dist/index.js.map +1 -1
- package/package.json +8 -3
package/dist/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
globe,
|
|
3
|
+
hardRain,
|
|
4
|
+
rainstorm,
|
|
5
|
+
spotlight,
|
|
6
|
+
warp
|
|
7
|
+
} from "./chunk-5EPTQV3C.js";
|
|
8
|
+
|
|
1
9
|
// src/toasters.ts
|
|
2
10
|
var toastersManifest = {
|
|
3
11
|
id: "toasters",
|
|
@@ -253,168 +261,6 @@ var dvd = {
|
|
|
253
261
|
mount: (ctx) => new DvdInstance(ctx)
|
|
254
262
|
};
|
|
255
263
|
|
|
256
|
-
// src/warp.ts
|
|
257
|
-
var warpManifest = {
|
|
258
|
-
id: "warp",
|
|
259
|
-
label: "Warp",
|
|
260
|
-
passthrough: false,
|
|
261
|
-
minBackend: "canvas2d",
|
|
262
|
-
costTier: "low",
|
|
263
|
-
motionIntensity: "energetic",
|
|
264
|
-
reducedMotionFallback: "static",
|
|
265
|
-
a11y: { flashSafe: true }
|
|
266
|
-
};
|
|
267
|
-
var STAR_COUNT = 520;
|
|
268
|
-
var SPEED = 0.012;
|
|
269
|
-
var WarpInstance = class {
|
|
270
|
-
ctxSaver;
|
|
271
|
-
canvas;
|
|
272
|
-
ctx;
|
|
273
|
-
w = 0;
|
|
274
|
-
h = 0;
|
|
275
|
-
stars = [];
|
|
276
|
-
frameId = null;
|
|
277
|
-
paused = false;
|
|
278
|
-
constructor(ctx) {
|
|
279
|
-
this.ctxSaver = ctx;
|
|
280
|
-
const canvas = document.createElement("canvas");
|
|
281
|
-
canvas.style.cssText = "display:block;width:100%;height:100%";
|
|
282
|
-
canvas.setAttribute("aria-hidden", "true");
|
|
283
|
-
ctx.host.appendChild(canvas);
|
|
284
|
-
this.canvas = canvas;
|
|
285
|
-
const c2d = canvas.getContext("2d", { alpha: false });
|
|
286
|
-
if (!c2d) throw new Error("warp: no 2d context");
|
|
287
|
-
this.ctx = c2d;
|
|
288
|
-
this.w = ctx.width;
|
|
289
|
-
this.h = ctx.height;
|
|
290
|
-
this.sizeCanvas();
|
|
291
|
-
this.buildStars();
|
|
292
|
-
this.paused = ctx.reducedMotion;
|
|
293
|
-
if (this.paused) this.renderStill();
|
|
294
|
-
else this.start();
|
|
295
|
-
}
|
|
296
|
-
sizeCanvas() {
|
|
297
|
-
const dpr = Math.min(typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1, 2);
|
|
298
|
-
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
299
|
-
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
300
|
-
this.ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
301
|
-
}
|
|
302
|
-
buildStars() {
|
|
303
|
-
const rng = this.ctxSaver.rng;
|
|
304
|
-
this.stars = new Array(STAR_COUNT);
|
|
305
|
-
for (let i = 0; i < STAR_COUNT; i++) {
|
|
306
|
-
this.stars[i] = this.spawn(rng.range(0.01, 1));
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
spawn(z) {
|
|
310
|
-
const rng = this.ctxSaver.rng;
|
|
311
|
-
return {
|
|
312
|
-
x: rng.range(-1, 1),
|
|
313
|
-
y: rng.range(-1, 1),
|
|
314
|
-
z,
|
|
315
|
-
pz: z
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
start() {
|
|
319
|
-
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
320
|
-
this.loop();
|
|
321
|
-
}
|
|
322
|
-
stop() {
|
|
323
|
-
if (this.frameId !== null) {
|
|
324
|
-
cancelAnimationFrame(this.frameId);
|
|
325
|
-
this.frameId = null;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
loop() {
|
|
329
|
-
this.frameId = requestAnimationFrame(() => this.loop());
|
|
330
|
-
this.step();
|
|
331
|
-
this.render();
|
|
332
|
-
}
|
|
333
|
-
step() {
|
|
334
|
-
for (const s of this.stars) {
|
|
335
|
-
s.pz = s.z;
|
|
336
|
-
s.z -= SPEED;
|
|
337
|
-
if (s.z <= 0.01) {
|
|
338
|
-
const respawned = this.spawn(1);
|
|
339
|
-
s.x = respawned.x;
|
|
340
|
-
s.y = respawned.y;
|
|
341
|
-
s.z = 1;
|
|
342
|
-
s.pz = 1;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
render() {
|
|
347
|
-
const ctx = this.ctx;
|
|
348
|
-
const w = this.w;
|
|
349
|
-
const h = this.h;
|
|
350
|
-
const cx = w / 2;
|
|
351
|
-
const cy = h / 2;
|
|
352
|
-
const focal = Math.min(w, h) * 0.9;
|
|
353
|
-
ctx.fillStyle = "rgba(17,17,17,0.45)";
|
|
354
|
-
ctx.fillRect(0, 0, w, h);
|
|
355
|
-
ctx.lineCap = "round";
|
|
356
|
-
for (const s of this.stars) {
|
|
357
|
-
const sx = cx + s.x / s.z * focal;
|
|
358
|
-
const sy = cy + s.y / s.z * focal;
|
|
359
|
-
const px = cx + s.x / s.pz * focal;
|
|
360
|
-
const py = cy + s.y / s.pz * focal;
|
|
361
|
-
if (sx < -50 || sx > w + 50 || sy < -50 || sy > h + 50) continue;
|
|
362
|
-
const depth = 1 - s.z;
|
|
363
|
-
const alpha = Math.min(1, 0.15 + depth * 1.1);
|
|
364
|
-
const size = Math.max(0.4, depth * 2.6);
|
|
365
|
-
ctx.strokeStyle = `rgba(220,235,255,${alpha.toFixed(3)})`;
|
|
366
|
-
ctx.lineWidth = size;
|
|
367
|
-
ctx.beginPath();
|
|
368
|
-
ctx.moveTo(px, py);
|
|
369
|
-
ctx.lineTo(sx, sy);
|
|
370
|
-
ctx.stroke();
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
renderStill() {
|
|
374
|
-
const ctx = this.ctx;
|
|
375
|
-
ctx.fillStyle = "#111";
|
|
376
|
-
ctx.fillRect(0, 0, this.w, this.h);
|
|
377
|
-
const cx = this.w / 2;
|
|
378
|
-
const cy = this.h / 2;
|
|
379
|
-
const focal = Math.min(this.w, this.h) * 0.9;
|
|
380
|
-
for (const s of this.stars) {
|
|
381
|
-
const sx = cx + s.x / s.z * focal;
|
|
382
|
-
const sy = cy + s.y / s.z * focal;
|
|
383
|
-
if (sx < 0 || sx > this.w || sy < 0 || sy > this.h) continue;
|
|
384
|
-
const depth = 1 - s.z;
|
|
385
|
-
const alpha = Math.min(1, 0.15 + depth * 1.1);
|
|
386
|
-
const size = Math.max(0.4, depth * 2.6);
|
|
387
|
-
ctx.fillStyle = `rgba(220,235,255,${alpha.toFixed(3)})`;
|
|
388
|
-
ctx.beginPath();
|
|
389
|
-
ctx.arc(sx, sy, size, 0, Math.PI * 2);
|
|
390
|
-
ctx.fill();
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
setPaused(paused) {
|
|
394
|
-
this.paused = paused;
|
|
395
|
-
if (paused) {
|
|
396
|
-
this.stop();
|
|
397
|
-
this.renderStill();
|
|
398
|
-
} else {
|
|
399
|
-
this.start();
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
resize(width, height) {
|
|
403
|
-
this.w = width;
|
|
404
|
-
this.h = height;
|
|
405
|
-
this.sizeCanvas();
|
|
406
|
-
if (this.paused) this.renderStill();
|
|
407
|
-
}
|
|
408
|
-
dispose() {
|
|
409
|
-
this.stop();
|
|
410
|
-
this.canvas.remove();
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
var warp = {
|
|
414
|
-
manifest: warpManifest,
|
|
415
|
-
mount: (ctx) =>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ez9wsTXgIYOe2AcM0/bbcp9x9/ZVlRR3f8Sg1/c3sksbwKq7//2yNI2qyWGNQWb4vkC5JyP6RlJZZ1Dgal5BMKoM/hXHl8BfFDD/V87BG+DpNAISBaFbDN5A/T3DlPZmckOv4qhKym9KCzyUyiqlLjSuNqCTXnr0KwpIBJHbwAv9fUtJWe9RARKp+52kpmDYOV5nzKXRktMy30n6O8mGPBN9UwnIlhYZ3tVmMuovde7Keln6dyJ94HsFmuFlNcpQJaMyfutye+8kYOoC48q7vVc1MKzJ4woD3lRg2Lre+pPH/wGnjh9dFtnZgAAAAABJRU5ErkJggg==";
|
|
@@ -532,807 +378,125 @@ var fish = {
|
|
|
532
378
|
mount: (ctx) => new FishInstance(ctx)
|
|
533
379
|
};
|
|
534
380
|
|
|
535
|
-
// src/
|
|
536
|
-
var
|
|
537
|
-
id: "
|
|
538
|
-
label: "
|
|
381
|
+
// src/fade-out.ts
|
|
382
|
+
var fadeOutManifest = {
|
|
383
|
+
id: "fade-out",
|
|
384
|
+
label: "Fade Out",
|
|
539
385
|
passthrough: false,
|
|
540
|
-
minBackend: "
|
|
541
|
-
costTier: "
|
|
542
|
-
motionIntensity: "
|
|
386
|
+
minBackend: "css",
|
|
387
|
+
costTier: "idle",
|
|
388
|
+
motionIntensity: "calm",
|
|
543
389
|
reducedMotionFallback: "static",
|
|
544
|
-
a11y: { flashSafe: true, notes: "
|
|
390
|
+
a11y: { flashSafe: true, notes: "A slow, smooth 40s dim to black; no flashing." }
|
|
545
391
|
};
|
|
546
|
-
var
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
392
|
+
var CSS = `
|
|
393
|
+
.is-fade-out {
|
|
394
|
+
position: absolute;
|
|
395
|
+
inset: 0;
|
|
396
|
+
overflow: hidden;
|
|
397
|
+
background: #2b2b33;
|
|
398
|
+
background-image:
|
|
399
|
+
radial-gradient(120% 90% at 30% 20%, #3b3f4a 0%, #23262e 55%, #16181d 100%);
|
|
400
|
+
}
|
|
401
|
+
.is-fade-out .dim {
|
|
402
|
+
position: absolute;
|
|
403
|
+
inset: 0;
|
|
404
|
+
background-color: #000;
|
|
405
|
+
opacity: 0;
|
|
406
|
+
animation: is-fade-out-fade 40s ease-out 1 forwards;
|
|
407
|
+
}
|
|
408
|
+
.is-fade-out.is-paused .dim {
|
|
409
|
+
animation-play-state: paused !important;
|
|
410
|
+
}
|
|
411
|
+
@keyframes is-fade-out-fade {
|
|
412
|
+
from { opacity: 0; }
|
|
413
|
+
to { opacity: 1; }
|
|
414
|
+
}
|
|
415
|
+
`;
|
|
416
|
+
var FadeOutInstance = class {
|
|
417
|
+
root;
|
|
418
|
+
style;
|
|
558
419
|
constructor(ctx) {
|
|
559
|
-
this.
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
this.
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
this.
|
|
568
|
-
this.
|
|
569
|
-
this.sizeCanvas();
|
|
570
|
-
this.buildLayers();
|
|
420
|
+
this.style = document.createElement("style");
|
|
421
|
+
this.style.textContent = CSS;
|
|
422
|
+
ctx.host.appendChild(this.style);
|
|
423
|
+
this.root = document.createElement("div");
|
|
424
|
+
this.root.className = "is-fade-out";
|
|
425
|
+
this.root.setAttribute("aria-hidden", "true");
|
|
426
|
+
const dim = document.createElement("div");
|
|
427
|
+
dim.className = "dim";
|
|
428
|
+
this.root.appendChild(dim);
|
|
429
|
+
ctx.host.appendChild(this.root);
|
|
571
430
|
this.setPaused(ctx.reducedMotion);
|
|
572
|
-
if (this.paused) this.renderStill();
|
|
573
|
-
}
|
|
574
|
-
sizeCanvas() {
|
|
575
|
-
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
576
|
-
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
577
|
-
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
578
|
-
this.c2d.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
579
|
-
}
|
|
580
|
-
/** Three depth layers: near (fast, long, bright), mid, distant (slow, faint). */
|
|
581
|
-
buildLayers() {
|
|
582
|
-
const rng = this.ctx.rng;
|
|
583
|
-
const area = this.w * this.h / (1280 * 800);
|
|
584
|
-
const specs = [
|
|
585
|
-
{ count: 220, minLen: 26, maxLen: 46, minSpd: 900, maxSpd: 1150, width: 1.6, alpha: 0.5, slant: 0.19 },
|
|
586
|
-
{ count: 160, minLen: 16, maxLen: 30, minSpd: 520, maxSpd: 700, width: 1.2, alpha: 0.34, slant: 0.19 },
|
|
587
|
-
{ count: 120, minLen: 10, maxLen: 20, minSpd: 300, maxSpd: 420, width: 0.9, alpha: 0.22, slant: 0.19 }
|
|
588
|
-
];
|
|
589
|
-
this.layers = specs.map((s) => {
|
|
590
|
-
const n = Math.max(8, Math.round(s.count * area));
|
|
591
|
-
const drops = new Array(n);
|
|
592
|
-
for (let i = 0; i < n; i++) {
|
|
593
|
-
drops[i] = {
|
|
594
|
-
x: rng.range(-40, this.w + 40),
|
|
595
|
-
y: rng.range(-this.h, this.h),
|
|
596
|
-
len: rng.range(s.minLen, s.maxLen),
|
|
597
|
-
speed: rng.range(s.minSpd, s.maxSpd),
|
|
598
|
-
width: s.width,
|
|
599
|
-
alpha: rng.range(s.alpha * 0.7, s.alpha)
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
return { drops, slant: s.slant };
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
// ---- lightning ----
|
|
606
|
-
/** 0..1 flash intensity given the wall clock (ms). A short white pulse near the
|
|
607
|
-
* top of each period, echoing the CSS `flash` keyframe (98% black → 99% white). */
|
|
608
|
-
flashLevel() {
|
|
609
|
-
const p = (this.clock % FLASH_PERIOD + FLASH_PERIOD) % FLASH_PERIOD;
|
|
610
|
-
const start = FLASH_PERIOD - 140;
|
|
611
|
-
if (p < start) return 0;
|
|
612
|
-
const k = (p - start) / 140;
|
|
613
|
-
return k < 0.4 ? k / 0.4 : Math.max(0, 1 - (k - 0.4) / 0.6);
|
|
614
|
-
}
|
|
615
|
-
// ---- loop ----
|
|
616
|
-
start() {
|
|
617
|
-
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
618
|
-
this.last = 0;
|
|
619
|
-
this.frameId = requestAnimationFrame((now) => this.loop(now));
|
|
620
|
-
}
|
|
621
|
-
stop() {
|
|
622
|
-
if (this.frameId !== null) {
|
|
623
|
-
cancelAnimationFrame(this.frameId);
|
|
624
|
-
this.frameId = null;
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
loop(now) {
|
|
628
|
-
this.frameId = requestAnimationFrame((n) => this.loop(n));
|
|
629
|
-
if (this.last === 0) this.last = now;
|
|
630
|
-
const dt = Math.min(0.05, (now - this.last) / 1e3);
|
|
631
|
-
this.last = now;
|
|
632
|
-
this.clock += dt * 1e3;
|
|
633
|
-
this.update(dt);
|
|
634
|
-
this.render();
|
|
635
|
-
}
|
|
636
|
-
update(dt) {
|
|
637
|
-
for (const layer of this.layers) {
|
|
638
|
-
for (const d of layer.drops) {
|
|
639
|
-
d.y += d.speed * dt;
|
|
640
|
-
d.x += d.speed * layer.slant * dt;
|
|
641
|
-
if (d.y - d.len > this.h) {
|
|
642
|
-
d.y = -d.len - this.ctx.rng.range(0, this.h * 0.4);
|
|
643
|
-
d.x = this.ctx.rng.range(-40, this.w + 40);
|
|
644
|
-
}
|
|
645
|
-
if (d.x - d.len > this.w) d.x = -40;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
render() {
|
|
650
|
-
const ctx = this.c2d;
|
|
651
|
-
const flash = this.flashLevel();
|
|
652
|
-
const base = 8 + flash * 235;
|
|
653
|
-
ctx.fillStyle = `rgb(${base | 0},${base + 2 | 0},${base + 8 | 0})`;
|
|
654
|
-
ctx.fillRect(0, 0, this.w, this.h);
|
|
655
|
-
ctx.lineCap = "round";
|
|
656
|
-
for (const layer of this.layers) {
|
|
657
|
-
const dx = -layer.slant;
|
|
658
|
-
for (const d of layer.drops) {
|
|
659
|
-
ctx.strokeStyle = `rgba(200,215,235,${d.alpha.toFixed(3)})`;
|
|
660
|
-
ctx.lineWidth = d.width;
|
|
661
|
-
ctx.beginPath();
|
|
662
|
-
ctx.moveTo(d.x, d.y);
|
|
663
|
-
ctx.lineTo(d.x + dx * d.len, d.y - d.len);
|
|
664
|
-
ctx.stroke();
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
renderStill() {
|
|
669
|
-
this.clock = 0;
|
|
670
|
-
this.render();
|
|
671
431
|
}
|
|
672
|
-
// ---- SaverInstance ----
|
|
673
432
|
setPaused(paused) {
|
|
674
|
-
this.paused
|
|
675
|
-
if (paused) {
|
|
676
|
-
this.stop();
|
|
677
|
-
this.renderStill();
|
|
678
|
-
} else {
|
|
679
|
-
this.start();
|
|
680
|
-
}
|
|
433
|
+
this.root.classList.toggle("is-paused", paused);
|
|
681
434
|
}
|
|
682
|
-
resize(
|
|
683
|
-
this.w = width;
|
|
684
|
-
this.h = height;
|
|
685
|
-
this.sizeCanvas();
|
|
686
|
-
this.buildLayers();
|
|
687
|
-
if (this.paused) this.renderStill();
|
|
435
|
+
resize(_width, _height) {
|
|
688
436
|
}
|
|
689
437
|
dispose() {
|
|
690
|
-
this.
|
|
691
|
-
this.
|
|
438
|
+
this.root.remove();
|
|
439
|
+
this.style.remove();
|
|
692
440
|
}
|
|
693
441
|
};
|
|
694
|
-
var
|
|
695
|
-
manifest:
|
|
696
|
-
mount: (ctx) => new
|
|
442
|
+
var fadeOut = {
|
|
443
|
+
manifest: fadeOutManifest,
|
|
444
|
+
mount: (ctx) => new FadeOutInstance(ctx)
|
|
697
445
|
};
|
|
698
446
|
|
|
699
|
-
// src/
|
|
700
|
-
var
|
|
701
|
-
id: "
|
|
702
|
-
label: "
|
|
447
|
+
// src/bouncing-ball.ts
|
|
448
|
+
var bouncingBallManifest = {
|
|
449
|
+
id: "bouncing-ball",
|
|
450
|
+
label: "Bouncing Ball",
|
|
703
451
|
passthrough: false,
|
|
704
|
-
minBackend: "
|
|
705
|
-
costTier: "
|
|
706
|
-
motionIntensity: "
|
|
452
|
+
minBackend: "css",
|
|
453
|
+
costTier: "idle",
|
|
454
|
+
motionIntensity: "calm",
|
|
707
455
|
reducedMotionFallback: "static",
|
|
708
|
-
a11y: { flashSafe: true, notes: "
|
|
709
|
-
};
|
|
710
|
-
var CYCLE = 4500;
|
|
711
|
-
var POSITIONS = {
|
|
712
|
-
"p0-1": [0.05, -0.02],
|
|
713
|
-
"p0-2": [0.25, -0.17],
|
|
714
|
-
"p0-3": [0.45, 0.04],
|
|
715
|
-
"p0-4": [0.65, -0.04],
|
|
716
|
-
"p0-5": [0.85, 0.01],
|
|
717
|
-
"p1-1": [0.05, 0.18],
|
|
718
|
-
"p1-2": [0.25, 0.07],
|
|
719
|
-
"p1-3": [0.45, 0.24],
|
|
720
|
-
"p1-4": [0.65, 0.16],
|
|
721
|
-
"p1-5": [0.85, 0.21],
|
|
722
|
-
"p2-1": [0.15, 0.38],
|
|
723
|
-
"p2-2": [0.35, 0.27],
|
|
724
|
-
"p2-3": [0.55, 0.44],
|
|
725
|
-
"p2-4": [0.75, 0.36],
|
|
726
|
-
"p2-5": [0.95, 0.41],
|
|
727
|
-
"p3-1": [0.05, 0.58],
|
|
728
|
-
"p3-2": [0.25, 0.47],
|
|
729
|
-
"p3-3": [0.45, 0.64],
|
|
730
|
-
"p3-4": [0.65, 0.56],
|
|
731
|
-
"p3-5": [0.85, 0.61],
|
|
732
|
-
"p4-1": [0.15, 0.78],
|
|
733
|
-
"p4-2": [0.35, 0.67],
|
|
734
|
-
"p4-3": [0.55, 0.84],
|
|
735
|
-
"p4-4": [0.75, 0.76],
|
|
736
|
-
"p4-5": [0.95, 0.81],
|
|
737
|
-
"p5-1": [0.15, 0.98],
|
|
738
|
-
"p5-2": [0.35, 0.87],
|
|
739
|
-
"p5-3": [0.55, 1.04],
|
|
740
|
-
"p5-4": [0.75, 0.96],
|
|
741
|
-
"p5-5": [0.95, 1.01]
|
|
742
|
-
};
|
|
743
|
-
var SIZES = { s140: 70, s200: 100, s250: 125, s300: 150, s350: 175 };
|
|
744
|
-
var COLOURS = {
|
|
745
|
-
dkblue: "#00006e",
|
|
746
|
-
lime: "#c8d354",
|
|
747
|
-
ltgray: "#c2c2c2",
|
|
748
|
-
red: "#861f23",
|
|
749
|
-
ltblue: "#45a0cc",
|
|
750
|
-
pink: "#9a3368",
|
|
751
|
-
yellow: "#efda1d",
|
|
752
|
-
green: "#397132"
|
|
456
|
+
a11y: { flashSafe: true, notes: "A single ball gliding smoothly; no flashing." }
|
|
753
457
|
};
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
t5: -3.75,
|
|
761
|
-
t6: -3.6,
|
|
762
|
-
t7: -3.45,
|
|
763
|
-
t8: -3.3,
|
|
764
|
-
t9: -3.15,
|
|
765
|
-
t10: -3,
|
|
766
|
-
t11: -2.85,
|
|
767
|
-
t12: -2.7,
|
|
768
|
-
t13: -2.55,
|
|
769
|
-
t14: -2.4,
|
|
770
|
-
t15: -2.25,
|
|
771
|
-
t16: -2.1,
|
|
772
|
-
t17: -1.95,
|
|
773
|
-
t18: -1.8,
|
|
774
|
-
t19: -1.65,
|
|
775
|
-
t20: -1.5,
|
|
776
|
-
t21: -1.35,
|
|
777
|
-
t22: -1.2,
|
|
778
|
-
t23: -1.05,
|
|
779
|
-
t24: -0.9,
|
|
780
|
-
t25: -0.75,
|
|
781
|
-
t26: -0.6,
|
|
782
|
-
t27: -0.45,
|
|
783
|
-
t28: 0.3,
|
|
784
|
-
t29: -0.15,
|
|
785
|
-
t30: 0
|
|
786
|
-
};
|
|
787
|
-
return (map[t] ?? 0) * 1e3;
|
|
458
|
+
var CSS2 = `
|
|
459
|
+
.is-bouncing-ball {
|
|
460
|
+
position: absolute;
|
|
461
|
+
inset: 0;
|
|
462
|
+
overflow: hidden;
|
|
463
|
+
background: #000;
|
|
788
464
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
"t27 p1-5 s250 dkblue",
|
|
800
|
-
"t10 p2-1 s140 pink",
|
|
801
|
-
"t4 p2-2 s200 red",
|
|
802
|
-
"t8 p2-3 s300 ltblue",
|
|
803
|
-
"t22 p2-4 s350 yellow",
|
|
804
|
-
"t1 p2-5 s250 lime",
|
|
805
|
-
"t3 p3-1 s300 green",
|
|
806
|
-
"t6 p3-2 s250 dkblue",
|
|
807
|
-
"t15 p3-3 s350 ltgray",
|
|
808
|
-
"t24 p3-4 s140 pink",
|
|
809
|
-
"t21 p3-5 s200 ltblue",
|
|
810
|
-
"t13 p4-1 s250 yellow",
|
|
811
|
-
"t28 p4-2 s140 red",
|
|
812
|
-
"t2 p4-3 s200 ltgray",
|
|
813
|
-
"t19 p4-4 s300 green",
|
|
814
|
-
"t25 p4-5 s350 lime",
|
|
815
|
-
"t5 p5-1 s350 dkblue",
|
|
816
|
-
"t26 p5-2 s300 pink",
|
|
817
|
-
"t20 p5-3 s140 ltblue",
|
|
818
|
-
"t16 p5-4 s250 yellow",
|
|
819
|
-
"t9 p5-5 s200 ltgray",
|
|
820
|
-
"t22 p0-1 s200 dkblue",
|
|
821
|
-
"t8 p0-2 s350 lime",
|
|
822
|
-
"t2 p0-3 s140 ltgray",
|
|
823
|
-
"t26 p0-4 s300 red",
|
|
824
|
-
"t29 p0-5 s250 ltblue",
|
|
825
|
-
"t14 p1-1 s350 pink",
|
|
826
|
-
"t3 p1-2 s300 yellow",
|
|
827
|
-
"t15 p1-3 s140 green",
|
|
828
|
-
"t27 p1-4 s200 ltgray",
|
|
829
|
-
"t12 p1-5 s250 dkblue",
|
|
830
|
-
"t25 p2-1 s140 pink",
|
|
831
|
-
"t19 p2-2 s200 red",
|
|
832
|
-
"t23 p2-3 s300 ltblue",
|
|
833
|
-
"t7 p2-4 s350 yellow",
|
|
834
|
-
"t16 p2-5 s250 lime",
|
|
835
|
-
"t18 p3-1 s300 green",
|
|
836
|
-
"t21 p3-2 s250 dkblue",
|
|
837
|
-
"t30 p3-3 s350 ltgray",
|
|
838
|
-
"t9 p3-4 s140 pink",
|
|
839
|
-
"t6 p3-5 s200 ltblue",
|
|
840
|
-
"t28 p4-1 s250 yellow",
|
|
841
|
-
"t13 p4-2 s140 red",
|
|
842
|
-
"t17 p4-3 s200 ltgray",
|
|
843
|
-
"t4 p4-4 s300 green",
|
|
844
|
-
"t10 p4-5 s350 lime",
|
|
845
|
-
"t20 p5-1 s350 dkblue",
|
|
846
|
-
"t11 p5-2 s300 pink",
|
|
847
|
-
"t5 p5-3 s140 ltblue",
|
|
848
|
-
"t1 p5-4 s250 yellow",
|
|
849
|
-
"t24 p5-5 s200 ltgray"
|
|
850
|
-
];
|
|
851
|
-
function hexToRgb(hex) {
|
|
852
|
-
const n = parseInt(hex.slice(1), 16);
|
|
853
|
-
return `${n >> 16 & 255},${n >> 8 & 255},${n & 255}`;
|
|
465
|
+
.is-bouncing-ball b {
|
|
466
|
+
display: block;
|
|
467
|
+
width: 40px;
|
|
468
|
+
height: 40px;
|
|
469
|
+
border-radius: 50%;
|
|
470
|
+
background-color: #fff;
|
|
471
|
+
position: absolute;
|
|
472
|
+
animation:
|
|
473
|
+
is-bouncing-ball-moveX 3.4s linear 0s infinite alternate,
|
|
474
|
+
is-bouncing-ball-moveY 3s linear 0s infinite alternate;
|
|
854
475
|
}
|
|
855
|
-
|
|
856
|
-
ctx;
|
|
857
|
-
canvas;
|
|
858
|
-
c2d;
|
|
859
|
-
w = 0;
|
|
860
|
-
h = 0;
|
|
861
|
-
scale = 1;
|
|
862
|
-
drops = [];
|
|
863
|
-
frameId = null;
|
|
864
|
-
paused = false;
|
|
865
|
-
last = 0;
|
|
866
|
-
clock = 0;
|
|
867
|
-
constructor(ctx) {
|
|
868
|
-
this.ctx = ctx;
|
|
869
|
-
const canvas = document.createElement("canvas");
|
|
870
|
-
canvas.style.cssText = "display:block;width:100%;height:100%";
|
|
871
|
-
ctx.host.appendChild(canvas);
|
|
872
|
-
this.canvas = canvas;
|
|
873
|
-
const c2d = canvas.getContext("2d", { alpha: false });
|
|
874
|
-
if (!c2d) throw new Error("hard-rain: no 2d context");
|
|
875
|
-
this.c2d = c2d;
|
|
876
|
-
this.w = ctx.width;
|
|
877
|
-
this.h = ctx.height;
|
|
878
|
-
this.buildDrops();
|
|
879
|
-
this.sizeCanvas();
|
|
880
|
-
this.setPaused(ctx.reducedMotion);
|
|
881
|
-
if (this.paused) this.renderStill();
|
|
882
|
-
}
|
|
883
|
-
buildDrops() {
|
|
884
|
-
this.drops = DROP_SPECS.map((spec) => {
|
|
885
|
-
const parts = spec.split(" ");
|
|
886
|
-
const [tCls, pCls, sCls, cCls] = parts;
|
|
887
|
-
const pos = POSITIONS[pCls] ?? [0.5, 0.5];
|
|
888
|
-
return {
|
|
889
|
-
fx: pos[0],
|
|
890
|
-
fy: pos[1],
|
|
891
|
-
maxR: SIZES[sCls] ?? 100,
|
|
892
|
-
rgb: hexToRgb(COLOURS[cCls] ?? "#c2c2c2"),
|
|
893
|
-
phase: timingPhase(tCls)
|
|
894
|
-
};
|
|
895
|
-
});
|
|
896
|
-
}
|
|
897
|
-
sizeCanvas() {
|
|
898
|
-
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
899
|
-
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
900
|
-
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
901
|
-
this.c2d.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
902
|
-
this.scale = Math.min(this.w, this.h * 1.4) / 900;
|
|
903
|
-
}
|
|
904
|
-
// ---- loop ----
|
|
905
|
-
start() {
|
|
906
|
-
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
907
|
-
this.last = 0;
|
|
908
|
-
this.frameId = requestAnimationFrame((now) => this.loop(now));
|
|
909
|
-
}
|
|
910
|
-
stop() {
|
|
911
|
-
if (this.frameId !== null) {
|
|
912
|
-
cancelAnimationFrame(this.frameId);
|
|
913
|
-
this.frameId = null;
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
loop(now) {
|
|
917
|
-
this.frameId = requestAnimationFrame((n) => this.loop(n));
|
|
918
|
-
if (this.last === 0) this.last = now;
|
|
919
|
-
const dt = now - this.last;
|
|
920
|
-
this.last = now;
|
|
921
|
-
this.clock += Math.min(50, dt);
|
|
922
|
-
this.render();
|
|
923
|
-
}
|
|
924
|
-
render() {
|
|
925
|
-
const ctx = this.c2d;
|
|
926
|
-
ctx.fillStyle = "#000";
|
|
927
|
-
ctx.fillRect(0, 0, this.w, this.h);
|
|
928
|
-
for (const d of this.drops) {
|
|
929
|
-
let k = (this.clock - d.phase) % CYCLE / CYCLE;
|
|
930
|
-
if (k < 0) k += 1;
|
|
931
|
-
if (k >= 0.89) continue;
|
|
932
|
-
const g = k / 0.89;
|
|
933
|
-
const r = g * d.maxR * this.scale;
|
|
934
|
-
if (r < 0.5) continue;
|
|
935
|
-
const alpha = Math.min(1, g * 4) * (1 - g * 0.55);
|
|
936
|
-
ctx.strokeStyle = `rgba(${d.rgb},${alpha.toFixed(3)})`;
|
|
937
|
-
ctx.lineWidth = 2;
|
|
938
|
-
ctx.beginPath();
|
|
939
|
-
ctx.arc(d.fx * this.w, d.fy * this.h, r, 0, Math.PI * 2);
|
|
940
|
-
ctx.stroke();
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
renderStill() {
|
|
944
|
-
this.clock = CYCLE * 0.4;
|
|
945
|
-
this.render();
|
|
946
|
-
}
|
|
947
|
-
// ---- SaverInstance ----
|
|
948
|
-
setPaused(paused) {
|
|
949
|
-
this.paused = paused;
|
|
950
|
-
if (paused) {
|
|
951
|
-
this.stop();
|
|
952
|
-
this.renderStill();
|
|
953
|
-
} else {
|
|
954
|
-
this.start();
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
resize(width, height) {
|
|
958
|
-
this.w = width;
|
|
959
|
-
this.h = height;
|
|
960
|
-
this.sizeCanvas();
|
|
961
|
-
if (this.paused) this.renderStill();
|
|
962
|
-
}
|
|
963
|
-
dispose() {
|
|
964
|
-
this.stop();
|
|
965
|
-
this.canvas.remove();
|
|
966
|
-
}
|
|
967
|
-
};
|
|
968
|
-
var hardRain = {
|
|
969
|
-
manifest: hardRainManifest,
|
|
970
|
-
mount: (ctx) => new HardRainInstance(ctx)
|
|
971
|
-
};
|
|
972
|
-
|
|
973
|
-
// src/globe.ts
|
|
974
|
-
var globeManifest = {
|
|
975
|
-
id: "globe",
|
|
976
|
-
label: "Globe",
|
|
977
|
-
passthrough: false,
|
|
978
|
-
minBackend: "canvas2d",
|
|
979
|
-
costTier: "low",
|
|
980
|
-
motionIntensity: "calm",
|
|
981
|
-
reducedMotionFallback: "static",
|
|
982
|
-
a11y: { flashSafe: true, notes: "A slowly spinning dotted globe drifting on black; no flashing." }
|
|
983
|
-
};
|
|
984
|
-
var RADIUS = 120;
|
|
985
|
-
var SPIN = 0.9;
|
|
986
|
-
var LAT_LINES = 11;
|
|
987
|
-
var LON_LINES = 21;
|
|
988
|
-
var GlobeInstance = class {
|
|
989
|
-
ctx;
|
|
990
|
-
canvas;
|
|
991
|
-
c2d;
|
|
992
|
-
w = 0;
|
|
993
|
-
h = 0;
|
|
994
|
-
// globe centre + velocity (DVD bounce)
|
|
995
|
-
cx = 0;
|
|
996
|
-
cy = 0;
|
|
997
|
-
vx = 0;
|
|
998
|
-
vy = 0;
|
|
999
|
-
spinPhase = 0;
|
|
1000
|
-
// precomputed unit-sphere lattice (spun about Y at render time)
|
|
1001
|
-
lattice = [];
|
|
1002
|
-
frameId = null;
|
|
1003
|
-
paused = false;
|
|
1004
|
-
last = 0;
|
|
1005
|
-
constructor(ctx) {
|
|
1006
|
-
this.ctx = ctx;
|
|
1007
|
-
const canvas = document.createElement("canvas");
|
|
1008
|
-
canvas.style.cssText = "display:block;width:100%;height:100%";
|
|
1009
|
-
ctx.host.appendChild(canvas);
|
|
1010
|
-
this.canvas = canvas;
|
|
1011
|
-
const c2d = canvas.getContext("2d", { alpha: false });
|
|
1012
|
-
if (!c2d) throw new Error("globe: no 2d context");
|
|
1013
|
-
this.c2d = c2d;
|
|
1014
|
-
this.buildLattice();
|
|
1015
|
-
this.w = ctx.width;
|
|
1016
|
-
this.h = ctx.height;
|
|
1017
|
-
this.sizeCanvas();
|
|
1018
|
-
const rng = ctx.rng;
|
|
1019
|
-
this.cx = rng.range(RADIUS, Math.max(RADIUS + 1, this.w - RADIUS));
|
|
1020
|
-
this.cy = rng.range(RADIUS, Math.max(RADIUS + 1, this.h - RADIUS));
|
|
1021
|
-
const dir = rng.range(0, Math.PI * 2);
|
|
1022
|
-
const speed = 90;
|
|
1023
|
-
this.vx = Math.cos(dir) * speed;
|
|
1024
|
-
this.vy = Math.sin(dir) * speed;
|
|
1025
|
-
this.setPaused(ctx.reducedMotion);
|
|
1026
|
-
if (this.paused) this.renderStill();
|
|
1027
|
-
}
|
|
1028
|
-
/** Dotted lat/long lattice on the unit sphere. */
|
|
1029
|
-
buildLattice() {
|
|
1030
|
-
for (let i = 1; i < LAT_LINES; i++) {
|
|
1031
|
-
const lat = -Math.PI / 2 + Math.PI * i / LAT_LINES;
|
|
1032
|
-
const ringR = Math.cos(lat);
|
|
1033
|
-
const y = Math.sin(lat);
|
|
1034
|
-
const dots = Math.max(6, Math.round(LON_LINES * ringR + 4));
|
|
1035
|
-
for (let j = 0; j < dots; j++) {
|
|
1036
|
-
const lon = Math.PI * 2 * j / dots;
|
|
1037
|
-
this.lattice.push({ x: ringR * Math.cos(lon), y, z: ringR * Math.sin(lon) });
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
for (let m = 0; m < LON_LINES; m++) {
|
|
1041
|
-
const lon = Math.PI * 2 * m / LON_LINES;
|
|
1042
|
-
for (let s = 0; s <= 24; s++) {
|
|
1043
|
-
const lat = -Math.PI / 2 + Math.PI * s / 24;
|
|
1044
|
-
const ringR = Math.cos(lat);
|
|
1045
|
-
this.lattice.push({ x: ringR * Math.cos(lon), y: Math.sin(lat), z: ringR * Math.sin(lon) });
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
sizeCanvas() {
|
|
1050
|
-
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
1051
|
-
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
1052
|
-
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
1053
|
-
this.c2d.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
1054
|
-
}
|
|
1055
|
-
// ---- loop ----
|
|
1056
|
-
start() {
|
|
1057
|
-
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
1058
|
-
this.last = 0;
|
|
1059
|
-
this.frameId = requestAnimationFrame((now) => this.loop(now));
|
|
1060
|
-
}
|
|
1061
|
-
stop() {
|
|
1062
|
-
if (this.frameId !== null) {
|
|
1063
|
-
cancelAnimationFrame(this.frameId);
|
|
1064
|
-
this.frameId = null;
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
loop(now) {
|
|
1068
|
-
this.frameId = requestAnimationFrame((n) => this.loop(n));
|
|
1069
|
-
if (this.last === 0) this.last = now;
|
|
1070
|
-
const dt = Math.min(0.05, (now - this.last) / 1e3);
|
|
1071
|
-
this.last = now;
|
|
1072
|
-
this.update(dt);
|
|
1073
|
-
this.render();
|
|
1074
|
-
}
|
|
1075
|
-
update(dt) {
|
|
1076
|
-
this.spinPhase += SPIN * dt;
|
|
1077
|
-
this.cx += this.vx * dt;
|
|
1078
|
-
this.cy += this.vy * dt;
|
|
1079
|
-
const minX = RADIUS;
|
|
1080
|
-
const maxX = this.w - RADIUS;
|
|
1081
|
-
const minY = RADIUS;
|
|
1082
|
-
const maxY = this.h - RADIUS;
|
|
1083
|
-
if (this.cx < minX) {
|
|
1084
|
-
this.cx = minX;
|
|
1085
|
-
this.vx = Math.abs(this.vx);
|
|
1086
|
-
} else if (this.cx > maxX) {
|
|
1087
|
-
this.cx = maxX;
|
|
1088
|
-
this.vx = -Math.abs(this.vx);
|
|
1089
|
-
}
|
|
1090
|
-
if (this.cy < minY) {
|
|
1091
|
-
this.cy = minY;
|
|
1092
|
-
this.vy = Math.abs(this.vy);
|
|
1093
|
-
} else if (this.cy > maxY) {
|
|
1094
|
-
this.cy = maxY;
|
|
1095
|
-
this.vy = -Math.abs(this.vy);
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
render() {
|
|
1099
|
-
const ctx = this.c2d;
|
|
1100
|
-
ctx.fillStyle = "#000";
|
|
1101
|
-
ctx.fillRect(0, 0, this.w, this.h);
|
|
1102
|
-
const body = ctx.createRadialGradient(
|
|
1103
|
-
this.cx - RADIUS * 0.35,
|
|
1104
|
-
this.cy - RADIUS * 0.35,
|
|
1105
|
-
RADIUS * 0.1,
|
|
1106
|
-
this.cx,
|
|
1107
|
-
this.cy,
|
|
1108
|
-
RADIUS
|
|
1109
|
-
);
|
|
1110
|
-
body.addColorStop(0, "rgba(30,60,90,0.55)");
|
|
1111
|
-
body.addColorStop(1, "rgba(6,14,26,0.15)");
|
|
1112
|
-
ctx.fillStyle = body;
|
|
1113
|
-
ctx.beginPath();
|
|
1114
|
-
ctx.arc(this.cx, this.cy, RADIUS, 0, Math.PI * 2);
|
|
1115
|
-
ctx.fill();
|
|
1116
|
-
const cos = Math.cos(this.spinPhase);
|
|
1117
|
-
const sin = Math.sin(this.spinPhase);
|
|
1118
|
-
for (const p of this.lattice) {
|
|
1119
|
-
const rx = p.x * cos + p.z * sin;
|
|
1120
|
-
const rz = -p.x * sin + p.z * cos;
|
|
1121
|
-
const x = this.cx + rx * RADIUS;
|
|
1122
|
-
const y = this.cy + p.y * RADIUS;
|
|
1123
|
-
const depth = (rz + 1) / 2;
|
|
1124
|
-
const alpha = 0.12 + depth * 0.7;
|
|
1125
|
-
const size = 0.7 + depth * 1.2;
|
|
1126
|
-
ctx.fillStyle = `rgba(120,200,255,${alpha.toFixed(3)})`;
|
|
1127
|
-
ctx.beginPath();
|
|
1128
|
-
ctx.arc(x, y, size, 0, Math.PI * 2);
|
|
1129
|
-
ctx.fill();
|
|
1130
|
-
}
|
|
1131
|
-
ctx.strokeStyle = "rgba(120,200,255,0.35)";
|
|
1132
|
-
ctx.lineWidth = 1;
|
|
1133
|
-
ctx.beginPath();
|
|
1134
|
-
ctx.arc(this.cx, this.cy, RADIUS, 0, Math.PI * 2);
|
|
1135
|
-
ctx.stroke();
|
|
1136
|
-
}
|
|
1137
|
-
renderStill() {
|
|
1138
|
-
this.render();
|
|
1139
|
-
}
|
|
1140
|
-
// ---- SaverInstance ----
|
|
1141
|
-
setPaused(paused) {
|
|
1142
|
-
this.paused = paused;
|
|
1143
|
-
if (paused) {
|
|
1144
|
-
this.stop();
|
|
1145
|
-
this.renderStill();
|
|
1146
|
-
} else {
|
|
1147
|
-
this.start();
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
resize(width, height) {
|
|
1151
|
-
this.w = width;
|
|
1152
|
-
this.h = height;
|
|
1153
|
-
this.sizeCanvas();
|
|
1154
|
-
this.cx = Math.min(Math.max(this.cx, RADIUS), Math.max(RADIUS, this.w - RADIUS));
|
|
1155
|
-
this.cy = Math.min(Math.max(this.cy, RADIUS), Math.max(RADIUS, this.h - RADIUS));
|
|
1156
|
-
if (this.paused) this.renderStill();
|
|
1157
|
-
}
|
|
1158
|
-
dispose() {
|
|
1159
|
-
this.stop();
|
|
1160
|
-
this.canvas.remove();
|
|
1161
|
-
}
|
|
1162
|
-
};
|
|
1163
|
-
var globe = {
|
|
1164
|
-
manifest: globeManifest,
|
|
1165
|
-
mount: (ctx) => new GlobeInstance(ctx)
|
|
1166
|
-
};
|
|
1167
|
-
|
|
1168
|
-
// src/spotlight.ts
|
|
1169
|
-
var spotlightManifest = {
|
|
1170
|
-
id: "spotlight",
|
|
1171
|
-
label: "Spotlight",
|
|
1172
|
-
passthrough: true,
|
|
1173
|
-
minBackend: "canvas2d",
|
|
1174
|
-
costTier: "low",
|
|
1175
|
-
motionIntensity: "calm",
|
|
1176
|
-
reducedMotionFallback: "static",
|
|
1177
|
-
a11y: { flashSafe: true, notes: "A soft light circle drifting over the live page; no flashing." }
|
|
1178
|
-
};
|
|
1179
|
-
var HOLE_RADIUS = 220;
|
|
1180
|
-
var SPEED_X = 5e3;
|
|
1181
|
-
var SPEED_Y = 5600;
|
|
1182
|
-
var SpotlightInstance = class {
|
|
1183
|
-
canvas;
|
|
1184
|
-
c2d;
|
|
1185
|
-
w = 0;
|
|
1186
|
-
h = 0;
|
|
1187
|
-
frameId = null;
|
|
1188
|
-
paused = false;
|
|
1189
|
-
last = 0;
|
|
1190
|
-
clock = 0;
|
|
1191
|
-
constructor(ctx) {
|
|
1192
|
-
const canvas = document.createElement("canvas");
|
|
1193
|
-
canvas.style.cssText = "display:block;width:100%;height:100%";
|
|
1194
|
-
ctx.host.appendChild(canvas);
|
|
1195
|
-
this.canvas = canvas;
|
|
1196
|
-
const c2d = canvas.getContext("2d", { alpha: true });
|
|
1197
|
-
if (!c2d) throw new Error("spotlight: no 2d context");
|
|
1198
|
-
this.c2d = c2d;
|
|
1199
|
-
this.w = ctx.width;
|
|
1200
|
-
this.h = ctx.height;
|
|
1201
|
-
this.sizeCanvas();
|
|
1202
|
-
this.setPaused(ctx.reducedMotion);
|
|
1203
|
-
if (this.paused) this.render();
|
|
1204
|
-
}
|
|
1205
|
-
sizeCanvas() {
|
|
1206
|
-
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
1207
|
-
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
1208
|
-
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
1209
|
-
this.c2d.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
1210
|
-
}
|
|
1211
|
-
centre() {
|
|
1212
|
-
const tri = (t, period) => {
|
|
1213
|
-
const p = (t % (period * 2) + period * 2) % (period * 2);
|
|
1214
|
-
return p < period ? p / period : 2 - p / period;
|
|
1215
|
-
};
|
|
1216
|
-
const kx = tri(this.clock, SPEED_X);
|
|
1217
|
-
const ky = tri(this.clock, SPEED_Y);
|
|
1218
|
-
const x = HOLE_RADIUS + kx * (this.w - HOLE_RADIUS * 2);
|
|
1219
|
-
const y = HOLE_RADIUS + ky * (this.h - HOLE_RADIUS * 2);
|
|
1220
|
-
return [x, y];
|
|
1221
|
-
}
|
|
1222
|
-
start() {
|
|
1223
|
-
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
1224
|
-
this.last = 0;
|
|
1225
|
-
this.frameId = requestAnimationFrame((now) => this.loop(now));
|
|
1226
|
-
}
|
|
1227
|
-
stop() {
|
|
1228
|
-
if (this.frameId !== null) {
|
|
1229
|
-
cancelAnimationFrame(this.frameId);
|
|
1230
|
-
this.frameId = null;
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
loop(now) {
|
|
1234
|
-
this.frameId = requestAnimationFrame((n) => this.loop(n));
|
|
1235
|
-
if (this.last === 0) this.last = now;
|
|
1236
|
-
this.clock += Math.min(50, now - this.last);
|
|
1237
|
-
this.last = now;
|
|
1238
|
-
this.render();
|
|
1239
|
-
}
|
|
1240
|
-
render() {
|
|
1241
|
-
const ctx = this.c2d;
|
|
1242
|
-
const [sx, sy] = this.centre();
|
|
1243
|
-
ctx.clearRect(0, 0, this.w, this.h);
|
|
1244
|
-
ctx.fillStyle = "rgba(0, 0, 0, 0.92)";
|
|
1245
|
-
ctx.fillRect(0, 0, this.w, this.h);
|
|
1246
|
-
ctx.globalCompositeOperation = "destination-out";
|
|
1247
|
-
const hole = ctx.createRadialGradient(sx, sy, 0, sx, sy, HOLE_RADIUS * 1.15);
|
|
1248
|
-
hole.addColorStop(0, "rgba(0,0,0,1)");
|
|
1249
|
-
hole.addColorStop(0.62, "rgba(0,0,0,1)");
|
|
1250
|
-
hole.addColorStop(0.85, "rgba(0,0,0,0.5)");
|
|
1251
|
-
hole.addColorStop(1, "rgba(0,0,0,0)");
|
|
1252
|
-
ctx.fillStyle = hole;
|
|
1253
|
-
ctx.fillRect(sx - HOLE_RADIUS * 1.2, sy - HOLE_RADIUS * 1.2, HOLE_RADIUS * 2.4, HOLE_RADIUS * 2.4);
|
|
1254
|
-
ctx.globalCompositeOperation = "source-over";
|
|
1255
|
-
const glow = ctx.createRadialGradient(sx, sy, 0, sx, sy, HOLE_RADIUS);
|
|
1256
|
-
glow.addColorStop(0, "rgba(255,250,230,0.12)");
|
|
1257
|
-
glow.addColorStop(1, "rgba(255,250,230,0)");
|
|
1258
|
-
ctx.fillStyle = glow;
|
|
1259
|
-
ctx.beginPath();
|
|
1260
|
-
ctx.arc(sx, sy, HOLE_RADIUS, 0, Math.PI * 2);
|
|
1261
|
-
ctx.fill();
|
|
1262
|
-
}
|
|
1263
|
-
setPaused(paused) {
|
|
1264
|
-
this.paused = paused;
|
|
1265
|
-
if (paused) {
|
|
1266
|
-
this.stop();
|
|
1267
|
-
this.render();
|
|
1268
|
-
} else {
|
|
1269
|
-
this.start();
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
resize(width, height) {
|
|
1273
|
-
this.w = width;
|
|
1274
|
-
this.h = height;
|
|
1275
|
-
this.sizeCanvas();
|
|
1276
|
-
if (this.paused) this.render();
|
|
1277
|
-
}
|
|
1278
|
-
dispose() {
|
|
1279
|
-
this.stop();
|
|
1280
|
-
this.canvas.remove();
|
|
1281
|
-
}
|
|
1282
|
-
};
|
|
1283
|
-
var spotlight = {
|
|
1284
|
-
manifest: spotlightManifest,
|
|
1285
|
-
mount: (ctx) => new SpotlightInstance(ctx)
|
|
1286
|
-
};
|
|
1287
|
-
|
|
1288
|
-
// src/fade-out.ts
|
|
1289
|
-
var fadeOutManifest = {
|
|
1290
|
-
id: "fade-out",
|
|
1291
|
-
label: "Fade Out",
|
|
1292
|
-
passthrough: false,
|
|
1293
|
-
minBackend: "css",
|
|
1294
|
-
costTier: "idle",
|
|
1295
|
-
motionIntensity: "calm",
|
|
1296
|
-
reducedMotionFallback: "static",
|
|
1297
|
-
a11y: { flashSafe: true, notes: "A slow, smooth 40s dim to black; no flashing." }
|
|
1298
|
-
};
|
|
1299
|
-
var CSS = `
|
|
1300
|
-
.is-fade-out {
|
|
1301
|
-
position: absolute;
|
|
1302
|
-
inset: 0;
|
|
1303
|
-
overflow: hidden;
|
|
1304
|
-
background: #2b2b33;
|
|
1305
|
-
background-image:
|
|
1306
|
-
radial-gradient(120% 90% at 30% 20%, #3b3f4a 0%, #23262e 55%, #16181d 100%);
|
|
1307
|
-
}
|
|
1308
|
-
.is-fade-out .dim {
|
|
1309
|
-
position: absolute;
|
|
1310
|
-
inset: 0;
|
|
1311
|
-
background-color: #000;
|
|
1312
|
-
opacity: 0;
|
|
1313
|
-
animation: is-fade-out-fade 40s ease-out 1 forwards;
|
|
1314
|
-
}
|
|
1315
|
-
.is-fade-out.is-paused .dim {
|
|
476
|
+
.is-bouncing-ball.is-paused b {
|
|
1316
477
|
animation-play-state: paused !important;
|
|
1317
478
|
}
|
|
1318
|
-
@keyframes is-
|
|
1319
|
-
from {
|
|
1320
|
-
to {
|
|
479
|
+
@keyframes is-bouncing-ball-moveX {
|
|
480
|
+
from { left: calc(100% - 40px); }
|
|
481
|
+
to { left: 0; }
|
|
482
|
+
}
|
|
483
|
+
@keyframes is-bouncing-ball-moveY {
|
|
484
|
+
from { top: 0; }
|
|
485
|
+
to { top: calc(100% - 40px); }
|
|
1321
486
|
}
|
|
1322
487
|
`;
|
|
1323
|
-
var
|
|
488
|
+
var BouncingBallInstance = class {
|
|
1324
489
|
root;
|
|
1325
490
|
style;
|
|
1326
491
|
constructor(ctx) {
|
|
1327
492
|
this.style = document.createElement("style");
|
|
1328
|
-
this.style.textContent =
|
|
493
|
+
this.style.textContent = CSS2;
|
|
1329
494
|
ctx.host.appendChild(this.style);
|
|
1330
495
|
this.root = document.createElement("div");
|
|
1331
|
-
this.root.className = "is-
|
|
496
|
+
this.root.className = "is-bouncing-ball";
|
|
1332
497
|
this.root.setAttribute("aria-hidden", "true");
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1335
|
-
this.root.appendChild(dim);
|
|
498
|
+
const ball = document.createElement("b");
|
|
499
|
+
this.root.appendChild(ball);
|
|
1336
500
|
ctx.host.appendChild(this.root);
|
|
1337
501
|
this.setPaused(ctx.reducedMotion);
|
|
1338
502
|
}
|
|
@@ -1346,64 +510,72 @@ var FadeOutInstance = class {
|
|
|
1346
510
|
this.style.remove();
|
|
1347
511
|
}
|
|
1348
512
|
};
|
|
1349
|
-
var
|
|
1350
|
-
manifest:
|
|
1351
|
-
mount: (ctx) => new
|
|
513
|
+
var bouncingBall = {
|
|
514
|
+
manifest: bouncingBallManifest,
|
|
515
|
+
mount: (ctx) => new BouncingBallInstance(ctx)
|
|
1352
516
|
};
|
|
1353
517
|
|
|
1354
|
-
// src/
|
|
1355
|
-
var
|
|
1356
|
-
id: "
|
|
1357
|
-
label: "
|
|
518
|
+
// src/logo.ts
|
|
519
|
+
var logoManifest = {
|
|
520
|
+
id: "logo",
|
|
521
|
+
label: "Logo",
|
|
1358
522
|
passthrough: false,
|
|
1359
523
|
minBackend: "css",
|
|
1360
524
|
costTier: "idle",
|
|
1361
525
|
motionIntensity: "calm",
|
|
1362
526
|
reducedMotionFallback: "static",
|
|
1363
|
-
a11y: { flashSafe: true, notes: "A
|
|
527
|
+
a11y: { flashSafe: true, notes: "A wordmark gliding smoothly; no flashing." }
|
|
1364
528
|
};
|
|
1365
|
-
var
|
|
1366
|
-
.is-
|
|
529
|
+
var CSS3 = `
|
|
530
|
+
.is-logo {
|
|
1367
531
|
position: absolute;
|
|
1368
532
|
inset: 0;
|
|
1369
533
|
overflow: hidden;
|
|
1370
534
|
background: #000;
|
|
1371
535
|
}
|
|
1372
|
-
.is-
|
|
536
|
+
.is-logo .logo {
|
|
1373
537
|
display: block;
|
|
1374
|
-
width: 40px;
|
|
1375
|
-
height: 40px;
|
|
1376
|
-
border-radius: 50%;
|
|
1377
|
-
background-color: #fff;
|
|
1378
538
|
position: absolute;
|
|
539
|
+
width: 145px;
|
|
540
|
+
height: 54px;
|
|
541
|
+
line-height: 54px;
|
|
542
|
+
text-align: center;
|
|
543
|
+
white-space: nowrap;
|
|
544
|
+
font-family: 'Times New Roman', 'Georgia', serif;
|
|
545
|
+
font-weight: 700;
|
|
546
|
+
letter-spacing: 0.04em;
|
|
547
|
+
font-size: 34px;
|
|
548
|
+
color: #fff;
|
|
1379
549
|
animation:
|
|
1380
|
-
is-
|
|
1381
|
-
is-
|
|
550
|
+
is-logo-moveX 5s linear 0s infinite alternate,
|
|
551
|
+
is-logo-moveY 6.3s linear 0s infinite alternate;
|
|
1382
552
|
}
|
|
1383
|
-
.is-
|
|
553
|
+
.is-logo.is-paused .logo {
|
|
1384
554
|
animation-play-state: paused !important;
|
|
1385
555
|
}
|
|
1386
|
-
@keyframes is-
|
|
1387
|
-
from { left:
|
|
1388
|
-
to { left:
|
|
556
|
+
@keyframes is-logo-moveX {
|
|
557
|
+
from { left: 0; }
|
|
558
|
+
to { left: calc(100% - 145px); }
|
|
1389
559
|
}
|
|
1390
|
-
@keyframes is-
|
|
1391
|
-
from { top:
|
|
1392
|
-
to { top:
|
|
560
|
+
@keyframes is-logo-moveY {
|
|
561
|
+
from { top: calc(100% - 54px); }
|
|
562
|
+
to { top: 0; }
|
|
1393
563
|
}
|
|
1394
564
|
`;
|
|
1395
|
-
var
|
|
565
|
+
var LogoInstance = class {
|
|
1396
566
|
root;
|
|
1397
567
|
style;
|
|
1398
568
|
constructor(ctx) {
|
|
1399
569
|
this.style = document.createElement("style");
|
|
1400
|
-
this.style.textContent =
|
|
570
|
+
this.style.textContent = CSS3;
|
|
1401
571
|
ctx.host.appendChild(this.style);
|
|
1402
572
|
this.root = document.createElement("div");
|
|
1403
|
-
this.root.className = "is-
|
|
573
|
+
this.root.className = "is-logo";
|
|
1404
574
|
this.root.setAttribute("aria-hidden", "true");
|
|
1405
|
-
const
|
|
1406
|
-
|
|
575
|
+
const logo2 = document.createElement("div");
|
|
576
|
+
logo2.className = "logo";
|
|
577
|
+
logo2.textContent = "idle";
|
|
578
|
+
this.root.appendChild(logo2);
|
|
1407
579
|
ctx.host.appendChild(this.root);
|
|
1408
580
|
this.setPaused(ctx.reducedMotion);
|
|
1409
581
|
}
|
|
@@ -1417,72 +589,67 @@ var BouncingBallInstance = class {
|
|
|
1417
589
|
this.style.remove();
|
|
1418
590
|
}
|
|
1419
591
|
};
|
|
1420
|
-
var
|
|
1421
|
-
manifest:
|
|
1422
|
-
mount: (ctx) => new
|
|
592
|
+
var logo = {
|
|
593
|
+
manifest: logoManifest,
|
|
594
|
+
mount: (ctx) => new LogoInstance(ctx)
|
|
1423
595
|
};
|
|
1424
596
|
|
|
1425
|
-
// src/
|
|
1426
|
-
var
|
|
1427
|
-
id: "
|
|
1428
|
-
label: "
|
|
597
|
+
// src/messages.ts
|
|
598
|
+
var messagesManifest = {
|
|
599
|
+
id: "messages",
|
|
600
|
+
label: "Messages",
|
|
1429
601
|
passthrough: false,
|
|
1430
602
|
minBackend: "css",
|
|
1431
603
|
costTier: "idle",
|
|
1432
604
|
motionIntensity: "calm",
|
|
1433
605
|
reducedMotionFallback: "static",
|
|
1434
|
-
a11y: { flashSafe: true, notes: "
|
|
606
|
+
a11y: { flashSafe: true, notes: "Text crawls smoothly; no flashing." }
|
|
1435
607
|
};
|
|
1436
|
-
var
|
|
1437
|
-
|
|
608
|
+
var MESSAGE = "OUT TO LUNCH";
|
|
609
|
+
var CSS4 = `
|
|
610
|
+
.is-messages {
|
|
1438
611
|
position: absolute;
|
|
1439
612
|
inset: 0;
|
|
1440
613
|
overflow: hidden;
|
|
1441
614
|
background: #000;
|
|
1442
615
|
}
|
|
1443
|
-
.is-
|
|
1444
|
-
display: block;
|
|
1445
|
-
position: absolute;
|
|
1446
|
-
width: 145px;
|
|
1447
|
-
height: 54px;
|
|
1448
|
-
line-height: 54px;
|
|
1449
|
-
text-align: center;
|
|
616
|
+
.is-messages .message {
|
|
1450
617
|
white-space: nowrap;
|
|
618
|
+
margin: 0;
|
|
619
|
+
position: absolute;
|
|
1451
620
|
font-family: 'Times New Roman', 'Georgia', serif;
|
|
1452
|
-
font-
|
|
1453
|
-
letter-spacing: 0.04em;
|
|
1454
|
-
font-size: 34px;
|
|
621
|
+
font-size: 20px;
|
|
1455
622
|
color: #fff;
|
|
1456
623
|
animation:
|
|
1457
|
-
is-
|
|
1458
|
-
is-
|
|
624
|
+
is-messages-marquee 10s linear infinite,
|
|
625
|
+
is-messages-move 30s steps(3) infinite;
|
|
1459
626
|
}
|
|
1460
|
-
.is-
|
|
627
|
+
.is-messages.is-paused .message {
|
|
1461
628
|
animation-play-state: paused !important;
|
|
1462
629
|
}
|
|
1463
|
-
@keyframes is-
|
|
1464
|
-
|
|
1465
|
-
|
|
630
|
+
@keyframes is-messages-marquee {
|
|
631
|
+
0% { text-indent: 100%; }
|
|
632
|
+
100% { text-indent: -150px; }
|
|
1466
633
|
}
|
|
1467
|
-
@keyframes is-
|
|
1468
|
-
from { top:
|
|
1469
|
-
to { top:
|
|
634
|
+
@keyframes is-messages-move {
|
|
635
|
+
from { top: 20%; }
|
|
636
|
+
to { top: 100%; }
|
|
1470
637
|
}
|
|
1471
638
|
`;
|
|
1472
|
-
var
|
|
639
|
+
var MessagesInstance = class {
|
|
1473
640
|
root;
|
|
1474
641
|
style;
|
|
1475
642
|
constructor(ctx) {
|
|
1476
643
|
this.style = document.createElement("style");
|
|
1477
|
-
this.style.textContent =
|
|
644
|
+
this.style.textContent = CSS4;
|
|
1478
645
|
ctx.host.appendChild(this.style);
|
|
1479
646
|
this.root = document.createElement("div");
|
|
1480
|
-
this.root.className = "is-
|
|
647
|
+
this.root.className = "is-messages";
|
|
1481
648
|
this.root.setAttribute("aria-hidden", "true");
|
|
1482
|
-
const
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
this.root.appendChild(
|
|
649
|
+
const msg = document.createElement("h2");
|
|
650
|
+
msg.className = "message";
|
|
651
|
+
msg.textContent = MESSAGE;
|
|
652
|
+
this.root.appendChild(msg);
|
|
1486
653
|
ctx.host.appendChild(this.root);
|
|
1487
654
|
this.setPaused(ctx.reducedMotion);
|
|
1488
655
|
}
|
|
@@ -1496,178 +663,2377 @@ var LogoInstance = class {
|
|
|
1496
663
|
this.style.remove();
|
|
1497
664
|
}
|
|
1498
665
|
};
|
|
1499
|
-
var
|
|
1500
|
-
manifest:
|
|
1501
|
-
mount: (ctx) => new
|
|
666
|
+
var messages = {
|
|
667
|
+
manifest: messagesManifest,
|
|
668
|
+
mount: (ctx) => new MessagesInstance(ctx)
|
|
1502
669
|
};
|
|
1503
670
|
|
|
1504
|
-
// src/
|
|
1505
|
-
var
|
|
1506
|
-
id: "
|
|
1507
|
-
label: "Messages
|
|
671
|
+
// src/messages2.ts
|
|
672
|
+
var messages2Manifest = {
|
|
673
|
+
id: "messages2",
|
|
674
|
+
label: "Messages II",
|
|
1508
675
|
passthrough: false,
|
|
1509
676
|
minBackend: "css",
|
|
1510
677
|
costTier: "idle",
|
|
1511
678
|
motionIntensity: "calm",
|
|
1512
679
|
reducedMotionFallback: "static",
|
|
1513
|
-
a11y: { flashSafe: true, notes: "Text
|
|
680
|
+
a11y: { flashSafe: true, notes: "Text drifts smoothly; no flashing." }
|
|
1514
681
|
};
|
|
1515
|
-
var
|
|
1516
|
-
var
|
|
1517
|
-
.is-
|
|
682
|
+
var MESSAGE2 = "Why are you staring at my Macintosh?";
|
|
683
|
+
var CSS5 = `
|
|
684
|
+
.is-messages2 {
|
|
1518
685
|
position: absolute;
|
|
1519
686
|
inset: 0;
|
|
1520
687
|
overflow: hidden;
|
|
1521
688
|
background: #000;
|
|
1522
689
|
}
|
|
1523
|
-
.is-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
is-
|
|
690
|
+
.is-messages2 .message {
|
|
691
|
+
display: block;
|
|
692
|
+
width: 467px;
|
|
693
|
+
margin: 0;
|
|
694
|
+
color: #fff;
|
|
695
|
+
position: absolute;
|
|
696
|
+
font-family: 'Times New Roman', 'Georgia', serif;
|
|
697
|
+
font-size: 20px;
|
|
698
|
+
animation:
|
|
699
|
+
is-messages2-moveX 8s linear 0s infinite alternate,
|
|
700
|
+
is-messages2-moveY 17.3s linear 0s infinite alternate;
|
|
701
|
+
}
|
|
702
|
+
.is-messages2.is-paused .message {
|
|
703
|
+
animation-play-state: paused !important;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/* Responsive for less than 600px width screen size */
|
|
707
|
+
@media screen and (max-width: 600px) {
|
|
708
|
+
.is-messages2 .message {
|
|
709
|
+
width: 160px;
|
|
710
|
+
height: 85px;
|
|
711
|
+
}
|
|
712
|
+
@keyframes is-messages2-moveX {
|
|
713
|
+
from { left: 0; }
|
|
714
|
+
to { left: calc(100% - 160px); }
|
|
715
|
+
}
|
|
716
|
+
@keyframes is-messages2-moveY {
|
|
717
|
+
from { top: 0; }
|
|
718
|
+
to { top: calc(100% - 85px); }
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/* Responsive for greater than 600px width screen size */
|
|
723
|
+
@media screen and (min-width: 600px) {
|
|
724
|
+
@keyframes is-messages2-moveX {
|
|
725
|
+
from { left: 0; }
|
|
726
|
+
to { left: calc(100% - 467px); }
|
|
727
|
+
}
|
|
728
|
+
@keyframes is-messages2-moveY {
|
|
729
|
+
from { top: 0; }
|
|
730
|
+
to { top: calc(100% - 26px); }
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
`;
|
|
734
|
+
var Messages2Instance = class {
|
|
735
|
+
root;
|
|
736
|
+
style;
|
|
737
|
+
constructor(ctx) {
|
|
738
|
+
this.style = document.createElement("style");
|
|
739
|
+
this.style.textContent = CSS5;
|
|
740
|
+
ctx.host.appendChild(this.style);
|
|
741
|
+
this.root = document.createElement("div");
|
|
742
|
+
this.root.className = "is-messages2";
|
|
743
|
+
this.root.setAttribute("aria-hidden", "true");
|
|
744
|
+
const msg = document.createElement("h2");
|
|
745
|
+
msg.className = "message";
|
|
746
|
+
msg.textContent = MESSAGE2;
|
|
747
|
+
this.root.appendChild(msg);
|
|
748
|
+
ctx.host.appendChild(this.root);
|
|
749
|
+
this.setPaused(ctx.reducedMotion);
|
|
750
|
+
}
|
|
751
|
+
setPaused(paused) {
|
|
752
|
+
this.root.classList.toggle("is-paused", paused);
|
|
753
|
+
}
|
|
754
|
+
resize(_width, _height) {
|
|
755
|
+
}
|
|
756
|
+
dispose() {
|
|
757
|
+
this.root.remove();
|
|
758
|
+
this.style.remove();
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
var messages2 = {
|
|
762
|
+
manifest: messages2Manifest,
|
|
763
|
+
mount: (ctx) => new Messages2Instance(ctx)
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
// src/pipes.ts
|
|
767
|
+
var pipesManifest = {
|
|
768
|
+
id: "pipes",
|
|
769
|
+
label: "Pipes",
|
|
770
|
+
passthrough: false,
|
|
771
|
+
minBackend: "canvas2d",
|
|
772
|
+
costTier: "low",
|
|
773
|
+
motionIntensity: "moderate",
|
|
774
|
+
reducedMotionFallback: "static",
|
|
775
|
+
a11y: { flashSafe: true }
|
|
776
|
+
};
|
|
777
|
+
var CELL = 20;
|
|
778
|
+
var PIPE_WIDTH = 8;
|
|
779
|
+
var STEPS_PER_FRAME = 3;
|
|
780
|
+
var FILL_THRESHOLD = 0.65;
|
|
781
|
+
var PALETTE = ["#c0392b", "#2980b9", "#27ae60", "#f39c12", "#8e44ad", "#d4a259", "#7f8c8d"];
|
|
782
|
+
var DX = { 0: 1, 1: 0, 2: -1, 3: 0 };
|
|
783
|
+
var DY = { 0: 0, 1: 1, 2: 0, 3: -1 };
|
|
784
|
+
var PipesInstance = class {
|
|
785
|
+
ctxSaver;
|
|
786
|
+
canvas;
|
|
787
|
+
ctx;
|
|
788
|
+
w = 0;
|
|
789
|
+
h = 0;
|
|
790
|
+
cols = 0;
|
|
791
|
+
rows = 0;
|
|
792
|
+
grid = [];
|
|
793
|
+
filled = 0;
|
|
794
|
+
pipe = null;
|
|
795
|
+
rng;
|
|
796
|
+
frameId = null;
|
|
797
|
+
paused = false;
|
|
798
|
+
constructor(ctx) {
|
|
799
|
+
this.ctxSaver = ctx;
|
|
800
|
+
this.rng = ctx.rng;
|
|
801
|
+
let canvas;
|
|
802
|
+
if (ctx.surface) {
|
|
803
|
+
canvas = ctx.surface;
|
|
804
|
+
} else {
|
|
805
|
+
const el = document.createElement("canvas");
|
|
806
|
+
el.style.cssText = "display:block;width:100%;height:100%";
|
|
807
|
+
el.setAttribute("aria-hidden", "true");
|
|
808
|
+
ctx.host.appendChild(el);
|
|
809
|
+
canvas = el;
|
|
810
|
+
}
|
|
811
|
+
this.canvas = canvas;
|
|
812
|
+
const c2d = canvas.getContext("2d", { alpha: false });
|
|
813
|
+
if (!c2d) throw new Error("pipes: no 2d context");
|
|
814
|
+
this.ctx = c2d;
|
|
815
|
+
this.w = ctx.width;
|
|
816
|
+
this.h = ctx.height;
|
|
817
|
+
this.sizeCanvas();
|
|
818
|
+
this.rebuild();
|
|
819
|
+
this.paused = ctx.reducedMotion;
|
|
820
|
+
if (this.paused) this.renderStill();
|
|
821
|
+
else this.start();
|
|
822
|
+
}
|
|
823
|
+
sizeCanvas() {
|
|
824
|
+
const dpr = Math.min(this.ctxSaver.dpr, 2);
|
|
825
|
+
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
826
|
+
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
827
|
+
this.ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
828
|
+
}
|
|
829
|
+
rebuild() {
|
|
830
|
+
this.cols = Math.max(2, Math.floor(this.w / CELL));
|
|
831
|
+
this.rows = Math.max(2, Math.floor(this.h / CELL));
|
|
832
|
+
this.grid = new Array(this.cols * this.rows).fill(false);
|
|
833
|
+
this.filled = 0;
|
|
834
|
+
this.pipe = null;
|
|
835
|
+
this.paintBackground();
|
|
836
|
+
}
|
|
837
|
+
paintBackground() {
|
|
838
|
+
this.ctx.fillStyle = "#111";
|
|
839
|
+
this.ctx.fillRect(0, 0, this.w, this.h);
|
|
840
|
+
}
|
|
841
|
+
idx(col, row) {
|
|
842
|
+
return row * this.cols + col;
|
|
843
|
+
}
|
|
844
|
+
inBounds(col, row) {
|
|
845
|
+
return col >= 0 && col < this.cols && row >= 0 && row < this.rows;
|
|
846
|
+
}
|
|
847
|
+
spawnPipe() {
|
|
848
|
+
const empty = [];
|
|
849
|
+
for (let i = 0; i < this.grid.length; i++) {
|
|
850
|
+
if (!this.grid[i]) empty.push(i);
|
|
851
|
+
}
|
|
852
|
+
if (empty.length === 0) {
|
|
853
|
+
this.clearGrid();
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
const cell = this.rng.pick(empty);
|
|
857
|
+
const col = cell % this.cols;
|
|
858
|
+
const row = Math.floor(cell / this.cols);
|
|
859
|
+
this.pipe = {
|
|
860
|
+
col,
|
|
861
|
+
row,
|
|
862
|
+
dir: this.rng.int(0, 3),
|
|
863
|
+
color: this.rng.pick(PALETTE)
|
|
864
|
+
};
|
|
865
|
+
this.grid[cell] = true;
|
|
866
|
+
this.filled++;
|
|
867
|
+
this.drawJoint(col, row, this.pipe.color);
|
|
868
|
+
}
|
|
869
|
+
clearGrid() {
|
|
870
|
+
this.grid.fill(false);
|
|
871
|
+
this.filled = 0;
|
|
872
|
+
this.pipe = null;
|
|
873
|
+
this.paintBackground();
|
|
874
|
+
}
|
|
875
|
+
growStep() {
|
|
876
|
+
if (this.filled / this.grid.length > FILL_THRESHOLD) {
|
|
877
|
+
this.clearGrid();
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
if (!this.pipe) {
|
|
881
|
+
this.spawnPipe();
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
const candidates = this.getCandidates(this.pipe);
|
|
885
|
+
if (candidates.length === 0) {
|
|
886
|
+
this.pipe = null;
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
const oldCol = this.pipe.col;
|
|
890
|
+
const oldRow = this.pipe.row;
|
|
891
|
+
const oldDir = this.pipe.dir;
|
|
892
|
+
const newDir = this.rng.pick(candidates);
|
|
893
|
+
this.pipe.dir = newDir;
|
|
894
|
+
const nc = oldCol + DX[newDir];
|
|
895
|
+
const nr = oldRow + DY[newDir];
|
|
896
|
+
this.drawSegment(oldCol, oldRow, nc, nr, this.pipe.color);
|
|
897
|
+
if (newDir !== oldDir) {
|
|
898
|
+
this.drawJoint(oldCol, oldRow, this.pipe.color);
|
|
899
|
+
}
|
|
900
|
+
this.pipe.col = nc;
|
|
901
|
+
this.pipe.row = nr;
|
|
902
|
+
this.grid[this.idx(nc, nr)] = true;
|
|
903
|
+
this.filled++;
|
|
904
|
+
}
|
|
905
|
+
getCandidates(pipe) {
|
|
906
|
+
const out = [];
|
|
907
|
+
for (let d = 0; d < 4; d++) {
|
|
908
|
+
const nc = pipe.col + DX[d];
|
|
909
|
+
const nr = pipe.row + DY[d];
|
|
910
|
+
if (this.inBounds(nc, nr) && !this.grid[this.idx(nc, nr)]) {
|
|
911
|
+
out.push(d);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
if (out.includes(pipe.dir) && this.rng.next() < 0.65) {
|
|
915
|
+
return [pipe.dir];
|
|
916
|
+
}
|
|
917
|
+
return out;
|
|
918
|
+
}
|
|
919
|
+
cellCenter(col, row) {
|
|
920
|
+
return [col * CELL + CELL / 2, row * CELL + CELL / 2];
|
|
921
|
+
}
|
|
922
|
+
drawSegment(c1, r1, c2, r2, color) {
|
|
923
|
+
const [x1, y1] = this.cellCenter(c1, r1);
|
|
924
|
+
const [x2, y2] = this.cellCenter(c2, r2);
|
|
925
|
+
const ctx = this.ctx;
|
|
926
|
+
ctx.strokeStyle = color;
|
|
927
|
+
ctx.lineWidth = PIPE_WIDTH;
|
|
928
|
+
ctx.lineCap = "round";
|
|
929
|
+
ctx.beginPath();
|
|
930
|
+
ctx.moveTo(x1, y1);
|
|
931
|
+
ctx.lineTo(x2, y2);
|
|
932
|
+
ctx.stroke();
|
|
933
|
+
}
|
|
934
|
+
drawJoint(col, row, color) {
|
|
935
|
+
const [x, y] = this.cellCenter(col, row);
|
|
936
|
+
const ctx = this.ctx;
|
|
937
|
+
ctx.fillStyle = color;
|
|
938
|
+
ctx.beginPath();
|
|
939
|
+
ctx.arc(x, y, PIPE_WIDTH * 0.65, 0, Math.PI * 2);
|
|
940
|
+
ctx.fill();
|
|
941
|
+
}
|
|
942
|
+
start() {
|
|
943
|
+
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
944
|
+
this.loop();
|
|
945
|
+
}
|
|
946
|
+
stop() {
|
|
947
|
+
if (this.frameId !== null) {
|
|
948
|
+
cancelAnimationFrame(this.frameId);
|
|
949
|
+
this.frameId = null;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
loop() {
|
|
953
|
+
this.frameId = requestAnimationFrame(() => this.loop());
|
|
954
|
+
for (let i = 0; i < STEPS_PER_FRAME; i++) this.growStep();
|
|
955
|
+
}
|
|
956
|
+
renderStill() {
|
|
957
|
+
this.rebuild();
|
|
958
|
+
for (let i = 0; i < 80; i++) this.growStep();
|
|
959
|
+
}
|
|
960
|
+
setPaused(paused) {
|
|
961
|
+
this.paused = paused;
|
|
962
|
+
if (paused) {
|
|
963
|
+
this.stop();
|
|
964
|
+
} else {
|
|
965
|
+
this.start();
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
resize(width, height, dpr) {
|
|
969
|
+
this.w = width;
|
|
970
|
+
this.h = height;
|
|
971
|
+
if (dpr !== void 0) this.ctxSaver.dpr = dpr;
|
|
972
|
+
this.sizeCanvas();
|
|
973
|
+
this.rebuild();
|
|
974
|
+
if (this.paused) this.renderStill();
|
|
975
|
+
}
|
|
976
|
+
dispose() {
|
|
977
|
+
this.stop();
|
|
978
|
+
if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) this.canvas.remove();
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
var pipes = {
|
|
982
|
+
manifest: pipesManifest,
|
|
983
|
+
mount: (ctx) => new PipesInstance(ctx)
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
// src/bsod.ts
|
|
987
|
+
var bsodManifest = {
|
|
988
|
+
id: "bsod",
|
|
989
|
+
label: "BSOD",
|
|
990
|
+
passthrough: false,
|
|
991
|
+
minBackend: "css",
|
|
992
|
+
costTier: "idle",
|
|
993
|
+
motionIntensity: "calm",
|
|
994
|
+
reducedMotionFallback: "static",
|
|
995
|
+
a11y: { flashSafe: true, notes: "Static text screens, slow crossfade between them." }
|
|
996
|
+
};
|
|
997
|
+
var CYCLE_MS = 1e4;
|
|
998
|
+
var FADE_MS = 800;
|
|
999
|
+
var SCREENS = [
|
|
1000
|
+
{
|
|
1001
|
+
id: "win31",
|
|
1002
|
+
html: `<div class="is-bsod-win31">
|
|
1003
|
+
<pre>
|
|
1004
|
+
Windows
|
|
1005
|
+
|
|
1006
|
+
A fatal exception 0E has occurred at 0028:C0034B03
|
|
1007
|
+
in VXD VWIN32(01) + 00010A45. The current application
|
|
1008
|
+
will be terminated.
|
|
1009
|
+
|
|
1010
|
+
* Press any key to terminate the current application.
|
|
1011
|
+
* Press CTRL+ALT+DEL again to restart your computer.
|
|
1012
|
+
You will lose any unsaved information in all applications.
|
|
1013
|
+
|
|
1014
|
+
Press any key to continue _</pre></div>`
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
id: "win98",
|
|
1018
|
+
html: `<div class="is-bsod-win98">
|
|
1019
|
+
<pre>
|
|
1020
|
+
A problem has been detected and Windows has been shut down to prevent
|
|
1021
|
+
damage to your computer.
|
|
1022
|
+
|
|
1023
|
+
DRIVER_IRQL_NOT_LESS_OR_EQUAL
|
|
1024
|
+
|
|
1025
|
+
If this is the first time you've seen this Stop error screen,
|
|
1026
|
+
restart your computer. If this screen appears again, follow these steps:
|
|
1027
|
+
|
|
1028
|
+
Check to make sure any new hardware or software is properly installed.
|
|
1029
|
+
If this is a new installation, ask your hardware or software manufacturer
|
|
1030
|
+
for any Windows updates you might need.
|
|
1031
|
+
|
|
1032
|
+
If problems continue, disable or remove any newly installed hardware or
|
|
1033
|
+
software. Disable BIOS memory options such as caching or shadowing.
|
|
1034
|
+
If you need to use Safe Mode to remove or disable components, restart
|
|
1035
|
+
your computer, press F8 to select Advanced Startup Options, and then
|
|
1036
|
+
select Safe Mode.
|
|
1037
|
+
|
|
1038
|
+
Technical information:
|
|
1039
|
+
|
|
1040
|
+
*** STOP: 0x000000D1 (0x0000000C,0x00000002,0x00000000,0xF86B5A89)
|
|
1041
|
+
|
|
1042
|
+
*** gv3.sys - Address F86B5A89 base at F86B5000, DateStamp 3dd9919eb</pre></div>`
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
id: "win10",
|
|
1046
|
+
html: `<div class="is-bsod-win10">
|
|
1047
|
+
<div class="is-bsod-face">:(</div>
|
|
1048
|
+
<div class="is-bsod-title">Your PC ran into a problem and needs to restart. We're just collecting some error info, and then we'll restart for you.</div>
|
|
1049
|
+
<div class="is-bsod-pct">68% complete</div>
|
|
1050
|
+
<div class="is-bsod-detail">
|
|
1051
|
+
<div class="is-bsod-small">For more information about this issue and possible fixes, visit<br>https://www.windows.com/stopcode</div>
|
|
1052
|
+
<div class="is-bsod-small">If you call a support person, give them this info:<br>Stop code: CRITICAL_PROCESS_DIED</div>
|
|
1053
|
+
</div></div>`
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
id: "panic",
|
|
1057
|
+
html: `<div class="is-bsod-panic">
|
|
1058
|
+
<pre>
|
|
1059
|
+
panic(cpu 0 caller 0xffffff80003ade41): Kernel trap at 0xffffff7f80a3f6e5,
|
|
1060
|
+
type 14=page fault, registers:
|
|
1061
|
+
CR0: 0x000000008001003b, CR2: 0x0000000000000010, CR3: 0x000000000600f000,
|
|
1062
|
+
CR4: 0x00000000001626e0
|
|
1063
|
+
RAX: 0x0000000000000003, RBX: 0xffffff80175c9000, RCX: 0xffffff8017403310,
|
|
1064
|
+
RDX: 0x0000000000000000
|
|
1065
|
+
RSP: 0xffffff8116e63c30, RBP: 0xffffff8116e63c60, RSI: 0xffffff80175c9000,
|
|
1066
|
+
RDI: 0x0000000000000001
|
|
1067
|
+
R8: 0x0000000000000000, R9: 0x00000000000003ff, R10: 0x0000000000000008,
|
|
1068
|
+
R11: 0x0000000000000206
|
|
1069
|
+
R12: 0x0000000000000000, R13: 0x0000000000000001, R14: 0x0000000000000000,
|
|
1070
|
+
R15: 0x0000000000000000
|
|
1071
|
+
RFL: 0x0000000000010202, RIP: 0xffffff7f80a3f6e5, CS: 0x0000000000000008,
|
|
1072
|
+
SS: 0x0000000000000010
|
|
1073
|
+
|
|
1074
|
+
Backtrace (CPU 0), Frame : Return Address
|
|
1075
|
+
0xffffff8116e63880 : 0xffffff80002c3ae1
|
|
1076
|
+
0xffffff8116e63900 : 0xffffff80003ade41
|
|
1077
|
+
0xffffff8116e63ae0 : 0xffffff80003c9576
|
|
1078
|
+
0xffffff8116e63b00 : 0xffffff80002a4f10
|
|
1079
|
+
|
|
1080
|
+
|
|
1081
|
+
You need to restart your computer.
|
|
1082
|
+
Hold down the Power button for several seconds or
|
|
1083
|
+
press the Restart button.</pre></div>`
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
id: "amiga",
|
|
1087
|
+
html: `<div class="is-bsod-amiga">
|
|
1088
|
+
<div class="is-bsod-amiga-alert">
|
|
1089
|
+
<span class="is-bsod-amiga-icon"></span>
|
|
1090
|
+
<div class="is-bsod-amiga-text">
|
|
1091
|
+
Software Failure. Press left mouse button to continue.<br>
|
|
1092
|
+
Guru Meditation #48454C50.0BADF00D
|
|
1093
|
+
</div>
|
|
1094
|
+
</div></div>`
|
|
1095
|
+
}
|
|
1096
|
+
];
|
|
1097
|
+
var CSS6 = `
|
|
1098
|
+
.is-bsod-root {
|
|
1099
|
+
position: absolute;
|
|
1100
|
+
inset: 0;
|
|
1101
|
+
overflow: hidden;
|
|
1102
|
+
}
|
|
1103
|
+
.is-bsod-screen {
|
|
1104
|
+
position: absolute;
|
|
1105
|
+
inset: 0;
|
|
1106
|
+
display: flex;
|
|
1107
|
+
align-items: center;
|
|
1108
|
+
justify-content: center;
|
|
1109
|
+
opacity: 0;
|
|
1110
|
+
transition: opacity ${FADE_MS}ms ease;
|
|
1111
|
+
}
|
|
1112
|
+
.is-bsod-screen.is-active { opacity: 1; }
|
|
1113
|
+
.is-bsod-root.is-paused .is-bsod-screen { transition: none; }
|
|
1114
|
+
|
|
1115
|
+
/* Win 3.1 / 9x */
|
|
1116
|
+
.is-bsod-win31, .is-bsod-win98 {
|
|
1117
|
+
width: 100%; height: 100%;
|
|
1118
|
+
background: #0000aa;
|
|
1119
|
+
color: #aaa;
|
|
1120
|
+
font-family: 'Courier New', 'Lucida Console', monospace;
|
|
1121
|
+
font-size: clamp(10px, 1.4vw, 16px);
|
|
1122
|
+
display: flex;
|
|
1123
|
+
align-items: center;
|
|
1124
|
+
justify-content: center;
|
|
1125
|
+
}
|
|
1126
|
+
.is-bsod-win31 pre, .is-bsod-win98 pre {
|
|
1127
|
+
margin: 0;
|
|
1128
|
+
padding: 2em;
|
|
1129
|
+
max-width: 80ch;
|
|
1130
|
+
white-space: pre-wrap;
|
|
1131
|
+
word-break: break-word;
|
|
1132
|
+
line-height: 1.5;
|
|
1133
|
+
}
|
|
1134
|
+
.is-bsod-win31 { color: #fff; }
|
|
1135
|
+
|
|
1136
|
+
/* Win 10/11 */
|
|
1137
|
+
.is-bsod-win10 {
|
|
1138
|
+
width: 100%; height: 100%;
|
|
1139
|
+
background: #0078d7;
|
|
1140
|
+
color: #fff;
|
|
1141
|
+
font-family: 'Segoe UI', system-ui, sans-serif;
|
|
1142
|
+
display: flex;
|
|
1143
|
+
flex-direction: column;
|
|
1144
|
+
justify-content: center;
|
|
1145
|
+
padding: 10%;
|
|
1146
|
+
box-sizing: border-box;
|
|
1147
|
+
}
|
|
1148
|
+
.is-bsod-face {
|
|
1149
|
+
font-size: clamp(60px, 12vw, 140px);
|
|
1150
|
+
font-weight: 200;
|
|
1151
|
+
line-height: 1;
|
|
1152
|
+
margin-bottom: 0.3em;
|
|
1153
|
+
}
|
|
1154
|
+
.is-bsod-title {
|
|
1155
|
+
font-size: clamp(14px, 2.2vw, 26px);
|
|
1156
|
+
line-height: 1.4;
|
|
1157
|
+
max-width: 50ch;
|
|
1158
|
+
}
|
|
1159
|
+
.is-bsod-pct {
|
|
1160
|
+
font-size: clamp(14px, 2.2vw, 26px);
|
|
1161
|
+
margin-top: 1em;
|
|
1162
|
+
}
|
|
1163
|
+
.is-bsod-detail { margin-top: 2em; }
|
|
1164
|
+
.is-bsod-small {
|
|
1165
|
+
font-size: clamp(10px, 1.2vw, 14px);
|
|
1166
|
+
line-height: 1.6;
|
|
1167
|
+
margin-top: 0.8em;
|
|
1168
|
+
opacity: 0.9;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/* macOS kernel panic */
|
|
1172
|
+
.is-bsod-panic {
|
|
1173
|
+
width: 100%; height: 100%;
|
|
1174
|
+
background: #000;
|
|
1175
|
+
color: #fff;
|
|
1176
|
+
font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
|
|
1177
|
+
font-size: clamp(9px, 1.2vw, 14px);
|
|
1178
|
+
display: flex;
|
|
1179
|
+
align-items: center;
|
|
1180
|
+
justify-content: center;
|
|
1181
|
+
}
|
|
1182
|
+
.is-bsod-panic pre {
|
|
1183
|
+
margin: 0;
|
|
1184
|
+
padding: 2em;
|
|
1185
|
+
max-width: 90ch;
|
|
1186
|
+
white-space: pre-wrap;
|
|
1187
|
+
word-break: break-word;
|
|
1188
|
+
line-height: 1.6;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
/* Amiga Guru Meditation */
|
|
1192
|
+
.is-bsod-amiga {
|
|
1193
|
+
width: 100%; height: 100%;
|
|
1194
|
+
background: #000;
|
|
1195
|
+
color: #f00;
|
|
1196
|
+
font-family: 'Courier New', 'Lucida Console', monospace;
|
|
1197
|
+
display: flex;
|
|
1198
|
+
align-items: center;
|
|
1199
|
+
justify-content: center;
|
|
1200
|
+
}
|
|
1201
|
+
.is-bsod-amiga-alert {
|
|
1202
|
+
border: 3px solid #f00;
|
|
1203
|
+
padding: 0.8em 1.5em;
|
|
1204
|
+
display: flex;
|
|
1205
|
+
align-items: center;
|
|
1206
|
+
gap: 1em;
|
|
1207
|
+
}
|
|
1208
|
+
.is-bsod-amiga-icon {
|
|
1209
|
+
display: inline-block;
|
|
1210
|
+
width: 1.2em;
|
|
1211
|
+
height: 1.2em;
|
|
1212
|
+
border: 2px solid #f00;
|
|
1213
|
+
border-radius: 50%;
|
|
1214
|
+
flex-shrink: 0;
|
|
1215
|
+
}
|
|
1216
|
+
.is-bsod-amiga-text {
|
|
1217
|
+
font-size: clamp(12px, 1.8vw, 20px);
|
|
1218
|
+
line-height: 1.6;
|
|
1219
|
+
}
|
|
1220
|
+
`;
|
|
1221
|
+
var BsodInstance = class {
|
|
1222
|
+
root;
|
|
1223
|
+
style;
|
|
1224
|
+
screens;
|
|
1225
|
+
current = 0;
|
|
1226
|
+
timerId = null;
|
|
1227
|
+
constructor(ctx) {
|
|
1228
|
+
this.style = document.createElement("style");
|
|
1229
|
+
this.style.textContent = CSS6;
|
|
1230
|
+
ctx.host.appendChild(this.style);
|
|
1231
|
+
this.root = document.createElement("div");
|
|
1232
|
+
this.root.className = "is-bsod-root";
|
|
1233
|
+
this.root.setAttribute("aria-hidden", "true");
|
|
1234
|
+
this.screens = SCREENS.map((s) => {
|
|
1235
|
+
const wrapper = document.createElement("div");
|
|
1236
|
+
wrapper.className = "is-bsod-screen";
|
|
1237
|
+
wrapper.dataset["screen"] = s.id;
|
|
1238
|
+
wrapper.innerHTML = s.html;
|
|
1239
|
+
this.root.appendChild(wrapper);
|
|
1240
|
+
return wrapper;
|
|
1241
|
+
});
|
|
1242
|
+
ctx.host.appendChild(this.root);
|
|
1243
|
+
this.show(0);
|
|
1244
|
+
if (ctx.reducedMotion) {
|
|
1245
|
+
this.root.classList.add("is-paused");
|
|
1246
|
+
} else {
|
|
1247
|
+
this.startCycle();
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
show(idx) {
|
|
1251
|
+
for (let i = 0; i < this.screens.length; i++) {
|
|
1252
|
+
this.screens[i].classList.toggle("is-active", i === idx);
|
|
1253
|
+
}
|
|
1254
|
+
this.current = idx;
|
|
1255
|
+
}
|
|
1256
|
+
advance() {
|
|
1257
|
+
this.show((this.current + 1) % this.screens.length);
|
|
1258
|
+
}
|
|
1259
|
+
startCycle() {
|
|
1260
|
+
if (this.timerId !== null) return;
|
|
1261
|
+
this.timerId = setInterval(() => this.advance(), CYCLE_MS);
|
|
1262
|
+
}
|
|
1263
|
+
stopCycle() {
|
|
1264
|
+
if (this.timerId !== null) {
|
|
1265
|
+
clearInterval(this.timerId);
|
|
1266
|
+
this.timerId = null;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
setPaused(paused) {
|
|
1270
|
+
this.root.classList.toggle("is-paused", paused);
|
|
1271
|
+
if (paused) {
|
|
1272
|
+
this.stopCycle();
|
|
1273
|
+
} else {
|
|
1274
|
+
this.startCycle();
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
resize(_width, _height) {
|
|
1278
|
+
}
|
|
1279
|
+
dispose() {
|
|
1280
|
+
this.stopCycle();
|
|
1281
|
+
this.root.remove();
|
|
1282
|
+
this.style.remove();
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
var bsod = {
|
|
1286
|
+
manifest: bsodManifest,
|
|
1287
|
+
mount: (ctx) => new BsodInstance(ctx)
|
|
1288
|
+
};
|
|
1289
|
+
|
|
1290
|
+
// src/flurry.ts
|
|
1291
|
+
var flurryManifest = {
|
|
1292
|
+
id: "flurry",
|
|
1293
|
+
label: "Flurry",
|
|
1294
|
+
passthrough: false,
|
|
1295
|
+
minBackend: "canvas2d",
|
|
1296
|
+
costTier: "low",
|
|
1297
|
+
motionIntensity: "calm",
|
|
1298
|
+
reducedMotionFallback: "static",
|
|
1299
|
+
a11y: { flashSafe: true }
|
|
1300
|
+
};
|
|
1301
|
+
var STREAM_COUNT = 5;
|
|
1302
|
+
var PARTICLES_PER_STREAM = 12;
|
|
1303
|
+
var TRAIL_ALPHA = 0.06;
|
|
1304
|
+
var BASE_RADIUS = 6;
|
|
1305
|
+
var FlurryInstance = class {
|
|
1306
|
+
ctxSaver;
|
|
1307
|
+
canvas;
|
|
1308
|
+
ctx;
|
|
1309
|
+
w = 0;
|
|
1310
|
+
h = 0;
|
|
1311
|
+
streams;
|
|
1312
|
+
frameId = null;
|
|
1313
|
+
t = 0;
|
|
1314
|
+
lastTime = 0;
|
|
1315
|
+
paused = false;
|
|
1316
|
+
constructor(ctx) {
|
|
1317
|
+
this.ctxSaver = ctx;
|
|
1318
|
+
this.w = ctx.width;
|
|
1319
|
+
this.h = ctx.height;
|
|
1320
|
+
let canvas;
|
|
1321
|
+
if (ctx.surface) {
|
|
1322
|
+
canvas = ctx.surface;
|
|
1323
|
+
} else {
|
|
1324
|
+
const el = document.createElement("canvas");
|
|
1325
|
+
el.style.cssText = "display:block;width:100%;height:100%";
|
|
1326
|
+
el.setAttribute("aria-hidden", "true");
|
|
1327
|
+
ctx.host.appendChild(el);
|
|
1328
|
+
canvas = el;
|
|
1329
|
+
}
|
|
1330
|
+
this.canvas = canvas;
|
|
1331
|
+
const c2d = canvas.getContext("2d", { alpha: false });
|
|
1332
|
+
if (!c2d) throw new Error("flurry: no 2d context");
|
|
1333
|
+
this.ctx = c2d;
|
|
1334
|
+
this.streams = this.buildStreams(ctx.rng);
|
|
1335
|
+
this.sizeCanvas();
|
|
1336
|
+
this.clearFull();
|
|
1337
|
+
this.paused = ctx.reducedMotion;
|
|
1338
|
+
if (this.paused) {
|
|
1339
|
+
this.renderStill();
|
|
1340
|
+
} else {
|
|
1341
|
+
this.start();
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
buildStreams(rng) {
|
|
1345
|
+
const out = [];
|
|
1346
|
+
for (let i = 0; i < STREAM_COUNT; i++) {
|
|
1347
|
+
out.push({
|
|
1348
|
+
hue: (i * 360 / STREAM_COUNT + rng.range(0, 30)) % 360,
|
|
1349
|
+
freqX1: rng.range(0.3, 0.9),
|
|
1350
|
+
freqY1: rng.range(0.3, 0.9),
|
|
1351
|
+
freqX2: rng.range(0.1, 0.4),
|
|
1352
|
+
freqY2: rng.range(0.1, 0.4),
|
|
1353
|
+
phaseX: rng.range(0, Math.PI * 2),
|
|
1354
|
+
phaseY: rng.range(0, Math.PI * 2),
|
|
1355
|
+
ampX: rng.range(0.2, 0.4),
|
|
1356
|
+
ampY: rng.range(0.2, 0.4),
|
|
1357
|
+
speed: rng.range(0.6, 1.2)
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
return out;
|
|
1361
|
+
}
|
|
1362
|
+
sizeCanvas() {
|
|
1363
|
+
const dpr = Math.min(this.ctxSaver.dpr, 2);
|
|
1364
|
+
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
1365
|
+
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
1366
|
+
this.ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
1367
|
+
}
|
|
1368
|
+
clearFull() {
|
|
1369
|
+
this.ctx.fillStyle = "#000";
|
|
1370
|
+
this.ctx.fillRect(0, 0, this.w, this.h);
|
|
1371
|
+
}
|
|
1372
|
+
streamPos(s, t) {
|
|
1373
|
+
const cx = this.w / 2;
|
|
1374
|
+
const cy = this.h / 2;
|
|
1375
|
+
const x = cx + Math.sin(t * s.freqX1 + s.phaseX) * this.w * s.ampX + Math.sin(t * s.freqX2 + s.phaseX * 1.7) * this.w * s.ampX * 0.3;
|
|
1376
|
+
const y = cy + Math.cos(t * s.freqY1 + s.phaseY) * this.h * s.ampY + Math.cos(t * s.freqY2 + s.phaseY * 2.1) * this.h * s.ampY * 0.3;
|
|
1377
|
+
return [x, y];
|
|
1378
|
+
}
|
|
1379
|
+
drawFrame(dt) {
|
|
1380
|
+
const ctx = this.ctx;
|
|
1381
|
+
ctx.globalCompositeOperation = "source-over";
|
|
1382
|
+
ctx.fillStyle = `rgba(0,0,0,${TRAIL_ALPHA})`;
|
|
1383
|
+
ctx.fillRect(0, 0, this.w, this.h);
|
|
1384
|
+
ctx.globalCompositeOperation = "lighter";
|
|
1385
|
+
for (const s of this.streams) {
|
|
1386
|
+
const st = this.t * s.speed;
|
|
1387
|
+
for (let p = 0; p < PARTICLES_PER_STREAM; p++) {
|
|
1388
|
+
const offset = p * 0.012;
|
|
1389
|
+
const [x, y] = this.streamPos(s, st - offset);
|
|
1390
|
+
const hue = (s.hue + this.t * 8 + p * 3) % 360;
|
|
1391
|
+
const alpha = 0.15 + 0.1 * (1 - p / PARTICLES_PER_STREAM);
|
|
1392
|
+
const r = BASE_RADIUS * (1 - p * 0.04);
|
|
1393
|
+
const grad = ctx.createRadialGradient(x, y, 0, x, y, r * 3);
|
|
1394
|
+
grad.addColorStop(0, `hsla(${hue},90%,60%,${alpha})`);
|
|
1395
|
+
grad.addColorStop(0.4, `hsla(${hue},80%,50%,${alpha * 0.5})`);
|
|
1396
|
+
grad.addColorStop(1, `hsla(${hue},70%,40%,0)`);
|
|
1397
|
+
ctx.fillStyle = grad;
|
|
1398
|
+
ctx.beginPath();
|
|
1399
|
+
ctx.arc(x, y, r * 3, 0, Math.PI * 2);
|
|
1400
|
+
ctx.fill();
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
ctx.globalCompositeOperation = "source-over";
|
|
1404
|
+
}
|
|
1405
|
+
start() {
|
|
1406
|
+
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
1407
|
+
this.lastTime = 0;
|
|
1408
|
+
this.loop(0);
|
|
1409
|
+
}
|
|
1410
|
+
stop() {
|
|
1411
|
+
if (this.frameId !== null) {
|
|
1412
|
+
cancelAnimationFrame(this.frameId);
|
|
1413
|
+
this.frameId = null;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
loop(now) {
|
|
1417
|
+
this.frameId = requestAnimationFrame((n) => this.loop(n));
|
|
1418
|
+
const dt = this.lastTime ? (now - this.lastTime) / 1e3 : 1 / 60;
|
|
1419
|
+
this.lastTime = now;
|
|
1420
|
+
this.t += Math.min(dt, 0.1);
|
|
1421
|
+
this.drawFrame(dt);
|
|
1422
|
+
}
|
|
1423
|
+
renderStill() {
|
|
1424
|
+
this.clearFull();
|
|
1425
|
+
for (let i = 0; i < 120; i++) {
|
|
1426
|
+
this.t += 1 / 60;
|
|
1427
|
+
this.drawFrame(1 / 60);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
setPaused(paused) {
|
|
1431
|
+
this.paused = paused;
|
|
1432
|
+
if (paused) {
|
|
1433
|
+
this.stop();
|
|
1434
|
+
} else {
|
|
1435
|
+
this.start();
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
resize(width, height, dpr) {
|
|
1439
|
+
this.w = width;
|
|
1440
|
+
this.h = height;
|
|
1441
|
+
if (dpr !== void 0) this.ctxSaver.dpr = dpr;
|
|
1442
|
+
this.sizeCanvas();
|
|
1443
|
+
this.clearFull();
|
|
1444
|
+
if (this.paused) this.renderStill();
|
|
1445
|
+
}
|
|
1446
|
+
dispose() {
|
|
1447
|
+
this.stop();
|
|
1448
|
+
if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) this.canvas.remove();
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
var flurry = {
|
|
1452
|
+
manifest: flurryManifest,
|
|
1453
|
+
mount: (ctx) => new FlurryInstance(ctx)
|
|
1454
|
+
};
|
|
1455
|
+
|
|
1456
|
+
// src/fluid-shared.ts
|
|
1457
|
+
var DT = 0.025;
|
|
1458
|
+
var DENS_DECAY = 0.993;
|
|
1459
|
+
var VEL_DECAY = 0.98;
|
|
1460
|
+
var DYE_RATE = 1400;
|
|
1461
|
+
var FORCE_RATE = 5;
|
|
1462
|
+
var EMITTER_N = 4;
|
|
1463
|
+
function hue2rgb(h) {
|
|
1464
|
+
h = (h % 360 + 360) % 360;
|
|
1465
|
+
const s = h / 60;
|
|
1466
|
+
const x = 1 - Math.abs(s % 2 - 1);
|
|
1467
|
+
if (s < 1) return [1, x, 0];
|
|
1468
|
+
if (s < 2) return [x, 1, 0];
|
|
1469
|
+
if (s < 3) return [0, 1, x];
|
|
1470
|
+
if (s < 4) return [0, x, 1];
|
|
1471
|
+
if (s < 5) return [x, 0, 1];
|
|
1472
|
+
return [1, 0, x];
|
|
1473
|
+
}
|
|
1474
|
+
function buildEmitters(rng, N3) {
|
|
1475
|
+
const out = [];
|
|
1476
|
+
for (let i = 0; i < EMITTER_N; i++) {
|
|
1477
|
+
const px = rng.range(0, Math.PI * 2);
|
|
1478
|
+
const py = rng.range(0, Math.PI * 2);
|
|
1479
|
+
out.push({
|
|
1480
|
+
hue: (i * 360 / EMITTER_N + rng.range(0, 40)) % 360,
|
|
1481
|
+
fx: rng.range(0.3, 0.8),
|
|
1482
|
+
fy: rng.range(0.3, 0.8),
|
|
1483
|
+
px,
|
|
1484
|
+
py,
|
|
1485
|
+
speed: rng.range(0.5, 1),
|
|
1486
|
+
prevGx: (Math.sin(px) * 0.35 + 0.5) * N3 + 1,
|
|
1487
|
+
prevGy: (Math.cos(py) * 0.35 + 0.5) * N3 + 1
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
return out;
|
|
1491
|
+
}
|
|
1492
|
+
function stepEmitters(t, emitters, N3) {
|
|
1493
|
+
return emitters.map((e) => {
|
|
1494
|
+
const st = t * e.speed;
|
|
1495
|
+
const gx = (Math.sin(st * e.fx + e.px) * 0.35 + 0.5) * N3 + 1;
|
|
1496
|
+
const gy = (Math.cos(st * e.fy + e.py) * 0.35 + 0.5) * N3 + 1;
|
|
1497
|
+
const dx = gx - e.prevGx;
|
|
1498
|
+
const dy = gy - e.prevGy;
|
|
1499
|
+
const [r, g, b] = hue2rgb(e.hue + t * 15);
|
|
1500
|
+
e.prevGx = gx;
|
|
1501
|
+
e.prevGy = gy;
|
|
1502
|
+
return { gx, gy, dx, dy, r, g, b };
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
// src/fluid-gpu.ts
|
|
1507
|
+
var GPU_N = 256;
|
|
1508
|
+
var GPU_STRIDE = GPU_N + 2;
|
|
1509
|
+
var GPU_SZ = GPU_STRIDE * GPU_STRIDE;
|
|
1510
|
+
var GPU_DIFF = 3e-5 * (96 / GPU_N) ** 2;
|
|
1511
|
+
var GPU_VISC = 3e-4 * (96 / GPU_N) ** 2;
|
|
1512
|
+
var GPU_INJECT_R = Math.round(4 * (GPU_N / 96));
|
|
1513
|
+
var GPU_FORCE_RATE = FORCE_RATE * (96 / GPU_N);
|
|
1514
|
+
var JACOBI_DIFF = 10;
|
|
1515
|
+
var JACOBI_PRES = 40;
|
|
1516
|
+
var COPY_WGSL = (
|
|
1517
|
+
/* wgsl */
|
|
1518
|
+
`
|
|
1519
|
+
override SZ: u32;
|
|
1520
|
+
@group(0) @binding(0) var<storage, read_write> dst: array<f32>;
|
|
1521
|
+
@group(0) @binding(1) var<storage, read> src: array<f32>;
|
|
1522
|
+
@compute @workgroup_size(256)
|
|
1523
|
+
fn main(@builtin(global_invocation_id) gid: vec3u) {
|
|
1524
|
+
if (gid.x >= SZ) { return; }
|
|
1525
|
+
dst[gid.x] = src[gid.x];
|
|
1526
|
+
}`
|
|
1527
|
+
);
|
|
1528
|
+
var ADD_SOURCE_WGSL = (
|
|
1529
|
+
/* wgsl */
|
|
1530
|
+
`
|
|
1531
|
+
override SZ: u32;
|
|
1532
|
+
struct P { dt: f32 }
|
|
1533
|
+
@group(0) @binding(0) var<uniform> p: P;
|
|
1534
|
+
@group(0) @binding(1) var<storage, read_write> dst: array<f32>;
|
|
1535
|
+
@group(0) @binding(2) var<storage, read> src: array<f32>;
|
|
1536
|
+
@compute @workgroup_size(256)
|
|
1537
|
+
fn main(@builtin(global_invocation_id) gid: vec3u) {
|
|
1538
|
+
if (gid.x >= SZ) { return; }
|
|
1539
|
+
dst[gid.x] += p.dt * src[gid.x];
|
|
1540
|
+
}`
|
|
1541
|
+
);
|
|
1542
|
+
var SCALE_WGSL = (
|
|
1543
|
+
/* wgsl */
|
|
1544
|
+
`
|
|
1545
|
+
override SZ: u32;
|
|
1546
|
+
struct P { factor: f32 }
|
|
1547
|
+
@group(0) @binding(0) var<uniform> p: P;
|
|
1548
|
+
@group(0) @binding(1) var<storage, read_write> field: array<f32>;
|
|
1549
|
+
@compute @workgroup_size(256)
|
|
1550
|
+
fn main(@builtin(global_invocation_id) gid: vec3u) {
|
|
1551
|
+
if (gid.x >= SZ) { return; }
|
|
1552
|
+
field[gid.x] *= p.factor;
|
|
1553
|
+
}`
|
|
1554
|
+
);
|
|
1555
|
+
var JACOBI_WGSL = (
|
|
1556
|
+
/* wgsl */
|
|
1557
|
+
`
|
|
1558
|
+
override N: u32;
|
|
1559
|
+
override STRIDE: u32;
|
|
1560
|
+
struct P { a: f32, c: f32 }
|
|
1561
|
+
@group(0) @binding(0) var<uniform> p: P;
|
|
1562
|
+
@group(0) @binding(1) var<storage, read_write> dst: array<f32>;
|
|
1563
|
+
@group(0) @binding(2) var<storage, read> x0: array<f32>;
|
|
1564
|
+
@group(0) @binding(3) var<storage, read> prev: array<f32>;
|
|
1565
|
+
@compute @workgroup_size(8, 8)
|
|
1566
|
+
fn main(@builtin(global_invocation_id) gid: vec3u) {
|
|
1567
|
+
let i = gid.x + 1u;
|
|
1568
|
+
let j = gid.y + 1u;
|
|
1569
|
+
if (i > N || j > N) { return; }
|
|
1570
|
+
let idx = i + STRIDE * j;
|
|
1571
|
+
dst[idx] = (x0[idx] + p.a * (prev[idx - 1u] + prev[idx + 1u]
|
|
1572
|
+
+ prev[idx - STRIDE] + prev[idx + STRIDE])) / p.c;
|
|
1573
|
+
}`
|
|
1574
|
+
);
|
|
1575
|
+
var BOUNDARY_WGSL = (
|
|
1576
|
+
/* wgsl */
|
|
1577
|
+
`
|
|
1578
|
+
override N: u32;
|
|
1579
|
+
override STRIDE: u32;
|
|
1580
|
+
struct P { b: u32 }
|
|
1581
|
+
@group(0) @binding(0) var<uniform> p: P;
|
|
1582
|
+
@group(0) @binding(1) var<storage, read_write> x: array<f32>;
|
|
1583
|
+
@compute @workgroup_size(64)
|
|
1584
|
+
fn main(@builtin(global_invocation_id) gid: vec3u) {
|
|
1585
|
+
let i = gid.x + 1u;
|
|
1586
|
+
if (i > N) { return; }
|
|
1587
|
+
let s = STRIDE;
|
|
1588
|
+
let sl = select(1.0, -1.0, p.b == 1u);
|
|
1589
|
+
let st = select(1.0, -1.0, p.b == 2u);
|
|
1590
|
+
x[s * i] = sl * x[1u + s * i];
|
|
1591
|
+
x[(N + 1u) + s * i] = sl * x[N + s * i];
|
|
1592
|
+
x[i] = st * x[i + s];
|
|
1593
|
+
x[i + s * (N + 1u)] = st * x[i + s * N];
|
|
1594
|
+
if (i == 1u) {
|
|
1595
|
+
x[0u] = x[1u + s];
|
|
1596
|
+
x[s * (N + 1u)] = x[1u + s * N];
|
|
1597
|
+
x[N + 1u] = x[N + s];
|
|
1598
|
+
x[(N + 1u) + s * (N + 1u)] = x[N + s * N];
|
|
1599
|
+
}
|
|
1600
|
+
}`
|
|
1601
|
+
);
|
|
1602
|
+
var ADVECT_WGSL = (
|
|
1603
|
+
/* wgsl */
|
|
1604
|
+
`
|
|
1605
|
+
override N: u32;
|
|
1606
|
+
override STRIDE: u32;
|
|
1607
|
+
struct P { dt0: f32 }
|
|
1608
|
+
@group(0) @binding(0) var<uniform> p: P;
|
|
1609
|
+
@group(0) @binding(1) var<storage, read_write> d: array<f32>;
|
|
1610
|
+
@group(0) @binding(2) var<storage, read> d0: array<f32>;
|
|
1611
|
+
@group(0) @binding(3) var<storage, read> u: array<f32>;
|
|
1612
|
+
@group(0) @binding(4) var<storage, read> v: array<f32>;
|
|
1613
|
+
@compute @workgroup_size(8, 8)
|
|
1614
|
+
fn main(@builtin(global_invocation_id) gid: vec3u) {
|
|
1615
|
+
let i = gid.x + 1u;
|
|
1616
|
+
let j = gid.y + 1u;
|
|
1617
|
+
if (i > N || j > N) { return; }
|
|
1618
|
+
let idx = i + STRIDE * j;
|
|
1619
|
+
var bx = f32(i) - p.dt0 * u[idx];
|
|
1620
|
+
var by = f32(j) - p.dt0 * v[idx];
|
|
1621
|
+
bx = clamp(bx, 0.5, f32(N) + 0.5);
|
|
1622
|
+
by = clamp(by, 0.5, f32(N) + 0.5);
|
|
1623
|
+
let i0 = u32(floor(bx));
|
|
1624
|
+
let j0 = u32(floor(by));
|
|
1625
|
+
let s1 = bx - f32(i0);
|
|
1626
|
+
let s0 = 1.0 - s1;
|
|
1627
|
+
let t1 = by - f32(j0);
|
|
1628
|
+
let t0 = 1.0 - t1;
|
|
1629
|
+
let s = STRIDE;
|
|
1630
|
+
d[idx] = s0 * (t0 * d0[i0 + s * j0] + t1 * d0[i0 + s * (j0 + 1u)])
|
|
1631
|
+
+ s1 * (t0 * d0[(i0 + 1u) + s * j0] + t1 * d0[(i0 + 1u) + s * (j0 + 1u)]);
|
|
1632
|
+
}`
|
|
1633
|
+
);
|
|
1634
|
+
var DIVERGENCE_WGSL = (
|
|
1635
|
+
/* wgsl */
|
|
1636
|
+
`
|
|
1637
|
+
override N: u32;
|
|
1638
|
+
override STRIDE: u32;
|
|
1639
|
+
@group(0) @binding(0) var<storage, read_write> div: array<f32>;
|
|
1640
|
+
@group(0) @binding(1) var<storage, read> u: array<f32>;
|
|
1641
|
+
@group(0) @binding(2) var<storage, read> v: array<f32>;
|
|
1642
|
+
@compute @workgroup_size(8, 8)
|
|
1643
|
+
fn main(@builtin(global_invocation_id) gid: vec3u) {
|
|
1644
|
+
let i = gid.x + 1u;
|
|
1645
|
+
let j = gid.y + 1u;
|
|
1646
|
+
if (i > N || j > N) { return; }
|
|
1647
|
+
let idx = i + STRIDE * j;
|
|
1648
|
+
let h = 1.0 / f32(N);
|
|
1649
|
+
div[idx] = -0.5 * h * (u[idx + 1u] - u[idx - 1u] + v[idx + STRIDE] - v[idx - STRIDE]);
|
|
1650
|
+
}`
|
|
1651
|
+
);
|
|
1652
|
+
var GRADIENT_SUB_WGSL = (
|
|
1653
|
+
/* wgsl */
|
|
1654
|
+
`
|
|
1655
|
+
override N: u32;
|
|
1656
|
+
override STRIDE: u32;
|
|
1657
|
+
@group(0) @binding(0) var<storage, read_write> u: array<f32>;
|
|
1658
|
+
@group(0) @binding(1) var<storage, read_write> v: array<f32>;
|
|
1659
|
+
@group(0) @binding(2) var<storage, read> p: array<f32>;
|
|
1660
|
+
@compute @workgroup_size(8, 8)
|
|
1661
|
+
fn main(@builtin(global_invocation_id) gid: vec3u) {
|
|
1662
|
+
let i = gid.x + 1u;
|
|
1663
|
+
let j = gid.y + 1u;
|
|
1664
|
+
if (i > N || j > N) { return; }
|
|
1665
|
+
let idx = i + STRIDE * j;
|
|
1666
|
+
u[idx] -= 0.5 * f32(N) * (p[idx + 1u] - p[idx - 1u]);
|
|
1667
|
+
v[idx] -= 0.5 * f32(N) * (p[idx + STRIDE] - p[idx - STRIDE]);
|
|
1668
|
+
}`
|
|
1669
|
+
);
|
|
1670
|
+
var INJECT_WGSL = (
|
|
1671
|
+
/* wgsl */
|
|
1672
|
+
`
|
|
1673
|
+
override N: u32;
|
|
1674
|
+
override STRIDE: u32;
|
|
1675
|
+
struct EmitterData { pos: vec4f, col: vec4f }
|
|
1676
|
+
struct IP {
|
|
1677
|
+
inject_r: f32, dye_rate: f32, force_rate: f32, count: u32,
|
|
1678
|
+
data: array<EmitterData, 4>,
|
|
1679
|
+
}
|
|
1680
|
+
@group(0) @binding(0) var<uniform> p: IP;
|
|
1681
|
+
@group(0) @binding(1) var<storage, read_write> u0: array<f32>;
|
|
1682
|
+
@group(0) @binding(2) var<storage, read_write> v0: array<f32>;
|
|
1683
|
+
@group(0) @binding(3) var<storage, read_write> dr0: array<f32>;
|
|
1684
|
+
@group(0) @binding(4) var<storage, read_write> dg0: array<f32>;
|
|
1685
|
+
@group(0) @binding(5) var<storage, read_write> db0: array<f32>;
|
|
1686
|
+
@compute @workgroup_size(8, 8)
|
|
1687
|
+
fn main(@builtin(global_invocation_id) gid: vec3u) {
|
|
1688
|
+
let i = gid.x;
|
|
1689
|
+
let j = gid.y;
|
|
1690
|
+
if (i >= STRIDE || j >= STRIDE) { return; }
|
|
1691
|
+
let idx = i + STRIDE * j;
|
|
1692
|
+
u0[idx] = 0.0; v0[idx] = 0.0;
|
|
1693
|
+
dr0[idx] = 0.0; dg0[idx] = 0.0; db0[idx] = 0.0;
|
|
1694
|
+
if (i < 1u || i > N || j < 1u || j > N) { return; }
|
|
1695
|
+
let fi = f32(i);
|
|
1696
|
+
let fj = f32(j);
|
|
1697
|
+
for (var e = 0u; e < p.count; e = e + 1u) {
|
|
1698
|
+
let em = p.data[e];
|
|
1699
|
+
let dx = fi - em.pos.x;
|
|
1700
|
+
let dy = fj - em.pos.y;
|
|
1701
|
+
let dist = sqrt(dx * dx + dy * dy);
|
|
1702
|
+
if (dist > p.inject_r) { continue; }
|
|
1703
|
+
let w = 1.0 - dist / p.inject_r;
|
|
1704
|
+
dr0[idx] += em.col.x * p.dye_rate * w;
|
|
1705
|
+
dg0[idx] += em.col.y * p.dye_rate * w;
|
|
1706
|
+
db0[idx] += em.col.z * p.dye_rate * w;
|
|
1707
|
+
u0[idx] += em.pos.z * p.force_rate * w;
|
|
1708
|
+
v0[idx] += em.pos.w * p.force_rate * w;
|
|
1709
|
+
}
|
|
1710
|
+
}`
|
|
1711
|
+
);
|
|
1712
|
+
var RENDER_WGSL = (
|
|
1713
|
+
/* wgsl */
|
|
1714
|
+
`
|
|
1715
|
+
override N: u32;
|
|
1716
|
+
override STRIDE: u32;
|
|
1717
|
+
struct VO { @builtin(position) pos: vec4f, @location(0) uv: vec2f }
|
|
1718
|
+
@vertex fn vs(@builtin(vertex_index) vi: u32) -> VO {
|
|
1719
|
+
var o: VO;
|
|
1720
|
+
let x = f32(i32(vi) / 2) * 4.0 - 1.0;
|
|
1721
|
+
let y = f32(i32(vi) % 2) * 4.0 - 1.0;
|
|
1722
|
+
o.pos = vec4f(x, y, 0.0, 1.0);
|
|
1723
|
+
o.uv = vec2f((x + 1.0) * 0.5, (1.0 - y) * 0.5);
|
|
1724
|
+
return o;
|
|
1725
|
+
}
|
|
1726
|
+
@group(0) @binding(0) var<storage, read> dr: array<f32>;
|
|
1727
|
+
@group(0) @binding(1) var<storage, read> dg: array<f32>;
|
|
1728
|
+
@group(0) @binding(2) var<storage, read> db: array<f32>;
|
|
1729
|
+
@fragment fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {
|
|
1730
|
+
let gx = clamp(uv.x * f32(N) + 0.5, 1.0, f32(N));
|
|
1731
|
+
let gy = clamp(uv.y * f32(N) + 0.5, 1.0, f32(N));
|
|
1732
|
+
let i0 = u32(floor(gx));
|
|
1733
|
+
let j0 = u32(floor(gy));
|
|
1734
|
+
let s1 = gx - f32(i0);
|
|
1735
|
+
let s0 = 1.0 - s1;
|
|
1736
|
+
let t1 = gy - f32(j0);
|
|
1737
|
+
let t0 = 1.0 - t1;
|
|
1738
|
+
let s = STRIDE;
|
|
1739
|
+
let a00 = i0 + s * j0;
|
|
1740
|
+
let a01 = i0 + s * (j0 + 1u);
|
|
1741
|
+
let a10 = (i0 + 1u) + s * j0;
|
|
1742
|
+
let a11 = (i0 + 1u) + s * (j0 + 1u);
|
|
1743
|
+
let r = s0 * (t0 * dr[a00] + t1 * dr[a01]) + s1 * (t0 * dr[a10] + t1 * dr[a11]);
|
|
1744
|
+
let g = s0 * (t0 * dg[a00] + t1 * dg[a01]) + s1 * (t0 * dg[a10] + t1 * dg[a11]);
|
|
1745
|
+
let b = s0 * (t0 * db[a00] + t1 * db[a01]) + s1 * (t0 * db[a10] + t1 * db[a11]);
|
|
1746
|
+
return vec4f(clamp(r / 255.0, 0.0, 1.0), clamp(g / 255.0, 0.0, 1.0),
|
|
1747
|
+
clamp(b / 255.0, 0.0, 1.0), 1.0);
|
|
1748
|
+
}`
|
|
1749
|
+
);
|
|
1750
|
+
var WG1D = Math.ceil(GPU_SZ / 256);
|
|
1751
|
+
var WG2D = Math.ceil(GPU_N / 8);
|
|
1752
|
+
var WG_BND = Math.ceil(GPU_N / 64);
|
|
1753
|
+
var WG_INJ = Math.ceil(GPU_STRIDE / 8);
|
|
1754
|
+
function mkUniform(dev, data) {
|
|
1755
|
+
const size = Math.ceil(Math.max(data.byteLength, 16) / 16) * 16;
|
|
1756
|
+
const buf = dev.createBuffer({
|
|
1757
|
+
size,
|
|
1758
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
1759
|
+
});
|
|
1760
|
+
dev.queue.writeBuffer(buf, 0, data.buffer, data.byteOffset, data.byteLength);
|
|
1761
|
+
return buf;
|
|
1762
|
+
}
|
|
1763
|
+
function mkStorage(dev) {
|
|
1764
|
+
return dev.createBuffer({
|
|
1765
|
+
size: GPU_SZ * 4,
|
|
1766
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
function mkPipeline(dev, code, constants) {
|
|
1770
|
+
return dev.createComputePipeline({
|
|
1771
|
+
layout: "auto",
|
|
1772
|
+
compute: { module: dev.createShaderModule({ code }), constants }
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
var FIELDS = [
|
|
1776
|
+
"u",
|
|
1777
|
+
"v",
|
|
1778
|
+
"dr",
|
|
1779
|
+
"dg",
|
|
1780
|
+
"db",
|
|
1781
|
+
"u0",
|
|
1782
|
+
"v0",
|
|
1783
|
+
"dr0",
|
|
1784
|
+
"dg0",
|
|
1785
|
+
"db0",
|
|
1786
|
+
"sA",
|
|
1787
|
+
"sB",
|
|
1788
|
+
"div",
|
|
1789
|
+
"p"
|
|
1790
|
+
];
|
|
1791
|
+
var FluidGPU = class {
|
|
1792
|
+
device;
|
|
1793
|
+
canvas;
|
|
1794
|
+
gpuCtx;
|
|
1795
|
+
format;
|
|
1796
|
+
dpr;
|
|
1797
|
+
f;
|
|
1798
|
+
copyPL;
|
|
1799
|
+
addSrcPL;
|
|
1800
|
+
scalePL;
|
|
1801
|
+
jacobiPL;
|
|
1802
|
+
bndPL;
|
|
1803
|
+
advectPL;
|
|
1804
|
+
divPL;
|
|
1805
|
+
gradPL;
|
|
1806
|
+
injectPL;
|
|
1807
|
+
renderPL;
|
|
1808
|
+
dtUni;
|
|
1809
|
+
viscUni;
|
|
1810
|
+
diffUni;
|
|
1811
|
+
presUni;
|
|
1812
|
+
densDecUni;
|
|
1813
|
+
velDecUni;
|
|
1814
|
+
zeroUni;
|
|
1815
|
+
bndUni;
|
|
1816
|
+
advUni;
|
|
1817
|
+
emitterUni;
|
|
1818
|
+
emitters;
|
|
1819
|
+
t = 0;
|
|
1820
|
+
w;
|
|
1821
|
+
h;
|
|
1822
|
+
frameId = null;
|
|
1823
|
+
lost = false;
|
|
1824
|
+
constructor(ctx, device) {
|
|
1825
|
+
this.device = device;
|
|
1826
|
+
this.w = ctx.width;
|
|
1827
|
+
this.h = ctx.height;
|
|
1828
|
+
this.dpr = Math.min(ctx.dpr, 2);
|
|
1829
|
+
this.canvas = document.createElement("canvas");
|
|
1830
|
+
this.canvas.style.cssText = "display:block;width:100%;height:100%";
|
|
1831
|
+
this.canvas.setAttribute("aria-hidden", "true");
|
|
1832
|
+
this.canvas.setAttribute("data-fluid-backend", "webgpu");
|
|
1833
|
+
ctx.host.appendChild(this.canvas);
|
|
1834
|
+
this.canvas.width = Math.max(1, Math.round(this.w * this.dpr));
|
|
1835
|
+
this.canvas.height = Math.max(1, Math.round(this.h * this.dpr));
|
|
1836
|
+
this.gpuCtx = this.canvas.getContext("webgpu");
|
|
1837
|
+
this.format = navigator.gpu.getPreferredCanvasFormat();
|
|
1838
|
+
this.gpuCtx.configure({
|
|
1839
|
+
device,
|
|
1840
|
+
format: this.format,
|
|
1841
|
+
alphaMode: "opaque"
|
|
1842
|
+
});
|
|
1843
|
+
this.f = {};
|
|
1844
|
+
for (const n of FIELDS) this.f[n] = mkStorage(device);
|
|
1845
|
+
this.initPipelines();
|
|
1846
|
+
this.initUniforms();
|
|
1847
|
+
this.emitters = buildEmitters(ctx.rng, GPU_N);
|
|
1848
|
+
device.lost.then(() => {
|
|
1849
|
+
this.lost = true;
|
|
1850
|
+
this.stop();
|
|
1851
|
+
});
|
|
1852
|
+
if (ctx.reducedMotion) {
|
|
1853
|
+
this.renderStill();
|
|
1854
|
+
} else {
|
|
1855
|
+
this.start();
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
// --- pipeline creation -----------------------------------------------------
|
|
1859
|
+
initPipelines() {
|
|
1860
|
+
const dev = this.device;
|
|
1861
|
+
const ov1 = { SZ: GPU_SZ };
|
|
1862
|
+
const ov2 = { N: GPU_N, STRIDE: GPU_STRIDE };
|
|
1863
|
+
this.copyPL = mkPipeline(dev, COPY_WGSL, ov1);
|
|
1864
|
+
this.addSrcPL = mkPipeline(dev, ADD_SOURCE_WGSL, ov1);
|
|
1865
|
+
this.scalePL = mkPipeline(dev, SCALE_WGSL, ov1);
|
|
1866
|
+
this.jacobiPL = mkPipeline(dev, JACOBI_WGSL, ov2);
|
|
1867
|
+
this.bndPL = mkPipeline(dev, BOUNDARY_WGSL, ov2);
|
|
1868
|
+
this.advectPL = mkPipeline(dev, ADVECT_WGSL, ov2);
|
|
1869
|
+
this.divPL = mkPipeline(dev, DIVERGENCE_WGSL, ov2);
|
|
1870
|
+
this.gradPL = mkPipeline(dev, GRADIENT_SUB_WGSL, ov2);
|
|
1871
|
+
this.injectPL = mkPipeline(dev, INJECT_WGSL, ov2);
|
|
1872
|
+
const renderMod = dev.createShaderModule({ code: RENDER_WGSL });
|
|
1873
|
+
this.renderPL = dev.createRenderPipeline({
|
|
1874
|
+
layout: "auto",
|
|
1875
|
+
vertex: {
|
|
1876
|
+
module: renderMod,
|
|
1877
|
+
entryPoint: "vs",
|
|
1878
|
+
constants: ov2
|
|
1879
|
+
},
|
|
1880
|
+
fragment: {
|
|
1881
|
+
module: renderMod,
|
|
1882
|
+
entryPoint: "fs",
|
|
1883
|
+
targets: [{ format: this.format }],
|
|
1884
|
+
constants: ov2
|
|
1885
|
+
},
|
|
1886
|
+
primitive: { topology: "triangle-list" }
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
// --- uniform creation ------------------------------------------------------
|
|
1890
|
+
initUniforms() {
|
|
1891
|
+
const dev = this.device;
|
|
1892
|
+
this.dtUni = mkUniform(dev, new Float32Array([DT]));
|
|
1893
|
+
const aDiff = DT * GPU_DIFF * GPU_N * GPU_N;
|
|
1894
|
+
this.diffUni = mkUniform(dev, new Float32Array([aDiff, 1 + 4 * aDiff]));
|
|
1895
|
+
const aVisc = DT * GPU_VISC * GPU_N * GPU_N;
|
|
1896
|
+
this.viscUni = mkUniform(dev, new Float32Array([aVisc, 1 + 4 * aVisc]));
|
|
1897
|
+
this.presUni = mkUniform(dev, new Float32Array([1, 4]));
|
|
1898
|
+
this.densDecUni = mkUniform(dev, new Float32Array([DENS_DECAY]));
|
|
1899
|
+
this.velDecUni = mkUniform(dev, new Float32Array([VEL_DECAY]));
|
|
1900
|
+
this.zeroUni = mkUniform(dev, new Float32Array([0]));
|
|
1901
|
+
this.bndUni = [
|
|
1902
|
+
mkUniform(dev, new Uint32Array([0])),
|
|
1903
|
+
mkUniform(dev, new Uint32Array([1])),
|
|
1904
|
+
mkUniform(dev, new Uint32Array([2]))
|
|
1905
|
+
];
|
|
1906
|
+
this.advUni = mkUniform(dev, new Float32Array([DT * GPU_N]));
|
|
1907
|
+
this.emitterUni = dev.createBuffer({
|
|
1908
|
+
size: 256,
|
|
1909
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
// --- bind-group helper -----------------------------------------------------
|
|
1913
|
+
bg(pl, ...bufs) {
|
|
1914
|
+
return this.device.createBindGroup({
|
|
1915
|
+
layout: pl.getBindGroupLayout(0),
|
|
1916
|
+
entries: bufs.map((buffer, binding) => ({ binding, resource: { buffer } }))
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
// --- encoding helpers (each creates its own compute pass for barriers) -----
|
|
1920
|
+
eCopy(enc, dst, src) {
|
|
1921
|
+
const p = enc.beginComputePass();
|
|
1922
|
+
p.setPipeline(this.copyPL);
|
|
1923
|
+
p.setBindGroup(0, this.bg(this.copyPL, dst, src));
|
|
1924
|
+
p.dispatchWorkgroups(WG1D);
|
|
1925
|
+
p.end();
|
|
1926
|
+
}
|
|
1927
|
+
eAddSrc(enc, dst, src) {
|
|
1928
|
+
const p = enc.beginComputePass();
|
|
1929
|
+
p.setPipeline(this.addSrcPL);
|
|
1930
|
+
p.setBindGroup(0, this.bg(this.addSrcPL, this.dtUni, dst, src));
|
|
1931
|
+
p.dispatchWorkgroups(WG1D);
|
|
1932
|
+
p.end();
|
|
1933
|
+
}
|
|
1934
|
+
eScale(enc, field, uni) {
|
|
1935
|
+
const p = enc.beginComputePass();
|
|
1936
|
+
p.setPipeline(this.scalePL);
|
|
1937
|
+
p.setBindGroup(0, this.bg(this.scalePL, uni, field));
|
|
1938
|
+
p.dispatchWorkgroups(WG1D);
|
|
1939
|
+
p.end();
|
|
1940
|
+
}
|
|
1941
|
+
eJacobi(enc, dst, x0, prev, uni) {
|
|
1942
|
+
const p = enc.beginComputePass();
|
|
1943
|
+
p.setPipeline(this.jacobiPL);
|
|
1944
|
+
p.setBindGroup(0, this.bg(this.jacobiPL, uni, dst, x0, prev));
|
|
1945
|
+
p.dispatchWorkgroups(WG2D, WG2D);
|
|
1946
|
+
p.end();
|
|
1947
|
+
}
|
|
1948
|
+
eBnd(enc, field, b) {
|
|
1949
|
+
const p = enc.beginComputePass();
|
|
1950
|
+
p.setPipeline(this.bndPL);
|
|
1951
|
+
p.setBindGroup(0, this.bg(this.bndPL, this.bndUni[b], field));
|
|
1952
|
+
p.dispatchWorkgroups(WG_BND);
|
|
1953
|
+
p.end();
|
|
1954
|
+
}
|
|
1955
|
+
eAdvect(enc, d, d0, u, v) {
|
|
1956
|
+
const p = enc.beginComputePass();
|
|
1957
|
+
p.setPipeline(this.advectPL);
|
|
1958
|
+
p.setBindGroup(0, this.bg(this.advectPL, this.advUni, d, d0, u, v));
|
|
1959
|
+
p.dispatchWorkgroups(WG2D, WG2D);
|
|
1960
|
+
p.end();
|
|
1961
|
+
}
|
|
1962
|
+
eDiv(enc) {
|
|
1963
|
+
const p = enc.beginComputePass();
|
|
1964
|
+
p.setPipeline(this.divPL);
|
|
1965
|
+
p.setBindGroup(0, this.bg(this.divPL, this.f.div, this.f.u, this.f.v));
|
|
1966
|
+
p.dispatchWorkgroups(WG2D, WG2D);
|
|
1967
|
+
p.end();
|
|
1968
|
+
}
|
|
1969
|
+
eGrad(enc) {
|
|
1970
|
+
const p = enc.beginComputePass();
|
|
1971
|
+
p.setPipeline(this.gradPL);
|
|
1972
|
+
p.setBindGroup(0, this.bg(this.gradPL, this.f.u, this.f.v, this.f.p));
|
|
1973
|
+
p.dispatchWorkgroups(WG2D, WG2D);
|
|
1974
|
+
p.end();
|
|
1975
|
+
}
|
|
1976
|
+
eInject(enc) {
|
|
1977
|
+
const p = enc.beginComputePass();
|
|
1978
|
+
p.setPipeline(this.injectPL);
|
|
1979
|
+
p.setBindGroup(
|
|
1980
|
+
0,
|
|
1981
|
+
this.bg(this.injectPL, this.emitterUni, this.f.u0, this.f.v0, this.f.dr0, this.f.dg0, this.f.db0)
|
|
1982
|
+
);
|
|
1983
|
+
p.dispatchWorkgroups(WG_INJ, WG_INJ);
|
|
1984
|
+
p.end();
|
|
1985
|
+
}
|
|
1986
|
+
// --- composite steps -------------------------------------------------------
|
|
1987
|
+
encodeDiffuse(enc, field, uni, b) {
|
|
1988
|
+
this.eCopy(enc, this.f.sA, field);
|
|
1989
|
+
this.eCopy(enc, this.f.sB, this.f.sA);
|
|
1990
|
+
for (let k = 0; k < JACOBI_DIFF; k++) {
|
|
1991
|
+
if (k % 2 === 0) {
|
|
1992
|
+
this.eJacobi(enc, field, this.f.sA, this.f.sB, uni);
|
|
1993
|
+
} else {
|
|
1994
|
+
this.eJacobi(enc, this.f.sB, this.f.sA, field, uni);
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
if (JACOBI_DIFF % 2 === 0) this.eCopy(enc, field, this.f.sB);
|
|
1998
|
+
this.eBnd(enc, field, b);
|
|
1999
|
+
}
|
|
2000
|
+
encodeProject(enc) {
|
|
2001
|
+
this.eDiv(enc);
|
|
2002
|
+
this.eBnd(enc, this.f.div, 0);
|
|
2003
|
+
this.eScale(enc, this.f.p, this.zeroUni);
|
|
2004
|
+
this.eScale(enc, this.f.sA, this.zeroUni);
|
|
2005
|
+
for (let k = 0; k < JACOBI_PRES; k++) {
|
|
2006
|
+
if (k % 2 === 0) {
|
|
2007
|
+
this.eJacobi(enc, this.f.sA, this.f.div, this.f.p, this.presUni);
|
|
2008
|
+
} else {
|
|
2009
|
+
this.eJacobi(enc, this.f.p, this.f.div, this.f.sA, this.presUni);
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
if (JACOBI_PRES % 2 !== 0) this.eCopy(enc, this.f.p, this.f.sA);
|
|
2013
|
+
this.eBnd(enc, this.f.p, 0);
|
|
2014
|
+
this.eGrad(enc);
|
|
2015
|
+
this.eBnd(enc, this.f.u, 1);
|
|
2016
|
+
this.eBnd(enc, this.f.v, 2);
|
|
2017
|
+
}
|
|
2018
|
+
encodeVelStep(enc) {
|
|
2019
|
+
this.eAddSrc(enc, this.f.u, this.f.u0);
|
|
2020
|
+
this.eAddSrc(enc, this.f.v, this.f.v0);
|
|
2021
|
+
this.encodeDiffuse(enc, this.f.u, this.viscUni, 1);
|
|
2022
|
+
this.encodeDiffuse(enc, this.f.v, this.viscUni, 2);
|
|
2023
|
+
this.encodeProject(enc);
|
|
2024
|
+
this.eCopy(enc, this.f.sA, this.f.u);
|
|
2025
|
+
this.eCopy(enc, this.f.sB, this.f.v);
|
|
2026
|
+
this.eAdvect(enc, this.f.u, this.f.sA, this.f.sA, this.f.sB);
|
|
2027
|
+
this.eAdvect(enc, this.f.v, this.f.sB, this.f.sA, this.f.sB);
|
|
2028
|
+
this.eBnd(enc, this.f.u, 1);
|
|
2029
|
+
this.eBnd(enc, this.f.v, 2);
|
|
2030
|
+
this.encodeProject(enc);
|
|
2031
|
+
this.eScale(enc, this.f.u, this.velDecUni);
|
|
2032
|
+
this.eScale(enc, this.f.v, this.velDecUni);
|
|
2033
|
+
}
|
|
2034
|
+
encodeDensStep(enc, d, d0) {
|
|
2035
|
+
this.eAddSrc(enc, this.f[d], this.f[d0]);
|
|
2036
|
+
this.encodeDiffuse(enc, this.f[d], this.diffUni, 0);
|
|
2037
|
+
this.eCopy(enc, this.f.sA, this.f[d]);
|
|
2038
|
+
this.eAdvect(enc, this.f[d], this.f.sA, this.f.u, this.f.v);
|
|
2039
|
+
this.eBnd(enc, this.f[d], 0);
|
|
2040
|
+
this.eScale(enc, this.f[d], this.densDecUni);
|
|
2041
|
+
}
|
|
2042
|
+
// --- emitter upload --------------------------------------------------------
|
|
2043
|
+
writeEmitters() {
|
|
2044
|
+
const frames = stepEmitters(this.t, this.emitters, GPU_N);
|
|
2045
|
+
const buf = new ArrayBuffer(256);
|
|
2046
|
+
const fv = new Float32Array(buf);
|
|
2047
|
+
const uv = new Uint32Array(buf);
|
|
2048
|
+
fv[0] = GPU_INJECT_R;
|
|
2049
|
+
fv[1] = DYE_RATE;
|
|
2050
|
+
fv[2] = GPU_FORCE_RATE;
|
|
2051
|
+
uv[3] = frames.length;
|
|
2052
|
+
for (let i = 0; i < frames.length; i++) {
|
|
2053
|
+
const off = 4 + i * 8;
|
|
2054
|
+
const fr = frames[i];
|
|
2055
|
+
fv[off] = fr.gx;
|
|
2056
|
+
fv[off + 1] = fr.gy;
|
|
2057
|
+
fv[off + 2] = fr.dx;
|
|
2058
|
+
fv[off + 3] = fr.dy;
|
|
2059
|
+
fv[off + 4] = fr.r;
|
|
2060
|
+
fv[off + 5] = fr.g;
|
|
2061
|
+
fv[off + 6] = fr.b;
|
|
2062
|
+
fv[off + 7] = 0;
|
|
2063
|
+
}
|
|
2064
|
+
this.device.queue.writeBuffer(this.emitterUni, 0, buf);
|
|
2065
|
+
}
|
|
2066
|
+
// --- simulation step -------------------------------------------------------
|
|
2067
|
+
simStep() {
|
|
2068
|
+
this.writeEmitters();
|
|
2069
|
+
const enc = this.device.createCommandEncoder();
|
|
2070
|
+
this.eInject(enc);
|
|
2071
|
+
this.encodeVelStep(enc);
|
|
2072
|
+
this.encodeDensStep(enc, "dr", "dr0");
|
|
2073
|
+
this.encodeDensStep(enc, "dg", "dg0");
|
|
2074
|
+
this.encodeDensStep(enc, "db", "db0");
|
|
2075
|
+
this.device.queue.submit([enc.finish()]);
|
|
2076
|
+
}
|
|
2077
|
+
// --- render ----------------------------------------------------------------
|
|
2078
|
+
render() {
|
|
2079
|
+
if (this.lost) return;
|
|
2080
|
+
const tex = this.gpuCtx.getCurrentTexture();
|
|
2081
|
+
const enc = this.device.createCommandEncoder();
|
|
2082
|
+
const pass = enc.beginRenderPass({
|
|
2083
|
+
colorAttachments: [
|
|
2084
|
+
{
|
|
2085
|
+
view: tex.createView(),
|
|
2086
|
+
loadOp: "clear",
|
|
2087
|
+
storeOp: "store",
|
|
2088
|
+
clearValue: { r: 0, g: 0, b: 0, a: 1 }
|
|
2089
|
+
}
|
|
2090
|
+
]
|
|
2091
|
+
});
|
|
2092
|
+
pass.setPipeline(this.renderPL);
|
|
2093
|
+
pass.setBindGroup(0, this.bg(this.renderPL, this.f.dr, this.f.dg, this.f.db));
|
|
2094
|
+
pass.draw(3);
|
|
2095
|
+
pass.end();
|
|
2096
|
+
this.device.queue.submit([enc.finish()]);
|
|
2097
|
+
}
|
|
2098
|
+
// --- animation loop --------------------------------------------------------
|
|
2099
|
+
start() {
|
|
2100
|
+
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
2101
|
+
this.loop();
|
|
2102
|
+
}
|
|
2103
|
+
stop() {
|
|
2104
|
+
if (this.frameId !== null) {
|
|
2105
|
+
cancelAnimationFrame(this.frameId);
|
|
2106
|
+
this.frameId = null;
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
loop() {
|
|
2110
|
+
this.frameId = requestAnimationFrame(() => this.loop());
|
|
2111
|
+
this.t += DT;
|
|
2112
|
+
this.simStep();
|
|
2113
|
+
this.render();
|
|
2114
|
+
}
|
|
2115
|
+
renderStill() {
|
|
2116
|
+
for (let i = 0; i < 200; i++) {
|
|
2117
|
+
this.t += DT;
|
|
2118
|
+
this.simStep();
|
|
2119
|
+
}
|
|
2120
|
+
this.render();
|
|
2121
|
+
}
|
|
2122
|
+
// --- SaverInstance interface ------------------------------------------------
|
|
2123
|
+
setPaused(paused) {
|
|
2124
|
+
if (paused) this.stop();
|
|
2125
|
+
else this.start();
|
|
2126
|
+
}
|
|
2127
|
+
resize(width, height, dpr) {
|
|
2128
|
+
this.w = width;
|
|
2129
|
+
this.h = height;
|
|
2130
|
+
if (dpr !== void 0) this.dpr = Math.min(dpr, 2);
|
|
2131
|
+
this.canvas.width = Math.max(1, Math.round(this.w * this.dpr));
|
|
2132
|
+
this.canvas.height = Math.max(1, Math.round(this.h * this.dpr));
|
|
2133
|
+
if (!this.lost) {
|
|
2134
|
+
this.gpuCtx.configure({
|
|
2135
|
+
device: this.device,
|
|
2136
|
+
format: this.format,
|
|
2137
|
+
alphaMode: "opaque"
|
|
2138
|
+
});
|
|
2139
|
+
this.render();
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
dispose() {
|
|
2143
|
+
this.stop();
|
|
2144
|
+
for (const b of Object.values(this.f)) b.destroy();
|
|
2145
|
+
this.dtUni.destroy();
|
|
2146
|
+
this.diffUni.destroy();
|
|
2147
|
+
this.viscUni.destroy();
|
|
2148
|
+
this.presUni.destroy();
|
|
2149
|
+
this.densDecUni.destroy();
|
|
2150
|
+
this.velDecUni.destroy();
|
|
2151
|
+
this.zeroUni.destroy();
|
|
2152
|
+
for (const b of this.bndUni) b.destroy();
|
|
2153
|
+
this.advUni.destroy();
|
|
2154
|
+
this.emitterUni.destroy();
|
|
2155
|
+
this.canvas.remove();
|
|
2156
|
+
this.device.destroy();
|
|
2157
|
+
}
|
|
2158
|
+
};
|
|
2159
|
+
|
|
2160
|
+
// src/fluid.ts
|
|
2161
|
+
var fluidManifest = {
|
|
2162
|
+
id: "fluid",
|
|
2163
|
+
label: "Fluid",
|
|
2164
|
+
passthrough: false,
|
|
2165
|
+
minBackend: "canvas2d",
|
|
2166
|
+
costTier: "low",
|
|
2167
|
+
motionIntensity: "calm",
|
|
2168
|
+
reducedMotionFallback: "static",
|
|
2169
|
+
a11y: { flashSafe: true }
|
|
2170
|
+
};
|
|
2171
|
+
var N = 96;
|
|
2172
|
+
var SZ = (N + 2) * (N + 2);
|
|
2173
|
+
var DIFF = 3e-5;
|
|
2174
|
+
var VISC = 3e-4;
|
|
2175
|
+
var GS_ITER = 4;
|
|
2176
|
+
var INJECT_R = 4;
|
|
2177
|
+
function IX(i, j) {
|
|
2178
|
+
return i + (N + 2) * j;
|
|
2179
|
+
}
|
|
2180
|
+
var FluidCPU = class {
|
|
2181
|
+
ctxSaver;
|
|
2182
|
+
canvas;
|
|
2183
|
+
gc;
|
|
2184
|
+
buf;
|
|
2185
|
+
bufCtx;
|
|
2186
|
+
img;
|
|
2187
|
+
w = 0;
|
|
2188
|
+
h = 0;
|
|
2189
|
+
u = new Float32Array(SZ);
|
|
2190
|
+
v = new Float32Array(SZ);
|
|
2191
|
+
u0 = new Float32Array(SZ);
|
|
2192
|
+
v0 = new Float32Array(SZ);
|
|
2193
|
+
dr = new Float32Array(SZ);
|
|
2194
|
+
dg = new Float32Array(SZ);
|
|
2195
|
+
db = new Float32Array(SZ);
|
|
2196
|
+
dr0 = new Float32Array(SZ);
|
|
2197
|
+
dg0 = new Float32Array(SZ);
|
|
2198
|
+
db0 = new Float32Array(SZ);
|
|
2199
|
+
tmp = new Float32Array(SZ);
|
|
2200
|
+
emitters;
|
|
2201
|
+
t = 0;
|
|
2202
|
+
frameId = null;
|
|
2203
|
+
paused = false;
|
|
2204
|
+
constructor(ctx) {
|
|
2205
|
+
this.ctxSaver = ctx;
|
|
2206
|
+
this.w = ctx.width;
|
|
2207
|
+
this.h = ctx.height;
|
|
2208
|
+
let canvas;
|
|
2209
|
+
if (ctx.surface) {
|
|
2210
|
+
canvas = ctx.surface;
|
|
2211
|
+
} else {
|
|
2212
|
+
const el = document.createElement("canvas");
|
|
2213
|
+
el.style.cssText = "display:block;width:100%;height:100%";
|
|
2214
|
+
el.setAttribute("aria-hidden", "true");
|
|
2215
|
+
el.setAttribute("data-fluid-backend", "canvas2d");
|
|
2216
|
+
ctx.host.appendChild(el);
|
|
2217
|
+
canvas = el;
|
|
2218
|
+
}
|
|
2219
|
+
this.canvas = canvas;
|
|
2220
|
+
const gc = canvas.getContext("2d", { alpha: false });
|
|
2221
|
+
if (!gc) throw new Error("fluid: no 2d context");
|
|
2222
|
+
this.gc = gc;
|
|
2223
|
+
this.buf = document.createElement("canvas");
|
|
2224
|
+
this.buf.width = N;
|
|
2225
|
+
this.buf.height = N;
|
|
2226
|
+
this.bufCtx = this.buf.getContext("2d");
|
|
2227
|
+
this.img = new ImageData(N, N);
|
|
2228
|
+
this.emitters = this.buildEmitters(ctx.rng);
|
|
2229
|
+
this.sizeCanvas();
|
|
2230
|
+
this.paused = ctx.reducedMotion;
|
|
2231
|
+
if (this.paused) {
|
|
2232
|
+
this.renderStill();
|
|
2233
|
+
} else {
|
|
2234
|
+
this.start();
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
buildEmitters(rng) {
|
|
2238
|
+
const out = [];
|
|
2239
|
+
for (let i = 0; i < EMITTER_N; i++) {
|
|
2240
|
+
const cx = N / 2 + 1;
|
|
2241
|
+
out.push({
|
|
2242
|
+
hue: (i * 360 / EMITTER_N + rng.range(0, 40)) % 360,
|
|
2243
|
+
fx: rng.range(0.3, 0.8),
|
|
2244
|
+
fy: rng.range(0.3, 0.8),
|
|
2245
|
+
px: rng.range(0, Math.PI * 2),
|
|
2246
|
+
py: rng.range(0, Math.PI * 2),
|
|
2247
|
+
speed: rng.range(0.5, 1),
|
|
2248
|
+
prevGx: cx,
|
|
2249
|
+
prevGy: cx
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2252
|
+
return out;
|
|
2253
|
+
}
|
|
2254
|
+
sizeCanvas() {
|
|
2255
|
+
const dpr = Math.min(this.ctxSaver.dpr, 2);
|
|
2256
|
+
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
2257
|
+
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
2258
|
+
this.gc.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
2259
|
+
}
|
|
2260
|
+
// --- Stam stable-fluids solver ---
|
|
2261
|
+
setBnd(b, x) {
|
|
2262
|
+
for (let i = 1; i <= N; i++) {
|
|
2263
|
+
x[IX(0, i)] = b === 1 ? -x[IX(1, i)] : x[IX(1, i)];
|
|
2264
|
+
x[IX(N + 1, i)] = b === 1 ? -x[IX(N, i)] : x[IX(N, i)];
|
|
2265
|
+
x[IX(i, 0)] = b === 2 ? -x[IX(i, 1)] : x[IX(i, 1)];
|
|
2266
|
+
x[IX(i, N + 1)] = b === 2 ? -x[IX(i, N)] : x[IX(i, N)];
|
|
2267
|
+
}
|
|
2268
|
+
x[IX(0, 0)] = 0.5 * (x[IX(1, 0)] + x[IX(0, 1)]);
|
|
2269
|
+
x[IX(0, N + 1)] = 0.5 * (x[IX(1, N + 1)] + x[IX(0, N)]);
|
|
2270
|
+
x[IX(N + 1, 0)] = 0.5 * (x[IX(N, 0)] + x[IX(N + 1, 1)]);
|
|
2271
|
+
x[IX(N + 1, N + 1)] = 0.5 * (x[IX(N, N + 1)] + x[IX(N + 1, N)]);
|
|
2272
|
+
}
|
|
2273
|
+
diffuse(b, x, x0, diff) {
|
|
2274
|
+
const a = DT * diff * N * N;
|
|
2275
|
+
if (a === 0) {
|
|
2276
|
+
x.set(x0);
|
|
2277
|
+
return;
|
|
2278
|
+
}
|
|
2279
|
+
const denom = 1 + 4 * a;
|
|
2280
|
+
for (let k = 0; k < GS_ITER; k++) {
|
|
2281
|
+
for (let j = 1; j <= N; j++) {
|
|
2282
|
+
for (let i = 1; i <= N; i++) {
|
|
2283
|
+
const idx = IX(i, j);
|
|
2284
|
+
x[idx] = (x0[idx] + a * (x[IX(i - 1, j)] + x[IX(i + 1, j)] + x[IX(i, j - 1)] + x[IX(i, j + 1)])) / denom;
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
this.setBnd(b, x);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
advect(b, d, d0, u, v) {
|
|
2291
|
+
const dt0 = DT * N;
|
|
2292
|
+
for (let j = 1; j <= N; j++) {
|
|
2293
|
+
for (let i = 1; i <= N; i++) {
|
|
2294
|
+
const idx = IX(i, j);
|
|
2295
|
+
let x = i - dt0 * u[idx];
|
|
2296
|
+
let y = j - dt0 * v[idx];
|
|
2297
|
+
if (x < 0.5) x = 0.5;
|
|
2298
|
+
if (x > N + 0.5) x = N + 0.5;
|
|
2299
|
+
if (y < 0.5) y = 0.5;
|
|
2300
|
+
if (y > N + 0.5) y = N + 0.5;
|
|
2301
|
+
const i0 = Math.floor(x);
|
|
2302
|
+
const j0 = Math.floor(y);
|
|
2303
|
+
const s1 = x - i0;
|
|
2304
|
+
const s0 = 1 - s1;
|
|
2305
|
+
const t1 = y - j0;
|
|
2306
|
+
const t0 = 1 - t1;
|
|
2307
|
+
d[idx] = s0 * (t0 * d0[IX(i0, j0)] + t1 * d0[IX(i0, j0 + 1)]) + s1 * (t0 * d0[IX(i0 + 1, j0)] + t1 * d0[IX(i0 + 1, j0 + 1)]);
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
this.setBnd(b, d);
|
|
2311
|
+
}
|
|
2312
|
+
project(u, v, p, div) {
|
|
2313
|
+
const h = 1 / N;
|
|
2314
|
+
for (let j = 1; j <= N; j++) {
|
|
2315
|
+
for (let i = 1; i <= N; i++) {
|
|
2316
|
+
const idx = IX(i, j);
|
|
2317
|
+
div[idx] = -0.5 * h * (u[IX(i + 1, j)] - u[IX(i - 1, j)] + v[IX(i, j + 1)] - v[IX(i, j - 1)]);
|
|
2318
|
+
p[idx] = 0;
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
this.setBnd(0, div);
|
|
2322
|
+
this.setBnd(0, p);
|
|
2323
|
+
for (let k = 0; k < GS_ITER; k++) {
|
|
2324
|
+
for (let j = 1; j <= N; j++) {
|
|
2325
|
+
for (let i = 1; i <= N; i++) {
|
|
2326
|
+
const idx = IX(i, j);
|
|
2327
|
+
p[idx] = (div[idx] + p[IX(i - 1, j)] + p[IX(i + 1, j)] + p[IX(i, j - 1)] + p[IX(i, j + 1)]) / 4;
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
this.setBnd(0, p);
|
|
2331
|
+
}
|
|
2332
|
+
for (let j = 1; j <= N; j++) {
|
|
2333
|
+
for (let i = 1; i <= N; i++) {
|
|
2334
|
+
const idx = IX(i, j);
|
|
2335
|
+
u[idx] -= 0.5 * N * (p[IX(i + 1, j)] - p[IX(i - 1, j)]);
|
|
2336
|
+
v[idx] -= 0.5 * N * (p[IX(i, j + 1)] - p[IX(i, j - 1)]);
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
this.setBnd(1, u);
|
|
2340
|
+
this.setBnd(2, v);
|
|
2341
|
+
}
|
|
2342
|
+
velStep() {
|
|
2343
|
+
for (let i = 0; i < SZ; i++) {
|
|
2344
|
+
this.u[i] += DT * this.u0[i];
|
|
2345
|
+
this.v[i] += DT * this.v0[i];
|
|
2346
|
+
}
|
|
2347
|
+
[this.u, this.u0] = [this.u0, this.u];
|
|
2348
|
+
this.diffuse(1, this.u, this.u0, VISC);
|
|
2349
|
+
[this.v, this.v0] = [this.v0, this.v];
|
|
2350
|
+
this.diffuse(2, this.v, this.v0, VISC);
|
|
2351
|
+
this.project(this.u, this.v, this.u0, this.v0);
|
|
2352
|
+
[this.u, this.u0] = [this.u0, this.u];
|
|
2353
|
+
[this.v, this.v0] = [this.v0, this.v];
|
|
2354
|
+
this.advect(1, this.u, this.u0, this.u0, this.v0);
|
|
2355
|
+
this.advect(2, this.v, this.v0, this.u0, this.v0);
|
|
2356
|
+
this.project(this.u, this.v, this.u0, this.v0);
|
|
2357
|
+
for (let i = 0; i < SZ; i++) {
|
|
2358
|
+
this.u[i] *= VEL_DECAY;
|
|
2359
|
+
this.v[i] *= VEL_DECAY;
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
densStep(d, d0) {
|
|
2363
|
+
for (let i = 0; i < SZ; i++) d[i] += DT * d0[i];
|
|
2364
|
+
this.tmp.set(d);
|
|
2365
|
+
this.diffuse(0, d, this.tmp, DIFF);
|
|
2366
|
+
this.tmp.set(d);
|
|
2367
|
+
this.advect(0, d, this.tmp, this.u, this.v);
|
|
2368
|
+
for (let i = 0; i < SZ; i++) d[i] *= DENS_DECAY;
|
|
2369
|
+
}
|
|
2370
|
+
// --- Source injection ---
|
|
2371
|
+
injectSources() {
|
|
2372
|
+
this.u0.fill(0);
|
|
2373
|
+
this.v0.fill(0);
|
|
2374
|
+
this.dr0.fill(0);
|
|
2375
|
+
this.dg0.fill(0);
|
|
2376
|
+
this.db0.fill(0);
|
|
2377
|
+
for (const e of this.emitters) {
|
|
2378
|
+
const st = this.t * e.speed;
|
|
2379
|
+
const gx = (Math.sin(st * e.fx + e.px) * 0.35 + 0.5) * N + 1;
|
|
2380
|
+
const gy = (Math.cos(st * e.fy + e.py) * 0.35 + 0.5) * N + 1;
|
|
2381
|
+
const dx = gx - e.prevGx;
|
|
2382
|
+
const dy = gy - e.prevGy;
|
|
2383
|
+
const ci = Math.round(gx);
|
|
2384
|
+
const cj = Math.round(gy);
|
|
2385
|
+
const [cr, cg, cb] = hue2rgb(e.hue + this.t * 15);
|
|
2386
|
+
for (let di = -INJECT_R; di <= INJECT_R; di++) {
|
|
2387
|
+
for (let dj = -INJECT_R; dj <= INJECT_R; dj++) {
|
|
2388
|
+
const ii = ci + di;
|
|
2389
|
+
const jj = cj + dj;
|
|
2390
|
+
if (ii < 1 || ii > N || jj < 1 || jj > N) continue;
|
|
2391
|
+
const dist = Math.sqrt(di * di + dj * dj);
|
|
2392
|
+
if (dist > INJECT_R) continue;
|
|
2393
|
+
const s = 1 - dist / INJECT_R;
|
|
2394
|
+
const idx = IX(ii, jj);
|
|
2395
|
+
this.dr0[idx] += cr * DYE_RATE * s;
|
|
2396
|
+
this.dg0[idx] += cg * DYE_RATE * s;
|
|
2397
|
+
this.db0[idx] += cb * DYE_RATE * s;
|
|
2398
|
+
this.u0[idx] += dx * FORCE_RATE * s;
|
|
2399
|
+
this.v0[idx] += dy * FORCE_RATE * s;
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
e.prevGx = gx;
|
|
2403
|
+
e.prevGy = gy;
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
// --- Simulation step ---
|
|
2407
|
+
simStep() {
|
|
2408
|
+
this.injectSources();
|
|
2409
|
+
this.velStep();
|
|
2410
|
+
this.densStep(this.dr, this.dr0);
|
|
2411
|
+
this.densStep(this.dg, this.dg0);
|
|
2412
|
+
this.densStep(this.db, this.db0);
|
|
2413
|
+
}
|
|
2414
|
+
// --- Rendering ---
|
|
2415
|
+
render() {
|
|
2416
|
+
const data = this.img.data;
|
|
2417
|
+
for (let j = 0; j < N; j++) {
|
|
2418
|
+
for (let i = 0; i < N; i++) {
|
|
2419
|
+
const si = IX(i + 1, j + 1);
|
|
2420
|
+
const pi = (j * N + i) * 4;
|
|
2421
|
+
data[pi] = Math.min(255, this.dr[si] | 0);
|
|
2422
|
+
data[pi + 1] = Math.min(255, this.dg[si] | 0);
|
|
2423
|
+
data[pi + 2] = Math.min(255, this.db[si] | 0);
|
|
2424
|
+
data[pi + 3] = 255;
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
this.bufCtx.putImageData(this.img, 0, 0);
|
|
2428
|
+
this.gc.imageSmoothingEnabled = true;
|
|
2429
|
+
this.gc.drawImage(this.buf, 0, 0, this.w, this.h);
|
|
2430
|
+
}
|
|
2431
|
+
// --- Animation ---
|
|
2432
|
+
start() {
|
|
2433
|
+
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
2434
|
+
this.loop();
|
|
2435
|
+
}
|
|
2436
|
+
stop() {
|
|
2437
|
+
if (this.frameId !== null) {
|
|
2438
|
+
cancelAnimationFrame(this.frameId);
|
|
2439
|
+
this.frameId = null;
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
loop() {
|
|
2443
|
+
this.frameId = requestAnimationFrame(() => this.loop());
|
|
2444
|
+
this.t += DT;
|
|
2445
|
+
this.simStep();
|
|
2446
|
+
this.render();
|
|
2447
|
+
}
|
|
2448
|
+
renderStill() {
|
|
2449
|
+
for (let i = 0; i < 200; i++) {
|
|
2450
|
+
this.t += DT;
|
|
2451
|
+
this.simStep();
|
|
2452
|
+
}
|
|
2453
|
+
this.render();
|
|
2454
|
+
}
|
|
2455
|
+
setPaused(paused) {
|
|
2456
|
+
this.paused = paused;
|
|
2457
|
+
if (paused) this.stop();
|
|
2458
|
+
else this.start();
|
|
2459
|
+
}
|
|
2460
|
+
resize(width, height, dpr) {
|
|
2461
|
+
this.w = width;
|
|
2462
|
+
this.h = height;
|
|
2463
|
+
if (dpr !== void 0) this.ctxSaver.dpr = dpr;
|
|
2464
|
+
this.sizeCanvas();
|
|
2465
|
+
this.render();
|
|
2466
|
+
}
|
|
2467
|
+
dispose() {
|
|
2468
|
+
this.stop();
|
|
2469
|
+
if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) this.canvas.remove();
|
|
2470
|
+
}
|
|
2471
|
+
};
|
|
2472
|
+
var fluid = {
|
|
2473
|
+
manifest: fluidManifest,
|
|
2474
|
+
async mount(ctx) {
|
|
2475
|
+
try {
|
|
2476
|
+
const adapter = await navigator.gpu?.requestAdapter();
|
|
2477
|
+
if (adapter) {
|
|
2478
|
+
const device = await adapter.requestDevice();
|
|
2479
|
+
return new FluidGPU(ctx, device);
|
|
2480
|
+
}
|
|
2481
|
+
} catch {
|
|
2482
|
+
}
|
|
2483
|
+
return new FluidCPU(ctx);
|
|
2484
|
+
}
|
|
2485
|
+
};
|
|
2486
|
+
|
|
2487
|
+
// src/reaction-diffusion-shared.ts
|
|
2488
|
+
var RD_DU = 0.16;
|
|
2489
|
+
var RD_DV = 0.08;
|
|
2490
|
+
var RD_F = 0.055;
|
|
2491
|
+
var RD_K = 0.062;
|
|
2492
|
+
var RD_DT = 1;
|
|
2493
|
+
var SEED_R = 5;
|
|
2494
|
+
var SEED_COUNT = 15;
|
|
2495
|
+
var RESEED_INTERVAL = 360;
|
|
2496
|
+
var RESEED_BATCH = 3;
|
|
2497
|
+
function generateSeeds(rng, N3, count) {
|
|
2498
|
+
const seeds = [];
|
|
2499
|
+
for (let i = 0; i < count; i++) {
|
|
2500
|
+
seeds.push({
|
|
2501
|
+
x: rng.int(SEED_R + 1, N3 - SEED_R - 2),
|
|
2502
|
+
y: rng.int(SEED_R + 1, N3 - SEED_R - 2)
|
|
2503
|
+
});
|
|
2504
|
+
}
|
|
2505
|
+
return seeds;
|
|
2506
|
+
}
|
|
2507
|
+
function applySeedsCPU(u, v, N3, seeds, r) {
|
|
2508
|
+
for (const s of seeds) {
|
|
2509
|
+
for (let di = -r; di <= r; di++) {
|
|
2510
|
+
for (let dj = -r; dj <= r; dj++) {
|
|
2511
|
+
if (di * di + dj * dj > r * r) continue;
|
|
2512
|
+
const x = (s.x + di + N3) % N3;
|
|
2513
|
+
const y = (s.y + dj + N3) % N3;
|
|
2514
|
+
const idx = x + y * N3;
|
|
2515
|
+
u[idx] = 0.5;
|
|
2516
|
+
v[idx] = 0.25;
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
var LUT = buildColorLUT();
|
|
2522
|
+
function buildColorLUT() {
|
|
2523
|
+
const lut = new Uint8Array(256 * 3);
|
|
2524
|
+
for (let i = 0; i < 256; i++) {
|
|
2525
|
+
const t = i / 255;
|
|
2526
|
+
let r, g, b;
|
|
2527
|
+
if (t < 0.33) {
|
|
2528
|
+
const s = t / 0.33;
|
|
2529
|
+
r = 10 + s * 3;
|
|
2530
|
+
g = 10 + s * 67;
|
|
2531
|
+
b = 46 + s * 56;
|
|
2532
|
+
} else if (t < 0.66) {
|
|
2533
|
+
const s = (t - 0.33) / 0.33;
|
|
2534
|
+
r = 13 + s * 211;
|
|
2535
|
+
g = 77 + s * 35;
|
|
2536
|
+
b = 102 - s * 38;
|
|
2537
|
+
} else {
|
|
2538
|
+
const s = (t - 0.66) / 0.34;
|
|
2539
|
+
r = 224 + s * 16;
|
|
2540
|
+
g = 112 + s * 97;
|
|
2541
|
+
b = 64 + s * 96;
|
|
2542
|
+
}
|
|
2543
|
+
lut[i * 3] = Math.round(r);
|
|
2544
|
+
lut[i * 3 + 1] = Math.round(g);
|
|
2545
|
+
lut[i * 3 + 2] = Math.round(b);
|
|
2546
|
+
}
|
|
2547
|
+
return lut;
|
|
1533
2548
|
}
|
|
1534
|
-
|
|
1535
|
-
|
|
2549
|
+
function colorV(v) {
|
|
2550
|
+
const i = Math.min(255, Math.max(0, v * 768 | 0));
|
|
2551
|
+
return [LUT[i * 3], LUT[i * 3 + 1], LUT[i * 3 + 2]];
|
|
1536
2552
|
}
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
2553
|
+
|
|
2554
|
+
// src/reaction-diffusion-gpu.ts
|
|
2555
|
+
var GPU_N2 = 512;
|
|
2556
|
+
var GPU_SEED_R = Math.round(SEED_R * (GPU_N2 / 256));
|
|
2557
|
+
var GPU_STEPS = 32;
|
|
2558
|
+
var WG = 8;
|
|
2559
|
+
var SIM_WGSL = (
|
|
2560
|
+
/* wgsl */
|
|
2561
|
+
`
|
|
2562
|
+
override N: u32;
|
|
2563
|
+
|
|
2564
|
+
const Du = ${RD_DU};
|
|
2565
|
+
const Dv = ${RD_DV};
|
|
2566
|
+
const f = ${RD_F};
|
|
2567
|
+
const k = ${RD_K};
|
|
2568
|
+
const dt = ${RD_DT};
|
|
2569
|
+
|
|
2570
|
+
@group(0) @binding(0) var<storage, read> src: array<vec2f>;
|
|
2571
|
+
@group(0) @binding(1) var<storage, read_write> dst: array<vec2f>;
|
|
2572
|
+
|
|
2573
|
+
@compute @workgroup_size(${WG}, ${WG})
|
|
2574
|
+
fn main(@builtin(global_invocation_id) id: vec3u) {
|
|
2575
|
+
let x = id.x;
|
|
2576
|
+
let y = id.y;
|
|
2577
|
+
if (x >= N || y >= N) { return; }
|
|
2578
|
+
|
|
2579
|
+
let idx = x + y * N;
|
|
2580
|
+
let c = src[idx];
|
|
2581
|
+
|
|
2582
|
+
let lx = ((x + N - 1u) % N) + y * N;
|
|
2583
|
+
let rx = ((x + 1u) % N) + y * N;
|
|
2584
|
+
let uy = x + ((y + N - 1u) % N) * N;
|
|
2585
|
+
let dy = x + ((y + 1u) % N) * N;
|
|
2586
|
+
|
|
2587
|
+
let lap = src[lx] + src[rx] + src[uy] + src[dy] - 4.0 * c;
|
|
2588
|
+
|
|
2589
|
+
let uvv = c.x * c.y * c.y;
|
|
2590
|
+
let nu = c.x + dt * (Du * lap.x - uvv + f * (1.0 - c.x));
|
|
2591
|
+
let nv = c.y + dt * (Dv * lap.y + uvv - (f + k) * c.y);
|
|
2592
|
+
|
|
2593
|
+
dst[idx] = clamp(vec2f(nu, nv), vec2f(0.0), vec2f(1.0));
|
|
2594
|
+
}`
|
|
2595
|
+
);
|
|
2596
|
+
var RENDER_WGSL2 = (
|
|
2597
|
+
/* wgsl */
|
|
2598
|
+
`
|
|
2599
|
+
override N: u32;
|
|
2600
|
+
|
|
2601
|
+
@group(0) @binding(0) var<storage, read> field: array<vec2f>;
|
|
2602
|
+
|
|
2603
|
+
struct VOut {
|
|
2604
|
+
@builtin(position) pos: vec4f,
|
|
2605
|
+
@location(0) uv: vec2f,
|
|
1540
2606
|
}
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
2607
|
+
|
|
2608
|
+
@vertex
|
|
2609
|
+
fn vs(@builtin(vertex_index) i: u32) -> VOut {
|
|
2610
|
+
var p = array<vec2f, 3>(vec2f(-1,-1), vec2f(3,-1), vec2f(-1,3));
|
|
2611
|
+
var o: VOut;
|
|
2612
|
+
o.pos = vec4f(p[i], 0, 1);
|
|
2613
|
+
o.uv = (p[i] + 1.0) * 0.5;
|
|
2614
|
+
o.uv.y = 1.0 - o.uv.y;
|
|
2615
|
+
return o;
|
|
1544
2616
|
}
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
2617
|
+
|
|
2618
|
+
@fragment
|
|
2619
|
+
fn fs(v: VOut) -> @location(0) vec4f {
|
|
2620
|
+
let x = min(u32(v.uv.x * f32(N)), N - 1u);
|
|
2621
|
+
let y = min(u32(v.uv.y * f32(N)), N - 1u);
|
|
2622
|
+
let val = field[x + y * N];
|
|
2623
|
+
|
|
2624
|
+
let t = clamp(val.y * 3.0, 0.0, 1.0);
|
|
2625
|
+
|
|
2626
|
+
let c0 = vec3f(0.039, 0.039, 0.180);
|
|
2627
|
+
let c1 = vec3f(0.051, 0.302, 0.400);
|
|
2628
|
+
let c2 = vec3f(0.878, 0.439, 0.251);
|
|
2629
|
+
let c3 = vec3f(0.941, 0.820, 0.627);
|
|
2630
|
+
|
|
2631
|
+
var color: vec3f;
|
|
2632
|
+
if (t < 0.33) {
|
|
2633
|
+
color = mix(c0, c1, t / 0.33);
|
|
2634
|
+
} else if (t < 0.66) {
|
|
2635
|
+
color = mix(c1, c2, (t - 0.33) / 0.33);
|
|
2636
|
+
} else {
|
|
2637
|
+
color = mix(c2, c3, (t - 0.66) / 0.34);
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
return vec4f(color, 1.0);
|
|
2641
|
+
}`
|
|
2642
|
+
);
|
|
2643
|
+
var ReactionDiffusionGPU = class {
|
|
2644
|
+
device;
|
|
2645
|
+
canvas;
|
|
2646
|
+
gpuCtx;
|
|
2647
|
+
format;
|
|
2648
|
+
dpr;
|
|
2649
|
+
w;
|
|
2650
|
+
h;
|
|
2651
|
+
bufA;
|
|
2652
|
+
bufB;
|
|
2653
|
+
simPL;
|
|
2654
|
+
renderPL;
|
|
2655
|
+
simBG_AB;
|
|
2656
|
+
simBG_BA;
|
|
2657
|
+
renderBG_A;
|
|
2658
|
+
renderBG_B;
|
|
2659
|
+
parity = 0;
|
|
2660
|
+
frameId = null;
|
|
2661
|
+
frameCount = 0;
|
|
2662
|
+
lost = false;
|
|
2663
|
+
rng;
|
|
2664
|
+
constructor(ctx, device) {
|
|
2665
|
+
this.device = device;
|
|
2666
|
+
this.w = ctx.width;
|
|
2667
|
+
this.h = ctx.height;
|
|
2668
|
+
this.dpr = Math.min(ctx.dpr, 2);
|
|
2669
|
+
this.rng = ctx.rng;
|
|
2670
|
+
this.canvas = document.createElement("canvas");
|
|
2671
|
+
this.canvas.style.cssText = "display:block;width:100%;height:100%";
|
|
2672
|
+
this.canvas.setAttribute("aria-hidden", "true");
|
|
2673
|
+
this.canvas.setAttribute("data-rd-backend", "webgpu");
|
|
2674
|
+
ctx.host.appendChild(this.canvas);
|
|
2675
|
+
this.sizeCanvas();
|
|
2676
|
+
this.gpuCtx = this.canvas.getContext("webgpu");
|
|
2677
|
+
this.format = navigator.gpu.getPreferredCanvasFormat();
|
|
2678
|
+
this.gpuCtx.configure({ device, format: this.format, alphaMode: "opaque" });
|
|
2679
|
+
const sz = GPU_N2 * GPU_N2 * 8;
|
|
2680
|
+
const usage = GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST;
|
|
2681
|
+
this.bufA = device.createBuffer({ size: sz, usage });
|
|
2682
|
+
this.bufB = device.createBuffer({ size: sz, usage });
|
|
2683
|
+
this.initField();
|
|
2684
|
+
const simLayout = device.createBindGroupLayout({
|
|
2685
|
+
entries: [
|
|
2686
|
+
{ binding: 0, visibility: GPUShaderStage.COMPUTE, buffer: { type: "read-only-storage" } },
|
|
2687
|
+
{ binding: 1, visibility: GPUShaderStage.COMPUTE, buffer: { type: "storage" } }
|
|
2688
|
+
]
|
|
2689
|
+
});
|
|
2690
|
+
const simModule = device.createShaderModule({ code: SIM_WGSL });
|
|
2691
|
+
this.simPL = device.createComputePipeline({
|
|
2692
|
+
layout: device.createPipelineLayout({ bindGroupLayouts: [simLayout] }),
|
|
2693
|
+
compute: { module: simModule, entryPoint: "main", constants: { N: GPU_N2 } }
|
|
2694
|
+
});
|
|
2695
|
+
this.simBG_AB = device.createBindGroup({
|
|
2696
|
+
layout: simLayout,
|
|
2697
|
+
entries: [
|
|
2698
|
+
{ binding: 0, resource: { buffer: this.bufA } },
|
|
2699
|
+
{ binding: 1, resource: { buffer: this.bufB } }
|
|
2700
|
+
]
|
|
2701
|
+
});
|
|
2702
|
+
this.simBG_BA = device.createBindGroup({
|
|
2703
|
+
layout: simLayout,
|
|
2704
|
+
entries: [
|
|
2705
|
+
{ binding: 0, resource: { buffer: this.bufB } },
|
|
2706
|
+
{ binding: 1, resource: { buffer: this.bufA } }
|
|
2707
|
+
]
|
|
2708
|
+
});
|
|
2709
|
+
const renderLayout = device.createBindGroupLayout({
|
|
2710
|
+
entries: [
|
|
2711
|
+
{ binding: 0, visibility: GPUShaderStage.FRAGMENT, buffer: { type: "read-only-storage" } }
|
|
2712
|
+
]
|
|
2713
|
+
});
|
|
2714
|
+
const renderModule = device.createShaderModule({ code: RENDER_WGSL2 });
|
|
2715
|
+
this.renderPL = device.createRenderPipeline({
|
|
2716
|
+
layout: device.createPipelineLayout({ bindGroupLayouts: [renderLayout] }),
|
|
2717
|
+
vertex: { module: renderModule, entryPoint: "vs" },
|
|
2718
|
+
fragment: {
|
|
2719
|
+
module: renderModule,
|
|
2720
|
+
entryPoint: "fs",
|
|
2721
|
+
targets: [{ format: this.format }],
|
|
2722
|
+
constants: { N: GPU_N2 }
|
|
2723
|
+
}
|
|
2724
|
+
});
|
|
2725
|
+
this.renderBG_A = device.createBindGroup({
|
|
2726
|
+
layout: renderLayout,
|
|
2727
|
+
entries: [{ binding: 0, resource: { buffer: this.bufA } }]
|
|
2728
|
+
});
|
|
2729
|
+
this.renderBG_B = device.createBindGroup({
|
|
2730
|
+
layout: renderLayout,
|
|
2731
|
+
entries: [{ binding: 0, resource: { buffer: this.bufB } }]
|
|
2732
|
+
});
|
|
2733
|
+
device.lost.then(() => {
|
|
2734
|
+
this.lost = true;
|
|
2735
|
+
this.stop();
|
|
2736
|
+
});
|
|
2737
|
+
if (ctx.reducedMotion) {
|
|
2738
|
+
this.renderStill();
|
|
2739
|
+
} else {
|
|
2740
|
+
this.start();
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
initField() {
|
|
2744
|
+
const data = new Float32Array(GPU_N2 * GPU_N2 * 2);
|
|
2745
|
+
for (let i = 0; i < GPU_N2 * GPU_N2; i++) {
|
|
2746
|
+
data[i * 2] = 1;
|
|
2747
|
+
data[i * 2 + 1] = 0;
|
|
2748
|
+
}
|
|
2749
|
+
this.seedInto(data, SEED_COUNT);
|
|
2750
|
+
this.device.queue.writeBuffer(this.bufA, 0, data);
|
|
2751
|
+
this.device.queue.writeBuffer(this.bufB, 0, data);
|
|
2752
|
+
this.parity = 0;
|
|
2753
|
+
}
|
|
2754
|
+
seedInto(data, count) {
|
|
2755
|
+
const seeds = generateSeeds(this.rng, GPU_N2, count);
|
|
2756
|
+
for (const s of seeds) {
|
|
2757
|
+
for (let di = -GPU_SEED_R; di <= GPU_SEED_R; di++) {
|
|
2758
|
+
for (let dj = -GPU_SEED_R; dj <= GPU_SEED_R; dj++) {
|
|
2759
|
+
if (di * di + dj * dj > GPU_SEED_R * GPU_SEED_R) continue;
|
|
2760
|
+
const x = (s.x + di + GPU_N2) % GPU_N2;
|
|
2761
|
+
const y = (s.y + dj + GPU_N2) % GPU_N2;
|
|
2762
|
+
const idx = (x + y * GPU_N2) * 2;
|
|
2763
|
+
data[idx] = 0.5;
|
|
2764
|
+
data[idx + 1] = 0.25;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
reseed() {
|
|
2770
|
+
const seeds = generateSeeds(this.rng, GPU_N2, RESEED_BATCH);
|
|
2771
|
+
const buf = this.parity === 0 ? this.bufA : this.bufB;
|
|
2772
|
+
const cell = new Float32Array([0.5, 0.25]);
|
|
2773
|
+
for (const s of seeds) {
|
|
2774
|
+
for (let di = -GPU_SEED_R; di <= GPU_SEED_R; di++) {
|
|
2775
|
+
for (let dj = -GPU_SEED_R; dj <= GPU_SEED_R; dj++) {
|
|
2776
|
+
if (di * di + dj * dj > GPU_SEED_R * GPU_SEED_R) continue;
|
|
2777
|
+
const x = (s.x + di + GPU_N2) % GPU_N2;
|
|
2778
|
+
const y = (s.y + dj + GPU_N2) % GPU_N2;
|
|
2779
|
+
this.device.queue.writeBuffer(buf, (x + y * GPU_N2) * 8, cell);
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
sizeCanvas() {
|
|
2785
|
+
this.canvas.width = Math.max(1, Math.round(this.w * this.dpr));
|
|
2786
|
+
this.canvas.height = Math.max(1, Math.round(this.h * this.dpr));
|
|
2787
|
+
}
|
|
2788
|
+
simStep() {
|
|
2789
|
+
if (this.lost) return;
|
|
2790
|
+
const wgCount = Math.ceil(GPU_N2 / WG);
|
|
2791
|
+
const enc = this.device.createCommandEncoder();
|
|
2792
|
+
for (let i = 0; i < GPU_STEPS; i++) {
|
|
2793
|
+
const bg = this.parity === 0 ? this.simBG_AB : this.simBG_BA;
|
|
2794
|
+
const pass = enc.beginComputePass();
|
|
2795
|
+
pass.setPipeline(this.simPL);
|
|
2796
|
+
pass.setBindGroup(0, bg);
|
|
2797
|
+
pass.dispatchWorkgroups(wgCount, wgCount);
|
|
2798
|
+
pass.end();
|
|
2799
|
+
this.parity ^= 1;
|
|
2800
|
+
}
|
|
2801
|
+
this.device.queue.submit([enc.finish()]);
|
|
2802
|
+
}
|
|
2803
|
+
render() {
|
|
2804
|
+
if (this.lost) return;
|
|
2805
|
+
const tex = this.gpuCtx.getCurrentTexture();
|
|
2806
|
+
const enc = this.device.createCommandEncoder();
|
|
2807
|
+
const pass = enc.beginRenderPass({
|
|
2808
|
+
colorAttachments: [{
|
|
2809
|
+
view: tex.createView(),
|
|
2810
|
+
loadOp: "clear",
|
|
2811
|
+
storeOp: "store",
|
|
2812
|
+
clearValue: { r: 0, g: 0, b: 0, a: 1 }
|
|
2813
|
+
}]
|
|
2814
|
+
});
|
|
2815
|
+
pass.setPipeline(this.renderPL);
|
|
2816
|
+
pass.setBindGroup(0, this.parity === 0 ? this.renderBG_A : this.renderBG_B);
|
|
2817
|
+
pass.draw(3);
|
|
2818
|
+
pass.end();
|
|
2819
|
+
this.device.queue.submit([enc.finish()]);
|
|
2820
|
+
}
|
|
2821
|
+
start() {
|
|
2822
|
+
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
2823
|
+
this.loop();
|
|
2824
|
+
}
|
|
2825
|
+
stop() {
|
|
2826
|
+
if (this.frameId !== null) {
|
|
2827
|
+
cancelAnimationFrame(this.frameId);
|
|
2828
|
+
this.frameId = null;
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
loop() {
|
|
2832
|
+
this.frameId = requestAnimationFrame(() => this.loop());
|
|
2833
|
+
this.frameCount++;
|
|
2834
|
+
if (this.frameCount % RESEED_INTERVAL === 0) this.reseed();
|
|
2835
|
+
this.simStep();
|
|
2836
|
+
this.render();
|
|
2837
|
+
}
|
|
2838
|
+
renderStill() {
|
|
2839
|
+
for (let i = 0; i < 200; i++) {
|
|
2840
|
+
this.simStep();
|
|
2841
|
+
}
|
|
2842
|
+
this.render();
|
|
1562
2843
|
}
|
|
1563
2844
|
setPaused(paused) {
|
|
1564
|
-
this.
|
|
2845
|
+
if (paused) this.stop();
|
|
2846
|
+
else this.start();
|
|
1565
2847
|
}
|
|
1566
|
-
resize(
|
|
2848
|
+
resize(width, height, dpr) {
|
|
2849
|
+
this.w = width;
|
|
2850
|
+
this.h = height;
|
|
2851
|
+
if (dpr !== void 0) this.dpr = Math.min(dpr, 2);
|
|
2852
|
+
this.sizeCanvas();
|
|
2853
|
+
if (!this.lost) {
|
|
2854
|
+
this.gpuCtx.configure({
|
|
2855
|
+
device: this.device,
|
|
2856
|
+
format: this.format,
|
|
2857
|
+
alphaMode: "opaque"
|
|
2858
|
+
});
|
|
2859
|
+
this.render();
|
|
2860
|
+
}
|
|
1567
2861
|
}
|
|
1568
2862
|
dispose() {
|
|
1569
|
-
this.
|
|
1570
|
-
this.
|
|
2863
|
+
this.stop();
|
|
2864
|
+
this.bufA.destroy();
|
|
2865
|
+
this.bufB.destroy();
|
|
2866
|
+
this.canvas.remove();
|
|
2867
|
+
this.device.destroy();
|
|
1571
2868
|
}
|
|
1572
2869
|
};
|
|
1573
|
-
var messages = {
|
|
1574
|
-
manifest: messagesManifest,
|
|
1575
|
-
mount: (ctx) => new MessagesInstance(ctx)
|
|
1576
|
-
};
|
|
1577
2870
|
|
|
1578
|
-
// src/
|
|
1579
|
-
var
|
|
1580
|
-
id: "
|
|
1581
|
-
label: "
|
|
2871
|
+
// src/reaction-diffusion.ts
|
|
2872
|
+
var reactionDiffusionManifest = {
|
|
2873
|
+
id: "reaction-diffusion",
|
|
2874
|
+
label: "Reaction Diffusion",
|
|
1582
2875
|
passthrough: false,
|
|
1583
|
-
minBackend: "
|
|
1584
|
-
costTier: "
|
|
2876
|
+
minBackend: "canvas2d",
|
|
2877
|
+
costTier: "low",
|
|
1585
2878
|
motionIntensity: "calm",
|
|
1586
2879
|
reducedMotionFallback: "static",
|
|
1587
|
-
a11y: { flashSafe: true
|
|
2880
|
+
a11y: { flashSafe: true }
|
|
1588
2881
|
};
|
|
1589
|
-
var
|
|
1590
|
-
var
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
.
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
2882
|
+
var N2 = 256;
|
|
2883
|
+
var STEPS = 32;
|
|
2884
|
+
var ReactionDiffusionCPU = class {
|
|
2885
|
+
ctxSaver;
|
|
2886
|
+
canvas;
|
|
2887
|
+
gc;
|
|
2888
|
+
buf;
|
|
2889
|
+
bufCtx;
|
|
2890
|
+
img;
|
|
2891
|
+
w;
|
|
2892
|
+
h;
|
|
2893
|
+
u = new Float32Array(N2 * N2);
|
|
2894
|
+
v = new Float32Array(N2 * N2);
|
|
2895
|
+
uN = new Float32Array(N2 * N2);
|
|
2896
|
+
vN = new Float32Array(N2 * N2);
|
|
2897
|
+
rng;
|
|
2898
|
+
frameId = null;
|
|
2899
|
+
frameCount = 0;
|
|
2900
|
+
constructor(ctx) {
|
|
2901
|
+
this.ctxSaver = ctx;
|
|
2902
|
+
this.w = ctx.width;
|
|
2903
|
+
this.h = ctx.height;
|
|
2904
|
+
this.rng = ctx.rng;
|
|
2905
|
+
let canvas;
|
|
2906
|
+
if (ctx.surface) {
|
|
2907
|
+
canvas = ctx.surface;
|
|
2908
|
+
} else {
|
|
2909
|
+
const el = document.createElement("canvas");
|
|
2910
|
+
el.style.cssText = "display:block;width:100%;height:100%";
|
|
2911
|
+
el.setAttribute("aria-hidden", "true");
|
|
2912
|
+
el.setAttribute("data-rd-backend", "canvas2d");
|
|
2913
|
+
ctx.host.appendChild(el);
|
|
2914
|
+
canvas = el;
|
|
2915
|
+
}
|
|
2916
|
+
this.canvas = canvas;
|
|
2917
|
+
const gc = canvas.getContext("2d", { alpha: false });
|
|
2918
|
+
if (!gc) throw new Error("reaction-diffusion: no 2d context");
|
|
2919
|
+
this.gc = gc;
|
|
2920
|
+
this.buf = document.createElement("canvas");
|
|
2921
|
+
this.buf.width = N2;
|
|
2922
|
+
this.buf.height = N2;
|
|
2923
|
+
this.bufCtx = this.buf.getContext("2d");
|
|
2924
|
+
this.img = new ImageData(N2, N2);
|
|
2925
|
+
this.u.fill(1);
|
|
2926
|
+
applySeedsCPU(this.u, this.v, N2, generateSeeds(this.rng, N2, SEED_COUNT), SEED_R);
|
|
2927
|
+
this.sizeCanvas();
|
|
2928
|
+
if (ctx.reducedMotion) {
|
|
2929
|
+
this.renderStill();
|
|
2930
|
+
} else {
|
|
2931
|
+
this.start();
|
|
2932
|
+
}
|
|
1618
2933
|
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
2934
|
+
sizeCanvas() {
|
|
2935
|
+
const dpr = Math.min(this.ctxSaver.dpr, 2);
|
|
2936
|
+
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
2937
|
+
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
2938
|
+
this.gc.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
2939
|
+
}
|
|
2940
|
+
simStep() {
|
|
2941
|
+
const { u, v, uN, vN } = this;
|
|
2942
|
+
for (let y = 0; y < N2; y++) {
|
|
2943
|
+
for (let x = 0; x < N2; x++) {
|
|
2944
|
+
const idx = x + y * N2;
|
|
2945
|
+
const lx = (x - 1 + N2) % N2 + y * N2;
|
|
2946
|
+
const rx = (x + 1) % N2 + y * N2;
|
|
2947
|
+
const uy = x + (y - 1 + N2) % N2 * N2;
|
|
2948
|
+
const dy = x + (y + 1) % N2 * N2;
|
|
2949
|
+
const lapU = u[lx] + u[rx] + u[uy] + u[dy] - 4 * u[idx];
|
|
2950
|
+
const lapV = v[lx] + v[rx] + v[uy] + v[dy] - 4 * v[idx];
|
|
2951
|
+
const uvv = u[idx] * v[idx] * v[idx];
|
|
2952
|
+
uN[idx] = Math.max(0, Math.min(
|
|
2953
|
+
1,
|
|
2954
|
+
u[idx] + RD_DT * (RD_DU * lapU - uvv + RD_F * (1 - u[idx]))
|
|
2955
|
+
));
|
|
2956
|
+
vN[idx] = Math.max(0, Math.min(
|
|
2957
|
+
1,
|
|
2958
|
+
v[idx] + RD_DT * (RD_DV * lapV + uvv - (RD_F + RD_K) * v[idx])
|
|
2959
|
+
));
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
[this.u, this.uN] = [this.uN, this.u];
|
|
2963
|
+
[this.v, this.vN] = [this.vN, this.v];
|
|
1622
2964
|
}
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
2965
|
+
render() {
|
|
2966
|
+
const data = this.img.data;
|
|
2967
|
+
for (let i = 0; i < N2 * N2; i++) {
|
|
2968
|
+
const [r, g, b] = colorV(this.v[i]);
|
|
2969
|
+
const pi = i * 4;
|
|
2970
|
+
data[pi] = r;
|
|
2971
|
+
data[pi + 1] = g;
|
|
2972
|
+
data[pi + 2] = b;
|
|
2973
|
+
data[pi + 3] = 255;
|
|
2974
|
+
}
|
|
2975
|
+
this.bufCtx.putImageData(this.img, 0, 0);
|
|
2976
|
+
this.gc.imageSmoothingEnabled = true;
|
|
2977
|
+
this.gc.drawImage(this.buf, 0, 0, this.w, this.h);
|
|
1626
2978
|
}
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
@media screen and (min-width: 600px) {
|
|
1631
|
-
@keyframes is-messages2-moveX {
|
|
1632
|
-
from { left: 0; }
|
|
1633
|
-
to { left: calc(100% - 467px); }
|
|
2979
|
+
start() {
|
|
2980
|
+
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
2981
|
+
this.loop();
|
|
1634
2982
|
}
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
2983
|
+
stop() {
|
|
2984
|
+
if (this.frameId !== null) {
|
|
2985
|
+
cancelAnimationFrame(this.frameId);
|
|
2986
|
+
this.frameId = null;
|
|
2987
|
+
}
|
|
1638
2988
|
}
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
this.
|
|
2989
|
+
loop() {
|
|
2990
|
+
this.frameId = requestAnimationFrame(() => this.loop());
|
|
2991
|
+
this.frameCount++;
|
|
2992
|
+
if (this.frameCount % RESEED_INTERVAL === 0) {
|
|
2993
|
+
applySeedsCPU(
|
|
2994
|
+
this.u,
|
|
2995
|
+
this.v,
|
|
2996
|
+
N2,
|
|
2997
|
+
generateSeeds(this.rng, N2, RESEED_BATCH),
|
|
2998
|
+
SEED_R
|
|
2999
|
+
);
|
|
3000
|
+
}
|
|
3001
|
+
for (let i = 0; i < STEPS; i++) this.simStep();
|
|
3002
|
+
this.render();
|
|
3003
|
+
}
|
|
3004
|
+
renderStill() {
|
|
3005
|
+
for (let i = 0; i < 200; i++) this.simStep();
|
|
3006
|
+
this.render();
|
|
1657
3007
|
}
|
|
1658
3008
|
setPaused(paused) {
|
|
1659
|
-
this.
|
|
3009
|
+
if (paused) this.stop();
|
|
3010
|
+
else this.start();
|
|
1660
3011
|
}
|
|
1661
|
-
resize(
|
|
3012
|
+
resize(width, height, dpr) {
|
|
3013
|
+
this.w = width;
|
|
3014
|
+
this.h = height;
|
|
3015
|
+
if (dpr !== void 0) this.ctxSaver.dpr = dpr;
|
|
3016
|
+
this.sizeCanvas();
|
|
3017
|
+
this.render();
|
|
1662
3018
|
}
|
|
1663
3019
|
dispose() {
|
|
1664
|
-
this.
|
|
1665
|
-
this.
|
|
3020
|
+
this.stop();
|
|
3021
|
+
if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) this.canvas.remove();
|
|
1666
3022
|
}
|
|
1667
3023
|
};
|
|
1668
|
-
var
|
|
1669
|
-
manifest:
|
|
1670
|
-
mount
|
|
3024
|
+
var reactionDiffusion = {
|
|
3025
|
+
manifest: reactionDiffusionManifest,
|
|
3026
|
+
async mount(ctx) {
|
|
3027
|
+
try {
|
|
3028
|
+
const adapter = await navigator.gpu?.requestAdapter();
|
|
3029
|
+
if (adapter) {
|
|
3030
|
+
const device = await adapter.requestDevice();
|
|
3031
|
+
return new ReactionDiffusionGPU(ctx, device);
|
|
3032
|
+
}
|
|
3033
|
+
} catch {
|
|
3034
|
+
}
|
|
3035
|
+
return new ReactionDiffusionCPU(ctx);
|
|
3036
|
+
}
|
|
1671
3037
|
};
|
|
1672
3038
|
|
|
1673
3039
|
// src/index.ts
|
|
@@ -1684,20 +3050,30 @@ var CLASSIC_SAVERS = [
|
|
|
1684
3050
|
bouncingBall,
|
|
1685
3051
|
logo,
|
|
1686
3052
|
messages,
|
|
1687
|
-
messages2
|
|
3053
|
+
messages2,
|
|
3054
|
+
pipes,
|
|
3055
|
+
bsod,
|
|
3056
|
+
flurry,
|
|
3057
|
+
fluid,
|
|
3058
|
+
reactionDiffusion
|
|
1688
3059
|
];
|
|
1689
3060
|
export {
|
|
1690
3061
|
CLASSIC_SAVERS,
|
|
1691
3062
|
bouncingBall,
|
|
3063
|
+
bsod,
|
|
1692
3064
|
dvd,
|
|
1693
3065
|
fadeOut,
|
|
1694
3066
|
fish,
|
|
3067
|
+
fluid,
|
|
3068
|
+
flurry,
|
|
1695
3069
|
globe,
|
|
1696
3070
|
hardRain,
|
|
1697
3071
|
logo,
|
|
1698
3072
|
messages,
|
|
1699
3073
|
messages2,
|
|
3074
|
+
pipes,
|
|
1700
3075
|
rainstorm,
|
|
3076
|
+
reactionDiffusion,
|
|
1701
3077
|
spotlight,
|
|
1702
3078
|
toasters,
|
|
1703
3079
|
warp
|