@idle-screens/savers-classic 2.0.1 → 3.1.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-MIVXP2IL.js → chunk-PU6BQ5S3.js} +1172 -240
- package/dist/chunk-PU6BQ5S3.js.map +1 -0
- package/dist/idle-worker.js +416 -273
- package/dist/idle-worker.js.map +1 -1
- package/dist/index.d.ts +26 -11
- package/dist/index.js +254 -463
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-MIVXP2IL.js.map +0 -1
|
@@ -1,4 +1,367 @@
|
|
|
1
|
+
// src/dvd.ts
|
|
2
|
+
import {
|
|
3
|
+
sampleTrack,
|
|
4
|
+
defaultParams
|
|
5
|
+
} from "@idle-screens/core";
|
|
6
|
+
var MARKS = ["dvd", "idle-screens", "diamond", "ring"];
|
|
7
|
+
var PARAM_SPACE = {
|
|
8
|
+
/** Which shape bounces. 'dvd' = the classic wordmark-in-a-pill. */
|
|
9
|
+
mark: { type: "enum", default: "dvd", options: [...MARKS] },
|
|
10
|
+
/** Multiplies both axis speeds (and therefore the wall-hit rate). */
|
|
11
|
+
speed: { type: "number", default: 1, min: 0.25, max: 3, ease: "smooth" },
|
|
12
|
+
/** Multiplies the mark's box size. */
|
|
13
|
+
scale: { type: "number", default: 1, min: 0.5, max: 2, ease: "smooth" },
|
|
14
|
+
/** Base hue (0-360); each wall hit steps it deterministically from here. */
|
|
15
|
+
hue: { type: "number", default: 110, min: 0, max: 360, ease: "smooth" },
|
|
16
|
+
/** Phosphor glow around the mark. */
|
|
17
|
+
glow: { type: "number", default: 0.25, min: 0, max: 1, ease: "smooth" },
|
|
18
|
+
/** Burst intensity when both axes hit a wall at once (a corner hit). */
|
|
19
|
+
cornerParty: { type: "number", default: 0.6, min: 0, max: 1, ease: "smooth" }
|
|
20
|
+
};
|
|
21
|
+
var dvdManifest = {
|
|
22
|
+
id: "dvd",
|
|
23
|
+
label: "Bouncing Logo",
|
|
24
|
+
passthrough: false,
|
|
25
|
+
minBackend: "canvas2d",
|
|
26
|
+
costTier: "low",
|
|
27
|
+
motionIntensity: "calm",
|
|
28
|
+
reducedMotionFallback: "static",
|
|
29
|
+
paramSpace: PARAM_SPACE,
|
|
30
|
+
a11y: {
|
|
31
|
+
flashSafe: true,
|
|
32
|
+
notes: "Hue steps once per wall hit and a brief corner burst on exact corner hits; no strobing."
|
|
33
|
+
},
|
|
34
|
+
attribution: {
|
|
35
|
+
source: "DVD player idle screen + After Dark logo bounce \u2014 concepts. The DVD-Video logo is a trademark of DVD FLLC",
|
|
36
|
+
license: "MIT, original implementation; logo drawn from scratch as nostalgic homage (the bouncing-DVD meme) \u2014 no third-party assets"
|
|
37
|
+
},
|
|
38
|
+
workerReady: true
|
|
39
|
+
};
|
|
40
|
+
var BASE_SPEED_X = 144;
|
|
41
|
+
var BASE_SPEED_Y = 120;
|
|
42
|
+
var BASE_MARK_W = 200;
|
|
43
|
+
var BASE_MARK_H = 84;
|
|
44
|
+
var HUE_STEP_DEG = 47;
|
|
45
|
+
var CORNER_BURST_MS = 220;
|
|
46
|
+
var clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
|
47
|
+
function tri(t, p) {
|
|
48
|
+
const cycle = p * 2;
|
|
49
|
+
const k = (t % cycle + cycle) % cycle;
|
|
50
|
+
return k < p ? k / p : 2 - k / p;
|
|
51
|
+
}
|
|
52
|
+
function hitCount(t, p) {
|
|
53
|
+
return Math.floor(Math.max(0, t) / p);
|
|
54
|
+
}
|
|
55
|
+
function distToNearestHit(t, p) {
|
|
56
|
+
const r = (t % p + p) % p;
|
|
57
|
+
return Math.min(r, p - r);
|
|
58
|
+
}
|
|
59
|
+
var DvdInstance = class {
|
|
60
|
+
ctxSaver;
|
|
61
|
+
canvas;
|
|
62
|
+
c2d;
|
|
63
|
+
w = 0;
|
|
64
|
+
h = 0;
|
|
65
|
+
frameId = null;
|
|
66
|
+
paused = false;
|
|
67
|
+
startT = 0;
|
|
68
|
+
/** Logical time the next rAF origin resumes from.
|
|
69
|
+
*
|
|
70
|
+
* `start()` re-anchors `startT` to the next frame's timestamp, so on its own
|
|
71
|
+
* `now - startT` always begins at zero. Mount wants that; resuming from a
|
|
72
|
+
* pause does not — without carrying the frozen `t` forward, every
|
|
73
|
+
* pause/resume (and every reduced-motion toggle) snaps the scene back to its
|
|
74
|
+
* opening frame and restarts any applied control track. Set only in
|
|
75
|
+
* `setPaused(false)`, so first mount still starts at 0. */
|
|
76
|
+
resumeFrom = 0;
|
|
77
|
+
t = 0;
|
|
78
|
+
params = defaultParams(PARAM_SPACE);
|
|
79
|
+
track = null;
|
|
80
|
+
constructor(ctx) {
|
|
81
|
+
this.ctxSaver = ctx;
|
|
82
|
+
if (ctx.surface) {
|
|
83
|
+
this.canvas = ctx.surface;
|
|
84
|
+
} else {
|
|
85
|
+
const el = document.createElement("canvas");
|
|
86
|
+
el.style.cssText = "display:block;width:100%;height:100%;background:#04050a";
|
|
87
|
+
ctx.host.appendChild(el);
|
|
88
|
+
this.canvas = el;
|
|
89
|
+
}
|
|
90
|
+
const c2d = this.canvas.getContext("2d", { alpha: false });
|
|
91
|
+
if (!c2d) throw new Error("dvd: no 2d context");
|
|
92
|
+
this.c2d = c2d;
|
|
93
|
+
this.w = ctx.width;
|
|
94
|
+
this.h = ctx.height;
|
|
95
|
+
this.sizeCanvas();
|
|
96
|
+
this.paused = ctx.reducedMotion;
|
|
97
|
+
if (this.paused) this.renderStill();
|
|
98
|
+
else this.start();
|
|
99
|
+
}
|
|
100
|
+
// ---- params ----
|
|
101
|
+
applyParams(t) {
|
|
102
|
+
const p = this.track ? sampleTrack(PARAM_SPACE, this.track, t) : this.params;
|
|
103
|
+
for (const k of Object.keys(PARAM_SPACE)) {
|
|
104
|
+
const v = p[k];
|
|
105
|
+
if (v !== void 0) this.params[k] = v;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
sizeCanvas() {
|
|
109
|
+
const dpr = Math.min(this.ctxSaver.dpr, 2);
|
|
110
|
+
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
111
|
+
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
112
|
+
this.c2d.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
113
|
+
}
|
|
114
|
+
// ---- closed-form geometry ----
|
|
115
|
+
markSize() {
|
|
116
|
+
const s = this.params.scale;
|
|
117
|
+
return {
|
|
118
|
+
markW: clamp(BASE_MARK_W * s, 60, this.w * 0.7),
|
|
119
|
+
markH: clamp(BASE_MARK_H * s, 26, this.h * 0.7)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** One-way traversal periods (ms) for each axis at the current box size
|
|
123
|
+
* and speed. Pure function of (w, h, markW, markH, speed). */
|
|
124
|
+
periods(markW, markH) {
|
|
125
|
+
const distX = Math.max(1, this.w - markW);
|
|
126
|
+
const distY = Math.max(1, this.h - markH);
|
|
127
|
+
const speedX = BASE_SPEED_X * Math.max(0.05, this.params.speed);
|
|
128
|
+
const speedY = BASE_SPEED_Y * Math.max(0.05, this.params.speed);
|
|
129
|
+
return { px: distX / speedX * 1e3, py: distY / speedY * 1e3 };
|
|
130
|
+
}
|
|
131
|
+
// ---- loop ----
|
|
132
|
+
start() {
|
|
133
|
+
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
134
|
+
this.startT = 0;
|
|
135
|
+
this.frameId = requestAnimationFrame((now) => this.loop(now));
|
|
136
|
+
}
|
|
137
|
+
stop() {
|
|
138
|
+
if (this.frameId !== null) {
|
|
139
|
+
cancelAnimationFrame(this.frameId);
|
|
140
|
+
this.frameId = null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
loop(now) {
|
|
144
|
+
this.frameId = requestAnimationFrame((n) => this.loop(n));
|
|
145
|
+
if (this.startT === 0) this.startT = now;
|
|
146
|
+
this.renderFrame(now - this.startT + this.resumeFrom, this.ctxSaver.seed);
|
|
147
|
+
}
|
|
148
|
+
renderStill() {
|
|
149
|
+
this.renderFrame(this.t, this.ctxSaver.seed);
|
|
150
|
+
}
|
|
151
|
+
// ---- draw ----
|
|
152
|
+
/** Rounded-rect path built from `arc` + `lineTo` only (no `quadraticCurveTo`/
|
|
153
|
+
* `roundRect`, to stay inside the minimal Canvas2D surface classic savers
|
|
154
|
+
* rely on). */
|
|
155
|
+
roundRectPath(c, x, y, w, h, r) {
|
|
156
|
+
const rr = Math.max(0, Math.min(r, w / 2, h / 2));
|
|
157
|
+
c.beginPath();
|
|
158
|
+
c.moveTo(x + rr, y);
|
|
159
|
+
c.lineTo(x + w - rr, y);
|
|
160
|
+
c.arc(x + w - rr, y + rr, rr, -Math.PI / 2, 0);
|
|
161
|
+
c.lineTo(x + w, y + h - rr);
|
|
162
|
+
c.arc(x + w - rr, y + h - rr, rr, 0, Math.PI / 2);
|
|
163
|
+
c.lineTo(x + rr, y + h);
|
|
164
|
+
c.arc(x + rr, y + h - rr, rr, Math.PI / 2, Math.PI);
|
|
165
|
+
c.lineTo(x, y + rr);
|
|
166
|
+
c.arc(x + rr, y + rr, rr, Math.PI, Math.PI * 1.5);
|
|
167
|
+
c.closePath();
|
|
168
|
+
}
|
|
169
|
+
/** The classic mark, as the meme remembers it: heavy italic "DVD" letters
|
|
170
|
+
* over the wide disc ellipse with its centre hole. Drawn entirely from
|
|
171
|
+
* text + ellipse paths — no imported asset. The DVD-Video logo shape is a
|
|
172
|
+
* trademark of the DVD Format/Logo Licensing Corp; it appears here as the
|
|
173
|
+
* nostalgic bouncing-logo homage (see CREDITS.md). */
|
|
174
|
+
drawDvd(c, x, y, w, h, color) {
|
|
175
|
+
c.save();
|
|
176
|
+
c.fillStyle = color;
|
|
177
|
+
c.font = `italic 900 ${Math.round(h * 0.66)}px "Arial Black", Arial, sans-serif`;
|
|
178
|
+
c.textAlign = "center";
|
|
179
|
+
c.textBaseline = "middle";
|
|
180
|
+
c.fillText("DVD", x + w / 2, y + h * 0.32);
|
|
181
|
+
c.restore();
|
|
182
|
+
const cx = x + w / 2;
|
|
183
|
+
const cy = y + h * 0.8;
|
|
184
|
+
c.fillStyle = color;
|
|
185
|
+
c.beginPath();
|
|
186
|
+
c.ellipse(cx, cy, w * 0.5, h * 0.155, 0, 0, Math.PI * 2);
|
|
187
|
+
c.fill();
|
|
188
|
+
c.fillStyle = "#04050a";
|
|
189
|
+
c.beginPath();
|
|
190
|
+
c.ellipse(cx, cy, w * 0.115, h * 0.052, 0, 0, Math.PI * 2);
|
|
191
|
+
c.fill();
|
|
192
|
+
}
|
|
193
|
+
drawWordmark(c, x, y, w, h, color) {
|
|
194
|
+
c.fillStyle = color;
|
|
195
|
+
c.textAlign = "center";
|
|
196
|
+
c.textBaseline = "middle";
|
|
197
|
+
c.font = `700 ${Math.round(h * 0.32)}px ui-rounded, "Avenir Next", system-ui, sans-serif`;
|
|
198
|
+
c.fillText("idle-screens", x + w / 2, y + h / 2);
|
|
199
|
+
}
|
|
200
|
+
drawDiamond(c, x, y, w, h, color) {
|
|
201
|
+
const cx = x + w / 2;
|
|
202
|
+
const cy = y + h / 2;
|
|
203
|
+
const s = Math.min(w, h) * 0.62;
|
|
204
|
+
c.save();
|
|
205
|
+
c.translate(cx, cy);
|
|
206
|
+
c.rotate(Math.PI / 4);
|
|
207
|
+
c.fillStyle = color;
|
|
208
|
+
c.fillRect(-s / 2, -s / 2, s, s);
|
|
209
|
+
c.restore();
|
|
210
|
+
}
|
|
211
|
+
drawRing(c, x, y, w, h, color) {
|
|
212
|
+
const cx = x + w / 2;
|
|
213
|
+
const cy = y + h / 2;
|
|
214
|
+
const r = Math.min(w, h) * 0.4;
|
|
215
|
+
c.beginPath();
|
|
216
|
+
c.arc(cx, cy, r, 0, Math.PI * 2);
|
|
217
|
+
c.strokeStyle = color;
|
|
218
|
+
c.lineWidth = Math.max(4, r * 0.34);
|
|
219
|
+
c.stroke();
|
|
220
|
+
}
|
|
221
|
+
drawMark(mark, c, x, y, w, h, color) {
|
|
222
|
+
switch (mark) {
|
|
223
|
+
case "idle-screens":
|
|
224
|
+
this.drawWordmark(c, x, y, w, h, color);
|
|
225
|
+
break;
|
|
226
|
+
case "diamond":
|
|
227
|
+
this.drawDiamond(c, x, y, w, h, color);
|
|
228
|
+
break;
|
|
229
|
+
case "ring":
|
|
230
|
+
this.drawRing(c, x, y, w, h, color);
|
|
231
|
+
break;
|
|
232
|
+
case "dvd":
|
|
233
|
+
default:
|
|
234
|
+
this.drawDvd(c, x, y, w, h, color);
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/** A tiny sparkle burst — the "corner party" — purely a function of how
|
|
239
|
+
* close both axes are to hitting simultaneously right now. */
|
|
240
|
+
drawBurst(c, cx, cy, intensity, hue) {
|
|
241
|
+
const rays = 8;
|
|
242
|
+
const radius = 10 + 46 * intensity;
|
|
243
|
+
c.save();
|
|
244
|
+
c.globalCompositeOperation = "lighter";
|
|
245
|
+
for (let i = 0; i < rays; i++) {
|
|
246
|
+
const a = i / rays * Math.PI * 2;
|
|
247
|
+
c.strokeStyle = `hsla(${hue.toFixed(1)}, 92%, 72%, ${(0.85 * intensity).toFixed(3)})`;
|
|
248
|
+
c.lineWidth = 1.5 + 3 * intensity;
|
|
249
|
+
c.beginPath();
|
|
250
|
+
c.moveTo(cx, cy);
|
|
251
|
+
c.lineTo(cx + Math.cos(a) * radius, cy + Math.sin(a) * radius);
|
|
252
|
+
c.stroke();
|
|
253
|
+
}
|
|
254
|
+
c.restore();
|
|
255
|
+
}
|
|
256
|
+
/** Pure render at logical time `t` for `seed`: everything below is a closed
|
|
257
|
+
* -form function of (t, seed, this.w, this.h, this.params) — nothing is
|
|
258
|
+
* read from or written to accumulated instance state. */
|
|
259
|
+
render(t, seed) {
|
|
260
|
+
const c = this.c2d;
|
|
261
|
+
c.fillStyle = "#04050a";
|
|
262
|
+
c.fillRect(0, 0, this.w, this.h);
|
|
263
|
+
const { markW, markH } = this.markSize();
|
|
264
|
+
const { px, py } = this.periods(markW, markH);
|
|
265
|
+
const shifted = t + Math.abs(seed) * 233 % 5e3;
|
|
266
|
+
const x = tri(shifted, px) * Math.max(0, this.w - markW);
|
|
267
|
+
const y = tri(shifted, py) * Math.max(0, this.h - markH);
|
|
268
|
+
const hits = hitCount(shifted, px) + hitCount(shifted, py);
|
|
269
|
+
const hue = ((this.params.hue + hits * HUE_STEP_DEG) % 360 + 360) % 360;
|
|
270
|
+
const color = `hsl(${hue.toFixed(1)}, 78%, 56%)`;
|
|
271
|
+
if (this.params.glow > 0.02) {
|
|
272
|
+
c.shadowColor = color;
|
|
273
|
+
c.shadowBlur = 26 * this.params.glow;
|
|
274
|
+
} else {
|
|
275
|
+
c.shadowBlur = 0;
|
|
276
|
+
}
|
|
277
|
+
this.drawMark(this.params.mark, c, x, y, markW, markH, color);
|
|
278
|
+
c.shadowBlur = 0;
|
|
279
|
+
const ax = Math.max(0, 1 - distToNearestHit(shifted, px) / CORNER_BURST_MS);
|
|
280
|
+
const ay = Math.max(0, 1 - distToNearestHit(shifted, py) / CORNER_BURST_MS);
|
|
281
|
+
const cornerIntensity = this.params.cornerParty * ax * ax * ay * ay;
|
|
282
|
+
if (cornerIntensity > 2e-3) {
|
|
283
|
+
this.drawBurst(c, x + markW / 2, y + markH / 2, cornerIntensity, hue);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
// ---- SaverInstance ----
|
|
287
|
+
setPaused(paused) {
|
|
288
|
+
this.paused = paused;
|
|
289
|
+
if (paused) {
|
|
290
|
+
this.stop();
|
|
291
|
+
this.renderStill();
|
|
292
|
+
} else {
|
|
293
|
+
this.resumeFrom = this.t;
|
|
294
|
+
this.start();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
resize(width, height, dpr) {
|
|
298
|
+
this.w = width;
|
|
299
|
+
this.h = height;
|
|
300
|
+
if (dpr !== void 0) this.ctxSaver.dpr = dpr;
|
|
301
|
+
this.sizeCanvas();
|
|
302
|
+
if (this.paused) this.renderStill();
|
|
303
|
+
}
|
|
304
|
+
applyTrack(track) {
|
|
305
|
+
this.track = track;
|
|
306
|
+
if (this.paused) this.renderStill();
|
|
307
|
+
}
|
|
308
|
+
/** Pure, frame-addressable render: draw the state at logical time `t` for `seed`. */
|
|
309
|
+
renderFrame(t, seed) {
|
|
310
|
+
this.t = t;
|
|
311
|
+
this.applyParams(t);
|
|
312
|
+
this.render(t, seed);
|
|
313
|
+
}
|
|
314
|
+
dispose() {
|
|
315
|
+
this.stop();
|
|
316
|
+
if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) {
|
|
317
|
+
this.canvas.remove();
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
var dvd = {
|
|
322
|
+
manifest: dvdManifest,
|
|
323
|
+
mount: (ctx) => new DvdInstance(ctx)
|
|
324
|
+
};
|
|
325
|
+
var dvdDemoTrack = {
|
|
326
|
+
program: "dvd",
|
|
327
|
+
seed: 7,
|
|
328
|
+
duration: 16e3,
|
|
329
|
+
loop: true,
|
|
330
|
+
deltas: [
|
|
331
|
+
// The DVD logo IS the act; the other marks get a quick tour at the end.
|
|
332
|
+
{ t: 0, path: "mark", value: "dvd" },
|
|
333
|
+
{ t: 1e4, path: "mark", value: "diamond" },
|
|
334
|
+
{ t: 12e3, path: "mark", value: "ring" },
|
|
335
|
+
{ t: 14e3, path: "mark", value: "idle-screens" },
|
|
336
|
+
{ t: 0, path: "hue", value: 110 },
|
|
337
|
+
{ t: 8e3, path: "hue", value: 280, ease: "smooth" },
|
|
338
|
+
{ t: 16e3, path: "hue", value: 110, ease: "smooth" },
|
|
339
|
+
{ t: 0, path: "speed", value: 0.8 },
|
|
340
|
+
{ t: 8e3, path: "speed", value: 1.7, ease: "smooth" },
|
|
341
|
+
{ t: 16e3, path: "speed", value: 0.8, ease: "smooth" }
|
|
342
|
+
]
|
|
343
|
+
};
|
|
344
|
+
|
|
1
345
|
// src/warp.ts
|
|
346
|
+
import {
|
|
347
|
+
sampleTrack as sampleTrack2,
|
|
348
|
+
defaultParams as defaultParams2
|
|
349
|
+
} from "@idle-screens/core";
|
|
350
|
+
var PARAM_SPACE2 = {
|
|
351
|
+
/** Star count basis. Read only at build time — rebuilding the field live
|
|
352
|
+
* would reshuffle star identity and break renderFrame purity, so steer
|
|
353
|
+
* the other knobs to change the feel while live; density only takes
|
|
354
|
+
* effect on (re)mount. */
|
|
355
|
+
density: { type: "number", default: 520, min: 120, max: 1400 },
|
|
356
|
+
speed: { type: "number", default: 1, min: 0.25, max: 3, ease: "smooth" },
|
|
357
|
+
/** Star color. '#ffffff' is the classic white starfield. */
|
|
358
|
+
tint: { type: "color", default: "#ffffff" },
|
|
359
|
+
/** Elongation of the per-star motion streak. */
|
|
360
|
+
streak: { type: "number", default: 0.4, min: 0, max: 1, ease: "smooth" },
|
|
361
|
+
/** Subtle per-star brightness shimmer. No strobe: each star's shimmer
|
|
362
|
+
* period is fixed at build (800-1800ms), well under any flash threshold. */
|
|
363
|
+
twinkle: { type: "number", default: 0.3, min: 0, max: 1, ease: "smooth" }
|
|
364
|
+
};
|
|
2
365
|
var warpManifest = {
|
|
3
366
|
id: "warp",
|
|
4
367
|
label: "Warp",
|
|
@@ -7,11 +370,31 @@ var warpManifest = {
|
|
|
7
370
|
costTier: "low",
|
|
8
371
|
motionIntensity: "energetic",
|
|
9
372
|
reducedMotionFallback: "static",
|
|
10
|
-
|
|
373
|
+
paramSpace: PARAM_SPACE2,
|
|
374
|
+
a11y: { flashSafe: true, notes: "Streaming star field; brightness shimmer is subtle and >=800ms per cycle." },
|
|
11
375
|
workerReady: true
|
|
12
376
|
};
|
|
13
|
-
var
|
|
14
|
-
var
|
|
377
|
+
var BASE_RATE = 727e-6;
|
|
378
|
+
var frac = (x) => x - Math.floor(x);
|
|
379
|
+
function smoothstep01(x) {
|
|
380
|
+
const c = Math.max(0, Math.min(1, x));
|
|
381
|
+
return c * c * (3 - 2 * c);
|
|
382
|
+
}
|
|
383
|
+
var FADE_IN_END = 0.15;
|
|
384
|
+
var FADE_OUT_START = 0.94;
|
|
385
|
+
function fadeEnvelope(p) {
|
|
386
|
+
let e = 1;
|
|
387
|
+
if (p < FADE_IN_END) e *= smoothstep01(p / FADE_IN_END);
|
|
388
|
+
if (p > FADE_OUT_START) e *= smoothstep01((1 - p) / (1 - FADE_OUT_START));
|
|
389
|
+
return e;
|
|
390
|
+
}
|
|
391
|
+
function hexToRgb(hex) {
|
|
392
|
+
const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
393
|
+
if (!m) return [255, 255, 255];
|
|
394
|
+
const h = m[1].length === 3 ? m[1].split("").map((c) => c + c).join("") : m[1];
|
|
395
|
+
const n = parseInt(h, 16);
|
|
396
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
397
|
+
}
|
|
15
398
|
var WarpInstance = class {
|
|
16
399
|
ctxSaver;
|
|
17
400
|
canvas;
|
|
@@ -21,6 +404,19 @@ var WarpInstance = class {
|
|
|
21
404
|
stars = [];
|
|
22
405
|
frameId = null;
|
|
23
406
|
paused = false;
|
|
407
|
+
startT = 0;
|
|
408
|
+
/** Logical time the next rAF origin resumes from.
|
|
409
|
+
*
|
|
410
|
+
* `start()` re-anchors `startT` to the next frame's timestamp, so on its own
|
|
411
|
+
* `now - startT` always begins at zero. Mount wants that; resuming from a
|
|
412
|
+
* pause does not — without carrying the frozen `t` forward, every
|
|
413
|
+
* pause/resume (and every reduced-motion toggle) snaps the scene back to its
|
|
414
|
+
* opening frame and restarts any applied control track. Set only in
|
|
415
|
+
* `setPaused(false)`, so first mount still starts at 0. */
|
|
416
|
+
resumeFrom = 0;
|
|
417
|
+
t = 0;
|
|
418
|
+
params = defaultParams2(PARAM_SPACE2);
|
|
419
|
+
track = null;
|
|
24
420
|
constructor(ctx) {
|
|
25
421
|
this.ctxSaver = ctx;
|
|
26
422
|
let canvas;
|
|
@@ -45,31 +441,43 @@ var WarpInstance = class {
|
|
|
45
441
|
if (this.paused) this.renderStill();
|
|
46
442
|
else this.start();
|
|
47
443
|
}
|
|
444
|
+
// ---- params ----
|
|
445
|
+
applyParams(t) {
|
|
446
|
+
const p = this.track ? sampleTrack2(PARAM_SPACE2, this.track, t) : this.params;
|
|
447
|
+
for (const k of Object.keys(PARAM_SPACE2)) {
|
|
448
|
+
const v = p[k];
|
|
449
|
+
if (v !== void 0) this.params[k] = v;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
48
452
|
sizeCanvas() {
|
|
49
453
|
const dpr = Math.min(this.ctxSaver.dpr, 2);
|
|
50
454
|
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
51
455
|
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
52
456
|
this.ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
53
457
|
}
|
|
458
|
+
/** Build the star field's fixed identity from forked streams. Deterministic
|
|
459
|
+
* regardless of how much of `ctx.rng` other code has consumed, and safe
|
|
460
|
+
* to call again (e.g. a future density change on remount) without
|
|
461
|
+
* reshuffling existing star identities. */
|
|
54
462
|
buildStars() {
|
|
55
|
-
const
|
|
56
|
-
this.stars = new Array(
|
|
57
|
-
for (let i = 0; i <
|
|
58
|
-
|
|
463
|
+
const count = Math.max(1, Math.round(this.params.density));
|
|
464
|
+
this.stars = new Array(count);
|
|
465
|
+
for (let i = 0; i < count; i++) {
|
|
466
|
+
const r = this.ctxSaver.rng.fork(i);
|
|
467
|
+
this.stars[i] = {
|
|
468
|
+
x: r.range(-1, 1),
|
|
469
|
+
y: r.range(-1, 1),
|
|
470
|
+
phase: r.next(),
|
|
471
|
+
twinklePhase: r.range(0, Math.PI * 2),
|
|
472
|
+
twinklePeriod: r.range(800, 1800)
|
|
473
|
+
};
|
|
59
474
|
}
|
|
60
475
|
}
|
|
61
|
-
|
|
62
|
-
const rng = this.ctxSaver.rng;
|
|
63
|
-
return {
|
|
64
|
-
x: rng.range(-1, 1),
|
|
65
|
-
y: rng.range(-1, 1),
|
|
66
|
-
z,
|
|
67
|
-
pz: z
|
|
68
|
-
};
|
|
69
|
-
}
|
|
476
|
+
// ---- loop ----
|
|
70
477
|
start() {
|
|
71
478
|
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
72
|
-
this.
|
|
479
|
+
this.startT = 0;
|
|
480
|
+
this.frameId = requestAnimationFrame((now) => this.loop(now));
|
|
73
481
|
}
|
|
74
482
|
stop() {
|
|
75
483
|
if (this.frameId !== null) {
|
|
@@ -77,44 +485,54 @@ var WarpInstance = class {
|
|
|
77
485
|
this.frameId = null;
|
|
78
486
|
}
|
|
79
487
|
}
|
|
80
|
-
loop() {
|
|
81
|
-
this.frameId = requestAnimationFrame(() => this.loop());
|
|
82
|
-
this.
|
|
83
|
-
this.
|
|
488
|
+
loop(now) {
|
|
489
|
+
this.frameId = requestAnimationFrame((n) => this.loop(n));
|
|
490
|
+
if (this.startT === 0) this.startT = now;
|
|
491
|
+
this.renderFrame(now - this.startT + this.resumeFrom, this.ctxSaver.seed);
|
|
84
492
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
s.pz = s.z;
|
|
88
|
-
s.z -= SPEED;
|
|
89
|
-
if (s.z <= 0.01) {
|
|
90
|
-
const respawned = this.spawn(1);
|
|
91
|
-
s.x = respawned.x;
|
|
92
|
-
s.y = respawned.y;
|
|
93
|
-
s.z = 1;
|
|
94
|
-
s.pz = 1;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
493
|
+
renderStill() {
|
|
494
|
+
this.renderFrame(this.t, this.ctxSaver.seed);
|
|
97
495
|
}
|
|
98
|
-
|
|
496
|
+
// ---- closed-form travel + draw ----
|
|
497
|
+
/** A star's travel progress at time `t`: 0 = just spawned (near center,
|
|
498
|
+
* dim), approaches 1 as it nears the eye and is about to recycle. Pure
|
|
499
|
+
* function of `t` and the star's fixed phase — no accumulation. */
|
|
500
|
+
progress(star, t, rate) {
|
|
501
|
+
return frac(star.phase + t * rate);
|
|
502
|
+
}
|
|
503
|
+
render(t) {
|
|
99
504
|
const ctx = this.ctx;
|
|
100
505
|
const w = this.w;
|
|
101
506
|
const h = this.h;
|
|
102
507
|
const cx = w / 2;
|
|
103
508
|
const cy = h / 2;
|
|
104
509
|
const focal = Math.min(w, h) * 0.9;
|
|
510
|
+
const p = this.params;
|
|
511
|
+
const rate = BASE_RATE * p.speed;
|
|
512
|
+
const [tr, tg, tb] = hexToRgb(p.tint);
|
|
513
|
+
const streakDt = 16 * (1 + p.streak * 5);
|
|
105
514
|
ctx.fillStyle = "rgba(17,17,17,0.45)";
|
|
106
515
|
ctx.fillRect(0, 0, w, h);
|
|
107
516
|
ctx.lineCap = "round";
|
|
108
517
|
for (const s of this.stars) {
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
|
|
518
|
+
const prog = this.progress(s, t, rate);
|
|
519
|
+
const z = 1 - prog * 0.99;
|
|
520
|
+
const sx = cx + s.x / z * focal;
|
|
521
|
+
const sy = cy + s.y / z * focal;
|
|
522
|
+
let progPrev = this.progress(s, t - streakDt, rate);
|
|
523
|
+
if (progPrev > prog) progPrev = prog;
|
|
524
|
+
const zPrev = 1 - progPrev * 0.99;
|
|
525
|
+
const px = cx + s.x / zPrev * focal;
|
|
526
|
+
const py = cy + s.y / zPrev * focal;
|
|
527
|
+
const headOut = sx < -50 || sx > w + 50 || sy < -50 || sy > h + 50;
|
|
528
|
+
const tailOut = px < -50 || px > w + 50 || py < -50 || py > h + 50;
|
|
529
|
+
if (headOut && tailOut) continue;
|
|
530
|
+
const envelope = fadeEnvelope(prog);
|
|
531
|
+
const shimmer = 1 + p.twinkle * 0.4 * Math.sin(2 * Math.PI * t / s.twinklePeriod + s.twinklePhase);
|
|
532
|
+
const alpha = Math.max(0, Math.min(1, (0.15 + prog * 1.1) * envelope * shimmer));
|
|
533
|
+
if (alpha <= 2e-3) continue;
|
|
534
|
+
const size = Math.max(0.4, prog * 2.6);
|
|
535
|
+
ctx.strokeStyle = `rgba(${tr},${tg},${tb},${alpha.toFixed(3)})`;
|
|
118
536
|
ctx.lineWidth = size;
|
|
119
537
|
ctx.beginPath();
|
|
120
538
|
ctx.moveTo(px, py);
|
|
@@ -122,32 +540,14 @@ var WarpInstance = class {
|
|
|
122
540
|
ctx.stroke();
|
|
123
541
|
}
|
|
124
542
|
}
|
|
125
|
-
|
|
126
|
-
const ctx = this.ctx;
|
|
127
|
-
ctx.fillStyle = "#111";
|
|
128
|
-
ctx.fillRect(0, 0, this.w, this.h);
|
|
129
|
-
const cx = this.w / 2;
|
|
130
|
-
const cy = this.h / 2;
|
|
131
|
-
const focal = Math.min(this.w, this.h) * 0.9;
|
|
132
|
-
for (const s of this.stars) {
|
|
133
|
-
const sx = cx + s.x / s.z * focal;
|
|
134
|
-
const sy = cy + s.y / s.z * focal;
|
|
135
|
-
if (sx < 0 || sx > this.w || sy < 0 || sy > this.h) continue;
|
|
136
|
-
const depth = 1 - s.z;
|
|
137
|
-
const alpha = Math.min(1, 0.15 + depth * 1.1);
|
|
138
|
-
const size = Math.max(0.4, depth * 2.6);
|
|
139
|
-
ctx.fillStyle = `rgba(220,235,255,${alpha.toFixed(3)})`;
|
|
140
|
-
ctx.beginPath();
|
|
141
|
-
ctx.arc(sx, sy, size, 0, Math.PI * 2);
|
|
142
|
-
ctx.fill();
|
|
143
|
-
}
|
|
144
|
-
}
|
|
543
|
+
// ---- SaverInstance ----
|
|
145
544
|
setPaused(paused) {
|
|
146
545
|
this.paused = paused;
|
|
147
546
|
if (paused) {
|
|
148
547
|
this.stop();
|
|
149
548
|
this.renderStill();
|
|
150
549
|
} else {
|
|
550
|
+
this.resumeFrom = this.t;
|
|
151
551
|
this.start();
|
|
152
552
|
}
|
|
153
553
|
}
|
|
@@ -158,6 +558,18 @@ var WarpInstance = class {
|
|
|
158
558
|
this.sizeCanvas();
|
|
159
559
|
if (this.paused) this.renderStill();
|
|
160
560
|
}
|
|
561
|
+
applyTrack(track) {
|
|
562
|
+
this.track = track;
|
|
563
|
+
if (this.paused) this.renderStill();
|
|
564
|
+
}
|
|
565
|
+
/** Pure, frame-addressable render: draw the state at logical time `t` for
|
|
566
|
+
* `seed`. Identical (t, seed, applied track) always produces the same
|
|
567
|
+
* frame — safe to seek forward or backward. */
|
|
568
|
+
renderFrame(t, _seed) {
|
|
569
|
+
this.t = t;
|
|
570
|
+
this.applyParams(t);
|
|
571
|
+
this.render(t);
|
|
572
|
+
}
|
|
161
573
|
dispose() {
|
|
162
574
|
this.stop();
|
|
163
575
|
if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) this.canvas.remove();
|
|
@@ -167,6 +579,25 @@ var warp = {
|
|
|
167
579
|
manifest: warpManifest,
|
|
168
580
|
mount: (ctx) => new WarpInstance(ctx)
|
|
169
581
|
};
|
|
582
|
+
var warpDemoTrack = {
|
|
583
|
+
program: "warp",
|
|
584
|
+
seed: 7,
|
|
585
|
+
duration: 14e3,
|
|
586
|
+
loop: true,
|
|
587
|
+
deltas: [
|
|
588
|
+
{ t: 0, path: "speed", value: 0.6 },
|
|
589
|
+
{ t: 5e3, path: "speed", value: 2.4, ease: "smooth" },
|
|
590
|
+
{ t: 9e3, path: "speed", value: 0.6, ease: "smooth" },
|
|
591
|
+
{ t: 14e3, path: "speed", value: 0.6 },
|
|
592
|
+
{ t: 0, path: "streak", value: 0.15 },
|
|
593
|
+
{ t: 5e3, path: "streak", value: 0.9, ease: "smooth" },
|
|
594
|
+
{ t: 9e3, path: "streak", value: 0.15, ease: "smooth" },
|
|
595
|
+
{ t: 14e3, path: "streak", value: 0.15 },
|
|
596
|
+
{ t: 0, path: "tint", value: "#ffffff" },
|
|
597
|
+
{ t: 7e3, path: "tint", value: "#8fd8ff", ease: "smooth" },
|
|
598
|
+
{ t: 14e3, path: "tint", value: "#ffffff", ease: "smooth" }
|
|
599
|
+
]
|
|
600
|
+
};
|
|
170
601
|
|
|
171
602
|
// src/hard-rain.ts
|
|
172
603
|
var hardRainManifest = {
|
|
@@ -177,6 +608,11 @@ var hardRainManifest = {
|
|
|
177
608
|
costTier: "low",
|
|
178
609
|
motionIntensity: "moderate",
|
|
179
610
|
reducedMotionFallback: "static",
|
|
611
|
+
attribution: {
|
|
612
|
+
source: 'After Dark "Hard Rain" \u2014 concept by Berkeley Systems',
|
|
613
|
+
license: "MIT port; reference CSS MIT (Bryan Braun)",
|
|
614
|
+
url: "https://github.com/bryanbraun/after-dark-css"
|
|
615
|
+
},
|
|
180
616
|
a11y: { flashSafe: true, notes: "Slow-expanding coloured rings on black; no flashing." },
|
|
181
617
|
workerReady: true
|
|
182
618
|
};
|
|
@@ -321,7 +757,7 @@ var DROP_SPECS = [
|
|
|
321
757
|
"t1 p5-4 s250 yellow",
|
|
322
758
|
"t24 p5-5 s200 ltgray"
|
|
323
759
|
];
|
|
324
|
-
function
|
|
760
|
+
function hexToRgb2(hex) {
|
|
325
761
|
const n = parseInt(hex.slice(1), 16);
|
|
326
762
|
return `${n >> 16 & 255},${n >> 8 & 255},${n & 255}`;
|
|
327
763
|
}
|
|
@@ -368,7 +804,7 @@ var HardRainInstance = class {
|
|
|
368
804
|
fx: pos[0],
|
|
369
805
|
fy: pos[1],
|
|
370
806
|
maxR: SIZES[sCls] ?? 100,
|
|
371
|
-
rgb:
|
|
807
|
+
rgb: hexToRgb2(COLOURS[cCls] ?? "#c2c2c2"),
|
|
372
808
|
phase: timingPhase(tCls)
|
|
373
809
|
};
|
|
374
810
|
});
|
|
@@ -463,6 +899,11 @@ var rainstormManifest = {
|
|
|
463
899
|
costTier: "low",
|
|
464
900
|
motionIntensity: "moderate",
|
|
465
901
|
reducedMotionFallback: "static",
|
|
902
|
+
attribution: {
|
|
903
|
+
source: 'After Dark "Rainstorm" \u2014 concept by Berkeley Systems',
|
|
904
|
+
license: "MIT port; reference CSS MIT (Bryan Braun)",
|
|
905
|
+
url: "https://github.com/bryanbraun/after-dark-css"
|
|
906
|
+
},
|
|
466
907
|
a11y: { flashSafe: true, notes: "Rain streaks over a dark sky; the lightning is a brief, gentle brightening (no rapid strobe)." },
|
|
467
908
|
workerReady: true
|
|
468
909
|
};
|
|
@@ -631,6 +1072,35 @@ var rainstorm = {
|
|
|
631
1072
|
};
|
|
632
1073
|
|
|
633
1074
|
// src/globe.ts
|
|
1075
|
+
import {
|
|
1076
|
+
sampleTrack as sampleTrack3,
|
|
1077
|
+
defaultParams as defaultParams3
|
|
1078
|
+
} from "@idle-screens/core";
|
|
1079
|
+
var RADIUS = 120;
|
|
1080
|
+
var SPIN_BASE = 0.9;
|
|
1081
|
+
var BOUNCE_SPEED = 90;
|
|
1082
|
+
var SEG_LAT = 24;
|
|
1083
|
+
var SEG_LON = 48;
|
|
1084
|
+
var LINE_W_DEVICE = 0.85;
|
|
1085
|
+
var TAU = Math.PI * 2;
|
|
1086
|
+
var PARAM_SPACE3 = {
|
|
1087
|
+
/** Meridian count (longitude lines); parallel count is derived proportionally
|
|
1088
|
+
* (11 parallels : 21 meridians, the original's ratio). Read once at mount —
|
|
1089
|
+
* the lattice is built at construction time and does not respond to a
|
|
1090
|
+
* control-track delta, same convention as `bubbleCount` in saver-tide. */
|
|
1091
|
+
density: { type: "number", default: 21, min: 8, max: 42 },
|
|
1092
|
+
/** Rotation-rate multiplier on the preserved 0.9 rad/s base. */
|
|
1093
|
+
spin: { type: "number", default: 1, min: 0.25, max: 3, ease: "smooth" },
|
|
1094
|
+
/** DVD-bounce amplitude. 1 = the original's full corner-to-corner bounce;
|
|
1095
|
+
* 0 = the globe floats motionless at viewport center. */
|
|
1096
|
+
bounce: { type: "number", default: 1, min: 0, max: 1, ease: "smooth" },
|
|
1097
|
+
/** Wireframe stroke color. */
|
|
1098
|
+
wire: { type: "color", default: "#78c8ff" },
|
|
1099
|
+
/** Soft additive glow on the globe's limb. */
|
|
1100
|
+
glow: { type: "number", default: 0.35, min: 0, max: 1, ease: "smooth" },
|
|
1101
|
+
/** How much the far (back) hemisphere dims relative to the near hemisphere. */
|
|
1102
|
+
depthFade: { type: "number", default: 0.8, min: 0, max: 1, ease: "smooth" }
|
|
1103
|
+
};
|
|
634
1104
|
var globeManifest = {
|
|
635
1105
|
id: "globe",
|
|
636
1106
|
label: "Globe",
|
|
@@ -639,32 +1109,59 @@ var globeManifest = {
|
|
|
639
1109
|
costTier: "low",
|
|
640
1110
|
motionIntensity: "calm",
|
|
641
1111
|
reducedMotionFallback: "static",
|
|
642
|
-
|
|
1112
|
+
paramSpace: PARAM_SPACE3,
|
|
1113
|
+
attribution: {
|
|
1114
|
+
source: 'After Dark "Globe" \u2014 concept by Berkeley Systems',
|
|
1115
|
+
license: "MIT port; reference CSS MIT (Bryan Braun)",
|
|
1116
|
+
url: "https://github.com/bryanbraun/after-dark-css"
|
|
1117
|
+
},
|
|
1118
|
+
a11y: { flashSafe: true, notes: "A slowly spinning wireframe globe drifting on black; no flashing." },
|
|
643
1119
|
workerReady: true
|
|
644
1120
|
};
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
1121
|
+
function reflect(pos, size) {
|
|
1122
|
+
const period = size * 2;
|
|
1123
|
+
const k = (pos % period + period) % period;
|
|
1124
|
+
return k <= size ? k : period - k;
|
|
1125
|
+
}
|
|
1126
|
+
function lerp(a, b, p) {
|
|
1127
|
+
return a + (b - a) * p;
|
|
1128
|
+
}
|
|
1129
|
+
function parseHex(c) {
|
|
1130
|
+
const m = /^#?([0-9a-f]{6})$/i.exec(c.trim());
|
|
1131
|
+
if (!m) return [120, 200, 255];
|
|
1132
|
+
const n = parseInt(m[1], 16);
|
|
1133
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1134
|
+
}
|
|
1135
|
+
var rgba = (r, g, b, a) => `rgba(${r.toFixed(0)},${g.toFixed(0)},${b.toFixed(0)},${Math.max(0, Math.min(1, a)).toFixed(3)})`;
|
|
1136
|
+
function depthAlpha(depth, depthFade) {
|
|
1137
|
+
const front = 0.82;
|
|
1138
|
+
const backMin = 0.04;
|
|
1139
|
+
const back = front - depthFade * (front - backMin);
|
|
1140
|
+
return back + (front - back) * depth;
|
|
1141
|
+
}
|
|
649
1142
|
var GlobeInstance = class {
|
|
650
|
-
|
|
1143
|
+
ctxSaver;
|
|
651
1144
|
canvas;
|
|
652
1145
|
c2d;
|
|
653
1146
|
w = 0;
|
|
654
1147
|
h = 0;
|
|
655
|
-
|
|
656
|
-
cx = 0;
|
|
657
|
-
cy = 0;
|
|
658
|
-
vx = 0;
|
|
659
|
-
vy = 0;
|
|
660
|
-
spinPhase = 0;
|
|
661
|
-
// precomputed unit-sphere lattice (spun about Y at render time)
|
|
662
|
-
lattice = [];
|
|
1148
|
+
t = 0;
|
|
663
1149
|
frameId = null;
|
|
664
1150
|
paused = false;
|
|
665
|
-
|
|
1151
|
+
startT = 0;
|
|
1152
|
+
params = defaultParams3(PARAM_SPACE3);
|
|
1153
|
+
track = null;
|
|
1154
|
+
// Seeded once at construction (never rebuilt on resize) — the exact analog
|
|
1155
|
+
// of saver-tide's `build()`. Determinism only requires the SAME instance to
|
|
1156
|
+
// reproduce a given t; these constants make the DVD-bounce path pure in t.
|
|
1157
|
+
x0Frac;
|
|
1158
|
+
y0Frac;
|
|
1159
|
+
dirAngle;
|
|
1160
|
+
// Lattice, built once from the manifest-default `density` (build-time param).
|
|
1161
|
+
meridians = [];
|
|
1162
|
+
parallels = [];
|
|
666
1163
|
constructor(ctx) {
|
|
667
|
-
this.
|
|
1164
|
+
this.ctxSaver = ctx;
|
|
668
1165
|
let canvas;
|
|
669
1166
|
if (ctx.surface) {
|
|
670
1167
|
canvas = ctx.surface;
|
|
@@ -678,51 +1175,85 @@ var GlobeInstance = class {
|
|
|
678
1175
|
const c2d = canvas.getContext("2d", { alpha: false });
|
|
679
1176
|
if (!c2d) throw new Error("globe: no 2d context");
|
|
680
1177
|
this.c2d = c2d;
|
|
681
|
-
this.buildLattice();
|
|
1178
|
+
this.buildLattice(PARAM_SPACE3.density.default);
|
|
682
1179
|
this.w = ctx.width;
|
|
683
1180
|
this.h = ctx.height;
|
|
684
1181
|
this.sizeCanvas();
|
|
685
1182
|
const rng = ctx.rng;
|
|
686
|
-
this.
|
|
687
|
-
this.
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
this.vx = Math.cos(dir) * speed;
|
|
691
|
-
this.vy = Math.sin(dir) * speed;
|
|
692
|
-
this.setPaused(ctx.reducedMotion);
|
|
1183
|
+
this.x0Frac = rng.next();
|
|
1184
|
+
this.y0Frac = rng.next();
|
|
1185
|
+
this.dirAngle = rng.range(0, TAU);
|
|
1186
|
+
this.paused = ctx.reducedMotion;
|
|
693
1187
|
if (this.paused) this.renderStill();
|
|
1188
|
+
else this.start();
|
|
694
1189
|
}
|
|
695
|
-
/**
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
1190
|
+
/** Meridian half-ellipses + parallel rings on the unit sphere. Pure geometry,
|
|
1191
|
+
* no randomness — `density` is read once, at build time, per the paramSpace
|
|
1192
|
+
* comment; a later control-track delta on `density` updates `params.density`
|
|
1193
|
+
* but does not re-tessellate the lattice. */
|
|
1194
|
+
buildLattice(density) {
|
|
1195
|
+
const meridianCount = Math.max(4, Math.round(density));
|
|
1196
|
+
const parallelCount = Math.max(3, Math.round(density * (11 / 21)));
|
|
1197
|
+
for (let m = 0; m < meridianCount; m++) {
|
|
1198
|
+
const lon = TAU * m / meridianCount;
|
|
1199
|
+
const line = [];
|
|
1200
|
+
for (let s = 0; s <= SEG_LAT; s++) {
|
|
1201
|
+
const lat = -Math.PI / 2 + Math.PI * s / SEG_LAT;
|
|
1202
|
+
const ringR = Math.cos(lat);
|
|
1203
|
+
line.push({ x: ringR * Math.cos(lon), y: Math.sin(lat), z: ringR * Math.sin(lon) });
|
|
705
1204
|
}
|
|
1205
|
+
this.meridians.push(line);
|
|
706
1206
|
}
|
|
707
|
-
for (let
|
|
708
|
-
const
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
1207
|
+
for (let i = 1; i < parallelCount; i++) {
|
|
1208
|
+
const lat = -Math.PI / 2 + Math.PI * i / parallelCount;
|
|
1209
|
+
const ringR = Math.cos(lat);
|
|
1210
|
+
const y = Math.sin(lat);
|
|
1211
|
+
const line = [];
|
|
1212
|
+
for (let k = 0; k <= SEG_LON; k++) {
|
|
1213
|
+
const lon = TAU * k / SEG_LON;
|
|
1214
|
+
line.push({ x: ringR * Math.cos(lon), y, z: ringR * Math.sin(lon) });
|
|
713
1215
|
}
|
|
1216
|
+
this.parallels.push(line);
|
|
714
1217
|
}
|
|
715
1218
|
}
|
|
716
1219
|
sizeCanvas() {
|
|
717
|
-
const dpr = Math.min(this.
|
|
1220
|
+
const dpr = Math.min(this.ctxSaver.dpr, 2);
|
|
718
1221
|
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
719
1222
|
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
720
1223
|
this.c2d.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
721
1224
|
}
|
|
1225
|
+
applyParams(t) {
|
|
1226
|
+
const p = this.track ? sampleTrack3(PARAM_SPACE3, this.track, t) : this.params;
|
|
1227
|
+
for (const k of Object.keys(PARAM_SPACE3)) {
|
|
1228
|
+
const v = p[k];
|
|
1229
|
+
if (v !== void 0) this.params[k] = v;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
// ---- closed-form placement ----
|
|
1233
|
+
/** Globe center at time `t` (ms). `bounce` blends between the full
|
|
1234
|
+
* DVD-bounce path and a fixed viewport center. Pure in `t` given the
|
|
1235
|
+
* instance's current w/h and the seeded x0Frac/y0Frac/dirAngle. */
|
|
1236
|
+
center(t) {
|
|
1237
|
+
const p = this.params;
|
|
1238
|
+
const rangeX = Math.max(1, this.w - RADIUS * 2);
|
|
1239
|
+
const rangeY = Math.max(1, this.h - RADIUS * 2);
|
|
1240
|
+
const tSec = t / 1e3;
|
|
1241
|
+
const vx = Math.cos(this.dirAngle) * BOUNCE_SPEED;
|
|
1242
|
+
const vy = Math.sin(this.dirAngle) * BOUNCE_SPEED;
|
|
1243
|
+
const bx = RADIUS + reflect(this.x0Frac * rangeX + vx * tSec, rangeX);
|
|
1244
|
+
const by = RADIUS + reflect(this.y0Frac * rangeY + vy * tSec, rangeY);
|
|
1245
|
+
return [lerp(this.w / 2, bx, p.bounce), lerp(this.h / 2, by, p.bounce)];
|
|
1246
|
+
}
|
|
1247
|
+
/** Rotation angle at time `t` (ms). Pure: the instantaneous `spin` sample
|
|
1248
|
+
* times the preserved base rate, times elapsed seconds — same convention
|
|
1249
|
+
* as saver-tide's `waveSpeed * t` (no integration across changing spin). */
|
|
1250
|
+
angle(t) {
|
|
1251
|
+
return t / 1e3 * SPIN_BASE * this.params.spin;
|
|
1252
|
+
}
|
|
722
1253
|
// ---- loop ----
|
|
723
1254
|
start() {
|
|
724
1255
|
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
725
|
-
this.
|
|
1256
|
+
this.startT = 0;
|
|
726
1257
|
this.frameId = requestAnimationFrame((now) => this.loop(now));
|
|
727
1258
|
}
|
|
728
1259
|
stop() {
|
|
@@ -733,76 +1264,90 @@ var GlobeInstance = class {
|
|
|
733
1264
|
}
|
|
734
1265
|
loop(now) {
|
|
735
1266
|
this.frameId = requestAnimationFrame((n) => this.loop(n));
|
|
736
|
-
if (this.
|
|
737
|
-
|
|
738
|
-
this.last = now;
|
|
739
|
-
this.update(dt);
|
|
740
|
-
this.render();
|
|
1267
|
+
if (this.startT === 0) this.startT = now;
|
|
1268
|
+
this.renderFrame(now - this.startT, this.ctxSaver.seed);
|
|
741
1269
|
}
|
|
742
|
-
|
|
743
|
-
this.
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
1270
|
+
renderStill() {
|
|
1271
|
+
this.renderFrame(this.t, this.ctxSaver.seed);
|
|
1272
|
+
}
|
|
1273
|
+
/** Stroke one lattice polyline (a meridian or a parallel ring), rotated and
|
|
1274
|
+
* projected at render time. `ctx.strokeStyle` is set by the caller;
|
|
1275
|
+
* per-segment alpha/width vary with `depthFade`/`lineW` for a sense of
|
|
1276
|
+
* depth on the back hemisphere. */
|
|
1277
|
+
strokeLine(line, cx, cy, cosA, sinA, lineW, depthFade) {
|
|
1278
|
+
const ctx = this.c2d;
|
|
1279
|
+
let prevX = 0;
|
|
1280
|
+
let prevY = 0;
|
|
1281
|
+
let prevDepth = 0;
|
|
1282
|
+
for (let i = 0; i < line.length; i++) {
|
|
1283
|
+
const p = line[i];
|
|
1284
|
+
const rx = p.x * cosA + p.z * sinA;
|
|
1285
|
+
const rz = -p.x * sinA + p.z * cosA;
|
|
1286
|
+
const x = cx + rx * RADIUS;
|
|
1287
|
+
const y = cy + p.y * RADIUS;
|
|
1288
|
+
const depth = (rz + 1) / 2;
|
|
1289
|
+
if (i > 0) {
|
|
1290
|
+
const avgDepth = (prevDepth + depth) / 2;
|
|
1291
|
+
ctx.globalAlpha = depthAlpha(avgDepth, depthFade);
|
|
1292
|
+
ctx.lineWidth = lineW * (0.55 + 0.65 * avgDepth);
|
|
1293
|
+
ctx.beginPath();
|
|
1294
|
+
ctx.moveTo(prevX, prevY);
|
|
1295
|
+
ctx.lineTo(x, y);
|
|
1296
|
+
ctx.stroke();
|
|
1297
|
+
}
|
|
1298
|
+
prevX = x;
|
|
1299
|
+
prevY = y;
|
|
1300
|
+
prevDepth = depth;
|
|
763
1301
|
}
|
|
1302
|
+
ctx.globalAlpha = 1;
|
|
764
1303
|
}
|
|
765
|
-
render() {
|
|
1304
|
+
render(t) {
|
|
766
1305
|
const ctx = this.c2d;
|
|
1306
|
+
const p = this.params;
|
|
1307
|
+
const [cx, cy] = this.center(t);
|
|
1308
|
+
const a = this.angle(t);
|
|
1309
|
+
const cosA = Math.cos(a);
|
|
1310
|
+
const sinA = Math.sin(a);
|
|
1311
|
+
const dpr = Math.min(this.ctxSaver.dpr, 2);
|
|
1312
|
+
const lineW = LINE_W_DEVICE / dpr;
|
|
1313
|
+
const [wr, wg, wb] = parseHex(p.wire);
|
|
767
1314
|
ctx.fillStyle = "#000";
|
|
768
1315
|
ctx.fillRect(0, 0, this.w, this.h);
|
|
769
1316
|
const body = ctx.createRadialGradient(
|
|
770
|
-
|
|
771
|
-
|
|
1317
|
+
cx - RADIUS * 0.35,
|
|
1318
|
+
cy - RADIUS * 0.35,
|
|
772
1319
|
RADIUS * 0.1,
|
|
773
|
-
|
|
774
|
-
|
|
1320
|
+
cx,
|
|
1321
|
+
cy,
|
|
775
1322
|
RADIUS
|
|
776
1323
|
);
|
|
777
|
-
body.addColorStop(0,
|
|
778
|
-
body.addColorStop(1,
|
|
1324
|
+
body.addColorStop(0, rgba(wr * 0.35, wg * 0.4, wb * 0.5, 0.5));
|
|
1325
|
+
body.addColorStop(1, rgba(wr * 0.1, wg * 0.14, wb * 0.2, 0.15));
|
|
779
1326
|
ctx.fillStyle = body;
|
|
780
1327
|
ctx.beginPath();
|
|
781
|
-
ctx.arc(
|
|
1328
|
+
ctx.arc(cx, cy, RADIUS, 0, TAU);
|
|
782
1329
|
ctx.fill();
|
|
783
|
-
|
|
784
|
-
const
|
|
785
|
-
for (const
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
ctx.
|
|
1330
|
+
ctx.strokeStyle = rgba(wr, wg, wb, 1);
|
|
1331
|
+
for (const line of this.meridians) this.strokeLine(line, cx, cy, cosA, sinA, lineW, p.depthFade);
|
|
1332
|
+
for (const line of this.parallels) this.strokeLine(line, cx, cy, cosA, sinA, lineW, p.depthFade);
|
|
1333
|
+
ctx.globalAlpha = 1;
|
|
1334
|
+
ctx.strokeStyle = rgba(wr, wg, wb, 0.4);
|
|
1335
|
+
ctx.lineWidth = lineW;
|
|
1336
|
+
ctx.beginPath();
|
|
1337
|
+
ctx.arc(cx, cy, RADIUS, 0, TAU);
|
|
1338
|
+
ctx.stroke();
|
|
1339
|
+
if (p.glow > 0.01) {
|
|
1340
|
+
ctx.save();
|
|
1341
|
+
ctx.globalCompositeOperation = "lighter";
|
|
1342
|
+
const glow = ctx.createRadialGradient(cx, cy, RADIUS * 0.82, cx, cy, RADIUS * 1.4);
|
|
1343
|
+
glow.addColorStop(0, rgba(wr, wg, wb, 0.4 * p.glow));
|
|
1344
|
+
glow.addColorStop(1, rgba(wr, wg, wb, 0));
|
|
1345
|
+
ctx.fillStyle = glow;
|
|
794
1346
|
ctx.beginPath();
|
|
795
|
-
ctx.arc(
|
|
1347
|
+
ctx.arc(cx, cy, RADIUS * 1.4, 0, TAU);
|
|
796
1348
|
ctx.fill();
|
|
1349
|
+
ctx.restore();
|
|
797
1350
|
}
|
|
798
|
-
ctx.strokeStyle = "rgba(120,200,255,0.35)";
|
|
799
|
-
ctx.lineWidth = 1;
|
|
800
|
-
ctx.beginPath();
|
|
801
|
-
ctx.arc(this.cx, this.cy, RADIUS, 0, Math.PI * 2);
|
|
802
|
-
ctx.stroke();
|
|
803
|
-
}
|
|
804
|
-
renderStill() {
|
|
805
|
-
this.render();
|
|
806
1351
|
}
|
|
807
1352
|
// ---- SaverInstance ----
|
|
808
1353
|
setPaused(paused) {
|
|
@@ -817,12 +1362,22 @@ var GlobeInstance = class {
|
|
|
817
1362
|
resize(width, height, dpr) {
|
|
818
1363
|
this.w = width;
|
|
819
1364
|
this.h = height;
|
|
820
|
-
if (dpr !== void 0) this.
|
|
1365
|
+
if (dpr !== void 0) this.ctxSaver.dpr = dpr;
|
|
821
1366
|
this.sizeCanvas();
|
|
822
|
-
this.cx = Math.min(Math.max(this.cx, RADIUS), Math.max(RADIUS, this.w - RADIUS));
|
|
823
|
-
this.cy = Math.min(Math.max(this.cy, RADIUS), Math.max(RADIUS, this.h - RADIUS));
|
|
824
1367
|
if (this.paused) this.renderStill();
|
|
825
1368
|
}
|
|
1369
|
+
applyTrack(track) {
|
|
1370
|
+
this.track = track;
|
|
1371
|
+
if (this.paused) this.renderStill();
|
|
1372
|
+
}
|
|
1373
|
+
/** Pure, frame-addressable render at logical time `t` (ms). Position and
|
|
1374
|
+
* rotation are both closed-form in `t` — no accumulated state — so seeking
|
|
1375
|
+
* to any `t`, in any order, reproduces the same frame. */
|
|
1376
|
+
renderFrame(t, _seed) {
|
|
1377
|
+
this.t = t;
|
|
1378
|
+
this.applyParams(t);
|
|
1379
|
+
this.render(t);
|
|
1380
|
+
}
|
|
826
1381
|
dispose() {
|
|
827
1382
|
this.stop();
|
|
828
1383
|
if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) this.canvas.remove();
|
|
@@ -832,6 +1387,25 @@ var globe = {
|
|
|
832
1387
|
manifest: globeManifest,
|
|
833
1388
|
mount: (ctx) => new GlobeInstance(ctx)
|
|
834
1389
|
};
|
|
1390
|
+
var globeDemoTrack = {
|
|
1391
|
+
program: "globe",
|
|
1392
|
+
seed: 3,
|
|
1393
|
+
duration: 12e3,
|
|
1394
|
+
loop: true,
|
|
1395
|
+
deltas: [
|
|
1396
|
+
{ t: 0, path: "spin", value: 0.6 },
|
|
1397
|
+
{ t: 4e3, path: "spin", value: 2.2, ease: "smooth" },
|
|
1398
|
+
{ t: 8e3, path: "spin", value: 0.6, ease: "smooth" },
|
|
1399
|
+
{ t: 12e3, path: "spin", value: 0.6 },
|
|
1400
|
+
{ t: 0, path: "bounce", value: 1 },
|
|
1401
|
+
{ t: 5e3, path: "bounce", value: 0.1, ease: "smooth" },
|
|
1402
|
+
{ t: 9e3, path: "bounce", value: 1, ease: "smooth" },
|
|
1403
|
+
{ t: 12e3, path: "bounce", value: 1 },
|
|
1404
|
+
{ t: 0, path: "glow", value: 0.25 },
|
|
1405
|
+
{ t: 6e3, path: "glow", value: 0.9, ease: "smooth" },
|
|
1406
|
+
{ t: 12e3, path: "glow", value: 0.25, ease: "smooth" }
|
|
1407
|
+
]
|
|
1408
|
+
};
|
|
835
1409
|
|
|
836
1410
|
// src/spotlight.ts
|
|
837
1411
|
var spotlightManifest = {
|
|
@@ -842,6 +1416,11 @@ var spotlightManifest = {
|
|
|
842
1416
|
costTier: "low",
|
|
843
1417
|
motionIntensity: "calm",
|
|
844
1418
|
reducedMotionFallback: "static",
|
|
1419
|
+
attribution: {
|
|
1420
|
+
source: 'After Dark "Spotlight" \u2014 concept by Berkeley Systems',
|
|
1421
|
+
license: "MIT port; reference CSS MIT (Bryan Braun)",
|
|
1422
|
+
url: "https://github.com/bryanbraun/after-dark-css"
|
|
1423
|
+
},
|
|
845
1424
|
a11y: { flashSafe: true, notes: "A soft light circle drifting over the live page; no flashing." },
|
|
846
1425
|
workerReady: true
|
|
847
1426
|
};
|
|
@@ -886,12 +1465,12 @@ var SpotlightInstance = class {
|
|
|
886
1465
|
this.c2d.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
887
1466
|
}
|
|
888
1467
|
centre() {
|
|
889
|
-
const
|
|
1468
|
+
const tri3 = (t, period) => {
|
|
890
1469
|
const p = (t % (period * 2) + period * 2) % (period * 2);
|
|
891
1470
|
return p < period ? p / period : 2 - p / period;
|
|
892
1471
|
};
|
|
893
|
-
const kx =
|
|
894
|
-
const ky =
|
|
1472
|
+
const kx = tri3(this.clock, SPEED_X);
|
|
1473
|
+
const ky = tri3(this.clock, SPEED_Y);
|
|
895
1474
|
const x = HOLE_RADIUS + kx * (this.w - HOLE_RADIUS * 2);
|
|
896
1475
|
const y = HOLE_RADIUS + ky * (this.h - HOLE_RADIUS * 2);
|
|
897
1476
|
return [x, y];
|
|
@@ -976,6 +1555,10 @@ var mystifyManifest = {
|
|
|
976
1555
|
costTier: "low",
|
|
977
1556
|
motionIntensity: "moderate",
|
|
978
1557
|
reducedMotionFallback: "static",
|
|
1558
|
+
attribution: {
|
|
1559
|
+
source: 'Windows "Mystify" \u2014 concept only; clean-room reimplementation',
|
|
1560
|
+
license: "MIT (original code)"
|
|
1561
|
+
},
|
|
979
1562
|
a11y: { flashSafe: true, notes: "Slow-fade polygon trails on black; no strobing." },
|
|
980
1563
|
workerReady: true
|
|
981
1564
|
};
|
|
@@ -1372,6 +1955,34 @@ var pipes = {
|
|
|
1372
1955
|
};
|
|
1373
1956
|
|
|
1374
1957
|
// src/flurry.ts
|
|
1958
|
+
import {
|
|
1959
|
+
sampleTrack as sampleTrack4,
|
|
1960
|
+
defaultParams as defaultParams4
|
|
1961
|
+
} from "@idle-screens/core";
|
|
1962
|
+
var STREAM_COUNT = 5;
|
|
1963
|
+
var PARTICLES_PER_ARM = 56;
|
|
1964
|
+
var BASE_RADIUS = 6;
|
|
1965
|
+
var STILL_T = 6e3;
|
|
1966
|
+
var TRAIL_FRAC_MIN = 0.12;
|
|
1967
|
+
var TRAIL_FRAC_MAX = 0.42;
|
|
1968
|
+
var TAIL_SIZE_FLOOR = 0.45;
|
|
1969
|
+
var TAIL_ALPHA_POWER = 1.4;
|
|
1970
|
+
var PARAM_SPACE4 = {
|
|
1971
|
+
/** Arm count. Build-time: rebuilt (deterministically, from the same seeded
|
|
1972
|
+
* RNG forks) whenever this changes rather than smoothly animated — more
|
|
1973
|
+
* arms means re-deriving the whole cast, not interpolating between two. */
|
|
1974
|
+
arms: { type: "number", default: STREAM_COUNT, min: 3, max: 10, ease: "step" },
|
|
1975
|
+
speed: { type: "number", default: 1, min: 0.25, max: 3, ease: "smooth" },
|
|
1976
|
+
/** Additive glow strength: halo reach and brightness of each particle. */
|
|
1977
|
+
glow: { type: "number", default: 0.6, min: 0, max: 1.5, ease: "smooth" },
|
|
1978
|
+
/** How far back each arm's analytic trail reads, as a fraction of the
|
|
1979
|
+
* screen diagonal (0 = short stub, 1 = long flowing ribbon). */
|
|
1980
|
+
trail: { type: "number", default: 0.5, min: 0, max: 1, ease: "smooth" },
|
|
1981
|
+
/** Color scheme. 'spectrum' rotates hue continuously over ~20s — well
|
|
1982
|
+
* outside flash-safety limits, no strobing. */
|
|
1983
|
+
palette: { type: "enum", default: "aurora", options: ["aurora", "ember", "mono", "spectrum"] },
|
|
1984
|
+
size: { type: "number", default: 1, min: 0.5, max: 2, ease: "smooth" }
|
|
1985
|
+
};
|
|
1375
1986
|
var flurryManifest = {
|
|
1376
1987
|
id: "flurry",
|
|
1377
1988
|
label: "Flurry",
|
|
@@ -1380,24 +1991,70 @@ var flurryManifest = {
|
|
|
1380
1991
|
costTier: "low",
|
|
1381
1992
|
motionIntensity: "calm",
|
|
1382
1993
|
reducedMotionFallback: "static",
|
|
1383
|
-
|
|
1994
|
+
paramSpace: PARAM_SPACE4,
|
|
1995
|
+
a11y: {
|
|
1996
|
+
flashSafe: true,
|
|
1997
|
+
notes: "Softly glowing arms drifting on black. The spectrum palette rotates hue over ~20s; no flashing."
|
|
1998
|
+
},
|
|
1384
1999
|
workerReady: true
|
|
1385
2000
|
};
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
2001
|
+
function buildArm(rng) {
|
|
2002
|
+
return {
|
|
2003
|
+
freqX1: rng.range(0.3, 0.9),
|
|
2004
|
+
freqY1: rng.range(0.3, 0.9),
|
|
2005
|
+
freqX2: rng.range(0.1, 0.4),
|
|
2006
|
+
freqY2: rng.range(0.1, 0.4),
|
|
2007
|
+
freqX3: rng.range(0.04, 0.15),
|
|
2008
|
+
freqY3: rng.range(0.04, 0.15),
|
|
2009
|
+
phaseX: rng.range(0, Math.PI * 2),
|
|
2010
|
+
phaseY: rng.range(0, Math.PI * 2),
|
|
2011
|
+
ampX: rng.range(0.2, 0.4),
|
|
2012
|
+
ampY: rng.range(0.2, 0.4),
|
|
2013
|
+
armSpeed: rng.range(0.6, 1.2),
|
|
2014
|
+
hueJitter: rng.range(0, 1)
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
function paletteHue(palette, arm, armIndex, armCount, t) {
|
|
2018
|
+
const spread = armCount > 0 ? armIndex / armCount : 0;
|
|
2019
|
+
switch (palette) {
|
|
2020
|
+
case "ember":
|
|
2021
|
+
return (8 + spread * 46 + arm.hueJitter * 10) % 360;
|
|
2022
|
+
// reds -> oranges -> yellows
|
|
2023
|
+
case "mono":
|
|
2024
|
+
return 201 + arm.hueJitter * 14;
|
|
2025
|
+
// narrow cool-blue band, 201-215
|
|
2026
|
+
case "spectrum": {
|
|
2027
|
+
const rotation = t / 2e4 * 360;
|
|
2028
|
+
return (arm.hueJitter * 360 + rotation) % 360;
|
|
2029
|
+
}
|
|
2030
|
+
case "aurora":
|
|
2031
|
+
default:
|
|
2032
|
+
return (150 + spread * 70 + arm.hueJitter * 20) % 360;
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
1390
2035
|
var FlurryInstance = class {
|
|
1391
2036
|
ctxSaver;
|
|
1392
2037
|
canvas;
|
|
1393
|
-
|
|
2038
|
+
c2d;
|
|
1394
2039
|
w = 0;
|
|
1395
2040
|
h = 0;
|
|
1396
|
-
|
|
2041
|
+
arms = [];
|
|
1397
2042
|
frameId = null;
|
|
1398
|
-
t = 0;
|
|
1399
|
-
lastTime = 0;
|
|
1400
2043
|
paused = false;
|
|
2044
|
+
startT = 0;
|
|
2045
|
+
/** Logical time the next rAF origin resumes from.
|
|
2046
|
+
*
|
|
2047
|
+
* `start()` re-anchors `startT` to the next frame's timestamp, so on its own
|
|
2048
|
+
* `now - startT` always begins at zero. Mount wants that; resuming from a
|
|
2049
|
+
* pause does not — without carrying the frozen `t` forward, every
|
|
2050
|
+
* pause/resume (and every reduced-motion toggle) snaps the scene back to its
|
|
2051
|
+
* opening frame and restarts any applied control track. Set only in
|
|
2052
|
+
* `setPaused(false)`, so first mount still starts at 0. */
|
|
2053
|
+
resumeFrom = 0;
|
|
2054
|
+
t = STILL_T;
|
|
2055
|
+
// anchor frame until the loop (or a seek) moves it
|
|
2056
|
+
params = defaultParams4(PARAM_SPACE4);
|
|
2057
|
+
track = null;
|
|
1401
2058
|
constructor(ctx) {
|
|
1402
2059
|
this.ctxSaver = ctx;
|
|
1403
2060
|
this.w = ctx.width;
|
|
@@ -1415,10 +2072,8 @@ var FlurryInstance = class {
|
|
|
1415
2072
|
this.canvas = canvas;
|
|
1416
2073
|
const c2d = canvas.getContext("2d", { alpha: false });
|
|
1417
2074
|
if (!c2d) throw new Error("flurry: no 2d context");
|
|
1418
|
-
this.
|
|
1419
|
-
this.streams = this.buildStreams(ctx.rng);
|
|
2075
|
+
this.c2d = c2d;
|
|
1420
2076
|
this.sizeCanvas();
|
|
1421
|
-
this.clearFull();
|
|
1422
2077
|
this.paused = ctx.reducedMotion;
|
|
1423
2078
|
if (this.paused) {
|
|
1424
2079
|
this.renderStill();
|
|
@@ -1426,71 +2081,95 @@ var FlurryInstance = class {
|
|
|
1426
2081
|
this.start();
|
|
1427
2082
|
}
|
|
1428
2083
|
}
|
|
1429
|
-
|
|
1430
|
-
const
|
|
1431
|
-
for (
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
freqX1: rng.range(0.3, 0.9),
|
|
1435
|
-
freqY1: rng.range(0.3, 0.9),
|
|
1436
|
-
freqX2: rng.range(0.1, 0.4),
|
|
1437
|
-
freqY2: rng.range(0.1, 0.4),
|
|
1438
|
-
phaseX: rng.range(0, Math.PI * 2),
|
|
1439
|
-
phaseY: rng.range(0, Math.PI * 2),
|
|
1440
|
-
ampX: rng.range(0.2, 0.4),
|
|
1441
|
-
ampY: rng.range(0.2, 0.4),
|
|
1442
|
-
speed: rng.range(0.6, 1.2)
|
|
1443
|
-
});
|
|
2084
|
+
applyParams(t) {
|
|
2085
|
+
const p = this.track ? sampleTrack4(PARAM_SPACE4, this.track, t) : this.params;
|
|
2086
|
+
for (const k of Object.keys(PARAM_SPACE4)) {
|
|
2087
|
+
const v = p[k];
|
|
2088
|
+
if (v !== void 0) this.params[k] = v;
|
|
1444
2089
|
}
|
|
1445
|
-
|
|
2090
|
+
}
|
|
2091
|
+
/** Rebuild the arm cast for a given count, deterministically, from the
|
|
2092
|
+
* saver's own seeded RNG. Pure w.r.t. (ctx.rng, count) — safe to call any
|
|
2093
|
+
* number of times, in any order, from any `t`. Keying off `arms.length`
|
|
2094
|
+
* alone is correct here (not a "rebuild every frame" bug): `ctx.rng`
|
|
2095
|
+
* never changes for this instance and `Rng.fork(salt)` is itself a pure
|
|
2096
|
+
* function of the salt, so a given count always yields the same cast. */
|
|
2097
|
+
ensureArms(count) {
|
|
2098
|
+
if (count === this.arms.length) return;
|
|
2099
|
+
const out = [];
|
|
2100
|
+
for (let i = 0; i < count; i++) out.push(buildArm(this.ctxSaver.rng.fork(i)));
|
|
2101
|
+
this.arms = out;
|
|
1446
2102
|
}
|
|
1447
2103
|
sizeCanvas() {
|
|
1448
2104
|
const dpr = Math.min(this.ctxSaver.dpr, 2);
|
|
1449
2105
|
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
1450
2106
|
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
1451
|
-
this.
|
|
1452
|
-
}
|
|
1453
|
-
clearFull() {
|
|
1454
|
-
this.ctx.fillStyle = "#000";
|
|
1455
|
-
this.ctx.fillRect(0, 0, this.w, this.h);
|
|
2107
|
+
this.c2d.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
1456
2108
|
}
|
|
1457
|
-
|
|
2109
|
+
/** Closed-form arm-tip position at arm-local time `s` (seconds). Pure. */
|
|
2110
|
+
armTip(arm, s) {
|
|
1458
2111
|
const cx = this.w / 2;
|
|
1459
2112
|
const cy = this.h / 2;
|
|
1460
|
-
const x = cx + Math.sin(
|
|
1461
|
-
const y = cy + Math.cos(
|
|
2113
|
+
const x = cx + Math.sin(s * arm.freqX1 + arm.phaseX) * this.w * arm.ampX + Math.sin(s * arm.freqX2 + arm.phaseX * 1.7) * this.w * arm.ampX * 0.3 + Math.sin(s * arm.freqX3 + arm.phaseX * 0.6) * this.w * arm.ampX * 0.12;
|
|
2114
|
+
const y = cy + Math.cos(s * arm.freqY1 + arm.phaseY) * this.h * arm.ampY + Math.cos(s * arm.freqY2 + arm.phaseY * 2.1) * this.h * arm.ampY * 0.3 + Math.cos(s * arm.freqY3 + arm.phaseY * 1.3) * this.h * arm.ampY * 0.12;
|
|
1462
2115
|
return [x, y];
|
|
1463
2116
|
}
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
2117
|
+
/** Pure render at logical time `t` (ms): background + every arm's analytic trail. */
|
|
2118
|
+
render(t) {
|
|
2119
|
+
const c2d = this.c2d;
|
|
2120
|
+
const p = this.params;
|
|
2121
|
+
c2d.fillStyle = "#000";
|
|
2122
|
+
c2d.fillRect(0, 0, this.w, this.h);
|
|
2123
|
+
const armCount = Math.max(3, Math.min(10, Math.round(p.arms)));
|
|
2124
|
+
this.ensureArms(armCount);
|
|
2125
|
+
c2d.globalCompositeOperation = "lighter";
|
|
2126
|
+
c2d.lineCap = "butt";
|
|
2127
|
+
c2d.lineJoin = "round";
|
|
2128
|
+
const globalS = t / 1e3 * p.speed;
|
|
2129
|
+
const glow = Math.max(0, Math.min(1.5, p.glow));
|
|
2130
|
+
const size = Math.max(0.5, Math.min(2, p.size));
|
|
2131
|
+
const glowReach = 3.6 + glow * 2.6;
|
|
2132
|
+
const headAlpha = 0.85 * (0.5 + glow * 0.6);
|
|
2133
|
+
const diag = Math.hypot(this.w, this.h);
|
|
2134
|
+
const trailFrac = TRAIL_FRAC_MIN + Math.max(0, Math.min(1, p.trail)) * (TRAIL_FRAC_MAX - TRAIL_FRAC_MIN);
|
|
2135
|
+
const targetArcPx = trailFrac * diag;
|
|
2136
|
+
const avgDim = (this.w + this.h) / 2;
|
|
2137
|
+
for (let i = 0; i < this.arms.length; i++) {
|
|
2138
|
+
const arm = this.arms[i];
|
|
2139
|
+
const armS = globalS * arm.armSpeed;
|
|
2140
|
+
const charRate = Math.max(0.02, (arm.freqX1 * arm.ampX + arm.freqY1 * arm.ampY) / 2);
|
|
2141
|
+
const spanS = targetArcPx / (charRate * avgDim);
|
|
2142
|
+
const stepS = spanS / (PARTICLES_PER_ARM - 1);
|
|
2143
|
+
const pts = new Array(PARTICLES_PER_ARM);
|
|
2144
|
+
for (let k = 0; k < PARTICLES_PER_ARM; k++) pts[k] = this.armTip(arm, armS - k * stepS);
|
|
2145
|
+
const hue = paletteHue(p.palette, arm, i, this.arms.length, t);
|
|
2146
|
+
for (let k = 0; k < PARTICLES_PER_ARM - 1; k++) {
|
|
2147
|
+
const kFrac = (k + 0.5) / (PARTICLES_PER_ARM - 1);
|
|
2148
|
+
const r = BASE_RADIUS * size * (1 - kFrac * (1 - TAIL_SIZE_FLOOR));
|
|
2149
|
+
const alpha = headAlpha * Math.pow(1 - kFrac, TAIL_ALPHA_POWER);
|
|
2150
|
+
const [x0, y0] = pts[k];
|
|
2151
|
+
const [x1, y1] = pts[k + 1];
|
|
2152
|
+
c2d.strokeStyle = `hsla(${hue},85%,58%,${alpha * 0.5})`;
|
|
2153
|
+
c2d.lineWidth = Math.max(0.5, r * glowReach);
|
|
2154
|
+
c2d.beginPath();
|
|
2155
|
+
c2d.moveTo(x0, y0);
|
|
2156
|
+
c2d.lineTo(x1, y1);
|
|
2157
|
+
c2d.stroke();
|
|
2158
|
+
c2d.strokeStyle = `hsla(${hue},95%,74%,${Math.min(1, alpha * 1.15)})`;
|
|
2159
|
+
c2d.lineWidth = Math.max(0.5, r * 1.15);
|
|
2160
|
+
c2d.beginPath();
|
|
2161
|
+
c2d.moveTo(x0, y0);
|
|
2162
|
+
c2d.lineTo(x1, y1);
|
|
2163
|
+
c2d.stroke();
|
|
1486
2164
|
}
|
|
1487
2165
|
}
|
|
1488
|
-
|
|
2166
|
+
c2d.globalCompositeOperation = "source-over";
|
|
1489
2167
|
}
|
|
2168
|
+
// ---- loop ----
|
|
1490
2169
|
start() {
|
|
1491
2170
|
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
1492
|
-
this.
|
|
1493
|
-
this.loop(
|
|
2171
|
+
this.startT = 0;
|
|
2172
|
+
this.frameId = requestAnimationFrame((now) => this.loop(now));
|
|
1494
2173
|
}
|
|
1495
2174
|
stop() {
|
|
1496
2175
|
if (this.frameId !== null) {
|
|
@@ -1500,23 +2179,23 @@ var FlurryInstance = class {
|
|
|
1500
2179
|
}
|
|
1501
2180
|
loop(now) {
|
|
1502
2181
|
this.frameId = requestAnimationFrame((n) => this.loop(n));
|
|
1503
|
-
|
|
1504
|
-
this.
|
|
1505
|
-
this.t += Math.min(dt, 0.1);
|
|
1506
|
-
this.drawFrame(dt);
|
|
2182
|
+
if (this.startT === 0) this.startT = now;
|
|
2183
|
+
this.renderFrame(now - this.startT + this.resumeFrom, this.ctxSaver.seed);
|
|
1507
2184
|
}
|
|
2185
|
+
/** Freeze on whatever frame we're actually at — not a fixed anchor — so
|
|
2186
|
+
* pausing mid-loop, resizing while paused, or steering a track while
|
|
2187
|
+
* paused all repaint the same instant instead of snapping elsewhere. */
|
|
1508
2188
|
renderStill() {
|
|
1509
|
-
this.
|
|
1510
|
-
for (let i = 0; i < 120; i++) {
|
|
1511
|
-
this.t += 1 / 60;
|
|
1512
|
-
this.drawFrame(1 / 60);
|
|
1513
|
-
}
|
|
2189
|
+
this.renderFrame(this.t, this.ctxSaver.seed);
|
|
1514
2190
|
}
|
|
2191
|
+
// ---- SaverInstance ----
|
|
1515
2192
|
setPaused(paused) {
|
|
1516
2193
|
this.paused = paused;
|
|
1517
2194
|
if (paused) {
|
|
1518
2195
|
this.stop();
|
|
2196
|
+
this.renderStill();
|
|
1519
2197
|
} else {
|
|
2198
|
+
this.resumeFrom = this.t;
|
|
1520
2199
|
this.start();
|
|
1521
2200
|
}
|
|
1522
2201
|
}
|
|
@@ -1525,9 +2204,19 @@ var FlurryInstance = class {
|
|
|
1525
2204
|
this.h = height;
|
|
1526
2205
|
if (dpr !== void 0) this.ctxSaver.dpr = dpr;
|
|
1527
2206
|
this.sizeCanvas();
|
|
1528
|
-
this.clearFull();
|
|
1529
2207
|
if (this.paused) this.renderStill();
|
|
1530
2208
|
}
|
|
2209
|
+
applyTrack(track) {
|
|
2210
|
+
this.track = track;
|
|
2211
|
+
if (this.paused) this.renderStill();
|
|
2212
|
+
}
|
|
2213
|
+
/** Pure, frame-addressable render at logical time `t` (ms) for `seed`.
|
|
2214
|
+
* Same (t, seed) always paints the same pixels — seek-back safe. */
|
|
2215
|
+
renderFrame(t, _seed) {
|
|
2216
|
+
this.t = t;
|
|
2217
|
+
this.applyParams(t);
|
|
2218
|
+
this.render(t);
|
|
2219
|
+
}
|
|
1531
2220
|
dispose() {
|
|
1532
2221
|
this.stop();
|
|
1533
2222
|
if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) this.canvas.remove();
|
|
@@ -1537,6 +2226,24 @@ var flurry = {
|
|
|
1537
2226
|
manifest: flurryManifest,
|
|
1538
2227
|
mount: (ctx) => new FlurryInstance(ctx)
|
|
1539
2228
|
};
|
|
2229
|
+
var flurryDemoTrack = {
|
|
2230
|
+
program: "flurry",
|
|
2231
|
+
seed: 3,
|
|
2232
|
+
duration: 16e3,
|
|
2233
|
+
loop: true,
|
|
2234
|
+
deltas: [
|
|
2235
|
+
{ t: 0, path: "palette", value: "aurora" },
|
|
2236
|
+
{ t: 8e3, path: "palette", value: "ember" },
|
|
2237
|
+
{ t: 0, path: "speed", value: 0.6 },
|
|
2238
|
+
{ t: 8e3, path: "speed", value: 1.8, ease: "smooth" },
|
|
2239
|
+
{ t: 16e3, path: "speed", value: 0.6, ease: "smooth" },
|
|
2240
|
+
{ t: 0, path: "glow", value: 0.3 },
|
|
2241
|
+
{ t: 4e3, path: "glow", value: 0.9, ease: "smooth" },
|
|
2242
|
+
{ t: 8e3, path: "glow", value: 0.3, ease: "smooth" },
|
|
2243
|
+
{ t: 12e3, path: "glow", value: 0.9, ease: "smooth" },
|
|
2244
|
+
{ t: 16e3, path: "glow", value: 0.3, ease: "smooth" }
|
|
2245
|
+
]
|
|
2246
|
+
};
|
|
1540
2247
|
|
|
1541
2248
|
// src/fluid-shared.ts
|
|
1542
2249
|
var DT = 0.025;
|
|
@@ -3217,16 +3924,241 @@ var reactionDiffusion = {
|
|
|
3217
3924
|
}
|
|
3218
3925
|
};
|
|
3219
3926
|
|
|
3927
|
+
// src/messages.ts
|
|
3928
|
+
import {
|
|
3929
|
+
sampleTrack as sampleTrack5,
|
|
3930
|
+
defaultParams as defaultParams5
|
|
3931
|
+
} from "@idle-screens/core";
|
|
3932
|
+
var PHRASES = {
|
|
3933
|
+
"out-to-lunch": "OUT TO LUNCH",
|
|
3934
|
+
"staring": "Why are you staring at my Macintosh?",
|
|
3935
|
+
"brb": "BE RIGHT BACK",
|
|
3936
|
+
"gone-idle": "gone idle \u2014 leave a message",
|
|
3937
|
+
"ship-it": "SHIP IT IN THE MORNING"
|
|
3938
|
+
};
|
|
3939
|
+
var PARAM_SPACE5 = {
|
|
3940
|
+
/** Which line the screen mutters. */
|
|
3941
|
+
phrase: { type: "enum", default: "out-to-lunch", options: Object.keys(PHRASES) },
|
|
3942
|
+
/** 'marquee' = the Out-to-Lunch crawl (steps down the page);
|
|
3943
|
+
* 'drift' = the Macintosh corner-to-corner wander. */
|
|
3944
|
+
mode: { type: "enum", default: "marquee", options: ["marquee", "drift"] },
|
|
3945
|
+
speed: { type: "number", default: 1, min: 0.25, max: 3, ease: "smooth" },
|
|
3946
|
+
/** Text size multiplier on the short-edge-relative base. */
|
|
3947
|
+
textScale: { type: "number", default: 1, min: 0.5, max: 2.6, ease: "smooth" },
|
|
3948
|
+
ink: { type: "color", default: "#e8ecf4" },
|
|
3949
|
+
/** Phosphor glow around the letters. */
|
|
3950
|
+
glow: { type: "number", default: 0.4, min: 0, max: 1, ease: "smooth" },
|
|
3951
|
+
/** Ghost trail of previous instants. */
|
|
3952
|
+
trail: { type: "number", default: 0.25, min: 0, max: 1, ease: "smooth" }
|
|
3953
|
+
};
|
|
3954
|
+
var messagesManifest = {
|
|
3955
|
+
id: "messages",
|
|
3956
|
+
label: "Messages",
|
|
3957
|
+
passthrough: false,
|
|
3958
|
+
minBackend: "canvas2d",
|
|
3959
|
+
costTier: "low",
|
|
3960
|
+
motionIntensity: "calm",
|
|
3961
|
+
reducedMotionFallback: "static",
|
|
3962
|
+
paramSpace: PARAM_SPACE5,
|
|
3963
|
+
attribution: {
|
|
3964
|
+
source: 'After Dark "Messages" \u2014 concepts by Berkeley Systems',
|
|
3965
|
+
license: "MIT port; reference CSS MIT (Bryan Braun)",
|
|
3966
|
+
url: "https://github.com/bryanbraun/after-dark-css"
|
|
3967
|
+
},
|
|
3968
|
+
a11y: { flashSafe: true, notes: "A single line of text moving smoothly; no flashing." },
|
|
3969
|
+
workerReady: true
|
|
3970
|
+
};
|
|
3971
|
+
var tri2 = (t, p) => {
|
|
3972
|
+
const k = (t % (p * 2) + p * 2) % (p * 2);
|
|
3973
|
+
return k < p ? k / p : 2 - k / p;
|
|
3974
|
+
};
|
|
3975
|
+
var MessagesInstance = class {
|
|
3976
|
+
ctxSaver;
|
|
3977
|
+
canvas;
|
|
3978
|
+
c2d;
|
|
3979
|
+
w = 0;
|
|
3980
|
+
h = 0;
|
|
3981
|
+
frameId = null;
|
|
3982
|
+
paused = false;
|
|
3983
|
+
startT = 0;
|
|
3984
|
+
t = 0;
|
|
3985
|
+
params = defaultParams5(PARAM_SPACE5);
|
|
3986
|
+
track = null;
|
|
3987
|
+
constructor(ctx) {
|
|
3988
|
+
this.ctxSaver = ctx;
|
|
3989
|
+
if (ctx.surface) {
|
|
3990
|
+
this.canvas = ctx.surface;
|
|
3991
|
+
} else {
|
|
3992
|
+
const el = document.createElement("canvas");
|
|
3993
|
+
el.style.cssText = "display:block;width:100%;height:100%;background:#04050a";
|
|
3994
|
+
ctx.host.appendChild(el);
|
|
3995
|
+
this.canvas = el;
|
|
3996
|
+
}
|
|
3997
|
+
const c2d = this.canvas.getContext("2d", { alpha: false });
|
|
3998
|
+
if (!c2d) throw new Error("messages: no 2d context");
|
|
3999
|
+
this.c2d = c2d;
|
|
4000
|
+
this.w = ctx.width;
|
|
4001
|
+
this.h = ctx.height;
|
|
4002
|
+
this.sizeCanvas();
|
|
4003
|
+
this.paused = ctx.reducedMotion;
|
|
4004
|
+
if (this.paused) this.renderStill();
|
|
4005
|
+
else this.start();
|
|
4006
|
+
}
|
|
4007
|
+
applyParams(t) {
|
|
4008
|
+
const p = this.track ? sampleTrack5(PARAM_SPACE5, this.track, t) : this.params;
|
|
4009
|
+
for (const k of Object.keys(PARAM_SPACE5)) {
|
|
4010
|
+
const v = p[k];
|
|
4011
|
+
if (v !== void 0) this.params[k] = v;
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
sizeCanvas() {
|
|
4015
|
+
const dpr = Math.min(this.ctxSaver.dpr, 2);
|
|
4016
|
+
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
4017
|
+
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
4018
|
+
this.c2d.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
4019
|
+
}
|
|
4020
|
+
// ---- closed-form placement ----
|
|
4021
|
+
fontPx() {
|
|
4022
|
+
return Math.max(14, Math.min(this.w, this.h) * 0.05 * this.params.textScale);
|
|
4023
|
+
}
|
|
4024
|
+
font() {
|
|
4025
|
+
return `500 ${this.fontPx().toFixed(1)}px ui-rounded, "Avenir Next", "Segoe UI Variable Display", system-ui, sans-serif`;
|
|
4026
|
+
}
|
|
4027
|
+
/** Position of the line's left baseline at time `t`. Pure. */
|
|
4028
|
+
place(t, textW) {
|
|
4029
|
+
const p = this.params;
|
|
4030
|
+
const fs = this.fontPx();
|
|
4031
|
+
if (p.mode === "marquee") {
|
|
4032
|
+
const crawl = 1e4 / p.speed;
|
|
4033
|
+
const k = (t % crawl + crawl) % crawl;
|
|
4034
|
+
const x2 = this.w - k / crawl * (this.w + textW * 1.5);
|
|
4035
|
+
const stepPhase = (t % (crawl * 3) + crawl * 3) % (crawl * 3);
|
|
4036
|
+
const row = Math.floor(stepPhase / crawl);
|
|
4037
|
+
const y2 = this.h * 0.22 + row * this.h * 0.27 + fs * 0.5;
|
|
4038
|
+
return [x2, y2];
|
|
4039
|
+
}
|
|
4040
|
+
const x = tri2(t, 8e3 / p.speed) * Math.max(0, this.w - textW);
|
|
4041
|
+
const y = fs + tri2(t, 17300 / p.speed) * Math.max(0, this.h - fs * 1.6);
|
|
4042
|
+
return [x, y];
|
|
4043
|
+
}
|
|
4044
|
+
// ---- loop ----
|
|
4045
|
+
start() {
|
|
4046
|
+
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
4047
|
+
this.startT = 0;
|
|
4048
|
+
this.frameId = requestAnimationFrame((now) => this.loop(now));
|
|
4049
|
+
}
|
|
4050
|
+
stop() {
|
|
4051
|
+
if (this.frameId !== null) {
|
|
4052
|
+
cancelAnimationFrame(this.frameId);
|
|
4053
|
+
this.frameId = null;
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4056
|
+
loop(now) {
|
|
4057
|
+
this.frameId = requestAnimationFrame((n) => this.loop(n));
|
|
4058
|
+
if (this.startT === 0) this.startT = now;
|
|
4059
|
+
this.renderFrame(now - this.startT, this.ctxSaver.seed);
|
|
4060
|
+
}
|
|
4061
|
+
renderStill() {
|
|
4062
|
+
this.renderFrame(this.t, this.ctxSaver.seed);
|
|
4063
|
+
}
|
|
4064
|
+
render(t) {
|
|
4065
|
+
const ctx = this.c2d;
|
|
4066
|
+
const p = this.params;
|
|
4067
|
+
ctx.fillStyle = "#04050a";
|
|
4068
|
+
ctx.fillRect(0, 0, this.w, this.h);
|
|
4069
|
+
ctx.font = this.font();
|
|
4070
|
+
ctx.textBaseline = "alphabetic";
|
|
4071
|
+
const text = PHRASES[p.phrase] ?? PHRASES["out-to-lunch"];
|
|
4072
|
+
const textW = ctx.measureText(text).width;
|
|
4073
|
+
if (p.trail > 0.02) {
|
|
4074
|
+
for (let k = 4; k >= 1; k--) {
|
|
4075
|
+
const [gx, gy] = this.place(t - k * 90, textW);
|
|
4076
|
+
ctx.globalAlpha = p.trail * 0.16 * (1 - k / 5);
|
|
4077
|
+
ctx.fillStyle = p.ink;
|
|
4078
|
+
ctx.fillText(text, gx, gy);
|
|
4079
|
+
}
|
|
4080
|
+
ctx.globalAlpha = 1;
|
|
4081
|
+
}
|
|
4082
|
+
const [x, y] = this.place(t, textW);
|
|
4083
|
+
if (p.glow > 0.02) {
|
|
4084
|
+
ctx.shadowColor = p.ink;
|
|
4085
|
+
ctx.shadowBlur = this.fontPx() * 0.55 * p.glow;
|
|
4086
|
+
}
|
|
4087
|
+
ctx.fillStyle = p.ink;
|
|
4088
|
+
ctx.fillText(text, x, y);
|
|
4089
|
+
ctx.shadowBlur = 0;
|
|
4090
|
+
}
|
|
4091
|
+
// ---- SaverInstance ----
|
|
4092
|
+
setPaused(paused) {
|
|
4093
|
+
this.paused = paused;
|
|
4094
|
+
if (paused) {
|
|
4095
|
+
this.stop();
|
|
4096
|
+
this.renderStill();
|
|
4097
|
+
} else {
|
|
4098
|
+
this.start();
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
resize(width, height, dpr) {
|
|
4102
|
+
this.w = width;
|
|
4103
|
+
this.h = height;
|
|
4104
|
+
if (dpr !== void 0) this.ctxSaver.dpr = dpr;
|
|
4105
|
+
this.sizeCanvas();
|
|
4106
|
+
if (this.paused) this.renderStill();
|
|
4107
|
+
}
|
|
4108
|
+
applyTrack(track) {
|
|
4109
|
+
this.track = track;
|
|
4110
|
+
if (this.paused) this.renderStill();
|
|
4111
|
+
}
|
|
4112
|
+
/** Pure, frame-addressable render at logical time `t`. */
|
|
4113
|
+
renderFrame(t, _seed) {
|
|
4114
|
+
this.t = t;
|
|
4115
|
+
this.applyParams(t);
|
|
4116
|
+
this.render(t);
|
|
4117
|
+
}
|
|
4118
|
+
dispose() {
|
|
4119
|
+
this.stop();
|
|
4120
|
+
if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) this.canvas.remove();
|
|
4121
|
+
}
|
|
4122
|
+
};
|
|
4123
|
+
var messages = {
|
|
4124
|
+
manifest: messagesManifest,
|
|
4125
|
+
mount: (ctx) => new MessagesInstance(ctx)
|
|
4126
|
+
};
|
|
4127
|
+
var messagesDemoTrack = {
|
|
4128
|
+
program: "messages",
|
|
4129
|
+
seed: 2,
|
|
4130
|
+
duration: 2e4,
|
|
4131
|
+
loop: true,
|
|
4132
|
+
deltas: [
|
|
4133
|
+
{ t: 0, path: "mode", value: "marquee" },
|
|
4134
|
+
{ t: 1e4, path: "mode", value: "drift" },
|
|
4135
|
+
{ t: 0, path: "phrase", value: "out-to-lunch" },
|
|
4136
|
+
{ t: 1e4, path: "phrase", value: "staring" },
|
|
4137
|
+
{ t: 0, path: "glow", value: 0.2 },
|
|
4138
|
+
{ t: 5e3, path: "glow", value: 0.7, ease: "smooth" },
|
|
4139
|
+
{ t: 1e4, path: "glow", value: 0.2, ease: "smooth" },
|
|
4140
|
+
{ t: 15e3, path: "glow", value: 0.7, ease: "smooth" },
|
|
4141
|
+
{ t: 2e4, path: "glow", value: 0.2, ease: "smooth" }
|
|
4142
|
+
]
|
|
4143
|
+
};
|
|
4144
|
+
|
|
3220
4145
|
export {
|
|
4146
|
+
dvd,
|
|
4147
|
+
dvdDemoTrack,
|
|
3221
4148
|
warp,
|
|
4149
|
+
warpDemoTrack,
|
|
3222
4150
|
hardRain,
|
|
3223
4151
|
rainstorm,
|
|
3224
4152
|
globe,
|
|
4153
|
+
globeDemoTrack,
|
|
3225
4154
|
spotlight,
|
|
3226
4155
|
mystify,
|
|
3227
4156
|
pipes,
|
|
3228
4157
|
flurry,
|
|
4158
|
+
flurryDemoTrack,
|
|
3229
4159
|
fluid,
|
|
3230
|
-
reactionDiffusion
|
|
4160
|
+
reactionDiffusion,
|
|
4161
|
+
messages,
|
|
4162
|
+
messagesDemoTrack
|
|
3231
4163
|
};
|
|
3232
|
-
//# sourceMappingURL=chunk-
|
|
4164
|
+
//# sourceMappingURL=chunk-PU6BQ5S3.js.map
|