@idle-screens/savers-classic 1.0.0 → 2.0.1
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 +3232 -0
- package/dist/chunk-MIVXP2IL.js.map +1 -0
- package/dist/idle-worker.js +2889 -8
- package/dist/idle-worker.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +9 -1971
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/chunk-5EPTQV3C.js +0 -965
- package/dist/chunk-5EPTQV3C.js.map +0 -1
package/dist/idle-worker.js
CHANGED
|
@@ -1,18 +1,2899 @@
|
|
|
1
1
|
import {
|
|
2
|
+
fluid,
|
|
3
|
+
flurry,
|
|
2
4
|
globe,
|
|
3
5
|
hardRain,
|
|
6
|
+
mystify,
|
|
7
|
+
pipes,
|
|
4
8
|
rainstorm,
|
|
9
|
+
reactionDiffusion,
|
|
5
10
|
spotlight,
|
|
6
11
|
warp
|
|
7
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-MIVXP2IL.js";
|
|
8
13
|
|
|
9
14
|
// src/idle-worker.ts
|
|
10
15
|
import { runIdleWorker } from "@idle-screens/core";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
16
|
+
|
|
17
|
+
// ../schema/dist/index.js
|
|
18
|
+
import {
|
|
19
|
+
createRng
|
|
20
|
+
} from "@idle-screens/core";
|
|
21
|
+
import { createRng as createRng2 } from "@idle-screens/core";
|
|
22
|
+
import { createRng as createRng3 } from "@idle-screens/core";
|
|
23
|
+
import { createRng as createRng4 } from "@idle-screens/core";
|
|
24
|
+
var SCHEMA_VERSION = 1;
|
|
25
|
+
var LIMITS = {
|
|
26
|
+
maxPerLayer: 400,
|
|
27
|
+
maxTotal: 800,
|
|
28
|
+
maxLayers: 36,
|
|
29
|
+
maxSpeed: 4e3,
|
|
30
|
+
// px/sec — bounds motion so nothing teleports
|
|
31
|
+
maxPulseAmp: 0.5,
|
|
32
|
+
// opacity breathing amplitude cap
|
|
33
|
+
minPulsePeriod: 500,
|
|
34
|
+
// ms — caps pulse at 2 Hz (WCAG flash threshold is 3 Hz)
|
|
35
|
+
maxSpin: 360,
|
|
36
|
+
// degrees/sec — one full revolution per second
|
|
37
|
+
maxGrowAmp: 0.8,
|
|
38
|
+
// size breathing amplitude cap (fraction of base size)
|
|
39
|
+
maxOrbitSpeed: 180,
|
|
40
|
+
// degrees/sec — half a revolution per second
|
|
41
|
+
maxLinksK: 8,
|
|
42
|
+
maxLinkLayerCount: 200,
|
|
43
|
+
minCyclePeriod: 500,
|
|
44
|
+
// ms — same flash-safety floor as pulse
|
|
45
|
+
referenceViewport: 1080,
|
|
46
|
+
// for validating viewport-unit dimensional caps
|
|
47
|
+
maxTrailLength: 5e3,
|
|
48
|
+
// ms — cap trail duration
|
|
49
|
+
maxTrailSamples: 24,
|
|
50
|
+
// dots per trail
|
|
51
|
+
minDriftPeriod: 1e4,
|
|
52
|
+
// ms — background drift floor (10 s)
|
|
53
|
+
maxDriftAmount: 0.3,
|
|
54
|
+
// fraction of gradient stop shift
|
|
55
|
+
maxGhosting: 0.95,
|
|
56
|
+
// frame persistence cap — bounds the seek warm-up replay
|
|
57
|
+
maxGhostReplayFrames: 120,
|
|
58
|
+
// fixed-step frames replayed on a non-contiguous seek
|
|
59
|
+
maxMeander: 500,
|
|
60
|
+
// px — wander harmonic amplitude cap (viewport cap: /referenceViewport)
|
|
61
|
+
maxWarpSpeed: 1.5,
|
|
62
|
+
// depth-units/sec — full near-to-far span in ~0.7 s at max
|
|
63
|
+
minPathPoints: 2,
|
|
64
|
+
maxPathPoints: 24,
|
|
65
|
+
minPathDuration: 2e3,
|
|
66
|
+
// ms — a path lap can't be faster than this
|
|
67
|
+
maxGridColumns: 100
|
|
68
|
+
};
|
|
69
|
+
var HEX = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
70
|
+
var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
71
|
+
var isStr = (v) => typeof v === "string";
|
|
72
|
+
var isNum = (v) => typeof v === "number" && Number.isFinite(v);
|
|
73
|
+
var isRange = (v) => Array.isArray(v) && v.length === 2 && isNum(v[0]) && isNum(v[1]) && v[0] <= v[1];
|
|
74
|
+
var KNOWN_TOP = /* @__PURE__ */ new Set(["schemaVersion", "id", "label", "seed", "motionIntensity", "units", "referenceViewport", "background", "layers", "ghosting"]);
|
|
75
|
+
var KNOWN_LAYER = /* @__PURE__ */ new Set([
|
|
76
|
+
"count",
|
|
77
|
+
"sprite",
|
|
78
|
+
"motion",
|
|
79
|
+
"size",
|
|
80
|
+
"wrap",
|
|
81
|
+
"flip",
|
|
82
|
+
"alpha",
|
|
83
|
+
"blend",
|
|
84
|
+
"region",
|
|
85
|
+
"pulse",
|
|
86
|
+
"spin",
|
|
87
|
+
"grow",
|
|
88
|
+
"key",
|
|
89
|
+
"position",
|
|
90
|
+
"trail",
|
|
91
|
+
"links",
|
|
92
|
+
"layout",
|
|
93
|
+
"life"
|
|
94
|
+
]);
|
|
95
|
+
var KNOWN_CIRCLE = /* @__PURE__ */ new Set(["kind", "radius", "color", "soft", "colors", "colorWeights"]);
|
|
96
|
+
var KNOWN_RING = /* @__PURE__ */ new Set(["kind", "radius", "color", "width", "colors", "colorWeights"]);
|
|
97
|
+
var KNOWN_STREAK = /* @__PURE__ */ new Set(["kind", "length", "color", "width", "colors", "colorWeights"]);
|
|
98
|
+
var KNOWN_RECT = /* @__PURE__ */ new Set(["kind", "width", "aspect", "color", "colors", "colorWeights"]);
|
|
99
|
+
var KNOWN_EMOJI = /* @__PURE__ */ new Set(["kind", "glyphs", "cycle"]);
|
|
100
|
+
var KNOWN_TEXT = /* @__PURE__ */ new Set(["kind", "strings", "color", "font", "align", "baseline", "maxWidth", "cycle"]);
|
|
101
|
+
var KNOWN_DRIFT = /* @__PURE__ */ new Set(["type", "speed", "angle", "bidirectional", "bob"]);
|
|
102
|
+
var KNOWN_RISE = /* @__PURE__ */ new Set(["type", "speed", "sway"]);
|
|
103
|
+
var KNOWN_BOUNCE = /* @__PURE__ */ new Set(["type", "speed"]);
|
|
104
|
+
var KNOWN_STATIC = /* @__PURE__ */ new Set(["type"]);
|
|
105
|
+
var KNOWN_ORBIT = /* @__PURE__ */ new Set(["type", "speed", "radius", "center"]);
|
|
106
|
+
var KNOWN_WANDER = /* @__PURE__ */ new Set(["type", "speed", "angle", "meander", "coherence"]);
|
|
107
|
+
var KNOWN_WARP = /* @__PURE__ */ new Set(["type", "speed", "center"]);
|
|
108
|
+
var KNOWN_PATH = /* @__PURE__ */ new Set(["type", "points", "duration", "curve", "closed", "scatter"]);
|
|
109
|
+
var KNOWN_BG_SOLID = /* @__PURE__ */ new Set(["type", "color"]);
|
|
110
|
+
var KNOWN_BG_GRADIENT = /* @__PURE__ */ new Set(["type", "stops", "band", "drift"]);
|
|
111
|
+
var LAYER_PROPS_ON_SPRITE = /* @__PURE__ */ new Set(["blend", "trail", "alpha", "pulse", "spin", "grow", "region", "links", "flip", "wrap", "key"]);
|
|
112
|
+
function unknownKeys(obj, known) {
|
|
113
|
+
return Object.keys(obj).filter((k) => !known.has(k));
|
|
114
|
+
}
|
|
115
|
+
function validateSpec(spec) {
|
|
116
|
+
const errors = [];
|
|
117
|
+
const warnings = [];
|
|
118
|
+
const err = (path, message) => void errors.push({ path, message });
|
|
119
|
+
const warn = (path, code, message) => void warnings.push({ path, code, message });
|
|
120
|
+
if (!isObj(spec)) return { valid: false, errors: [{ path: "", message: "spec must be an object" }], warnings: [] };
|
|
121
|
+
if (spec.schemaVersion !== SCHEMA_VERSION) err("schemaVersion", `must be ${SCHEMA_VERSION}`);
|
|
122
|
+
if (!isStr(spec.id) || spec.id.trim() === "") err("id", "must be a non-empty string");
|
|
123
|
+
if (!isStr(spec.label) || spec.label.trim() === "") err("label", "must be a non-empty string");
|
|
124
|
+
if (spec.seed !== void 0 && !isNum(spec.seed)) err("seed", "must be a number");
|
|
125
|
+
if (spec.motionIntensity !== void 0 && !["calm", "moderate", "energetic"].includes(spec.motionIntensity)) {
|
|
126
|
+
err("motionIntensity", "must be calm | moderate | energetic");
|
|
127
|
+
}
|
|
128
|
+
if (spec.units !== void 0 && spec.units !== "px" && spec.units !== "viewport") {
|
|
129
|
+
err("units", "must be 'px' | 'viewport'");
|
|
130
|
+
}
|
|
131
|
+
if (spec.referenceViewport !== void 0) {
|
|
132
|
+
if (!isNum(spec.referenceViewport) || spec.referenceViewport < 100 || spec.referenceViewport > 8640) {
|
|
133
|
+
err("referenceViewport", "must be a number between 100 and 8640");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (spec.ghosting !== void 0 && (!isNum(spec.ghosting) || spec.ghosting < 0 || spec.ghosting > LIMITS.maxGhosting)) {
|
|
137
|
+
err("ghosting", `must be a number 0..${LIMITS.maxGhosting}`);
|
|
138
|
+
}
|
|
139
|
+
for (const k of unknownKeys(spec, KNOWN_TOP)) {
|
|
140
|
+
warn(k, "unknown-property", `unknown top-level property '${k}' \u2014 will be ignored`);
|
|
141
|
+
}
|
|
142
|
+
if (spec.background !== void 0) validateBackground(spec.background, err, warn);
|
|
143
|
+
if (!Array.isArray(spec.layers) || spec.layers.length === 0) {
|
|
144
|
+
err("layers", "must be a non-empty array");
|
|
145
|
+
} else {
|
|
146
|
+
if (spec.layers.length > LIMITS.maxLayers) err("layers", `at most ${LIMITS.maxLayers} layers`);
|
|
147
|
+
let total = 0;
|
|
148
|
+
spec.layers.forEach((layer, i) => {
|
|
149
|
+
total += isObj(layer) && isNum(layer.count) ? layer.count : 0;
|
|
150
|
+
validateLayer(layer, `layers[${i}]`, err, warn, spec);
|
|
151
|
+
});
|
|
152
|
+
if (total > LIMITS.maxTotal) err("layers", `total entities ${total} exceeds cap ${LIMITS.maxTotal}`);
|
|
153
|
+
}
|
|
154
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
155
|
+
}
|
|
156
|
+
function color(v, path, err) {
|
|
157
|
+
if (!isStr(v) || !HEX.test(v)) err(path, "must be a hex colour like #0a3a52");
|
|
158
|
+
}
|
|
159
|
+
function validateBackground(bg, err, warn) {
|
|
160
|
+
if (!isObj(bg)) return err("background", "must be an object");
|
|
161
|
+
if (bg.type === "solid") {
|
|
162
|
+
color(bg.color, "background.color", err);
|
|
163
|
+
for (const k of unknownKeys(bg, KNOWN_BG_SOLID)) {
|
|
164
|
+
warn(`background.${k}`, "unknown-property", `unknown background property '${k}' \u2014 will be ignored`);
|
|
165
|
+
}
|
|
166
|
+
} else if (bg.type === "gradient") {
|
|
167
|
+
if (!Array.isArray(bg.stops) || bg.stops.length < 2) {
|
|
168
|
+
err("background.stops", "gradient needs at least 2 stops");
|
|
169
|
+
} else {
|
|
170
|
+
bg.stops.forEach((s, i) => {
|
|
171
|
+
if (!isObj(s) || !isNum(s.at) || s.at < 0 || s.at > 1) err(`background.stops[${i}].at`, "must be 0..1");
|
|
172
|
+
color(isObj(s) ? s.color : void 0, `background.stops[${i}].color`, err);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
if (bg.drift !== void 0) {
|
|
176
|
+
if (!isObj(bg.drift)) err("background.drift", "must be an object");
|
|
177
|
+
else {
|
|
178
|
+
if (!isNum(bg.drift.period) || bg.drift.period < LIMITS.minDriftPeriod) {
|
|
179
|
+
err("background.drift.period", `must be >= ${LIMITS.minDriftPeriod} ms`);
|
|
180
|
+
}
|
|
181
|
+
if (bg.drift.amount !== void 0 && (!isNum(bg.drift.amount) || bg.drift.amount <= 0 || bg.drift.amount > LIMITS.maxDriftAmount)) {
|
|
182
|
+
err("background.drift.amount", `must be > 0 and <= ${LIMITS.maxDriftAmount}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (bg.band !== void 0) {
|
|
187
|
+
if (!isObj(bg.band)) err("background.band", "must be an object");
|
|
188
|
+
else {
|
|
189
|
+
color(bg.band.color, "background.band.color", err);
|
|
190
|
+
if (!isNum(bg.band.height) || bg.band.height <= 0) err("background.band.height", "must be > 0");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
for (const k of unknownKeys(bg, KNOWN_BG_GRADIENT)) {
|
|
194
|
+
warn(`background.${k}`, "unknown-property", `unknown background property '${k}' \u2014 will be ignored`);
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
err("background.type", "must be solid | gradient");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function validateLayer(layer, path, err, warn, spec) {
|
|
201
|
+
if (!isObj(layer)) return err(path, "must be an object");
|
|
202
|
+
for (const k of unknownKeys(layer, KNOWN_LAYER)) {
|
|
203
|
+
if (k === "id") {
|
|
204
|
+
warn(`${path}.id`, "misplaced-property", `'id' is not a layer property \u2014 did you mean 'key'? Use 'key' to name a layer`);
|
|
205
|
+
} else if (k === "depth") {
|
|
206
|
+
warn(`${path}.depth`, "unknown-property", `'depth' is not a layer property \u2014 use motion type 'warp' for true perspective depth, or fake parallax with size/speed/alpha across layers`);
|
|
207
|
+
} else {
|
|
208
|
+
warn(`${path}.${k}`, "unknown-property", `unknown layer property '${k}' \u2014 will be ignored`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (!isNum(layer.count) || !Number.isInteger(layer.count) || layer.count < 1) {
|
|
212
|
+
err(`${path}.count`, "must be a positive integer");
|
|
213
|
+
} else if (layer.count > LIMITS.maxPerLayer) {
|
|
214
|
+
err(`${path}.count`, `at most ${LIMITS.maxPerLayer} per layer`);
|
|
215
|
+
}
|
|
216
|
+
if (layer.size !== void 0 && (!isRange(layer.size) || layer.size[0] <= 0)) {
|
|
217
|
+
err(`${path}.size`, "must be a [min,max] range of positive px");
|
|
218
|
+
}
|
|
219
|
+
if (layer.wrap !== void 0 && typeof layer.wrap !== "boolean") err(`${path}.wrap`, "must be a boolean");
|
|
220
|
+
if (layer.flip !== void 0 && typeof layer.flip !== "boolean") err(`${path}.flip`, "must be a boolean");
|
|
221
|
+
if (layer.alpha !== void 0 && (!isRange(layer.alpha) || layer.alpha[0] < 0 || layer.alpha[1] > 1)) {
|
|
222
|
+
err(`${path}.alpha`, "must be a [min,max] range within 0..1");
|
|
223
|
+
}
|
|
224
|
+
if (layer.blend !== void 0 && !["lighter", "screen", "multiply"].includes(layer.blend)) {
|
|
225
|
+
err(`${path}.blend`, "must be 'lighter' | 'screen' | 'multiply' when set");
|
|
226
|
+
}
|
|
227
|
+
if (layer.key !== void 0 && (!isStr(layer.key) || layer.key.trim() === "")) {
|
|
228
|
+
err(`${path}.key`, "must be a non-empty string");
|
|
229
|
+
}
|
|
230
|
+
if (layer.position !== void 0) {
|
|
231
|
+
if (!isObj(layer.position) || !isNum(layer.position.x) || !isNum(layer.position.y)) {
|
|
232
|
+
err(`${path}.position`, "must be {x, y} with numbers 0..1");
|
|
233
|
+
} else {
|
|
234
|
+
if (layer.position.x < 0 || layer.position.x > 1) err(`${path}.position.x`, "must be 0..1");
|
|
235
|
+
if (layer.position.y < 0 || layer.position.y > 1) err(`${path}.position.y`, "must be 0..1");
|
|
236
|
+
if (isNum(layer.count) && layer.count !== 1) err(`${path}.position`, "position requires count: 1");
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (layer.region !== void 0) {
|
|
240
|
+
if (!isObj(layer.region)) err(`${path}.region`, "must be an object");
|
|
241
|
+
else {
|
|
242
|
+
for (const axis of ["x", "y"]) {
|
|
243
|
+
const r = layer.region[axis];
|
|
244
|
+
if (r !== void 0 && (!isRange(r) || r[0] < 0 || r[1] > 1)) {
|
|
245
|
+
err(`${path}.region.${axis}`, "must be a [min,max] range within 0..1");
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (layer.pulse !== void 0) {
|
|
251
|
+
if (!isObj(layer.pulse)) err(`${path}.pulse`, "must be an object");
|
|
252
|
+
else {
|
|
253
|
+
if (!isNum(layer.pulse.amp) || layer.pulse.amp <= 0 || layer.pulse.amp > LIMITS.maxPulseAmp) {
|
|
254
|
+
err(`${path}.pulse.amp`, `must be within 0..${LIMITS.maxPulseAmp}`);
|
|
255
|
+
}
|
|
256
|
+
if (!isNum(layer.pulse.period) || layer.pulse.period < LIMITS.minPulsePeriod) {
|
|
257
|
+
err(`${path}.pulse.period`, `must be >= ${LIMITS.minPulsePeriod} ms (flash-safety floor)`);
|
|
258
|
+
}
|
|
259
|
+
if (layer.pulse.wave !== void 0) {
|
|
260
|
+
if (!isObj(layer.pulse.wave)) err(`${path}.pulse.wave`, "must be an object");
|
|
261
|
+
else {
|
|
262
|
+
if (!isNum(layer.pulse.wave.wavelength) || layer.pulse.wave.wavelength <= 0) {
|
|
263
|
+
err(`${path}.pulse.wave.wavelength`, "must be > 0 (px or viewport-units)");
|
|
264
|
+
}
|
|
265
|
+
if (layer.pulse.wave.angle !== void 0 && !isNum(layer.pulse.wave.angle)) {
|
|
266
|
+
err(`${path}.pulse.wave.angle`, "must be a number (degrees)");
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (layer.spin !== void 0) {
|
|
273
|
+
if (!isNum(layer.spin)) err(`${path}.spin`, "must be a number (degrees/sec)");
|
|
274
|
+
else if (Math.abs(layer.spin) > LIMITS.maxSpin) err(`${path}.spin`, `must be within \xB1${LIMITS.maxSpin} deg/sec`);
|
|
275
|
+
}
|
|
276
|
+
if (layer.grow !== void 0) {
|
|
277
|
+
if (!isObj(layer.grow)) err(`${path}.grow`, "must be an object");
|
|
278
|
+
else {
|
|
279
|
+
if (!isNum(layer.grow.amp) || layer.grow.amp <= 0 || layer.grow.amp > LIMITS.maxGrowAmp) {
|
|
280
|
+
err(`${path}.grow.amp`, `must be within 0..${LIMITS.maxGrowAmp}`);
|
|
281
|
+
}
|
|
282
|
+
if (!isNum(layer.grow.period) || layer.grow.period < LIMITS.minPulsePeriod) {
|
|
283
|
+
err(`${path}.grow.period`, `must be >= ${LIMITS.minPulsePeriod} ms (flash-safety floor)`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (layer.links !== void 0) {
|
|
288
|
+
if (!isObj(layer.links)) err(`${path}.links`, "must be an object");
|
|
289
|
+
else {
|
|
290
|
+
if (!isNum(layer.links.k) || !Number.isInteger(layer.links.k) || layer.links.k < 1 || layer.links.k > LIMITS.maxLinksK) {
|
|
291
|
+
err(`${path}.links.k`, `must be an integer 1..${LIMITS.maxLinksK}`);
|
|
292
|
+
}
|
|
293
|
+
if (!isNum(layer.links.maxDist) || layer.links.maxDist <= 0) {
|
|
294
|
+
err(`${path}.links.maxDist`, "must be > 0");
|
|
295
|
+
}
|
|
296
|
+
if (layer.links.color !== void 0) color(layer.links.color, `${path}.links.color`, err);
|
|
297
|
+
if (layer.links.alpha !== void 0 && (!isNum(layer.links.alpha) || layer.links.alpha < 0 || layer.links.alpha > 1)) {
|
|
298
|
+
err(`${path}.links.alpha`, "must be 0..1");
|
|
299
|
+
}
|
|
300
|
+
if (layer.links.width !== void 0 && (!isNum(layer.links.width) || layer.links.width <= 0)) {
|
|
301
|
+
err(`${path}.links.width`, "must be > 0");
|
|
302
|
+
}
|
|
303
|
+
if (layer.links.mode !== void 0 && !["nearest", "chain", "random"].includes(layer.links.mode)) {
|
|
304
|
+
err(`${path}.links.mode`, "must be 'nearest' | 'chain' | 'random'");
|
|
305
|
+
}
|
|
306
|
+
if (layer.links.falloff !== void 0 && typeof layer.links.falloff !== "boolean") {
|
|
307
|
+
err(`${path}.links.falloff`, "must be a boolean");
|
|
308
|
+
}
|
|
309
|
+
if (layer.links.closed !== void 0 && typeof layer.links.closed !== "boolean") {
|
|
310
|
+
err(`${path}.links.closed`, "must be a boolean");
|
|
311
|
+
}
|
|
312
|
+
if (isNum(layer.count) && layer.count > LIMITS.maxLinkLayerCount) {
|
|
313
|
+
err(`${path}.links`, `layer count must be <= ${LIMITS.maxLinkLayerCount} when links is set`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (layer.layout !== void 0) {
|
|
318
|
+
if (!isObj(layer.layout) || layer.layout.type !== "grid") {
|
|
319
|
+
err(`${path}.layout`, "must be an object with type: 'grid'");
|
|
320
|
+
} else {
|
|
321
|
+
if (layer.layout.columns !== void 0 && (!isNum(layer.layout.columns) || !Number.isInteger(layer.layout.columns) || layer.layout.columns < 1 || layer.layout.columns > LIMITS.maxGridColumns)) {
|
|
322
|
+
err(`${path}.layout.columns`, `must be an integer 1..${LIMITS.maxGridColumns}`);
|
|
323
|
+
}
|
|
324
|
+
const jit = layer.layout.jitter;
|
|
325
|
+
if (jit !== void 0) {
|
|
326
|
+
const jitterOk = (v) => isNum(v) && v >= 0 && v <= 1;
|
|
327
|
+
if (isNum(jit)) {
|
|
328
|
+
if (!jitterOk(jit)) err(`${path}.layout.jitter`, "must be 0..1");
|
|
329
|
+
} else if (isObj(jit)) {
|
|
330
|
+
if (jit.x !== void 0 && !jitterOk(jit.x)) err(`${path}.layout.jitter.x`, "must be 0..1");
|
|
331
|
+
if (jit.y !== void 0 && !jitterOk(jit.y)) err(`${path}.layout.jitter.y`, "must be 0..1");
|
|
332
|
+
} else {
|
|
333
|
+
err(`${path}.layout.jitter`, "must be a number 0..1 or { x?, y? }");
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (layer.position !== void 0) {
|
|
337
|
+
warn(`${path}.layout`, "layout-with-position", "position overrides layout for the single entity \u2014 layout has no effect");
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
if (layer.life !== void 0) {
|
|
342
|
+
if (!isObj(layer.life)) err(`${path}.life`, "must be an object");
|
|
343
|
+
else {
|
|
344
|
+
if (layer.life.enter !== void 0 && (!isNum(layer.life.enter) || layer.life.enter < 0)) {
|
|
345
|
+
err(`${path}.life.enter`, "must be >= 0 (ms)");
|
|
346
|
+
}
|
|
347
|
+
if (layer.life.exit !== void 0 && (!isNum(layer.life.exit) || layer.life.exit < 0)) {
|
|
348
|
+
err(`${path}.life.exit`, "must be >= 0 (ms)");
|
|
349
|
+
}
|
|
350
|
+
if (isNum(layer.life.enter) && isNum(layer.life.exit) && layer.life.exit <= layer.life.enter) {
|
|
351
|
+
err(`${path}.life.exit`, "must be greater than life.enter");
|
|
352
|
+
}
|
|
353
|
+
if (layer.life.fade !== void 0 && (!isNum(layer.life.fade) || layer.life.fade < 0)) {
|
|
354
|
+
err(`${path}.life.fade`, "must be >= 0 (ms)");
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (layer.trail !== void 0) {
|
|
359
|
+
if (!isObj(layer.trail)) err(`${path}.trail`, "must be an object");
|
|
360
|
+
else {
|
|
361
|
+
if (!isNum(layer.trail.length) || layer.trail.length <= 0 || layer.trail.length > LIMITS.maxTrailLength) {
|
|
362
|
+
err(`${path}.trail.length`, `must be > 0 and <= ${LIMITS.maxTrailLength} ms`);
|
|
363
|
+
}
|
|
364
|
+
if (layer.trail.fade !== void 0 && (!isNum(layer.trail.fade) || layer.trail.fade < 0 || layer.trail.fade > 1)) {
|
|
365
|
+
err(`${path}.trail.fade`, "must be 0..1");
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
validateSprite(layer.sprite, `${path}.sprite`, err, warn);
|
|
370
|
+
validateMotion(layer.motion, `${path}.motion`, err, warn, spec);
|
|
371
|
+
}
|
|
372
|
+
function validateSprite(sprite, path, err, warn) {
|
|
373
|
+
if (!isObj(sprite)) return err(path, "must be an object");
|
|
374
|
+
let knownSet;
|
|
375
|
+
if (sprite.kind === "emoji") {
|
|
376
|
+
knownSet = KNOWN_EMOJI;
|
|
377
|
+
if (!Array.isArray(sprite.glyphs) || sprite.glyphs.length === 0 || !sprite.glyphs.every(isStr)) {
|
|
378
|
+
err(`${path}.glyphs`, "must be a non-empty array of strings");
|
|
379
|
+
}
|
|
380
|
+
validateCycle(sprite, path, err);
|
|
381
|
+
} else if (sprite.kind === "text") {
|
|
382
|
+
knownSet = KNOWN_TEXT;
|
|
383
|
+
if (!Array.isArray(sprite.strings) || sprite.strings.length === 0 || !sprite.strings.every(isStr)) {
|
|
384
|
+
err(`${path}.strings`, "must be a non-empty array of strings");
|
|
385
|
+
}
|
|
386
|
+
if (sprite.color !== void 0) color(sprite.color, `${path}.color`, err);
|
|
387
|
+
if (sprite.align !== void 0 && !["left", "center", "right"].includes(sprite.align)) {
|
|
388
|
+
err(`${path}.align`, "must be left | center | right");
|
|
389
|
+
}
|
|
390
|
+
if (sprite.baseline !== void 0 && !["top", "middle", "bottom"].includes(sprite.baseline)) {
|
|
391
|
+
err(`${path}.baseline`, "must be top | middle | bottom");
|
|
392
|
+
}
|
|
393
|
+
if (sprite.maxWidth !== void 0 && (!isNum(sprite.maxWidth) || sprite.maxWidth <= 0)) {
|
|
394
|
+
err(`${path}.maxWidth`, "must be a positive number");
|
|
395
|
+
}
|
|
396
|
+
validateCycle(sprite, path, err);
|
|
397
|
+
} else if (sprite.kind === "circle") {
|
|
398
|
+
knownSet = KNOWN_CIRCLE;
|
|
399
|
+
if (!isRange(sprite.radius) || sprite.radius[0] <= 0) err(`${path}.radius`, "must be a [min,max] range of positive px");
|
|
400
|
+
color(sprite.color, `${path}.color`, err);
|
|
401
|
+
if (sprite.soft !== void 0 && typeof sprite.soft !== "boolean") err(`${path}.soft`, "must be a boolean");
|
|
402
|
+
validatePalette(sprite, path, err);
|
|
403
|
+
} else if (sprite.kind === "ring") {
|
|
404
|
+
knownSet = KNOWN_RING;
|
|
405
|
+
if (!isRange(sprite.radius) || sprite.radius[0] <= 0) err(`${path}.radius`, "must be a [min,max] range of positive px");
|
|
406
|
+
color(sprite.color, `${path}.color`, err);
|
|
407
|
+
if (sprite.width !== void 0 && (!isNum(sprite.width) || sprite.width <= 0)) err(`${path}.width`, "must be > 0");
|
|
408
|
+
validatePalette(sprite, path, err);
|
|
409
|
+
} else if (sprite.kind === "streak") {
|
|
410
|
+
knownSet = KNOWN_STREAK;
|
|
411
|
+
if (!isRange(sprite.length) || sprite.length[0] <= 0) err(`${path}.length`, "must be a [min,max] range of positive px");
|
|
412
|
+
color(sprite.color, `${path}.color`, err);
|
|
413
|
+
if (sprite.width !== void 0 && (!isNum(sprite.width) || sprite.width <= 0)) err(`${path}.width`, "must be > 0");
|
|
414
|
+
validatePalette(sprite, path, err);
|
|
415
|
+
} else if (sprite.kind === "rect") {
|
|
416
|
+
knownSet = KNOWN_RECT;
|
|
417
|
+
if (!isRange(sprite.width) || sprite.width[0] <= 0) err(`${path}.width`, "must be a [min,max] range of positive px");
|
|
418
|
+
if (sprite.aspect !== void 0 && (!isRange(sprite.aspect) || sprite.aspect[0] <= 0)) {
|
|
419
|
+
err(`${path}.aspect`, "must be a [min,max] range of positive height/width ratios");
|
|
420
|
+
}
|
|
421
|
+
color(sprite.color, `${path}.color`, err);
|
|
422
|
+
validatePalette(sprite, path, err);
|
|
423
|
+
} else {
|
|
424
|
+
err(`${path}.kind`, "must be emoji | text | circle | ring | streak | rect");
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
for (const k of unknownKeys(sprite, knownSet)) {
|
|
428
|
+
if (LAYER_PROPS_ON_SPRITE.has(k)) {
|
|
429
|
+
warn(`${path}.${k}`, "misplaced-property", `'${k}' belongs on the layer, not inside sprite \u2014 move it up one level`);
|
|
430
|
+
} else {
|
|
431
|
+
warn(`${path}.${k}`, "unknown-property", `unknown sprite property '${k}' \u2014 will be ignored`);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function validatePalette(sprite, path, err) {
|
|
436
|
+
if (sprite.colors !== void 0) {
|
|
437
|
+
if (!Array.isArray(sprite.colors) || sprite.colors.length === 0) {
|
|
438
|
+
err(`${path}.colors`, "must be a non-empty array of hex colours");
|
|
439
|
+
} else {
|
|
440
|
+
sprite.colors.forEach((c, ci) => color(c, `${path}.colors[${ci}]`, err));
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (sprite.colorWeights !== void 0) {
|
|
444
|
+
if (!Array.isArray(sprite.colors)) {
|
|
445
|
+
err(`${path}.colorWeights`, "requires colors to be set");
|
|
446
|
+
} else if (!Array.isArray(sprite.colorWeights) || sprite.colorWeights.length !== sprite.colors.length) {
|
|
447
|
+
err(`${path}.colorWeights`, "must be an array the same length as colors");
|
|
448
|
+
} else if (!sprite.colorWeights.every((v) => isNum(v) && v >= 0) || !sprite.colorWeights.some((v) => isNum(v) && v > 0)) {
|
|
449
|
+
err(`${path}.colorWeights`, "weights must be >= 0 with at least one > 0");
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function validateCycle(sprite, path, err) {
|
|
454
|
+
if (sprite.cycle === void 0) return;
|
|
455
|
+
if (!isObj(sprite.cycle)) return err(`${path}.cycle`, "must be an object");
|
|
456
|
+
if (!isNum(sprite.cycle.period) || sprite.cycle.period < LIMITS.minCyclePeriod) {
|
|
457
|
+
err(`${path}.cycle.period`, `must be >= ${LIMITS.minCyclePeriod} ms (flash-safety floor)`);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function validateMotion(motion, path, err, warn, spec) {
|
|
461
|
+
if (!isObj(motion)) return err(path, "must be an object");
|
|
462
|
+
const isViewport = !isObj(spec) || spec.units !== "px";
|
|
463
|
+
const refVp = isObj(spec) && isNum(spec.referenceViewport) ? spec.referenceViewport : LIMITS.referenceViewport;
|
|
464
|
+
const speedCap = isViewport ? LIMITS.maxSpeed / refVp : LIMITS.maxSpeed;
|
|
465
|
+
const speedOk = (v, p) => {
|
|
466
|
+
if (!isRange(v)) err(p, "must be a [min,max] range");
|
|
467
|
+
else if (v[0] < 0) err(p, "speed lower bound must be >= 0");
|
|
468
|
+
else if (v[1] > speedCap) err(p, `speed exceeds cap ${isViewport ? speedCap.toFixed(2) + " viewport-units/sec" : LIMITS.maxSpeed + " px/sec"}`);
|
|
469
|
+
};
|
|
470
|
+
let knownSet;
|
|
471
|
+
if (motion.type === "drift") {
|
|
472
|
+
knownSet = KNOWN_DRIFT;
|
|
473
|
+
speedOk(motion.speed, `${path}.speed`);
|
|
474
|
+
if (motion.angle !== void 0 && !isNum(motion.angle)) err(`${path}.angle`, "must be a number (degrees)");
|
|
475
|
+
if (motion.bidirectional !== void 0 && typeof motion.bidirectional !== "boolean") err(`${path}.bidirectional`, "must be a boolean");
|
|
476
|
+
if (motion.bob !== void 0 && !isNum(motion.bob)) err(`${path}.bob`, "must be a number");
|
|
477
|
+
if (isRange(motion.speed) && motion.speed[1] < 1 && !isViewport) {
|
|
478
|
+
warn(`${path}.speed`, "near-zero-speed", `max speed is ${motion.speed[1]} px/sec \u2014 entities will appear frozen. Typical range: 10\u2013200 px/sec`);
|
|
479
|
+
}
|
|
480
|
+
} else if (motion.type === "rise") {
|
|
481
|
+
knownSet = KNOWN_RISE;
|
|
482
|
+
speedOk(motion.speed, `${path}.speed`);
|
|
483
|
+
if (motion.sway !== void 0 && !isNum(motion.sway)) err(`${path}.sway`, "must be a number");
|
|
484
|
+
if (isRange(motion.speed) && motion.speed[1] < 1 && !isViewport) {
|
|
485
|
+
warn(`${path}.speed`, "near-zero-speed", `max speed is ${motion.speed[1]} px/sec \u2014 entities will appear frozen. Typical range: 5\u201380 px/sec`);
|
|
486
|
+
}
|
|
487
|
+
} else if (motion.type === "bounce") {
|
|
488
|
+
knownSet = KNOWN_BOUNCE;
|
|
489
|
+
speedOk(motion.speed, `${path}.speed`);
|
|
490
|
+
if (isRange(motion.speed) && motion.speed[1] < 1 && !isViewport) {
|
|
491
|
+
warn(`${path}.speed`, "near-zero-speed", `max speed is ${motion.speed[1]} px/sec \u2014 entities will appear frozen. Typical range: 20\u2013150 px/sec`);
|
|
492
|
+
}
|
|
493
|
+
} else if (motion.type === "static") {
|
|
494
|
+
knownSet = KNOWN_STATIC;
|
|
495
|
+
} else if (motion.type === "orbit") {
|
|
496
|
+
knownSet = KNOWN_ORBIT;
|
|
497
|
+
if (!isRange(motion.speed)) err(`${path}.speed`, "must be a [min,max] range");
|
|
498
|
+
else {
|
|
499
|
+
if (Math.abs(motion.speed[0]) > LIMITS.maxOrbitSpeed || Math.abs(motion.speed[1]) > LIMITS.maxOrbitSpeed) err(`${path}.speed`, `orbit speed exceeds cap ${LIMITS.maxOrbitSpeed} deg/sec`);
|
|
500
|
+
if (Math.max(Math.abs(motion.speed[0]), Math.abs(motion.speed[1])) < 1) {
|
|
501
|
+
warn(`${path}.speed`, "near-zero-speed", `orbit speed is near zero \u2014 entities will appear frozen. Typical range: 5\u201360 deg/sec`);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (!isRange(motion.radius) || motion.radius[0] <= 0) err(`${path}.radius`, "must be a [min,max] range of positive px");
|
|
505
|
+
if (motion.center !== void 0) {
|
|
506
|
+
if (!isObj(motion.center)) {
|
|
507
|
+
err(`${path}.center`, "must be {x, y} (0..1) or { layer: key }");
|
|
508
|
+
} else if ("layer" in motion.center) {
|
|
509
|
+
if (!isStr(motion.center.layer) || motion.center.layer.trim() === "") {
|
|
510
|
+
err(`${path}.center.layer`, "must be a non-empty layer key");
|
|
511
|
+
} else if (isObj(spec) && Array.isArray(spec.layers)) {
|
|
512
|
+
const layers = spec.layers;
|
|
513
|
+
const parent = layers.find((l) => isObj(l) && l.key === motion.center.layer);
|
|
514
|
+
if (!parent) {
|
|
515
|
+
err(`${path}.center.layer`, `no layer with key '${motion.center.layer}'`);
|
|
516
|
+
} else {
|
|
517
|
+
if (parent.count !== 1) err(`${path}.center.layer`, "parent layer must have count: 1");
|
|
518
|
+
const pm = parent.motion;
|
|
519
|
+
if (isObj(pm) && pm.type === "orbit" && isObj(pm.center) && "layer" in pm.center) {
|
|
520
|
+
err(`${path}.center.layer`, "parent may not itself orbit a layer (one level deep only)");
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
} else if (!isNum(motion.center.x) || !isNum(motion.center.y)) {
|
|
525
|
+
err(`${path}.center`, "must be {x, y} with numbers 0..1");
|
|
526
|
+
} else {
|
|
527
|
+
if (motion.center.x < 0 || motion.center.x > 1) err(`${path}.center.x`, "must be 0..1");
|
|
528
|
+
if (motion.center.y < 0 || motion.center.y > 1) err(`${path}.center.y`, "must be 0..1");
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
} else if (motion.type === "wander") {
|
|
532
|
+
knownSet = KNOWN_WANDER;
|
|
533
|
+
speedOk(motion.speed, `${path}.speed`);
|
|
534
|
+
if (motion.angle !== void 0 && !isNum(motion.angle)) err(`${path}.angle`, "must be a number (degrees)");
|
|
535
|
+
const meanderCap = isViewport ? LIMITS.maxMeander / refVp : LIMITS.maxMeander;
|
|
536
|
+
if (motion.meander !== void 0 && (!isNum(motion.meander) || motion.meander <= 0 || motion.meander > meanderCap)) {
|
|
537
|
+
err(`${path}.meander`, `must be > 0 and <= ${isViewport ? meanderCap.toFixed(3) + " viewport-units" : LIMITS.maxMeander + " px"}`);
|
|
538
|
+
}
|
|
539
|
+
if (motion.coherence !== void 0 && (!isNum(motion.coherence) || motion.coherence < 0 || motion.coherence > 1)) {
|
|
540
|
+
err(`${path}.coherence`, "must be 0..1");
|
|
541
|
+
}
|
|
542
|
+
} else if (motion.type === "warp") {
|
|
543
|
+
knownSet = KNOWN_WARP;
|
|
544
|
+
if (!isRange(motion.speed) || motion.speed[0] < 0) err(`${path}.speed`, "must be a [min,max] range >= 0 (depth-units/sec)");
|
|
545
|
+
else if (motion.speed[1] > LIMITS.maxWarpSpeed) err(`${path}.speed`, `warp speed exceeds cap ${LIMITS.maxWarpSpeed} depth-units/sec`);
|
|
546
|
+
if (motion.center !== void 0) {
|
|
547
|
+
if (!isObj(motion.center) || !isNum(motion.center.x) || !isNum(motion.center.y)) {
|
|
548
|
+
err(`${path}.center`, "must be {x, y} with numbers 0..1");
|
|
549
|
+
} else {
|
|
550
|
+
if (motion.center.x < 0 || motion.center.x > 1) err(`${path}.center.x`, "must be 0..1");
|
|
551
|
+
if (motion.center.y < 0 || motion.center.y > 1) err(`${path}.center.y`, "must be 0..1");
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
} else if (motion.type === "path") {
|
|
555
|
+
knownSet = KNOWN_PATH;
|
|
556
|
+
if (!Array.isArray(motion.points) || motion.points.length < LIMITS.minPathPoints || motion.points.length > LIMITS.maxPathPoints) {
|
|
557
|
+
err(`${path}.points`, `must be an array of ${LIMITS.minPathPoints}..${LIMITS.maxPathPoints} points`);
|
|
558
|
+
} else {
|
|
559
|
+
motion.points.forEach((p, pi) => {
|
|
560
|
+
if (!isObj(p) || !isNum(p.x) || !isNum(p.y) || p.x < 0 || p.x > 1 || p.y < 0 || p.y > 1) {
|
|
561
|
+
err(`${path}.points[${pi}]`, "must be {x, y} with numbers 0..1");
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
if (!isNum(motion.duration) || motion.duration < LIMITS.minPathDuration) {
|
|
566
|
+
err(`${path}.duration`, `must be >= ${LIMITS.minPathDuration} ms`);
|
|
567
|
+
}
|
|
568
|
+
if (motion.curve !== void 0 && motion.curve !== "linear" && motion.curve !== "smooth") {
|
|
569
|
+
err(`${path}.curve`, "must be 'linear' | 'smooth'");
|
|
570
|
+
}
|
|
571
|
+
if (motion.closed !== void 0 && typeof motion.closed !== "boolean") err(`${path}.closed`, "must be a boolean");
|
|
572
|
+
const scatterCap = isViewport ? LIMITS.maxMeander / refVp : LIMITS.maxMeander;
|
|
573
|
+
if (motion.scatter !== void 0 && (!isNum(motion.scatter) || motion.scatter <= 0 || motion.scatter > scatterCap)) {
|
|
574
|
+
err(`${path}.scatter`, `must be > 0 and <= ${isViewport ? scatterCap.toFixed(3) + " viewport-units" : LIMITS.maxMeander + " px"}`);
|
|
575
|
+
}
|
|
576
|
+
} else {
|
|
577
|
+
err(`${path}.type`, "must be drift | rise | bounce | static | orbit | wander | warp | path");
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
for (const k of unknownKeys(motion, knownSet)) {
|
|
581
|
+
warn(`${path}.${k}`, "unknown-property", `unknown motion property '${k}' \u2014 will be ignored`);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
function assertValidSpec(spec) {
|
|
585
|
+
const r = validateSpec(spec);
|
|
586
|
+
if (!r.valid) {
|
|
587
|
+
throw new Error(`invalid saver spec:
|
|
588
|
+
${r.errors.map((e) => ` ${e.path || "<root>"}: ${e.message}`).join("\n")}`);
|
|
589
|
+
}
|
|
590
|
+
return spec;
|
|
591
|
+
}
|
|
592
|
+
var WARP_NEAR = 0.08;
|
|
593
|
+
var WARP_MAX_SCALE = 8;
|
|
594
|
+
function spriteVariants(sprite) {
|
|
595
|
+
if (sprite.kind === "emoji") return sprite.glyphs.length;
|
|
596
|
+
if (sprite.kind === "text") return sprite.strings.length;
|
|
597
|
+
return 1;
|
|
598
|
+
}
|
|
599
|
+
var OCT_AMP = [1, 0.5, 0.25];
|
|
600
|
+
var OCT_PERIOD = [
|
|
601
|
+
[6e3, 14e3],
|
|
602
|
+
[3e3, 7e3],
|
|
603
|
+
[1500, 4e3]
|
|
604
|
+
];
|
|
605
|
+
function drawOsc(rng, amp) {
|
|
606
|
+
const osc = { ax: [], fx: [], phx: [], ay: [], fy: [], phy: [] };
|
|
607
|
+
for (let i = 0; i < 3; i++) {
|
|
608
|
+
osc.ax.push(amp * OCT_AMP[i] * rng.range(0.6, 1.4));
|
|
609
|
+
osc.fx.push(2 * Math.PI / rng.range(OCT_PERIOD[i][0], OCT_PERIOD[i][1]));
|
|
610
|
+
osc.phx.push(rng.range(0, Math.PI * 2));
|
|
611
|
+
}
|
|
612
|
+
for (let i = 0; i < 3; i++) {
|
|
613
|
+
osc.ay.push(amp * OCT_AMP[i] * rng.range(0.6, 1.4));
|
|
614
|
+
osc.fy.push(2 * Math.PI / rng.range(OCT_PERIOD[i][0], OCT_PERIOD[i][1]));
|
|
615
|
+
osc.phy.push(rng.range(0, Math.PI * 2));
|
|
616
|
+
}
|
|
617
|
+
return osc;
|
|
618
|
+
}
|
|
619
|
+
function weightedIndex(u, weights) {
|
|
620
|
+
const total = weights.reduce((a, b) => a + b, 0);
|
|
621
|
+
let acc = 0;
|
|
622
|
+
for (let i = 0; i < weights.length; i++) {
|
|
623
|
+
acc += weights[i] / total;
|
|
624
|
+
if (u < acc) return i;
|
|
625
|
+
}
|
|
626
|
+
return weights.length - 1;
|
|
627
|
+
}
|
|
628
|
+
function buildEntities(layer, rng, w, h, scale = 1, countScale = 1) {
|
|
629
|
+
const effectiveCount = countScale === 1 ? layer.count : Math.max(1, Math.min(
|
|
630
|
+
Math.round(layer.count * countScale),
|
|
631
|
+
layer.links ? LIMITS.maxLinkLayerCount : LIMITS.maxPerLayer
|
|
632
|
+
));
|
|
633
|
+
const [smin, smax] = layer.size ?? [20, 40];
|
|
634
|
+
const variants = spriteVariants(layer.sprite);
|
|
635
|
+
const sprite = layer.sprite;
|
|
636
|
+
const spriteColors = sprite.kind === "circle" || sprite.kind === "ring" || sprite.kind === "streak" || sprite.kind === "rect" ? sprite.colors : void 0;
|
|
637
|
+
const colorWeights = sprite.kind === "circle" || sprite.kind === "ring" || sprite.kind === "streak" || sprite.kind === "rect" ? sprite.colorWeights : void 0;
|
|
638
|
+
const colorsLen = spriteColors?.length ?? 0;
|
|
639
|
+
const cycle = sprite.kind === "emoji" || sprite.kind === "text" ? sprite.cycle : void 0;
|
|
640
|
+
const mSpec = layer.motion;
|
|
641
|
+
let sharedOsc = null;
|
|
642
|
+
let meanderPx = 0;
|
|
643
|
+
if (mSpec.type === "wander") {
|
|
644
|
+
meanderPx = (mSpec.meander ?? (scale === 1 ? 60 : 0.05)) * scale;
|
|
645
|
+
sharedOsc = drawOsc(rng, meanderPx);
|
|
646
|
+
}
|
|
647
|
+
let pathPts = null;
|
|
648
|
+
if (mSpec.type === "path") {
|
|
649
|
+
pathPts = mSpec.points.map((p) => ({ x: p.x * w, y: p.y * h }));
|
|
650
|
+
}
|
|
651
|
+
const layout = layer.layout;
|
|
652
|
+
let gridCols = 0;
|
|
653
|
+
let cellW = 0;
|
|
654
|
+
let cellH = 0;
|
|
655
|
+
let gridX0 = 0;
|
|
656
|
+
let gridY0 = 0;
|
|
657
|
+
if (layout?.type === "grid") {
|
|
658
|
+
const [rx0, rx1] = layer.region?.x ?? [0, 1];
|
|
659
|
+
const [ry0, ry1] = layer.region?.y ?? [0, 1];
|
|
660
|
+
const gw = Math.max(1, (rx1 - rx0) * w);
|
|
661
|
+
const gh = Math.max(1, (ry1 - ry0) * h);
|
|
662
|
+
gridCols = Math.min(
|
|
663
|
+
layout.columns ?? Math.max(1, Math.round(Math.sqrt(effectiveCount * (gw / gh)))),
|
|
664
|
+
LIMITS.maxGridColumns
|
|
665
|
+
);
|
|
666
|
+
const gridRows = Math.max(1, Math.ceil(effectiveCount / gridCols));
|
|
667
|
+
cellW = gw / gridCols;
|
|
668
|
+
cellH = gh / gridRows;
|
|
669
|
+
gridX0 = rx0 * w;
|
|
670
|
+
gridY0 = ry0 * h;
|
|
671
|
+
}
|
|
672
|
+
const out = [];
|
|
673
|
+
for (let i = 0; i < effectiveCount; i++) {
|
|
674
|
+
const size = sprite.kind === "circle" || sprite.kind === "ring" ? rng.range(sprite.radius[0], sprite.radius[1]) * 2 * scale : sprite.kind === "streak" ? rng.range(sprite.length[0], sprite.length[1]) * scale : sprite.kind === "rect" ? rng.range(sprite.width[0], sprite.width[1]) * scale : rng.range(smin, smax) * scale;
|
|
675
|
+
const size2 = sprite.kind === "rect" ? size * (sprite.aspect ? rng.range(sprite.aspect[0], sprite.aspect[1]) : 1) : void 0;
|
|
676
|
+
let vx = 0;
|
|
677
|
+
let vy = 0;
|
|
678
|
+
let bob = 0;
|
|
679
|
+
let motion = "drift";
|
|
680
|
+
let warpParams;
|
|
681
|
+
let pathPhase = 0;
|
|
682
|
+
let pathOffX = 0;
|
|
683
|
+
let pathOffY = 0;
|
|
684
|
+
const m = layer.motion;
|
|
685
|
+
if (m.type === "static") {
|
|
686
|
+
motion = "static";
|
|
687
|
+
} else if (m.type === "drift") {
|
|
688
|
+
const s = rng.range(m.speed[0], m.speed[1]) * scale;
|
|
689
|
+
let angle = (m.angle ?? 0) * Math.PI / 180;
|
|
690
|
+
if (m.bidirectional && rng.next() < 0.5) angle = Math.PI - angle;
|
|
691
|
+
vx = s * Math.cos(angle);
|
|
692
|
+
vy = s * Math.sin(angle);
|
|
693
|
+
bob = (m.bob ?? 0) * scale;
|
|
694
|
+
} else if (m.type === "rise") {
|
|
695
|
+
motion = "rise";
|
|
696
|
+
vy = -rng.range(m.speed[0], m.speed[1]) * scale;
|
|
697
|
+
bob = (m.sway ?? 0) * scale;
|
|
698
|
+
} else if (m.type === "bounce") {
|
|
699
|
+
motion = "bounce";
|
|
700
|
+
const s = rng.range(m.speed[0], m.speed[1]) * scale;
|
|
701
|
+
const a = rng.range(0, Math.PI * 2);
|
|
702
|
+
vx = s * Math.cos(a);
|
|
703
|
+
vy = s * Math.sin(a);
|
|
704
|
+
} else if (m.type === "orbit") {
|
|
705
|
+
motion = "orbit";
|
|
706
|
+
vx = rng.range(m.speed[0], m.speed[1]);
|
|
707
|
+
} else if (m.type === "wander") {
|
|
708
|
+
motion = "wander";
|
|
709
|
+
const s = rng.range(m.speed[0], m.speed[1]) * scale;
|
|
710
|
+
const heading = m.angle !== void 0 ? m.angle * Math.PI / 180 : rng.range(0, Math.PI * 2);
|
|
711
|
+
vx = s * Math.cos(heading);
|
|
712
|
+
vy = s * Math.sin(heading);
|
|
713
|
+
} else if (m.type === "warp") {
|
|
714
|
+
motion = "warp";
|
|
715
|
+
const vz = rng.range(m.speed[0], m.speed[1]);
|
|
716
|
+
const theta = rng.range(0, Math.PI * 2);
|
|
717
|
+
const r = rng.range(0.15, 1);
|
|
718
|
+
warpParams = {
|
|
719
|
+
ux: Math.cos(theta) * r,
|
|
720
|
+
uy: Math.sin(theta) * r,
|
|
721
|
+
z0: rng.range(WARP_NEAR, 1),
|
|
722
|
+
vz,
|
|
723
|
+
cx: (m.center?.x ?? 0.5) * w,
|
|
724
|
+
cy: (m.center?.y ?? 0.5) * h
|
|
725
|
+
};
|
|
726
|
+
} else if (m.type === "path") {
|
|
727
|
+
motion = "path";
|
|
728
|
+
pathPhase = rng.next();
|
|
729
|
+
if (m.scatter) {
|
|
730
|
+
pathOffX = rng.range(-1, 1) * m.scatter * scale;
|
|
731
|
+
pathOffY = rng.range(-1, 1) * m.scatter * scale;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
let x0;
|
|
735
|
+
let y0;
|
|
736
|
+
if (layer.position && layer.count === 1) {
|
|
737
|
+
x0 = layer.position.x * w;
|
|
738
|
+
y0 = layer.position.y * h;
|
|
739
|
+
} else if (layout?.type === "grid") {
|
|
740
|
+
const col = i % gridCols;
|
|
741
|
+
const row = Math.floor(i / gridCols);
|
|
742
|
+
const j = layout.jitter ?? 0;
|
|
743
|
+
const jx = typeof j === "number" ? j : j.x ?? 0;
|
|
744
|
+
const jy = typeof j === "number" ? j : j.y ?? 0;
|
|
745
|
+
x0 = gridX0 + (col + 0.5) * cellW + rng.range(-0.5, 0.5) * jx * cellW;
|
|
746
|
+
y0 = gridY0 + (row + 0.5) * cellH + rng.range(-0.5, 0.5) * jy * cellH;
|
|
747
|
+
} else {
|
|
748
|
+
const [rx0, rx1] = layer.region?.x ?? [0, 1];
|
|
749
|
+
const [ry0, ry1] = layer.region?.y ?? [0, 1];
|
|
750
|
+
x0 = rng.range(rx0 * w, rx1 * w);
|
|
751
|
+
y0 = rng.range(ry0 * h, ry1 * h);
|
|
752
|
+
}
|
|
753
|
+
const orbitParent = m.type === "orbit" && m.center && "layer" in m.center ? m.center.layer : void 0;
|
|
754
|
+
out.push({
|
|
755
|
+
x0,
|
|
756
|
+
y0,
|
|
757
|
+
size,
|
|
758
|
+
spriteIndex: variants > 1 ? rng.int(0, variants - 1) : 0,
|
|
759
|
+
phase: rng.range(0, Math.PI * 2),
|
|
760
|
+
vx,
|
|
761
|
+
vy,
|
|
762
|
+
bob,
|
|
763
|
+
motion,
|
|
764
|
+
headingLeft: vx < 0,
|
|
765
|
+
alpha: layer.alpha ? rng.range(layer.alpha[0], layer.alpha[1]) : 1,
|
|
766
|
+
pulseAmp: layer.pulse?.amp ?? 0,
|
|
767
|
+
pulsePeriod: layer.pulse?.period ?? 1e3,
|
|
768
|
+
pulsePhase: layer.pulse ? rng.range(0, Math.PI * 2) : 0,
|
|
769
|
+
// New draws AFTER pulsePhase — guarded so existing specs keep identical streams.
|
|
770
|
+
spinSpeed: layer.spin ? layer.spin * Math.PI / 180 : 0,
|
|
771
|
+
// deg/sec → rad/sec
|
|
772
|
+
spinPhase: layer.spin ? rng.range(0, Math.PI * 2) : 0,
|
|
773
|
+
growAmp: layer.grow?.amp ?? 0,
|
|
774
|
+
growPeriod: layer.grow?.period ?? 1e3,
|
|
775
|
+
growPhase: layer.grow ? rng.range(0, Math.PI * 2) : 0,
|
|
776
|
+
orbitR: m.type === "orbit" ? rng.range(m.radius[0], m.radius[1]) * scale : 0,
|
|
777
|
+
orbitCx: m.type === "orbit" && !orbitParent ? (m.center?.x ?? 0.5) * w : 0,
|
|
778
|
+
orbitCy: m.type === "orbit" && !orbitParent ? (m.center?.y ?? 0.5) * h : 0,
|
|
779
|
+
// New draws AFTER orbit — guarded so existing specs keep identical streams.
|
|
780
|
+
colorIndex: colorsLen > 0 ? colorWeights && colorWeights.length === colorsLen ? weightedIndex(rng.next(), colorWeights) : rng.int(0, colorsLen - 1) : -1,
|
|
781
|
+
cyclePeriod: cycle ? cycle.period : 0,
|
|
782
|
+
// Optional feature fields last (guarded draws inside — wander draws 18 here).
|
|
783
|
+
...size2 !== void 0 ? { size2 } : {},
|
|
784
|
+
...orbitParent ? { orbitParent } : {},
|
|
785
|
+
...m.type === "wander" ? {
|
|
786
|
+
wander: {
|
|
787
|
+
own: drawOsc(rng, meanderPx),
|
|
788
|
+
shared: sharedOsc,
|
|
789
|
+
coherence: Math.max(0, Math.min(1, m.coherence ?? 0)),
|
|
790
|
+
margin: meanderPx * (OCT_AMP[0] + OCT_AMP[1] + OCT_AMP[2]) * 1.4
|
|
791
|
+
}
|
|
792
|
+
} : {},
|
|
793
|
+
...warpParams ? { warp: warpParams } : {},
|
|
794
|
+
...m.type === "path" && pathPts ? {
|
|
795
|
+
path: {
|
|
796
|
+
pts: pathPts,
|
|
797
|
+
duration: m.duration,
|
|
798
|
+
closed: m.closed !== false,
|
|
799
|
+
smooth: m.curve !== "linear",
|
|
800
|
+
phase: pathPhase,
|
|
801
|
+
offX: pathOffX,
|
|
802
|
+
offY: pathOffY
|
|
803
|
+
}
|
|
804
|
+
} : {}
|
|
805
|
+
});
|
|
806
|
+
if (layer.pulse?.wave) {
|
|
807
|
+
const wl = Math.max(1e-6, layer.pulse.wave.wavelength * scale);
|
|
808
|
+
const ang = (layer.pulse.wave.angle ?? 0) * Math.PI / 180;
|
|
809
|
+
out[out.length - 1].pulsePhase = -((x0 * Math.cos(ang) + y0 * Math.sin(ang)) / wl) * Math.PI * 2;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return out;
|
|
813
|
+
}
|
|
814
|
+
function warpZ(e, t) {
|
|
815
|
+
const wp = e.warp;
|
|
816
|
+
return wrap(wp.z0 - wp.vz * (t / 1e3), WARP_NEAR, 1);
|
|
817
|
+
}
|
|
818
|
+
function alphaAt(e, t) {
|
|
819
|
+
let a = e.alpha;
|
|
820
|
+
if (e.pulseAmp) a = e.alpha + e.pulseAmp * Math.sin(t * 2 * Math.PI / e.pulsePeriod + e.pulsePhase);
|
|
821
|
+
if (e.motion === "warp") {
|
|
822
|
+
const z = warpZ(e, t);
|
|
823
|
+
a *= Math.max(0, Math.min(1, (1 - z) / 0.2));
|
|
824
|
+
}
|
|
825
|
+
return a < 0 ? 0 : a > 1 ? 1 : a;
|
|
826
|
+
}
|
|
827
|
+
function sizeAt(e, t) {
|
|
828
|
+
let s = e.size;
|
|
829
|
+
if (e.growAmp) s = e.size * (1 + e.growAmp * Math.sin(t * 2 * Math.PI / e.growPeriod + e.growPhase));
|
|
830
|
+
if (e.motion === "warp") s *= Math.min(1 / warpZ(e, t), WARP_MAX_SCALE);
|
|
831
|
+
return s > 0 ? s : 0.1;
|
|
832
|
+
}
|
|
833
|
+
function rotationAt(e, t) {
|
|
834
|
+
if (!e.spinSpeed) return 0;
|
|
835
|
+
return e.spinPhase + e.spinSpeed * (t / 1e3);
|
|
836
|
+
}
|
|
837
|
+
function lifeAlphaAt(life, t) {
|
|
838
|
+
if (!life) return 1;
|
|
839
|
+
const fade = life.fade ?? 1e3;
|
|
840
|
+
let a = 1;
|
|
841
|
+
if (life.enter !== void 0) {
|
|
842
|
+
if (t < life.enter) return 0;
|
|
843
|
+
a = fade > 0 ? Math.min(1, (t - life.enter) / fade) : 1;
|
|
844
|
+
}
|
|
845
|
+
if (life.exit !== void 0 && t >= life.exit) {
|
|
846
|
+
a *= fade > 0 ? Math.max(0, 1 - (t - life.exit) / fade) : 0;
|
|
847
|
+
}
|
|
848
|
+
return a;
|
|
849
|
+
}
|
|
850
|
+
function wrap(v, min, max) {
|
|
851
|
+
const range = max - min;
|
|
852
|
+
return ((v - min) % range + range) % range + min;
|
|
853
|
+
}
|
|
854
|
+
function reflect(v, min, max) {
|
|
855
|
+
const range = max - min;
|
|
856
|
+
if (range <= 0) return min;
|
|
857
|
+
const period = 2 * range;
|
|
858
|
+
const p = ((v - min) % period + period) % period;
|
|
859
|
+
return min + (p < range ? p : period - p);
|
|
860
|
+
}
|
|
861
|
+
function catmullRom(p0, p1, p2, p3, u) {
|
|
862
|
+
const u2 = u * u;
|
|
863
|
+
const u3 = u2 * u;
|
|
864
|
+
return 0.5 * (2 * p1 + (-p0 + p2) * u + (2 * p0 - 5 * p1 + 4 * p2 - p3) * u2 + (-p0 + 3 * p1 - 3 * p2 + p3) * u3);
|
|
865
|
+
}
|
|
866
|
+
function pathPosition(e, t) {
|
|
867
|
+
const p = e.path;
|
|
868
|
+
const n = p.pts.length;
|
|
869
|
+
let s = (t / p.duration + p.phase) % 1;
|
|
870
|
+
if (s < 0) s += 1;
|
|
871
|
+
if (!p.closed) {
|
|
872
|
+
const pp = s * 2;
|
|
873
|
+
s = pp < 1 ? pp : 2 - pp;
|
|
874
|
+
}
|
|
875
|
+
const segs = p.closed ? n : n - 1;
|
|
876
|
+
const u = Math.min(s * segs, segs - 1e-9);
|
|
877
|
+
const i = Math.floor(u);
|
|
878
|
+
const local = u - i;
|
|
879
|
+
const at = (k) => p.closed ? p.pts[(k % n + n) % n] : p.pts[Math.max(0, Math.min(n - 1, k))];
|
|
880
|
+
const p1 = at(i);
|
|
881
|
+
const p2 = at(i + 1);
|
|
882
|
+
if (!p.smooth) {
|
|
883
|
+
return {
|
|
884
|
+
x: p1.x + (p2.x - p1.x) * local + p.offX,
|
|
885
|
+
y: p1.y + (p2.y - p1.y) * local + p.offY
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
const p0 = at(i - 1);
|
|
889
|
+
const p3 = at(i + 2);
|
|
890
|
+
return {
|
|
891
|
+
x: catmullRom(p0.x, p1.x, p2.x, p3.x, local) + p.offX,
|
|
892
|
+
y: catmullRom(p0.y, p1.y, p2.y, p3.y, local) + p.offY
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
function positionAt(e, t, w, h) {
|
|
896
|
+
if (e.motion === "static") return { x: e.x0, y: e.y0, flip: false };
|
|
897
|
+
if (e.motion === "orbit") {
|
|
898
|
+
const angle = e.phase + e.vx * Math.PI / 180 * (t / 1e3);
|
|
899
|
+
return {
|
|
900
|
+
x: e.orbitCx + e.orbitR * Math.cos(angle),
|
|
901
|
+
y: e.orbitCy + e.orbitR * Math.sin(angle),
|
|
902
|
+
flip: false
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
if (e.motion === "warp") {
|
|
906
|
+
const wp = e.warp;
|
|
907
|
+
const persp = 1 / warpZ(e, t);
|
|
908
|
+
const halfMin = Math.min(w, h) / 2;
|
|
909
|
+
return {
|
|
910
|
+
x: wp.cx + wp.ux * halfMin * persp,
|
|
911
|
+
y: wp.cy + wp.uy * halfMin * persp,
|
|
912
|
+
flip: false
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
if (e.motion === "path") {
|
|
916
|
+
const pos = pathPosition(e, t);
|
|
917
|
+
return { x: pos.x, y: pos.y, flip: false };
|
|
918
|
+
}
|
|
919
|
+
const dt = t / 1e3;
|
|
920
|
+
const m = e.size;
|
|
921
|
+
if (e.motion === "bounce") {
|
|
922
|
+
return {
|
|
923
|
+
x: reflect(e.x0 + e.vx * dt, m / 2, w - m / 2),
|
|
924
|
+
y: reflect(e.y0 + e.vy * dt, m / 2, h - m / 2),
|
|
925
|
+
flip: false
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
if (e.motion === "rise") {
|
|
929
|
+
return {
|
|
930
|
+
x: e.x0 + (e.bob ? e.bob * Math.sin(t / 700 + e.phase) : 0),
|
|
931
|
+
y: wrap(e.y0 + e.vy * dt, -m, h + m),
|
|
932
|
+
flip: false
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
if (e.motion === "wander") {
|
|
936
|
+
const wp = e.wander;
|
|
937
|
+
const c = wp.coherence;
|
|
938
|
+
let hx = 0;
|
|
939
|
+
let hy = 0;
|
|
940
|
+
for (let i = 0; i < 3; i++) {
|
|
941
|
+
if (c < 1) {
|
|
942
|
+
hx += (1 - c) * wp.own.ax[i] * Math.sin(wp.own.fx[i] * t + wp.own.phx[i]);
|
|
943
|
+
hy += (1 - c) * wp.own.ay[i] * Math.sin(wp.own.fy[i] * t + wp.own.phy[i]);
|
|
944
|
+
}
|
|
945
|
+
if (c > 0) {
|
|
946
|
+
hx += c * wp.shared.ax[i] * Math.sin(wp.shared.fx[i] * t + wp.shared.phx[i]);
|
|
947
|
+
hy += c * wp.shared.ay[i] * Math.sin(wp.shared.fy[i] * t + wp.shared.phy[i]);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
const margin = m + wp.margin;
|
|
951
|
+
return {
|
|
952
|
+
x: wrap(e.x0 + e.vx * dt + hx, -margin, w + margin),
|
|
953
|
+
y: wrap(e.y0 + e.vy * dt + hy, -margin, h + margin),
|
|
954
|
+
flip: e.headingLeft
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
const x = wrap(e.x0 + e.vx * dt, -m, w + m);
|
|
958
|
+
let y = e.vy !== 0 ? wrap(e.y0 + e.vy * dt, -m, h + m) : e.y0;
|
|
959
|
+
if (e.bob) y += e.bob * Math.sin(t / 500 + e.phase);
|
|
960
|
+
return { x, y, flip: e.headingLeft };
|
|
961
|
+
}
|
|
962
|
+
function headingAt(e, t, w, h) {
|
|
963
|
+
const dtMs = 32;
|
|
964
|
+
const t1 = t < dtMs ? t + dtMs : t;
|
|
965
|
+
const t0 = t1 - dtMs;
|
|
966
|
+
const a = positionAt(e, t0, w, h);
|
|
967
|
+
const b = positionAt(e, t1, w, h);
|
|
968
|
+
const dx = b.x - a.x;
|
|
969
|
+
const dy = b.y - a.y;
|
|
970
|
+
if (Math.abs(dx) > w / 2 || Math.abs(dy) > h / 2) return null;
|
|
971
|
+
if (dx === 0 && dy === 0) return null;
|
|
972
|
+
return Math.atan2(dy, dx);
|
|
973
|
+
}
|
|
974
|
+
function spriteIndexAt(e, t, variants) {
|
|
975
|
+
if (!e.cyclePeriod || variants <= 1) return e.spriteIndex;
|
|
976
|
+
return Math.floor(t / e.cyclePeriod + e.phase / (2 * Math.PI)) % variants;
|
|
977
|
+
}
|
|
978
|
+
function wrapDist(pi, pj, doWrap, w, h) {
|
|
979
|
+
let dx = pj.x - pi.x;
|
|
980
|
+
let dy = pj.y - pi.y;
|
|
981
|
+
if (doWrap) {
|
|
982
|
+
if (Math.abs(dx) > w / 2) dx = dx > 0 ? dx - w : dx + w;
|
|
983
|
+
if (Math.abs(dy) > h / 2) dy = dy > 0 ? dy - h : dy + h;
|
|
984
|
+
}
|
|
985
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
986
|
+
}
|
|
987
|
+
function linkEdges(links, positions, maxDistPx, doWrap, w, h) {
|
|
988
|
+
const n = positions.length;
|
|
989
|
+
const mode = links.mode ?? "nearest";
|
|
990
|
+
if (mode === "chain") {
|
|
991
|
+
const out = [];
|
|
992
|
+
for (let i = 0; i < n - 1; i++) {
|
|
993
|
+
out.push({ i, j: i + 1, dist: wrapDist(positions[i], positions[i + 1], doWrap, w, h) });
|
|
994
|
+
}
|
|
995
|
+
if (links.closed && n > 2) out.push({ i: n - 1, j: 0, dist: wrapDist(positions[n - 1], positions[0], doWrap, w, h) });
|
|
996
|
+
return out;
|
|
997
|
+
}
|
|
998
|
+
if (mode === "random") {
|
|
999
|
+
const stride = Math.max(1, Math.round(n * 0.381966));
|
|
1000
|
+
const edges = /* @__PURE__ */ new Set();
|
|
1001
|
+
const out = [];
|
|
1002
|
+
for (let i = 0; i < n; i++) {
|
|
1003
|
+
for (let mIdx = 1; mIdx <= links.k; mIdx++) {
|
|
1004
|
+
const j = (i + mIdx * stride) % n;
|
|
1005
|
+
if (j === i) continue;
|
|
1006
|
+
const dist = wrapDist(positions[i], positions[j], doWrap, w, h);
|
|
1007
|
+
if (dist > maxDistPx) continue;
|
|
1008
|
+
const key = `${Math.min(i, j)}:${Math.max(i, j)}`;
|
|
1009
|
+
if (!edges.has(key)) {
|
|
1010
|
+
edges.add(key);
|
|
1011
|
+
out.push({ i: Math.min(i, j), j: Math.max(i, j), dist });
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
return out;
|
|
1016
|
+
}
|
|
1017
|
+
return linkPairs(positions, links.k, maxDistPx, doWrap, w, h).map(([i, j]) => ({
|
|
1018
|
+
i,
|
|
1019
|
+
j,
|
|
1020
|
+
dist: wrapDist(positions[i], positions[j], doWrap, w, h)
|
|
1021
|
+
}));
|
|
1022
|
+
}
|
|
1023
|
+
function linkPairs(positions, k, maxDist, doWrap, w, h) {
|
|
1024
|
+
const n = positions.length;
|
|
1025
|
+
const edges = /* @__PURE__ */ new Set();
|
|
1026
|
+
const out = [];
|
|
1027
|
+
for (let i = 0; i < n; i++) {
|
|
1028
|
+
const pi = positions[i];
|
|
1029
|
+
const neighbors = [];
|
|
1030
|
+
for (let j = 0; j < n; j++) {
|
|
1031
|
+
if (i === j) continue;
|
|
1032
|
+
const pj = positions[j];
|
|
1033
|
+
let dx = pj.x - pi.x;
|
|
1034
|
+
let dy = pj.y - pi.y;
|
|
1035
|
+
if (doWrap) {
|
|
1036
|
+
if (Math.abs(dx) > w / 2) dx = dx > 0 ? dx - w : dx + w;
|
|
1037
|
+
if (Math.abs(dy) > h / 2) dy = dy > 0 ? dy - h : dy + h;
|
|
1038
|
+
}
|
|
1039
|
+
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
1040
|
+
if (dist <= maxDist) neighbors.push({ dist, j });
|
|
1041
|
+
}
|
|
1042
|
+
neighbors.sort((a, b) => a.dist - b.dist || a.j - b.j);
|
|
1043
|
+
for (let ni = 0; ni < Math.min(k, neighbors.length); ni++) {
|
|
1044
|
+
const j = neighbors[ni].j;
|
|
1045
|
+
const lo = Math.min(i, j);
|
|
1046
|
+
const hi = Math.max(i, j);
|
|
1047
|
+
const key = `${lo}:${hi}`;
|
|
1048
|
+
if (!edges.has(key)) {
|
|
1049
|
+
edges.add(key);
|
|
1050
|
+
out.push([lo, hi]);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
return out;
|
|
1055
|
+
}
|
|
1056
|
+
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
1057
|
+
function resolveSpecPath(spec, path) {
|
|
1058
|
+
if (!spec || typeof spec !== "object" || !path) return null;
|
|
1059
|
+
const parts = path.split(".");
|
|
1060
|
+
if (parts.some((p) => UNSAFE_KEYS.has(p))) return null;
|
|
1061
|
+
const s = spec;
|
|
1062
|
+
if (parts[0] !== "layers" && parts[0] !== "background" && Array.isArray(s.layers)) {
|
|
1063
|
+
const idx = s.layers.findIndex((l) => l && l.key === parts[0]);
|
|
1064
|
+
if (idx === -1) return null;
|
|
1065
|
+
parts.splice(0, 1, "layers", String(idx));
|
|
1066
|
+
}
|
|
1067
|
+
let node = spec;
|
|
1068
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
1069
|
+
if (node === null || typeof node !== "object") return null;
|
|
1070
|
+
node = node[parts[i]];
|
|
1071
|
+
}
|
|
1072
|
+
if (node === null || typeof node !== "object") return null;
|
|
1073
|
+
const last = parts[parts.length - 1];
|
|
1074
|
+
const key = Array.isArray(node) ? Number(last) : last;
|
|
1075
|
+
const exists = Array.isArray(node) ? Number.isInteger(key) && key >= 0 && key < node.length : last in node;
|
|
1076
|
+
return exists ? { parent: node, key } : null;
|
|
1077
|
+
}
|
|
1078
|
+
function applyDeltasToSpec(spec, deltas) {
|
|
1079
|
+
const copy = JSON.parse(JSON.stringify(spec));
|
|
1080
|
+
for (const d of deltas) {
|
|
1081
|
+
const loc = resolveSpecPath(copy, d.path);
|
|
1082
|
+
if (loc) loc.parent[loc.key] = d.value;
|
|
1083
|
+
}
|
|
1084
|
+
return copy;
|
|
1085
|
+
}
|
|
1086
|
+
var HEX2 = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
1087
|
+
function hexToRgb(hex) {
|
|
1088
|
+
const h = hex.length === 4 ? `#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}` : hex;
|
|
1089
|
+
const n = parseInt(h.slice(1), 16);
|
|
1090
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1091
|
+
}
|
|
1092
|
+
function lerpHex(a, b, k) {
|
|
1093
|
+
const ca = hexToRgb(a);
|
|
1094
|
+
const cb = hexToRgb(b);
|
|
1095
|
+
const mix = ca.map((v, i) => Math.round(v + (cb[i] - v) * k));
|
|
1096
|
+
return `#${mix.map((v) => v.toString(16).padStart(2, "0")).join("")}`;
|
|
1097
|
+
}
|
|
1098
|
+
function lerpSpec(from, to, k) {
|
|
1099
|
+
const kk = Math.max(0, Math.min(1, k));
|
|
1100
|
+
const walk = (a, b, key) => {
|
|
1101
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
1102
|
+
const v = a + (b - a) * kk;
|
|
1103
|
+
return key === "count" ? Math.max(1, Math.round(v)) : v;
|
|
1104
|
+
}
|
|
1105
|
+
if (typeof a === "string" && typeof b === "string" && HEX2.test(a) && HEX2.test(b)) {
|
|
1106
|
+
return lerpHex(a, b, kk);
|
|
1107
|
+
}
|
|
1108
|
+
if (Array.isArray(a) && Array.isArray(b) && a.length === b.length) {
|
|
1109
|
+
return b.map((bv, i) => walk(a[i], bv, i));
|
|
1110
|
+
}
|
|
1111
|
+
if (a && b && typeof a === "object" && typeof b === "object" && !Array.isArray(a) && !Array.isArray(b)) {
|
|
1112
|
+
const out = {};
|
|
1113
|
+
for (const kName of Object.keys(b)) {
|
|
1114
|
+
out[kName] = walk(a[kName], b[kName], kName);
|
|
1115
|
+
}
|
|
1116
|
+
return out;
|
|
1117
|
+
}
|
|
1118
|
+
return kk > 0 ? b : a;
|
|
1119
|
+
};
|
|
1120
|
+
return walk(from, to);
|
|
1121
|
+
}
|
|
1122
|
+
function easeSmooth(k) {
|
|
1123
|
+
const c = Math.max(0, Math.min(1, k));
|
|
1124
|
+
return c * c * (3 - 2 * c);
|
|
1125
|
+
}
|
|
1126
|
+
function structuralSignature(spec) {
|
|
1127
|
+
return JSON.stringify([
|
|
1128
|
+
spec.units,
|
|
1129
|
+
spec.layers.map((l) => {
|
|
1130
|
+
const s = l.sprite;
|
|
1131
|
+
return [
|
|
1132
|
+
l.count,
|
|
1133
|
+
l.size,
|
|
1134
|
+
l.region,
|
|
1135
|
+
l.position,
|
|
1136
|
+
l.motion,
|
|
1137
|
+
l.wrap,
|
|
1138
|
+
l.flip,
|
|
1139
|
+
l.alpha,
|
|
1140
|
+
l.pulse,
|
|
1141
|
+
l.spin,
|
|
1142
|
+
l.grow,
|
|
1143
|
+
l.layout,
|
|
1144
|
+
l.sprite.kind,
|
|
1145
|
+
// Dimensional draws baked into entities: radius (circle/ring), length
|
|
1146
|
+
// (streak), width+aspect (rect), palette pick (all shaped sprites).
|
|
1147
|
+
s.radius,
|
|
1148
|
+
s.length,
|
|
1149
|
+
l.sprite.kind === "rect" ? [s.width, s.aspect] : void 0,
|
|
1150
|
+
Array.isArray(s.colors) ? s.colors.length : void 0,
|
|
1151
|
+
s.colorWeights,
|
|
1152
|
+
l.sprite.kind === "emoji" ? [l.sprite.glyphs.length, l.sprite.cycle?.period] : l.sprite.kind === "text" ? [l.sprite.strings.length, l.sprite.cycle?.period] : void 0
|
|
1153
|
+
];
|
|
1154
|
+
})
|
|
1155
|
+
]);
|
|
1156
|
+
}
|
|
1157
|
+
var DEFAULT_STEER_DUR = 1e3;
|
|
1158
|
+
function hexToRgba(hex, alpha) {
|
|
1159
|
+
const h = hex.length === 4 ? `#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}` : hex;
|
|
1160
|
+
const n = parseInt(h.slice(1), 16);
|
|
1161
|
+
return `rgba(${n >> 16 & 255},${n >> 8 & 255},${n & 255},${alpha})`;
|
|
1162
|
+
}
|
|
1163
|
+
var FONT_PREFIX_RE = /^((?:(?:italic|oblique|bold|bolder|lighter|normal|\d{3})\s+)+)/;
|
|
1164
|
+
function composeFontShorthand(sz, font) {
|
|
1165
|
+
const m = FONT_PREFIX_RE.exec(font);
|
|
1166
|
+
if (m) return `${m[1].trim()} ${sz}px ${font.slice(m[0].length)}`;
|
|
1167
|
+
return `${sz}px ${font}`;
|
|
1168
|
+
}
|
|
1169
|
+
function manifestFor(spec) {
|
|
1170
|
+
const total = spec.layers.reduce((n, l) => n + l.count, 0);
|
|
1171
|
+
const costTier = total < 30 ? "idle" : total < 150 ? "low" : total < 400 ? "medium" : "high";
|
|
1172
|
+
return {
|
|
1173
|
+
id: spec.id,
|
|
1174
|
+
label: spec.label,
|
|
1175
|
+
passthrough: false,
|
|
1176
|
+
minBackend: "canvas2d",
|
|
1177
|
+
costTier,
|
|
1178
|
+
motionIntensity: spec.motionIntensity ?? "moderate",
|
|
1179
|
+
reducedMotionFallback: "static",
|
|
1180
|
+
// Flash-safe by construction: static background + bounded sprites, no strobe
|
|
1181
|
+
// primitive. Proven by sampling a compiled spec through @idle-screens/validator.
|
|
1182
|
+
a11y: { flashSafe: true },
|
|
1183
|
+
workerReady: true
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
var SpecInstance = class {
|
|
1187
|
+
constructor(spec, ctx) {
|
|
1188
|
+
this.spec = spec;
|
|
1189
|
+
this.effSpec = spec;
|
|
1190
|
+
this.saverCtx = ctx;
|
|
1191
|
+
this.seed = (spec.seed ?? ctx.seed) >>> 0 || 1;
|
|
1192
|
+
let canvas;
|
|
1193
|
+
if (ctx.surface) {
|
|
1194
|
+
canvas = ctx.surface;
|
|
1195
|
+
} else {
|
|
1196
|
+
const el = document.createElement("canvas");
|
|
1197
|
+
el.style.cssText = "display:block;width:100%;height:100%";
|
|
1198
|
+
el.setAttribute("aria-hidden", "true");
|
|
1199
|
+
ctx.host.appendChild(el);
|
|
1200
|
+
canvas = el;
|
|
1201
|
+
}
|
|
1202
|
+
this.canvas = canvas;
|
|
1203
|
+
const c2d = canvas.getContext("2d", { alpha: false });
|
|
1204
|
+
if (!c2d) throw new Error("schema saver: no 2d context");
|
|
1205
|
+
this.ctx = c2d;
|
|
1206
|
+
this.w = ctx.width;
|
|
1207
|
+
this.h = ctx.height;
|
|
1208
|
+
this.sizeCanvas();
|
|
1209
|
+
this.rebuild();
|
|
1210
|
+
this.paused = ctx.reducedMotion;
|
|
1211
|
+
if (this.paused) this.renderFrame(0, this.seed);
|
|
1212
|
+
else this.start();
|
|
1213
|
+
}
|
|
1214
|
+
spec;
|
|
1215
|
+
canvas;
|
|
1216
|
+
ctx;
|
|
1217
|
+
saverCtx;
|
|
1218
|
+
seed;
|
|
1219
|
+
w;
|
|
1220
|
+
h;
|
|
1221
|
+
layers = [];
|
|
1222
|
+
frameId = null;
|
|
1223
|
+
paused = false;
|
|
1224
|
+
startT = 0;
|
|
1225
|
+
baseT = 0;
|
|
1226
|
+
// elapsed logical time carried across pause/resume
|
|
1227
|
+
lastT = 0;
|
|
1228
|
+
/** Last time painted — detects non-contiguous seeks for the ghosting warm-up replay. */
|
|
1229
|
+
lastRenderT = Number.NEGATIVE_INFINITY;
|
|
1230
|
+
/** The spec currently being rendered (base spec + any applied steering). */
|
|
1231
|
+
effSpec;
|
|
1232
|
+
/** Active glide between two resolved specs (live setParam/applyTrack). */
|
|
1233
|
+
transition = null;
|
|
1234
|
+
lastStructural = "";
|
|
1235
|
+
sizeCanvas() {
|
|
1236
|
+
const dpr = Math.min(this.saverCtx.dpr, 2);
|
|
1237
|
+
this.canvas.width = Math.max(1, Math.round(this.w * dpr));
|
|
1238
|
+
this.canvas.height = Math.max(1, Math.round(this.h * dpr));
|
|
1239
|
+
this.ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
1240
|
+
this.lastRenderT = Number.NEGATIVE_INFINITY;
|
|
1241
|
+
}
|
|
1242
|
+
/** (Re)seed and place all entities — deterministic for the seed + viewport. */
|
|
1243
|
+
rebuild() {
|
|
1244
|
+
const rng = createRng(this.seed);
|
|
1245
|
+
const scale = this.effSpec.units === "px" ? 1 : Math.min(this.w, this.h);
|
|
1246
|
+
const refVp = this.effSpec.referenceViewport ?? LIMITS.referenceViewport;
|
|
1247
|
+
let countScale = scale > 1 ? Math.min(this.w, this.h) / refVp : 1;
|
|
1248
|
+
if (countScale > 1) {
|
|
1249
|
+
const rawTotal = this.effSpec.layers.reduce((s, l) => s + Math.round(l.count * countScale), 0);
|
|
1250
|
+
if (rawTotal > LIMITS.maxTotal) countScale *= LIMITS.maxTotal / rawTotal;
|
|
1251
|
+
}
|
|
1252
|
+
this.layers = this.effSpec.layers.map((layer) => ({ layer, entities: buildEntities(layer, rng, this.w, this.h, scale, countScale) }));
|
|
1253
|
+
this.lastStructural = structuralSignature(this.effSpec);
|
|
1254
|
+
}
|
|
1255
|
+
start() {
|
|
1256
|
+
if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
|
|
1257
|
+
this.startT = 0;
|
|
1258
|
+
this.frameId = requestAnimationFrame((now) => this.loop(now));
|
|
1259
|
+
}
|
|
1260
|
+
stop() {
|
|
1261
|
+
if (this.frameId !== null) {
|
|
1262
|
+
cancelAnimationFrame(this.frameId);
|
|
1263
|
+
this.frameId = null;
|
|
1264
|
+
}
|
|
1265
|
+
this.baseT = this.lastT;
|
|
1266
|
+
}
|
|
1267
|
+
loop(now) {
|
|
1268
|
+
this.frameId = requestAnimationFrame((n) => this.loop(n));
|
|
1269
|
+
if (this.startT === 0) this.startT = now;
|
|
1270
|
+
this.lastT = now - this.startT + this.baseT;
|
|
1271
|
+
this.renderFrame(this.lastT, this.seed);
|
|
1272
|
+
}
|
|
1273
|
+
drawBackground(t) {
|
|
1274
|
+
const { ctx, w, h } = this;
|
|
1275
|
+
const bg = this.effSpec.background;
|
|
1276
|
+
if (!bg || bg.type === "solid") {
|
|
1277
|
+
ctx.fillStyle = bg?.color ?? "#05050a";
|
|
1278
|
+
ctx.fillRect(0, 0, w, h);
|
|
1279
|
+
return;
|
|
1280
|
+
}
|
|
1281
|
+
const g = ctx.createLinearGradient(0, 0, 0, h);
|
|
1282
|
+
const drift = bg.drift;
|
|
1283
|
+
for (let i = 0; i < bg.stops.length; i++) {
|
|
1284
|
+
const s = bg.stops[i];
|
|
1285
|
+
let at = s.at;
|
|
1286
|
+
if (drift) {
|
|
1287
|
+
const amount = drift.amount ?? 0.15;
|
|
1288
|
+
const phase = i / bg.stops.length * Math.PI * 2;
|
|
1289
|
+
at = Math.max(0, Math.min(1, at + amount * Math.sin(t * 2 * Math.PI / drift.period + phase)));
|
|
1290
|
+
}
|
|
1291
|
+
g.addColorStop(at, s.color);
|
|
1292
|
+
}
|
|
1293
|
+
ctx.fillStyle = g;
|
|
1294
|
+
ctx.fillRect(0, 0, w, h);
|
|
1295
|
+
if (bg.band) {
|
|
1296
|
+
ctx.fillStyle = bg.band.color;
|
|
1297
|
+
const bh = bg.band.height * (this.effSpec.units === "px" ? 1 : Math.min(w, h));
|
|
1298
|
+
ctx.fillRect(0, h - bh, w, bh);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
/** Position with parent-orbit resolution: a layer-parented orbit entity's
|
|
1302
|
+
* positionAt is an offset around (0,0); add the parent's own analytic position. */
|
|
1303
|
+
entityPos(e, t, parentE) {
|
|
1304
|
+
const p = positionAt(e, t, this.w, this.h);
|
|
1305
|
+
if (parentE && e.orbitParent) {
|
|
1306
|
+
const pp = positionAt(parentE, t, this.w, this.h);
|
|
1307
|
+
p.x += pp.x;
|
|
1308
|
+
p.y += pp.y;
|
|
1309
|
+
}
|
|
1310
|
+
return p;
|
|
1311
|
+
}
|
|
1312
|
+
/** Resolve the single parent entity for a layer-parented orbit layer (or null). */
|
|
1313
|
+
parentEntityFor(built) {
|
|
1314
|
+
const m = built.layer.motion;
|
|
1315
|
+
if (m.type !== "orbit" || !m.center || !("layer" in m.center)) return null;
|
|
1316
|
+
const key = m.center.layer;
|
|
1317
|
+
const parent = this.layers.find((b) => b.layer.key === key);
|
|
1318
|
+
return parent?.entities[0] ?? null;
|
|
1319
|
+
}
|
|
1320
|
+
drawTrail(built, e, t, lifeA, parentE) {
|
|
1321
|
+
const trail = built.layer.trail;
|
|
1322
|
+
if (!trail) return;
|
|
1323
|
+
const { ctx, w, h } = this;
|
|
1324
|
+
const fade = trail.fade ?? 1;
|
|
1325
|
+
const n = Math.min(Math.ceil(trail.length / 50), LIMITS.maxTrailSamples);
|
|
1326
|
+
const headAlpha = alphaAt(e, t) * lifeA;
|
|
1327
|
+
const headSize = sizeAt(e, t);
|
|
1328
|
+
const sprite = built.layer.sprite;
|
|
1329
|
+
const resolvedColor = sprite.kind === "circle" || sprite.kind === "ring" || sprite.kind === "streak" || sprite.kind === "rect" ? sprite.colors?.[e.colorIndex] ?? sprite.color : sprite.kind === "text" ? sprite.color ?? "#e6e8ef" : "#e6e8ef";
|
|
1330
|
+
const isSoft = sprite.kind === "circle" && sprite.soft;
|
|
1331
|
+
const wrap2 = built.layer.wrap !== false;
|
|
1332
|
+
const head = this.entityPos(e, t, parentE);
|
|
1333
|
+
let prevX = head.x;
|
|
1334
|
+
let prevY = head.y;
|
|
1335
|
+
for (let s = 1; s <= n; s++) {
|
|
1336
|
+
const k = s / n;
|
|
1337
|
+
const pastT = t - k * trail.length;
|
|
1338
|
+
if (pastT < 0) break;
|
|
1339
|
+
const pos = this.entityPos(e, pastT, parentE);
|
|
1340
|
+
if (wrap2) {
|
|
1341
|
+
const dx = pos.x - prevX;
|
|
1342
|
+
const dy = pos.y - prevY;
|
|
1343
|
+
if (Math.abs(dx) > w / 2 || Math.abs(dy) > h / 2) break;
|
|
1344
|
+
}
|
|
1345
|
+
prevX = pos.x;
|
|
1346
|
+
prevY = pos.y;
|
|
1347
|
+
const a = headAlpha * (1 - k * fade);
|
|
1348
|
+
if (a <= 0) break;
|
|
1349
|
+
const r = headSize / 2 * (1 - k * 0.7);
|
|
1350
|
+
if (r < 0.2) break;
|
|
1351
|
+
ctx.globalAlpha = a;
|
|
1352
|
+
if (isSoft) {
|
|
1353
|
+
const g = ctx.createRadialGradient(pos.x, pos.y, 0, pos.x, pos.y, r);
|
|
1354
|
+
g.addColorStop(0, resolvedColor);
|
|
1355
|
+
g.addColorStop(0.35, hexToRgba(resolvedColor, 0.75));
|
|
1356
|
+
g.addColorStop(1, hexToRgba(resolvedColor, 0));
|
|
1357
|
+
ctx.fillStyle = g;
|
|
1358
|
+
} else {
|
|
1359
|
+
ctx.fillStyle = resolvedColor;
|
|
1360
|
+
}
|
|
1361
|
+
ctx.beginPath();
|
|
1362
|
+
ctx.arc(pos.x, pos.y, r, 0, Math.PI * 2);
|
|
1363
|
+
ctx.fill();
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
drawEntity(built, e, t, lifeA, parentE) {
|
|
1367
|
+
const { ctx } = this;
|
|
1368
|
+
const p = this.entityPos(e, t, parentE);
|
|
1369
|
+
const sprite = built.layer.sprite;
|
|
1370
|
+
const sz = sizeAt(e, t);
|
|
1371
|
+
const rot = rotationAt(e, t);
|
|
1372
|
+
const unitScale = this.effSpec.units === "px" ? 1 : Math.min(this.w, this.h);
|
|
1373
|
+
ctx.globalAlpha = alphaAt(e, t) * lifeA;
|
|
1374
|
+
if (sprite.kind === "ring") {
|
|
1375
|
+
const r = sz / 2;
|
|
1376
|
+
const resolvedColor = sprite.colors?.[e.colorIndex] ?? sprite.color;
|
|
1377
|
+
ctx.strokeStyle = resolvedColor;
|
|
1378
|
+
ctx.lineWidth = Math.max(0.5, (sprite.width ?? (unitScale === 1 ? 2 : 2e-3)) * unitScale);
|
|
1379
|
+
ctx.beginPath();
|
|
1380
|
+
ctx.arc(p.x, p.y, r, 0, Math.PI * 2);
|
|
1381
|
+
ctx.stroke();
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
if (sprite.kind === "streak") {
|
|
1385
|
+
const resolvedColor = sprite.colors?.[e.colorIndex] ?? sprite.color;
|
|
1386
|
+
const heading = headingAt(e, t, this.w, this.h) ?? 0;
|
|
1387
|
+
const tailX = p.x - Math.cos(heading) * sz;
|
|
1388
|
+
const tailY = p.y - Math.sin(heading) * sz;
|
|
1389
|
+
const g = ctx.createLinearGradient(tailX, tailY, p.x, p.y);
|
|
1390
|
+
g.addColorStop(0, hexToRgba(resolvedColor, 0));
|
|
1391
|
+
g.addColorStop(1, resolvedColor);
|
|
1392
|
+
ctx.strokeStyle = g;
|
|
1393
|
+
ctx.lineWidth = Math.max(0.5, (sprite.width ?? (unitScale === 1 ? 2 : 2e-3)) * unitScale);
|
|
1394
|
+
ctx.lineCap = "round";
|
|
1395
|
+
ctx.beginPath();
|
|
1396
|
+
ctx.moveTo(tailX, tailY);
|
|
1397
|
+
ctx.lineTo(p.x, p.y);
|
|
1398
|
+
ctx.stroke();
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
if (sprite.kind === "rect") {
|
|
1402
|
+
const resolvedColor = sprite.colors?.[e.colorIndex] ?? sprite.color;
|
|
1403
|
+
const rh = e.size2 !== void 0 ? e.size2 * (e.size > 0 ? sz / e.size : 1) : sz;
|
|
1404
|
+
ctx.save();
|
|
1405
|
+
ctx.translate(p.x, p.y);
|
|
1406
|
+
if (rot) ctx.rotate(rot);
|
|
1407
|
+
ctx.fillStyle = resolvedColor;
|
|
1408
|
+
ctx.fillRect(-sz / 2, -rh / 2, sz, rh);
|
|
1409
|
+
ctx.restore();
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
if (sprite.kind === "circle") {
|
|
1413
|
+
const r = sz / 2;
|
|
1414
|
+
const resolvedColor = sprite.colors?.[e.colorIndex] ?? sprite.color;
|
|
1415
|
+
ctx.save();
|
|
1416
|
+
if (rot) {
|
|
1417
|
+
ctx.translate(p.x, p.y);
|
|
1418
|
+
ctx.rotate(rot);
|
|
1419
|
+
ctx.translate(-p.x, -p.y);
|
|
1420
|
+
}
|
|
1421
|
+
if (sprite.soft) {
|
|
1422
|
+
const g = ctx.createRadialGradient(p.x, p.y, 0, p.x, p.y, r);
|
|
1423
|
+
g.addColorStop(0, resolvedColor);
|
|
1424
|
+
g.addColorStop(0.35, hexToRgba(resolvedColor, 0.75));
|
|
1425
|
+
g.addColorStop(1, hexToRgba(resolvedColor, 0));
|
|
1426
|
+
ctx.fillStyle = g;
|
|
1427
|
+
} else {
|
|
1428
|
+
ctx.fillStyle = resolvedColor;
|
|
1429
|
+
}
|
|
1430
|
+
ctx.beginPath();
|
|
1431
|
+
ctx.arc(p.x, p.y, r, 0, Math.PI * 2);
|
|
1432
|
+
ctx.fill();
|
|
1433
|
+
ctx.restore();
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
ctx.save();
|
|
1437
|
+
ctx.translate(p.x, p.y);
|
|
1438
|
+
if (rot) ctx.rotate(rot);
|
|
1439
|
+
if (p.flip && built.layer.flip) ctx.scale(-1, 1);
|
|
1440
|
+
ctx.textAlign = "center";
|
|
1441
|
+
ctx.textBaseline = "middle";
|
|
1442
|
+
if (sprite.kind === "emoji") {
|
|
1443
|
+
const idx = spriteIndexAt(e, t, sprite.glyphs.length);
|
|
1444
|
+
ctx.font = `${sz}px serif`;
|
|
1445
|
+
ctx.fillText(sprite.glyphs[idx] ?? sprite.glyphs[0], 0, 0);
|
|
1446
|
+
} else {
|
|
1447
|
+
ctx.textAlign = sprite.align ?? "center";
|
|
1448
|
+
ctx.textBaseline = sprite.baseline ?? "middle";
|
|
1449
|
+
ctx.font = sprite.font ? /\dpx/.test(sprite.font) ? sprite.font : composeFontShorthand(sz, sprite.font) : `${sz}px system-ui, sans-serif`;
|
|
1450
|
+
ctx.fillStyle = sprite.color ?? "#e6e8ef";
|
|
1451
|
+
const idx = spriteIndexAt(e, t, sprite.strings.length);
|
|
1452
|
+
const text = sprite.strings[idx] ?? sprite.strings[0];
|
|
1453
|
+
const mw = sprite.maxWidth ? sprite.maxWidth * (this.effSpec.units === "px" ? 1 : Math.min(this.w, this.h)) : void 0;
|
|
1454
|
+
if (mw) ctx.fillText(text, 0, 0, mw);
|
|
1455
|
+
else ctx.fillText(text, 0, 0);
|
|
1456
|
+
}
|
|
1457
|
+
ctx.restore();
|
|
1458
|
+
}
|
|
1459
|
+
/** Advance any live steering glide; rebuild entities on structural change. */
|
|
1460
|
+
stepTransition(t) {
|
|
1461
|
+
const tr = this.transition;
|
|
1462
|
+
if (!tr) return;
|
|
1463
|
+
const k = tr.dur <= 0 ? 1 : (t - tr.startT) / tr.dur;
|
|
1464
|
+
this.effSpec = k >= 1 ? tr.to : lerpSpec(tr.from, tr.to, easeSmooth(k));
|
|
1465
|
+
if (k >= 1) this.transition = null;
|
|
1466
|
+
const sig = structuralSignature(this.effSpec);
|
|
1467
|
+
if (sig !== this.lastStructural) this.rebuild();
|
|
1468
|
+
else this.layers.forEach((b, i) => {
|
|
1469
|
+
b.layer = this.effSpec.layers[i] ?? b.layer;
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Live steering: glide from what's currently rendered to the track's target
|
|
1474
|
+
* state (deltas applied last-wins). Duration = the longest delta `dur`.
|
|
1475
|
+
*/
|
|
1476
|
+
applyTrack(track) {
|
|
1477
|
+
const deltas = track?.deltas ?? [];
|
|
1478
|
+
const target = applyDeltasToSpec(this.effSpec, deltas);
|
|
1479
|
+
if (!validateSpec(target).valid) return;
|
|
1480
|
+
const dur = deltas.length ? deltas.reduce((m, d) => Math.max(m, d.dur ?? DEFAULT_STEER_DUR), 0) : DEFAULT_STEER_DUR;
|
|
1481
|
+
this.transition = {
|
|
1482
|
+
from: JSON.parse(JSON.stringify(this.effSpec)),
|
|
1483
|
+
to: target,
|
|
1484
|
+
startT: this.lastT,
|
|
1485
|
+
dur
|
|
1486
|
+
};
|
|
1487
|
+
if (this.paused) {
|
|
1488
|
+
this.transition = null;
|
|
1489
|
+
this.effSpec = target;
|
|
1490
|
+
if (structuralSignature(this.effSpec) !== this.lastStructural) this.rebuild();
|
|
1491
|
+
else this.layers.forEach((b, i) => {
|
|
1492
|
+
b.layer = this.effSpec.layers[i] ?? b.layer;
|
|
1493
|
+
});
|
|
1494
|
+
this.renderFrame(this.lastT, this.seed);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
drawLinks(built, t, lifeA, parentE) {
|
|
1498
|
+
const { links } = built.layer;
|
|
1499
|
+
if (!links) return;
|
|
1500
|
+
const { ctx } = this;
|
|
1501
|
+
const motionWraps = ["drift", "rise", "wander"].includes(built.layer.motion.type);
|
|
1502
|
+
const wrap2 = built.layer.wrap !== false && motionWraps;
|
|
1503
|
+
const positions = built.entities.map((e) => this.entityPos(e, t, parentE));
|
|
1504
|
+
const maxDistPx = links.maxDist * (this.effSpec.units === "px" ? 1 : Math.min(this.w, this.h));
|
|
1505
|
+
const edges = linkEdges(links, positions, maxDistPx, wrap2, this.w, this.h);
|
|
1506
|
+
const lw = (links.width ?? 1) * (this.effSpec.units === "px" ? 1 : Math.min(this.w, this.h));
|
|
1507
|
+
ctx.lineWidth = lw;
|
|
1508
|
+
ctx.lineCap = "butt";
|
|
1509
|
+
for (const { i, j, dist } of edges) {
|
|
1510
|
+
const pi = positions[i];
|
|
1511
|
+
const pj = positions[j];
|
|
1512
|
+
const ei = built.entities[i];
|
|
1513
|
+
let resolvedColor = links.color;
|
|
1514
|
+
if (!resolvedColor) {
|
|
1515
|
+
const sprite = built.layer.sprite;
|
|
1516
|
+
if (sprite.kind === "circle" || sprite.kind === "ring" || sprite.kind === "streak" || sprite.kind === "rect") {
|
|
1517
|
+
resolvedColor = sprite.colors?.[ei.colorIndex] ?? sprite.color;
|
|
1518
|
+
} else resolvedColor = "#e6e8ef";
|
|
1519
|
+
}
|
|
1520
|
+
let a = links.alpha ?? alphaAt(ei, t);
|
|
1521
|
+
if (links.falloff) a *= Math.max(0, 1 - dist / maxDistPx);
|
|
1522
|
+
ctx.globalAlpha = a * lifeA;
|
|
1523
|
+
ctx.strokeStyle = resolvedColor;
|
|
1524
|
+
let dx = pj.x - pi.x;
|
|
1525
|
+
let dy = pj.y - pi.y;
|
|
1526
|
+
if (wrap2) {
|
|
1527
|
+
if (Math.abs(dx) > this.w / 2) dx = dx > 0 ? dx - this.w : dx + this.w;
|
|
1528
|
+
if (Math.abs(dy) > this.h / 2) dy = dy > 0 ? dy - this.h : dy + this.h;
|
|
1529
|
+
}
|
|
1530
|
+
ctx.beginPath();
|
|
1531
|
+
ctx.moveTo(pi.x, pi.y);
|
|
1532
|
+
ctx.lineTo(pi.x + dx, pi.y + dy);
|
|
1533
|
+
ctx.stroke();
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
/** Paint one composite pass at time t. `bgAlpha` < 1 leaves the previous frame
|
|
1537
|
+
* showing through — the ghosting smear. */
|
|
1538
|
+
paintFrame(t, bgAlpha) {
|
|
1539
|
+
const { ctx } = this;
|
|
1540
|
+
ctx.globalAlpha = bgAlpha;
|
|
1541
|
+
ctx.globalCompositeOperation = "source-over";
|
|
1542
|
+
this.drawBackground(t);
|
|
1543
|
+
ctx.globalAlpha = 1;
|
|
1544
|
+
for (const built of this.layers) {
|
|
1545
|
+
const lifeA = lifeAlphaAt(built.layer.life, t);
|
|
1546
|
+
if (lifeA <= 0) continue;
|
|
1547
|
+
const parentE = this.parentEntityFor(built);
|
|
1548
|
+
ctx.globalCompositeOperation = built.layer.blend ?? "source-over";
|
|
1549
|
+
this.drawLinks(built, t, lifeA, parentE);
|
|
1550
|
+
for (const e of built.entities) {
|
|
1551
|
+
this.drawTrail(built, e, t, lifeA, parentE);
|
|
1552
|
+
this.drawEntity(built, e, t, lifeA, parentE);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
ctx.globalAlpha = 1;
|
|
1556
|
+
ctx.globalCompositeOperation = "source-over";
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* Deterministic, frame-addressable render (shared by the rAF loop).
|
|
1560
|
+
*
|
|
1561
|
+
* With `ghosting` set, contiguous frames composite over the previous frame with a
|
|
1562
|
+
* refresh-rate-normalized fade. A non-contiguous seek (pause render, e2e frame
|
|
1563
|
+
* addressing) replays a bounded fixed-step warm-up from a full clear, so the
|
|
1564
|
+
* accumulated smear at time t is identical on every run — the determinism proof
|
|
1565
|
+
* survives statefulness because the "state" is reconstructed from pure history.
|
|
1566
|
+
*/
|
|
1567
|
+
renderFrame(t, _seed) {
|
|
1568
|
+
this.stepTransition(t);
|
|
1569
|
+
const g = this.effSpec.ghosting ?? 0;
|
|
1570
|
+
if (g > 0) {
|
|
1571
|
+
const dt = 1e3 / 60;
|
|
1572
|
+
const contiguous = this.lastRenderT !== Number.NEGATIVE_INFINITY && t > this.lastRenderT && t - this.lastRenderT <= 250;
|
|
1573
|
+
if (contiguous) {
|
|
1574
|
+
this.paintFrame(t, 1 - Math.pow(g, (t - this.lastRenderT) / dt));
|
|
1575
|
+
} else {
|
|
1576
|
+
const k = Math.min(Math.ceil(Math.log(1 / 255) / Math.log(g)), LIMITS.maxGhostReplayFrames);
|
|
1577
|
+
const t0 = Math.max(0, t - k * dt);
|
|
1578
|
+
this.paintFrame(t0, 1);
|
|
1579
|
+
for (let ft = t0 + dt; ft < t - dt / 2; ft += dt) this.paintFrame(ft, 1 - g);
|
|
1580
|
+
if (t > t0) this.paintFrame(t, 1 - g);
|
|
1581
|
+
}
|
|
1582
|
+
} else {
|
|
1583
|
+
this.paintFrame(t, 1);
|
|
1584
|
+
}
|
|
1585
|
+
this.lastRenderT = t;
|
|
1586
|
+
}
|
|
1587
|
+
setPaused(paused) {
|
|
1588
|
+
this.paused = paused;
|
|
1589
|
+
if (paused) {
|
|
1590
|
+
this.stop();
|
|
1591
|
+
} else {
|
|
1592
|
+
this.start();
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
resize(width, height, dpr) {
|
|
1596
|
+
this.w = width;
|
|
1597
|
+
this.h = height;
|
|
1598
|
+
if (dpr !== void 0) this.saverCtx.dpr = dpr;
|
|
1599
|
+
this.sizeCanvas();
|
|
1600
|
+
this.rebuild();
|
|
1601
|
+
if (this.paused) this.renderFrame(0, this.seed);
|
|
1602
|
+
}
|
|
1603
|
+
dispose() {
|
|
1604
|
+
this.stop();
|
|
1605
|
+
if (typeof HTMLCanvasElement !== "undefined" && this.canvas instanceof HTMLCanvasElement) this.canvas.remove();
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
function compileSaver(spec) {
|
|
1609
|
+
const valid = assertValidSpec(spec);
|
|
1610
|
+
return {
|
|
1611
|
+
manifest: manifestFor(valid),
|
|
1612
|
+
mount: (ctx) => new SpecInstance(valid, ctx),
|
|
1613
|
+
spec: valid
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1616
|
+
var DITHER = [
|
|
1617
|
+
[0.5 / 8, 4.5 / 8],
|
|
1618
|
+
[2.5 / 8, 6.5 / 8],
|
|
1619
|
+
[1.5 / 8, 5.5 / 8],
|
|
1620
|
+
[3.5 / 8, 7.5 / 8]
|
|
1621
|
+
];
|
|
1622
|
+
var AQUARIUM_SPEC = {
|
|
1623
|
+
schemaVersion: 1,
|
|
1624
|
+
id: "aquarium",
|
|
1625
|
+
label: "Aquarium",
|
|
1626
|
+
seed: 42,
|
|
1627
|
+
motionIntensity: "calm",
|
|
1628
|
+
background: {
|
|
1629
|
+
type: "gradient",
|
|
1630
|
+
stops: [
|
|
1631
|
+
{ at: 0, color: "#0a3a52" },
|
|
1632
|
+
{ at: 0.6, color: "#062534" },
|
|
1633
|
+
{ at: 1, color: "#02141d" }
|
|
1634
|
+
],
|
|
1635
|
+
band: { color: "#0b1a12", height: 0.02222 }
|
|
1636
|
+
},
|
|
1637
|
+
layers: [
|
|
1638
|
+
{
|
|
1639
|
+
count: 14,
|
|
1640
|
+
sprite: { kind: "emoji", glyphs: ["\u{1F41F}", "\u{1F420}", "\u{1F421}", "\u{1F988}", "\u{1F419}"] },
|
|
1641
|
+
size: [0.03148, 0.06667],
|
|
1642
|
+
motion: { type: "drift", speed: [0.02778, 0.1019], bidirectional: true, bob: 5556e-6 },
|
|
1643
|
+
flip: true
|
|
1644
|
+
},
|
|
1645
|
+
{
|
|
1646
|
+
count: 22,
|
|
1647
|
+
sprite: { kind: "circle", radius: [1852e-6, 6481e-6], color: "#c8ebff" },
|
|
1648
|
+
motion: { type: "rise", speed: [0.02222, 0.07222], sway: 7407e-6 }
|
|
1649
|
+
}
|
|
1650
|
+
]
|
|
1651
|
+
};
|
|
1652
|
+
var AURORA_SPEC = {
|
|
1653
|
+
schemaVersion: 1,
|
|
1654
|
+
id: "aurora",
|
|
1655
|
+
label: "Aurora",
|
|
1656
|
+
seed: 66,
|
|
1657
|
+
motionIntensity: "calm",
|
|
1658
|
+
ghosting: 0.85,
|
|
1659
|
+
background: {
|
|
1660
|
+
type: "gradient",
|
|
1661
|
+
stops: [
|
|
1662
|
+
{ at: 0, color: "#02030d" },
|
|
1663
|
+
{ at: 0.65, color: "#050a18" },
|
|
1664
|
+
{ at: 1, color: "#0a1220" }
|
|
1665
|
+
],
|
|
1666
|
+
drift: { period: 4e4, amount: 0.1 }
|
|
1667
|
+
},
|
|
1668
|
+
layers: [
|
|
1669
|
+
{
|
|
1670
|
+
key: "stars",
|
|
1671
|
+
count: 110,
|
|
1672
|
+
sprite: { kind: "circle", radius: [5e-4, 15e-4], color: "#e8ecff", soft: true },
|
|
1673
|
+
motion: { type: "static" },
|
|
1674
|
+
region: { y: [0, 0.75] },
|
|
1675
|
+
alpha: [0.2, 0.6],
|
|
1676
|
+
// A slow shimmer travels across the sky instead of stars twinkling independently.
|
|
1677
|
+
pulse: { amp: 0.25, period: 6e3, wave: { wavelength: 0.5, angle: 15 } }
|
|
1678
|
+
},
|
|
1679
|
+
{
|
|
1680
|
+
key: "curtain-green",
|
|
1681
|
+
count: 100,
|
|
1682
|
+
sprite: {
|
|
1683
|
+
kind: "circle",
|
|
1684
|
+
radius: [0.055, 0.11],
|
|
1685
|
+
color: "#1fd68a",
|
|
1686
|
+
soft: true,
|
|
1687
|
+
colors: ["#1fd68a", "#2ee6c8", "#4bd1ff"],
|
|
1688
|
+
colorWeights: [5, 2, 1]
|
|
1689
|
+
},
|
|
1690
|
+
motion: { type: "wander", speed: [4e-3, 0.012], angle: 0, meander: 0.13, coherence: 0.7 },
|
|
1691
|
+
region: { y: [0.1, 0.42] },
|
|
1692
|
+
alpha: [0.04, 0.1],
|
|
1693
|
+
blend: "lighter",
|
|
1694
|
+
grow: { amp: 0.25, period: 9e3 }
|
|
1695
|
+
},
|
|
1696
|
+
{
|
|
1697
|
+
key: "curtain-violet",
|
|
1698
|
+
count: 60,
|
|
1699
|
+
sprite: {
|
|
1700
|
+
kind: "circle",
|
|
1701
|
+
radius: [0.045, 0.09],
|
|
1702
|
+
color: "#8d5bff",
|
|
1703
|
+
soft: true,
|
|
1704
|
+
colors: ["#8d5bff", "#d14bff", "#ff4bd8"],
|
|
1705
|
+
colorWeights: [4, 1.5, 0.5]
|
|
1706
|
+
},
|
|
1707
|
+
motion: { type: "wander", speed: [3e-3, 0.01], angle: 180, meander: 0.1, coherence: 0.55 },
|
|
1708
|
+
region: { y: [0.04, 0.28] },
|
|
1709
|
+
alpha: [0.03, 0.08],
|
|
1710
|
+
blend: "lighter",
|
|
1711
|
+
grow: { amp: 0.3, period: 12e3 }
|
|
1712
|
+
},
|
|
1713
|
+
{
|
|
1714
|
+
key: "fireflies",
|
|
1715
|
+
count: 14,
|
|
1716
|
+
sprite: { kind: "circle", radius: [1e-3, 3e-3], color: "#b8ffe1", soft: true },
|
|
1717
|
+
motion: { type: "wander", speed: [6e-3, 0.02], meander: 0.06 },
|
|
1718
|
+
region: { y: [0.55, 0.95] },
|
|
1719
|
+
alpha: [0.2, 0.55],
|
|
1720
|
+
pulse: { amp: 0.3, period: 3500 },
|
|
1721
|
+
blend: "lighter"
|
|
1722
|
+
}
|
|
1723
|
+
]
|
|
1724
|
+
};
|
|
1725
|
+
var COMETS_SPEC = {
|
|
1726
|
+
schemaVersion: 1,
|
|
1727
|
+
id: "comets",
|
|
1728
|
+
label: "Comet Shower",
|
|
1729
|
+
seed: 42,
|
|
1730
|
+
motionIntensity: "moderate",
|
|
1731
|
+
background: {
|
|
1732
|
+
type: "gradient",
|
|
1733
|
+
stops: [
|
|
1734
|
+
{ at: 0, color: "#0a0015" },
|
|
1735
|
+
{ at: 0.5, color: "#0d1b2a" },
|
|
1736
|
+
{ at: 1, color: "#1b0a2e" }
|
|
1737
|
+
],
|
|
1738
|
+
drift: { period: 25e3, amount: 0.12 }
|
|
1739
|
+
},
|
|
1740
|
+
layers: [
|
|
1741
|
+
{
|
|
1742
|
+
key: "stars",
|
|
1743
|
+
count: 120,
|
|
1744
|
+
sprite: { kind: "circle", radius: [463e-6, 1852e-6], color: "#ffffff", soft: true },
|
|
1745
|
+
motion: { type: "static" },
|
|
1746
|
+
alpha: [0.3, 0.7],
|
|
1747
|
+
pulse: { amp: 0.15, period: 3e3 }
|
|
1748
|
+
},
|
|
1749
|
+
{
|
|
1750
|
+
key: "comets",
|
|
1751
|
+
count: 8,
|
|
1752
|
+
sprite: { kind: "circle", radius: [2778e-6, 7407e-6], color: "#88ccff", soft: true },
|
|
1753
|
+
motion: { type: "drift", speed: [0.07407, 0.1852], angle: 225 },
|
|
1754
|
+
alpha: [0.7, 1],
|
|
1755
|
+
blend: "lighter",
|
|
1756
|
+
trail: { length: 1500, fade: 1 }
|
|
1757
|
+
},
|
|
1758
|
+
{
|
|
1759
|
+
key: "fireflies",
|
|
1760
|
+
count: 20,
|
|
1761
|
+
sprite: { kind: "circle", radius: [1852e-6, 463e-5], color: "#ffdd44", soft: true },
|
|
1762
|
+
motion: { type: "drift", speed: [9259e-6, 0.02778], bidirectional: true, bob: 0.01852 },
|
|
1763
|
+
alpha: [0.4, 0.8],
|
|
1764
|
+
pulse: { amp: 0.3, period: 2e3 },
|
|
1765
|
+
blend: "lighter",
|
|
1766
|
+
trail: { length: 800 }
|
|
1767
|
+
}
|
|
1768
|
+
]
|
|
1769
|
+
};
|
|
1770
|
+
var CONSTELLATION_SPEC = {
|
|
1771
|
+
schemaVersion: 1,
|
|
1772
|
+
id: "constellation",
|
|
1773
|
+
label: "Constellation",
|
|
1774
|
+
seed: 73,
|
|
1775
|
+
motionIntensity: "calm",
|
|
1776
|
+
background: {
|
|
1777
|
+
type: "gradient",
|
|
1778
|
+
stops: [
|
|
1779
|
+
{ at: 0, color: "#020212" },
|
|
1780
|
+
{ at: 0.5, color: "#050520" },
|
|
1781
|
+
{ at: 1, color: "#0a0830" }
|
|
1782
|
+
]
|
|
1783
|
+
},
|
|
1784
|
+
layers: [
|
|
1785
|
+
// Distant static stars (no links, just atmosphere)
|
|
1786
|
+
{
|
|
1787
|
+
count: 100,
|
|
1788
|
+
sprite: { kind: "circle", radius: [9259e-7, 2778e-6], color: "#667799", colors: ["#8899cc", "#99aadd", "#aabbee", "#7788aa"] },
|
|
1789
|
+
alpha: [0.2, 0.7],
|
|
1790
|
+
pulse: { amp: 0.2, period: 3e3 },
|
|
1791
|
+
motion: { type: "static" }
|
|
1792
|
+
},
|
|
1793
|
+
// Connected constellation nodes — slow drift, linked
|
|
1794
|
+
{
|
|
1795
|
+
key: "nodes",
|
|
1796
|
+
count: 40,
|
|
1797
|
+
sprite: { kind: "circle", radius: [1852e-6, 463e-5], color: "#88aaff", colors: ["#88aaff", "#aaccff", "#ffcc88", "#ff8866"], soft: true },
|
|
1798
|
+
alpha: [0.5, 0.9],
|
|
1799
|
+
blend: "lighter",
|
|
1800
|
+
motion: { type: "drift", speed: [1852e-6, 7407e-6], bidirectional: true, bob: 2778e-6 },
|
|
1801
|
+
links: { k: 3, maxDist: 0.1852, alpha: 0.15, width: 463e-6 }
|
|
1802
|
+
},
|
|
1803
|
+
// Cycling asterism markers
|
|
1804
|
+
{
|
|
1805
|
+
count: 6,
|
|
1806
|
+
sprite: { kind: "emoji", glyphs: ["\u2726", "\u2727", "\u22C6", "\u2217"], cycle: { period: 2e3 } },
|
|
1807
|
+
size: [0.01296, 0.02037],
|
|
1808
|
+
alpha: [0.4, 0.7],
|
|
1809
|
+
motion: { type: "drift", speed: [9259e-7, 3704e-6], bidirectional: true }
|
|
1810
|
+
}
|
|
1811
|
+
]
|
|
1812
|
+
};
|
|
1813
|
+
var DASHBOARD_SPEC = {
|
|
1814
|
+
schemaVersion: 1,
|
|
1815
|
+
id: "dev-dashboard",
|
|
1816
|
+
label: "Control Center",
|
|
1817
|
+
seed: 256,
|
|
1818
|
+
motionIntensity: "calm",
|
|
1819
|
+
background: {
|
|
1820
|
+
type: "gradient",
|
|
1821
|
+
stops: [
|
|
1822
|
+
{ at: 0, color: "#06060c" },
|
|
1823
|
+
{ at: 0.5, color: "#0a0a14" },
|
|
1824
|
+
{ at: 1, color: "#0c0c18" }
|
|
1825
|
+
]
|
|
1826
|
+
},
|
|
1827
|
+
layers: [
|
|
1828
|
+
// --- ambient depth ---
|
|
1829
|
+
{
|
|
1830
|
+
key: "dust",
|
|
1831
|
+
count: 40,
|
|
1832
|
+
sprite: { kind: "circle", radius: [1852e-7, 7407e-7], color: "#1a2538" },
|
|
1833
|
+
alpha: [0.1, 0.25],
|
|
1834
|
+
motion: { type: "drift", speed: [2778e-7, 1111e-6], bob: 2778e-7 }
|
|
1835
|
+
},
|
|
1836
|
+
{
|
|
1837
|
+
key: "led-wall",
|
|
1838
|
+
count: 140,
|
|
1839
|
+
sprite: { kind: "circle", radius: [8e-4, 12e-4], color: "#274058" },
|
|
1840
|
+
alpha: [0.05, 0.11],
|
|
1841
|
+
layout: { type: "grid", columns: 20, jitter: 0.15 },
|
|
1842
|
+
// A slow breath travels diagonally across the wall of dots.
|
|
1843
|
+
pulse: { amp: 0.3, period: 5e3, wave: { wavelength: 0.35, angle: 20 } },
|
|
1844
|
+
motion: { type: "static" }
|
|
1845
|
+
},
|
|
1846
|
+
// --- header (boots first) ---
|
|
1847
|
+
{
|
|
1848
|
+
key: "title",
|
|
1849
|
+
count: 1,
|
|
1850
|
+
position: { x: 0.5, y: 0.045 },
|
|
1851
|
+
sprite: {
|
|
1852
|
+
kind: "text",
|
|
1853
|
+
strings: ["CONTROL CENTER"],
|
|
1854
|
+
color: "#556677",
|
|
1855
|
+
font: "600 13px 'SF Mono', monospace",
|
|
1856
|
+
align: "center"
|
|
1857
|
+
},
|
|
1858
|
+
motion: { type: "static" },
|
|
1859
|
+
life: { enter: 200, fade: 600 }
|
|
1860
|
+
},
|
|
1861
|
+
{
|
|
1862
|
+
key: "status",
|
|
1863
|
+
count: 1,
|
|
1864
|
+
position: { x: 0.94, y: 0.045 },
|
|
1865
|
+
sprite: {
|
|
1866
|
+
kind: "text",
|
|
1867
|
+
strings: ["\u25CF ALL SYSTEMS GO"],
|
|
1868
|
+
color: "#44cc66",
|
|
1869
|
+
font: "bold 10px monospace",
|
|
1870
|
+
align: "right"
|
|
1871
|
+
},
|
|
1872
|
+
pulse: { amp: 0.2, period: 2400 },
|
|
1873
|
+
motion: { type: "static" },
|
|
1874
|
+
life: { enter: 200, fade: 600 }
|
|
1875
|
+
},
|
|
1876
|
+
{
|
|
1877
|
+
key: "clock",
|
|
1878
|
+
count: 1,
|
|
1879
|
+
position: { x: 0.06, y: 0.045 },
|
|
1880
|
+
sprite: {
|
|
1881
|
+
kind: "text",
|
|
1882
|
+
strings: ["21:47"],
|
|
1883
|
+
color: "#8899aa",
|
|
1884
|
+
font: "bold 12px monospace",
|
|
1885
|
+
align: "left"
|
|
1886
|
+
},
|
|
1887
|
+
motion: { type: "static" },
|
|
1888
|
+
life: { enter: 200, fade: 600 }
|
|
1889
|
+
},
|
|
1890
|
+
// --- left column: readings (boots second) ---
|
|
1891
|
+
{
|
|
1892
|
+
key: "power-label",
|
|
1893
|
+
count: 1,
|
|
1894
|
+
position: { x: 0.06, y: 0.14 },
|
|
1895
|
+
sprite: {
|
|
1896
|
+
kind: "text",
|
|
1897
|
+
strings: ["POWER"],
|
|
1898
|
+
color: "#445566",
|
|
1899
|
+
font: "9px monospace",
|
|
1900
|
+
align: "left",
|
|
1901
|
+
baseline: "top"
|
|
1902
|
+
},
|
|
1903
|
+
motion: { type: "static" },
|
|
1904
|
+
life: { enter: 700, fade: 600 }
|
|
1905
|
+
},
|
|
1906
|
+
{
|
|
1907
|
+
key: "power-value",
|
|
1908
|
+
count: 1,
|
|
1909
|
+
position: { x: 0.06, y: 0.18 },
|
|
1910
|
+
sprite: {
|
|
1911
|
+
kind: "text",
|
|
1912
|
+
strings: ["3.2 kW"],
|
|
1913
|
+
color: "#ffd166",
|
|
1914
|
+
font: "bold 26px monospace",
|
|
1915
|
+
align: "left",
|
|
1916
|
+
baseline: "top"
|
|
1917
|
+
},
|
|
1918
|
+
motion: { type: "static" },
|
|
1919
|
+
life: { enter: 700, fade: 600 }
|
|
1920
|
+
},
|
|
1921
|
+
{
|
|
1922
|
+
key: "network-label",
|
|
1923
|
+
count: 1,
|
|
1924
|
+
position: { x: 0.06, y: 0.28 },
|
|
1925
|
+
sprite: {
|
|
1926
|
+
kind: "text",
|
|
1927
|
+
strings: ["NETWORK"],
|
|
1928
|
+
color: "#445566",
|
|
1929
|
+
font: "9px monospace",
|
|
1930
|
+
align: "left",
|
|
1931
|
+
baseline: "top"
|
|
1932
|
+
},
|
|
1933
|
+
motion: { type: "static" },
|
|
1934
|
+
life: { enter: 700, fade: 600 }
|
|
1935
|
+
},
|
|
1936
|
+
{
|
|
1937
|
+
key: "network-value",
|
|
1938
|
+
count: 1,
|
|
1939
|
+
position: { x: 0.06, y: 0.32 },
|
|
1940
|
+
sprite: {
|
|
1941
|
+
kind: "text",
|
|
1942
|
+
strings: ["940 Mb/s"],
|
|
1943
|
+
color: "#44aaff",
|
|
1944
|
+
font: "bold 26px monospace",
|
|
1945
|
+
align: "left",
|
|
1946
|
+
baseline: "top"
|
|
1947
|
+
},
|
|
1948
|
+
motion: { type: "static" },
|
|
1949
|
+
life: { enter: 700, fade: 600 }
|
|
1950
|
+
},
|
|
1951
|
+
{
|
|
1952
|
+
key: "climate-label",
|
|
1953
|
+
count: 1,
|
|
1954
|
+
position: { x: 0.06, y: 0.42 },
|
|
1955
|
+
sprite: {
|
|
1956
|
+
kind: "text",
|
|
1957
|
+
strings: ["CLIMATE"],
|
|
1958
|
+
color: "#445566",
|
|
1959
|
+
font: "9px monospace",
|
|
1960
|
+
align: "left",
|
|
1961
|
+
baseline: "top"
|
|
1962
|
+
},
|
|
1963
|
+
motion: { type: "static" },
|
|
1964
|
+
life: { enter: 700, fade: 600 }
|
|
1965
|
+
},
|
|
1966
|
+
{
|
|
1967
|
+
key: "climate-value",
|
|
1968
|
+
count: 1,
|
|
1969
|
+
position: { x: 0.06, y: 0.46 },
|
|
1970
|
+
sprite: {
|
|
1971
|
+
kind: "text",
|
|
1972
|
+
strings: ["21.5\xB0"],
|
|
1973
|
+
color: "#44ddcc",
|
|
1974
|
+
font: "bold 26px monospace",
|
|
1975
|
+
align: "left",
|
|
1976
|
+
baseline: "top"
|
|
1977
|
+
},
|
|
1978
|
+
motion: { type: "static" },
|
|
1979
|
+
life: { enter: 700, fade: 600 }
|
|
1980
|
+
},
|
|
1981
|
+
{
|
|
1982
|
+
key: "alerts-label",
|
|
1983
|
+
count: 1,
|
|
1984
|
+
position: { x: 0.06, y: 0.56 },
|
|
1985
|
+
sprite: {
|
|
1986
|
+
kind: "text",
|
|
1987
|
+
strings: ["ALERTS"],
|
|
1988
|
+
color: "#445566",
|
|
1989
|
+
font: "9px monospace",
|
|
1990
|
+
align: "left",
|
|
1991
|
+
baseline: "top"
|
|
1992
|
+
},
|
|
1993
|
+
motion: { type: "static" },
|
|
1994
|
+
life: { enter: 700, fade: 600 }
|
|
1995
|
+
},
|
|
1996
|
+
{
|
|
1997
|
+
key: "alerts-value",
|
|
1998
|
+
count: 1,
|
|
1999
|
+
position: { x: 0.06, y: 0.6 },
|
|
2000
|
+
sprite: {
|
|
2001
|
+
kind: "text",
|
|
2002
|
+
strings: ["0"],
|
|
2003
|
+
color: "#44cc66",
|
|
2004
|
+
font: "bold 26px monospace",
|
|
2005
|
+
align: "left",
|
|
2006
|
+
baseline: "top"
|
|
2007
|
+
},
|
|
2008
|
+
motion: { type: "static" },
|
|
2009
|
+
life: { enter: 700, fade: 600 }
|
|
2010
|
+
},
|
|
2011
|
+
// --- center: energy gauge (boots third) ---
|
|
2012
|
+
{
|
|
2013
|
+
key: "gauge-ring",
|
|
2014
|
+
count: 1,
|
|
2015
|
+
position: { x: 0.4, y: 0.36 },
|
|
2016
|
+
sprite: { kind: "ring", radius: [0.105, 0.105], color: "#1e3a52", width: 28e-4 },
|
|
2017
|
+
alpha: [0.85, 0.85],
|
|
2018
|
+
motion: { type: "static" },
|
|
2019
|
+
life: { enter: 1200, fade: 700 }
|
|
2020
|
+
},
|
|
2021
|
+
{
|
|
2022
|
+
key: "gauge-glow",
|
|
2023
|
+
count: 1,
|
|
2024
|
+
position: { x: 0.4, y: 0.36 },
|
|
2025
|
+
sprite: { kind: "ring", radius: [0.088, 0.088], color: "#2ee6c8", width: 16e-4 },
|
|
2026
|
+
alpha: [0.55, 0.55],
|
|
2027
|
+
blend: "lighter",
|
|
2028
|
+
pulse: { amp: 0.25, period: 4e3 },
|
|
2029
|
+
grow: { amp: 0.05, period: 4e3 },
|
|
2030
|
+
motion: { type: "static" },
|
|
2031
|
+
life: { enter: 1200, fade: 700 }
|
|
2032
|
+
},
|
|
2033
|
+
{
|
|
2034
|
+
key: "gauge-label",
|
|
2035
|
+
count: 1,
|
|
2036
|
+
position: { x: 0.4, y: 0.29 },
|
|
2037
|
+
sprite: {
|
|
2038
|
+
kind: "text",
|
|
2039
|
+
strings: ["ENERGY"],
|
|
2040
|
+
color: "#445566",
|
|
2041
|
+
font: "9px monospace",
|
|
2042
|
+
align: "center"
|
|
2043
|
+
},
|
|
2044
|
+
motion: { type: "static" },
|
|
2045
|
+
life: { enter: 1200, fade: 700 }
|
|
2046
|
+
},
|
|
2047
|
+
{
|
|
2048
|
+
key: "gauge-value",
|
|
2049
|
+
count: 1,
|
|
2050
|
+
position: { x: 0.4, y: 0.375 },
|
|
2051
|
+
sprite: {
|
|
2052
|
+
kind: "text",
|
|
2053
|
+
strings: ["73%"],
|
|
2054
|
+
color: "#2ee6c8",
|
|
2055
|
+
font: "bold 34px monospace",
|
|
2056
|
+
align: "center"
|
|
2057
|
+
},
|
|
2058
|
+
motion: { type: "static" },
|
|
2059
|
+
life: { enter: 1200, fade: 700 }
|
|
2060
|
+
},
|
|
2061
|
+
{
|
|
2062
|
+
key: "equalizer",
|
|
2063
|
+
count: 22,
|
|
2064
|
+
sprite: {
|
|
2065
|
+
kind: "rect",
|
|
2066
|
+
width: [5e-3, 5e-3],
|
|
2067
|
+
aspect: [0.6, 3.4],
|
|
2068
|
+
color: "#2ee6c8",
|
|
2069
|
+
colors: ["#2ee6c8", "#44aaff", "#aa88ff"],
|
|
2070
|
+
colorWeights: [3, 2, 1]
|
|
2071
|
+
},
|
|
2072
|
+
alpha: [0.35, 0.7],
|
|
2073
|
+
layout: { type: "grid", columns: 22 },
|
|
2074
|
+
region: { x: [0.28, 0.52], y: [0.585, 0.615] },
|
|
2075
|
+
// Wave-phased pulse sweeps along the bars — reads as a live meter.
|
|
2076
|
+
pulse: { amp: 0.4, period: 1600, wave: { wavelength: 0.1, angle: 0 } },
|
|
2077
|
+
motion: { type: "static" },
|
|
2078
|
+
life: { enter: 1200, fade: 700 }
|
|
2079
|
+
},
|
|
2080
|
+
// --- right column: agenda + devices (boots fourth) ---
|
|
2081
|
+
{
|
|
2082
|
+
key: "agenda-label",
|
|
2083
|
+
count: 1,
|
|
2084
|
+
position: { x: 0.64, y: 0.14 },
|
|
2085
|
+
sprite: {
|
|
2086
|
+
kind: "text",
|
|
2087
|
+
strings: ["AGENDA"],
|
|
2088
|
+
color: "#445566",
|
|
2089
|
+
font: "9px monospace",
|
|
2090
|
+
align: "left",
|
|
2091
|
+
baseline: "top"
|
|
2092
|
+
},
|
|
2093
|
+
motion: { type: "static" },
|
|
2094
|
+
life: { enter: 1700, fade: 600 }
|
|
2095
|
+
},
|
|
2096
|
+
{
|
|
2097
|
+
key: "agenda-1",
|
|
2098
|
+
count: 1,
|
|
2099
|
+
position: { x: 0.64, y: 0.19 },
|
|
2100
|
+
sprite: {
|
|
2101
|
+
kind: "text",
|
|
2102
|
+
strings: ["09:00 Standup"],
|
|
2103
|
+
color: "#8899aa",
|
|
2104
|
+
font: "11px monospace",
|
|
2105
|
+
align: "left",
|
|
2106
|
+
baseline: "top",
|
|
2107
|
+
maxWidth: 0.2593
|
|
2108
|
+
},
|
|
2109
|
+
motion: { type: "static" },
|
|
2110
|
+
life: { enter: 1700, fade: 600 }
|
|
2111
|
+
},
|
|
2112
|
+
{
|
|
2113
|
+
key: "agenda-2",
|
|
2114
|
+
count: 1,
|
|
2115
|
+
position: { x: 0.64, y: 0.23 },
|
|
2116
|
+
sprite: {
|
|
2117
|
+
kind: "text",
|
|
2118
|
+
strings: ["12:30 Lunch w/ Kai"],
|
|
2119
|
+
color: "#778899",
|
|
2120
|
+
font: "11px monospace",
|
|
2121
|
+
align: "left",
|
|
2122
|
+
baseline: "top",
|
|
2123
|
+
maxWidth: 0.2593
|
|
2124
|
+
},
|
|
2125
|
+
motion: { type: "static" },
|
|
2126
|
+
life: { enter: 1700, fade: 600 }
|
|
2127
|
+
},
|
|
2128
|
+
{
|
|
2129
|
+
key: "agenda-3",
|
|
2130
|
+
count: 1,
|
|
2131
|
+
position: { x: 0.64, y: 0.27 },
|
|
2132
|
+
sprite: {
|
|
2133
|
+
kind: "text",
|
|
2134
|
+
strings: ["18:00 Gym"],
|
|
2135
|
+
color: "#667788",
|
|
2136
|
+
font: "11px monospace",
|
|
2137
|
+
align: "left",
|
|
2138
|
+
baseline: "top",
|
|
2139
|
+
maxWidth: 0.2593
|
|
2140
|
+
},
|
|
2141
|
+
motion: { type: "static" },
|
|
2142
|
+
life: { enter: 1700, fade: 600 }
|
|
2143
|
+
},
|
|
2144
|
+
{
|
|
2145
|
+
key: "devices-label",
|
|
2146
|
+
count: 1,
|
|
2147
|
+
position: { x: 0.64, y: 0.36 },
|
|
2148
|
+
sprite: {
|
|
2149
|
+
kind: "text",
|
|
2150
|
+
strings: ["DEVICES"],
|
|
2151
|
+
color: "#445566",
|
|
2152
|
+
font: "9px monospace",
|
|
2153
|
+
align: "left",
|
|
2154
|
+
baseline: "top"
|
|
2155
|
+
},
|
|
2156
|
+
motion: { type: "static" },
|
|
2157
|
+
life: { enter: 1700, fade: 600 }
|
|
2158
|
+
},
|
|
2159
|
+
{
|
|
2160
|
+
key: "devices-1",
|
|
2161
|
+
count: 1,
|
|
2162
|
+
position: { x: 0.64, y: 0.41 },
|
|
2163
|
+
sprite: {
|
|
2164
|
+
kind: "text",
|
|
2165
|
+
strings: ["Lights 6 on"],
|
|
2166
|
+
color: "#8899aa",
|
|
2167
|
+
font: "11px monospace",
|
|
2168
|
+
align: "left",
|
|
2169
|
+
baseline: "top"
|
|
2170
|
+
},
|
|
2171
|
+
motion: { type: "static" },
|
|
2172
|
+
life: { enter: 1700, fade: 600 }
|
|
2173
|
+
},
|
|
2174
|
+
{
|
|
2175
|
+
key: "devices-2",
|
|
2176
|
+
count: 1,
|
|
2177
|
+
position: { x: 0.64, y: 0.45 },
|
|
2178
|
+
sprite: {
|
|
2179
|
+
kind: "text",
|
|
2180
|
+
strings: ["Thermostat eco"],
|
|
2181
|
+
color: "#778899",
|
|
2182
|
+
font: "11px monospace",
|
|
2183
|
+
align: "left",
|
|
2184
|
+
baseline: "top"
|
|
2185
|
+
},
|
|
2186
|
+
motion: { type: "static" },
|
|
2187
|
+
life: { enter: 1700, fade: 600 }
|
|
2188
|
+
},
|
|
2189
|
+
{
|
|
2190
|
+
key: "devices-3",
|
|
2191
|
+
count: 1,
|
|
2192
|
+
position: { x: 0.64, y: 0.49 },
|
|
2193
|
+
sprite: {
|
|
2194
|
+
kind: "text",
|
|
2195
|
+
strings: ["Locks secured"],
|
|
2196
|
+
color: "#667788",
|
|
2197
|
+
font: "11px monospace",
|
|
2198
|
+
align: "left",
|
|
2199
|
+
baseline: "top"
|
|
2200
|
+
},
|
|
2201
|
+
motion: { type: "static" },
|
|
2202
|
+
life: { enter: 1700, fade: 600 }
|
|
2203
|
+
},
|
|
2204
|
+
{
|
|
2205
|
+
key: "devices-4",
|
|
2206
|
+
count: 1,
|
|
2207
|
+
position: { x: 0.64, y: 0.53 },
|
|
2208
|
+
sprite: {
|
|
2209
|
+
kind: "text",
|
|
2210
|
+
strings: ["Media paused"],
|
|
2211
|
+
color: "#556677",
|
|
2212
|
+
font: "11px monospace",
|
|
2213
|
+
align: "left",
|
|
2214
|
+
baseline: "top"
|
|
2215
|
+
},
|
|
2216
|
+
motion: { type: "static" },
|
|
2217
|
+
life: { enter: 1700, fade: 600 }
|
|
2218
|
+
},
|
|
2219
|
+
// --- bottom: activity feed (boots last) ---
|
|
2220
|
+
{
|
|
2221
|
+
key: "feed-label",
|
|
2222
|
+
count: 1,
|
|
2223
|
+
position: { x: 0.06, y: 0.74 },
|
|
2224
|
+
sprite: {
|
|
2225
|
+
kind: "text",
|
|
2226
|
+
strings: ["ACTIVITY"],
|
|
2227
|
+
color: "#445566",
|
|
2228
|
+
font: "9px monospace",
|
|
2229
|
+
align: "left",
|
|
2230
|
+
baseline: "top"
|
|
2231
|
+
},
|
|
2232
|
+
motion: { type: "static" },
|
|
2233
|
+
life: { enter: 2200, fade: 600 }
|
|
2234
|
+
},
|
|
2235
|
+
{
|
|
2236
|
+
key: "feed-1",
|
|
2237
|
+
count: 1,
|
|
2238
|
+
position: { x: 0.06, y: 0.78 },
|
|
2239
|
+
sprite: {
|
|
2240
|
+
kind: "text",
|
|
2241
|
+
strings: ["21:42 Front door locked"],
|
|
2242
|
+
color: "#7a8a7a",
|
|
2243
|
+
font: "10px monospace",
|
|
2244
|
+
align: "left",
|
|
2245
|
+
baseline: "top",
|
|
2246
|
+
maxWidth: 0.5556
|
|
2247
|
+
},
|
|
2248
|
+
motion: { type: "static" },
|
|
2249
|
+
life: { enter: 2200, fade: 600 }
|
|
2250
|
+
},
|
|
2251
|
+
{
|
|
2252
|
+
key: "feed-2",
|
|
2253
|
+
count: 1,
|
|
2254
|
+
position: { x: 0.06, y: 0.82 },
|
|
2255
|
+
sprite: {
|
|
2256
|
+
kind: "text",
|
|
2257
|
+
strings: ["21:36 Thermostat \u2192 eco"],
|
|
2258
|
+
color: "#6a7a6a",
|
|
2259
|
+
font: "10px monospace",
|
|
2260
|
+
align: "left",
|
|
2261
|
+
baseline: "top",
|
|
2262
|
+
maxWidth: 0.5556
|
|
2263
|
+
},
|
|
2264
|
+
motion: { type: "static" },
|
|
2265
|
+
life: { enter: 2200, fade: 600 }
|
|
2266
|
+
},
|
|
2267
|
+
{
|
|
2268
|
+
key: "feed-3",
|
|
2269
|
+
count: 1,
|
|
2270
|
+
position: { x: 0.06, y: 0.86 },
|
|
2271
|
+
sprite: {
|
|
2272
|
+
kind: "text",
|
|
2273
|
+
strings: ["21:14 Backup completed"],
|
|
2274
|
+
color: "#5a6a5a",
|
|
2275
|
+
font: "10px monospace",
|
|
2276
|
+
align: "left",
|
|
2277
|
+
baseline: "top",
|
|
2278
|
+
maxWidth: 0.5556
|
|
2279
|
+
},
|
|
2280
|
+
motion: { type: "static" },
|
|
2281
|
+
life: { enter: 2200, fade: 600 }
|
|
2282
|
+
},
|
|
2283
|
+
{
|
|
2284
|
+
key: "feed-4",
|
|
2285
|
+
count: 1,
|
|
2286
|
+
position: { x: 0.06, y: 0.9 },
|
|
2287
|
+
sprite: {
|
|
2288
|
+
kind: "text",
|
|
2289
|
+
strings: ["20:58 Motion \xB7 driveway"],
|
|
2290
|
+
color: "#4d5e4d",
|
|
2291
|
+
font: "10px monospace",
|
|
2292
|
+
align: "left",
|
|
2293
|
+
baseline: "top",
|
|
2294
|
+
maxWidth: 0.5556
|
|
2295
|
+
},
|
|
2296
|
+
motion: { type: "static" },
|
|
2297
|
+
life: { enter: 2200, fade: 600 }
|
|
2298
|
+
},
|
|
2299
|
+
{
|
|
2300
|
+
key: "feed-5",
|
|
2301
|
+
count: 1,
|
|
2302
|
+
position: { x: 0.06, y: 0.94 },
|
|
2303
|
+
sprite: {
|
|
2304
|
+
kind: "text",
|
|
2305
|
+
strings: ["20:41 Sunset scene on"],
|
|
2306
|
+
color: "#3d4e3d",
|
|
2307
|
+
font: "10px monospace",
|
|
2308
|
+
align: "left",
|
|
2309
|
+
baseline: "top",
|
|
2310
|
+
maxWidth: 0.5556
|
|
2311
|
+
},
|
|
2312
|
+
motion: { type: "static" },
|
|
2313
|
+
life: { enter: 2200, fade: 600 }
|
|
2314
|
+
}
|
|
2315
|
+
]
|
|
2316
|
+
};
|
|
2317
|
+
var LANTERNS_SPEC = {
|
|
2318
|
+
schemaVersion: 1,
|
|
2319
|
+
id: "lanterns",
|
|
2320
|
+
label: "Night Lanterns",
|
|
2321
|
+
seed: 88,
|
|
2322
|
+
motionIntensity: "calm",
|
|
2323
|
+
background: {
|
|
2324
|
+
type: "gradient",
|
|
2325
|
+
stops: [
|
|
2326
|
+
{ at: 0, color: "#04060f" },
|
|
2327
|
+
{ at: 0.55, color: "#0b1026" },
|
|
2328
|
+
{ at: 0.85, color: "#251731" },
|
|
2329
|
+
{ at: 1, color: "#472518" }
|
|
2330
|
+
]
|
|
2331
|
+
},
|
|
2332
|
+
layers: [
|
|
2333
|
+
{
|
|
2334
|
+
count: 60,
|
|
2335
|
+
sprite: { kind: "circle", radius: [463e-6, 1296e-6], color: "#8fa0c8" },
|
|
2336
|
+
alpha: [0.35, 1],
|
|
2337
|
+
region: { y: [0, 0.62] },
|
|
2338
|
+
motion: { type: "drift", speed: [463e-6, 1852e-6], bob: 9259e-7 }
|
|
2339
|
+
},
|
|
2340
|
+
{
|
|
2341
|
+
count: 36,
|
|
2342
|
+
sprite: {
|
|
2343
|
+
kind: "circle",
|
|
2344
|
+
radius: [1389e-6, 2778e-6],
|
|
2345
|
+
color: "#b06a2a",
|
|
2346
|
+
soft: true
|
|
2347
|
+
},
|
|
2348
|
+
alpha: [0.5, 0.9],
|
|
2349
|
+
blend: "lighter",
|
|
2350
|
+
pulse: { amp: 0.18, period: 2800 },
|
|
2351
|
+
motion: { type: "rise", speed: [5556e-6, 0.01296], sway: 3704e-6 }
|
|
2352
|
+
},
|
|
2353
|
+
{
|
|
2354
|
+
count: 14,
|
|
2355
|
+
sprite: {
|
|
2356
|
+
kind: "circle",
|
|
2357
|
+
radius: [3241e-6, 6019e-6],
|
|
2358
|
+
color: "#e08a34",
|
|
2359
|
+
soft: true
|
|
2360
|
+
},
|
|
2361
|
+
alpha: [0.6, 1],
|
|
2362
|
+
blend: "lighter",
|
|
2363
|
+
pulse: { amp: 0.22, period: 3400 },
|
|
2364
|
+
motion: { type: "rise", speed: [0.01481, 0.02593], sway: 6481e-6 }
|
|
2365
|
+
},
|
|
2366
|
+
{
|
|
2367
|
+
count: 8,
|
|
2368
|
+
sprite: { kind: "emoji", glyphs: ["\u{1F3EE}"] },
|
|
2369
|
+
size: [0.02407, 0.04074],
|
|
2370
|
+
alpha: [0.85, 1],
|
|
2371
|
+
motion: { type: "rise", speed: [0.02778, 0.04444], sway: 9259e-6 }
|
|
2372
|
+
},
|
|
2373
|
+
{
|
|
2374
|
+
count: 4,
|
|
2375
|
+
sprite: { kind: "emoji", glyphs: ["\u{1F3EE}"] },
|
|
2376
|
+
size: [0.0537, 0.07778],
|
|
2377
|
+
motion: { type: "rise", speed: [0.04815, 0.06852], sway: 0.01296 }
|
|
2378
|
+
},
|
|
2379
|
+
{
|
|
2380
|
+
count: 12,
|
|
2381
|
+
sprite: { kind: "circle", radius: [1852e-6, 463e-5], color: "#e08a34", soft: true },
|
|
2382
|
+
alpha: [0.12, 0.35],
|
|
2383
|
+
blend: "lighter",
|
|
2384
|
+
region: { y: [0.93, 1] },
|
|
2385
|
+
pulse: { amp: 0.1, period: 2200 },
|
|
2386
|
+
motion: { type: "drift", speed: [1852e-6, 5556e-6], bob: 1852e-6 }
|
|
2387
|
+
}
|
|
2388
|
+
]
|
|
2389
|
+
};
|
|
2390
|
+
var MATRIX_RAIN_SPEC = {
|
|
2391
|
+
schemaVersion: 1,
|
|
2392
|
+
id: "matrix-rain",
|
|
2393
|
+
label: "Matrix Rain",
|
|
2394
|
+
seed: 1999,
|
|
2395
|
+
motionIntensity: "moderate",
|
|
2396
|
+
ghosting: 0.88,
|
|
2397
|
+
background: { type: "solid", color: "#010401" },
|
|
2398
|
+
layers: [
|
|
2399
|
+
{
|
|
2400
|
+
key: "rain-far",
|
|
2401
|
+
count: 64,
|
|
2402
|
+
sprite: {
|
|
2403
|
+
kind: "text",
|
|
2404
|
+
strings: ["\u30A2", "\u30AB", "\u30B5", "\u30BF", "\u30CA", "\u30CF", "\u30DE", "\u30E4", "\u30E9", "\u30EF", "0", "1", "7", "Z", "X", "K"],
|
|
2405
|
+
color: "#1c7a2e",
|
|
2406
|
+
font: "bold monospace",
|
|
2407
|
+
cycle: { period: 900 }
|
|
2408
|
+
},
|
|
2409
|
+
size: [0.014, 0.02],
|
|
2410
|
+
layout: { type: "grid", columns: 32, jitter: { y: 1 } },
|
|
2411
|
+
motion: { type: "drift", speed: [0.06, 0.14], angle: 90 },
|
|
2412
|
+
alpha: [0.35, 0.6]
|
|
2413
|
+
},
|
|
2414
|
+
{
|
|
2415
|
+
key: "rain-near",
|
|
2416
|
+
count: 40,
|
|
2417
|
+
sprite: {
|
|
2418
|
+
kind: "text",
|
|
2419
|
+
strings: ["\u30DF", "\u30CD", "\u30EA", "\u30BD", "\u30C4", "\u30CC", "\u30DB", "\u30E6", "3", "8", "9", "V", "N"],
|
|
2420
|
+
color: "#2ecc40",
|
|
2421
|
+
font: "bold monospace",
|
|
2422
|
+
cycle: { period: 700 }
|
|
2423
|
+
},
|
|
2424
|
+
size: [0.022, 0.03],
|
|
2425
|
+
layout: { type: "grid", columns: 20, jitter: { y: 1 } },
|
|
2426
|
+
motion: { type: "drift", speed: [0.16, 0.3], angle: 90 },
|
|
2427
|
+
alpha: [0.6, 0.9]
|
|
2428
|
+
},
|
|
2429
|
+
{
|
|
2430
|
+
key: "heads",
|
|
2431
|
+
count: 12,
|
|
2432
|
+
sprite: {
|
|
2433
|
+
kind: "text",
|
|
2434
|
+
strings: ["\u30B1", "\u30E1", "\u30A8", "\u30E0", "\u30F2", "5", "2"],
|
|
2435
|
+
color: "#c8ffd4",
|
|
2436
|
+
font: "bold monospace",
|
|
2437
|
+
cycle: { period: 500 }
|
|
2438
|
+
},
|
|
2439
|
+
size: [0.024, 0.032],
|
|
2440
|
+
layout: { type: "grid", columns: 12, jitter: { y: 1 } },
|
|
2441
|
+
motion: { type: "drift", speed: [0.2, 0.34], angle: 90 },
|
|
2442
|
+
alpha: [0.9, 1]
|
|
2443
|
+
}
|
|
2444
|
+
]
|
|
2445
|
+
};
|
|
2446
|
+
var POLYGONS_SPEC = {
|
|
2447
|
+
schemaVersion: 1,
|
|
2448
|
+
id: "polygons",
|
|
2449
|
+
label: "Polygons",
|
|
2450
|
+
seed: 1995,
|
|
2451
|
+
motionIntensity: "moderate",
|
|
2452
|
+
ghosting: 0.95,
|
|
2453
|
+
background: { type: "solid", color: "#04040a" },
|
|
2454
|
+
layers: [
|
|
2455
|
+
{
|
|
2456
|
+
key: "poly-cyan",
|
|
2457
|
+
count: 4,
|
|
2458
|
+
sprite: { kind: "circle", radius: [25e-4, 25e-4], color: "#37e5d7" },
|
|
2459
|
+
motion: { type: "bounce", speed: [0.14, 0.24] },
|
|
2460
|
+
wrap: false,
|
|
2461
|
+
alpha: [0.9, 0.9],
|
|
2462
|
+
links: { k: 1, maxDist: 3, mode: "chain", closed: true, color: "#37e5d7", alpha: 0.85, width: 18e-4 }
|
|
2463
|
+
},
|
|
2464
|
+
{
|
|
2465
|
+
key: "poly-magenta",
|
|
2466
|
+
count: 4,
|
|
2467
|
+
sprite: { kind: "circle", radius: [25e-4, 25e-4], color: "#e83e9c" },
|
|
2468
|
+
motion: { type: "bounce", speed: [0.1, 0.2] },
|
|
2469
|
+
wrap: false,
|
|
2470
|
+
alpha: [0.9, 0.9],
|
|
2471
|
+
links: { k: 1, maxDist: 3, mode: "chain", closed: true, color: "#e83e9c", alpha: 0.85, width: 18e-4 }
|
|
2472
|
+
}
|
|
2473
|
+
]
|
|
2474
|
+
};
|
|
2475
|
+
var ORRERY_SPEC = {
|
|
2476
|
+
schemaVersion: 1,
|
|
2477
|
+
id: "orrery",
|
|
2478
|
+
label: "Orrery",
|
|
2479
|
+
seed: 7,
|
|
2480
|
+
motionIntensity: "calm",
|
|
2481
|
+
background: {
|
|
2482
|
+
type: "gradient",
|
|
2483
|
+
stops: [
|
|
2484
|
+
{ at: 0, color: "#020210" },
|
|
2485
|
+
{ at: 0.5, color: "#06051a" },
|
|
2486
|
+
{ at: 1, color: "#0a0820" }
|
|
2487
|
+
]
|
|
2488
|
+
},
|
|
2489
|
+
layers: [
|
|
2490
|
+
// Distant stars
|
|
2491
|
+
{
|
|
2492
|
+
count: 80,
|
|
2493
|
+
sprite: { kind: "circle", radius: [2778e-7, 1111e-6], color: "#8899cc" },
|
|
2494
|
+
alpha: [0.2, 0.8],
|
|
2495
|
+
pulse: { amp: 0.3, period: 3e3 },
|
|
2496
|
+
motion: { type: "static" }
|
|
2497
|
+
},
|
|
2498
|
+
// Sun corona (soft glow)
|
|
2499
|
+
{
|
|
2500
|
+
key: "corona",
|
|
2501
|
+
count: 1,
|
|
2502
|
+
sprite: { kind: "circle", radius: [0.05556, 0.05556], color: "#ffaa22", soft: true },
|
|
2503
|
+
blend: "lighter",
|
|
2504
|
+
alpha: [0.6, 0.6],
|
|
2505
|
+
grow: { amp: 0.15, period: 4e3 },
|
|
2506
|
+
motion: { type: "static" },
|
|
2507
|
+
position: { x: 0.5, y: 0.5 }
|
|
2508
|
+
},
|
|
2509
|
+
// Sun body
|
|
2510
|
+
{
|
|
2511
|
+
key: "sun",
|
|
2512
|
+
count: 1,
|
|
2513
|
+
sprite: { kind: "emoji", glyphs: ["\u2600\uFE0F"] },
|
|
2514
|
+
size: [0.04444, 0.04444],
|
|
2515
|
+
grow: { amp: 0.08, period: 4e3 },
|
|
2516
|
+
motion: { type: "static" },
|
|
2517
|
+
position: { x: 0.5, y: 0.5 }
|
|
2518
|
+
},
|
|
2519
|
+
// Inner ring — small fast planets
|
|
2520
|
+
{
|
|
2521
|
+
key: "inner",
|
|
2522
|
+
count: 3,
|
|
2523
|
+
sprite: { kind: "emoji", glyphs: ["\u{1FAA8}", "\u{1F534}", "\u{1F7E0}"] },
|
|
2524
|
+
size: [0.01481, 0.02037],
|
|
2525
|
+
spin: 30,
|
|
2526
|
+
motion: { type: "orbit", speed: [28, 42], radius: [0.07407, 0.1111] }
|
|
2527
|
+
},
|
|
2528
|
+
// Middle ring — gas giants
|
|
2529
|
+
{
|
|
2530
|
+
key: "middle",
|
|
2531
|
+
count: 2,
|
|
2532
|
+
sprite: { kind: "emoji", glyphs: ["\u{1F7E4}", "\u{1FA90}"] },
|
|
2533
|
+
size: [0.02593, 0.03519],
|
|
2534
|
+
spin: -15,
|
|
2535
|
+
motion: { type: "orbit", speed: [12, 20], radius: [0.1481, 0.1852] }
|
|
2536
|
+
},
|
|
2537
|
+
// Outer ring — ice giants
|
|
2538
|
+
{
|
|
2539
|
+
key: "outer",
|
|
2540
|
+
count: 2,
|
|
2541
|
+
sprite: { kind: "emoji", glyphs: ["\u{1F535}", "\u{1F48E}"] },
|
|
2542
|
+
size: [0.02037, 0.02778],
|
|
2543
|
+
spin: 10,
|
|
2544
|
+
motion: { type: "orbit", speed: [5, 10], radius: [0.2222, 0.2778] }
|
|
2545
|
+
},
|
|
2546
|
+
// Orbital dust ring (soft glow particles orbiting slowly)
|
|
2547
|
+
{
|
|
2548
|
+
count: 24,
|
|
2549
|
+
sprite: { kind: "circle", radius: [9259e-7, 2778e-6], color: "#ccaa66", soft: true },
|
|
2550
|
+
alpha: [0.15, 0.4],
|
|
2551
|
+
blend: "lighter",
|
|
2552
|
+
pulse: { amp: 0.2, period: 2500 },
|
|
2553
|
+
motion: { type: "orbit", speed: [2, 8], radius: [0.09259, 0.2963] }
|
|
2554
|
+
}
|
|
2555
|
+
]
|
|
2556
|
+
};
|
|
2557
|
+
var PROCESSION_SPEC = {
|
|
2558
|
+
schemaVersion: 1,
|
|
2559
|
+
id: "procession",
|
|
2560
|
+
label: "Night Procession",
|
|
2561
|
+
seed: 8,
|
|
2562
|
+
motionIntensity: "calm",
|
|
2563
|
+
background: {
|
|
2564
|
+
type: "gradient",
|
|
2565
|
+
stops: [
|
|
2566
|
+
{ at: 0, color: "#060612" },
|
|
2567
|
+
{ at: 0.8, color: "#101024" },
|
|
2568
|
+
{ at: 1, color: "#1a1428" }
|
|
2569
|
+
],
|
|
2570
|
+
drift: { period: 3e4, amount: 0.08 }
|
|
2571
|
+
},
|
|
2572
|
+
layers: [
|
|
2573
|
+
{
|
|
2574
|
+
key: "stars",
|
|
2575
|
+
count: 90,
|
|
2576
|
+
sprite: { kind: "circle", radius: [6e-4, 16e-4], color: "#f0ead8", soft: true },
|
|
2577
|
+
motion: { type: "static" },
|
|
2578
|
+
region: { y: [0, 0.6] },
|
|
2579
|
+
alpha: [0.25, 0.6],
|
|
2580
|
+
pulse: { amp: 0.15, period: 5e3 }
|
|
2581
|
+
},
|
|
2582
|
+
{
|
|
2583
|
+
key: "lanterns",
|
|
2584
|
+
count: 9,
|
|
2585
|
+
sprite: {
|
|
2586
|
+
kind: "rect",
|
|
2587
|
+
width: [0.012, 0.02],
|
|
2588
|
+
aspect: [1.3, 1.7],
|
|
2589
|
+
color: "#ffb347",
|
|
2590
|
+
colors: ["#ffb347", "#ff8c69", "#ffd97a"],
|
|
2591
|
+
colorWeights: [3, 1, 2]
|
|
2592
|
+
},
|
|
2593
|
+
motion: {
|
|
2594
|
+
type: "path",
|
|
2595
|
+
points: [
|
|
2596
|
+
{ x: 0.12, y: 0.72 },
|
|
2597
|
+
{ x: 0.38, y: 0.58 },
|
|
2598
|
+
{ x: 0.62, y: 0.78 },
|
|
2599
|
+
{ x: 0.88, y: 0.62 },
|
|
2600
|
+
{ x: 0.62, y: 0.5 },
|
|
2601
|
+
{ x: 0.38, y: 0.72 }
|
|
2602
|
+
],
|
|
2603
|
+
duration: 36e3,
|
|
2604
|
+
curve: "smooth",
|
|
2605
|
+
closed: true,
|
|
2606
|
+
scatter: 0.02
|
|
2607
|
+
},
|
|
2608
|
+
alpha: [0.65, 0.9],
|
|
2609
|
+
pulse: { amp: 0.15, period: 2600 },
|
|
2610
|
+
life: { enter: 4e3, fade: 2500 },
|
|
2611
|
+
trail: { length: 1200, fade: 1 }
|
|
2612
|
+
},
|
|
2613
|
+
{
|
|
2614
|
+
key: "bearer",
|
|
2615
|
+
count: 1,
|
|
2616
|
+
sprite: { kind: "circle", radius: [0.014, 0.014], color: "#ffe9b0", soft: true },
|
|
2617
|
+
motion: { type: "wander", speed: [8e-3, 0.012], meander: 0.08 },
|
|
2618
|
+
alpha: [0.8, 0.8],
|
|
2619
|
+
blend: "lighter",
|
|
2620
|
+
life: { enter: 4e3, fade: 2500 }
|
|
2621
|
+
},
|
|
2622
|
+
{
|
|
2623
|
+
key: "moths",
|
|
2624
|
+
count: 7,
|
|
2625
|
+
sprite: { kind: "ring", radius: [2e-3, 5e-3], color: "#d8f6ff", width: 1e-3 },
|
|
2626
|
+
motion: { type: "orbit", speed: [20, 55], radius: [0.03, 0.09], center: { layer: "bearer" } },
|
|
2627
|
+
alpha: [0.3, 0.7],
|
|
2628
|
+
life: { enter: 7e3, fade: 2e3 },
|
|
2629
|
+
trail: { length: 600 }
|
|
2630
|
+
}
|
|
2631
|
+
]
|
|
2632
|
+
};
|
|
2633
|
+
var RAIN_SPEC = {
|
|
2634
|
+
schemaVersion: 1,
|
|
2635
|
+
id: "rain",
|
|
2636
|
+
label: "Rain",
|
|
2637
|
+
seed: 7,
|
|
2638
|
+
motionIntensity: "moderate",
|
|
2639
|
+
background: { type: "solid", color: "#05070a" },
|
|
2640
|
+
layers: [
|
|
2641
|
+
{
|
|
2642
|
+
count: 140,
|
|
2643
|
+
sprite: { kind: "text", strings: ["\u2502"], color: "#9fd0ff" },
|
|
2644
|
+
size: [0.01111, 0.02407],
|
|
2645
|
+
motion: { type: "drift", angle: 90, speed: [0.4815, 0.8333] }
|
|
2646
|
+
}
|
|
2647
|
+
]
|
|
2648
|
+
};
|
|
2649
|
+
var SAKURA_SPEC = {
|
|
2650
|
+
schemaVersion: 1,
|
|
2651
|
+
id: "sakura",
|
|
2652
|
+
label: "Sakura Drift",
|
|
2653
|
+
seed: 314,
|
|
2654
|
+
motionIntensity: "calm",
|
|
2655
|
+
background: {
|
|
2656
|
+
type: "gradient",
|
|
2657
|
+
stops: [
|
|
2658
|
+
{ at: 0, color: "#1b1d38" },
|
|
2659
|
+
{ at: 0.45, color: "#3a2645" },
|
|
2660
|
+
{ at: 0.78, color: "#7d3d4e" },
|
|
2661
|
+
{ at: 0.92, color: "#4a2438" },
|
|
2662
|
+
{ at: 1, color: "#1c1018" }
|
|
2663
|
+
],
|
|
2664
|
+
drift: { period: 35e3, amount: 0.08 }
|
|
2665
|
+
},
|
|
2666
|
+
layers: [
|
|
2667
|
+
{
|
|
2668
|
+
key: "blossom-glow",
|
|
2669
|
+
count: 60,
|
|
2670
|
+
sprite: {
|
|
2671
|
+
kind: "circle",
|
|
2672
|
+
radius: [5556e-7, 1481e-6],
|
|
2673
|
+
color: "#ffe3ec",
|
|
2674
|
+
soft: true
|
|
2675
|
+
},
|
|
2676
|
+
alpha: [0.3, 0.9],
|
|
2677
|
+
blend: "lighter",
|
|
2678
|
+
region: { y: [0, 0.72] },
|
|
2679
|
+
// Shimmer travels across the sky instead of orbs twinkling independently.
|
|
2680
|
+
pulse: { amp: 0.22, period: 4e3, wave: { wavelength: 0.45, angle: 10 } },
|
|
2681
|
+
motion: { type: "drift", speed: [2778e-7, 1111e-6], bob: 9259e-7 }
|
|
2682
|
+
},
|
|
2683
|
+
{
|
|
2684
|
+
key: "petals-far",
|
|
2685
|
+
count: 28,
|
|
2686
|
+
sprite: { kind: "emoji", glyphs: ["\u{1F338}"] },
|
|
2687
|
+
size: [0.01204, 0.01852],
|
|
2688
|
+
alpha: [0.5, 0.8],
|
|
2689
|
+
spin: 16,
|
|
2690
|
+
motion: {
|
|
2691
|
+
type: "wander",
|
|
2692
|
+
speed: [0.011, 0.024],
|
|
2693
|
+
angle: 100,
|
|
2694
|
+
meander: 0.025,
|
|
2695
|
+
coherence: 0.35
|
|
2696
|
+
}
|
|
2697
|
+
},
|
|
2698
|
+
{
|
|
2699
|
+
key: "petals-mid",
|
|
2700
|
+
count: 18,
|
|
2701
|
+
sprite: { kind: "emoji", glyphs: ["\u{1F338}"] },
|
|
2702
|
+
size: [0.01852, 0.02963],
|
|
2703
|
+
alpha: [0.7, 0.95],
|
|
2704
|
+
spin: 24,
|
|
2705
|
+
motion: {
|
|
2706
|
+
type: "wander",
|
|
2707
|
+
speed: [0.022, 0.041],
|
|
2708
|
+
angle: 100,
|
|
2709
|
+
meander: 0.045,
|
|
2710
|
+
coherence: 0.35
|
|
2711
|
+
}
|
|
2712
|
+
},
|
|
2713
|
+
{
|
|
2714
|
+
key: "petals-near",
|
|
2715
|
+
count: 10,
|
|
2716
|
+
sprite: { kind: "emoji", glyphs: ["\u{1F338}"] },
|
|
2717
|
+
size: [0.03148, 0.05],
|
|
2718
|
+
alpha: [0.85, 1],
|
|
2719
|
+
spin: 32,
|
|
2720
|
+
motion: {
|
|
2721
|
+
type: "wander",
|
|
2722
|
+
speed: [0.039, 0.063],
|
|
2723
|
+
angle: 100,
|
|
2724
|
+
meander: 0.07,
|
|
2725
|
+
coherence: 0.35
|
|
2726
|
+
}
|
|
2727
|
+
},
|
|
2728
|
+
{
|
|
2729
|
+
key: "gusts",
|
|
2730
|
+
count: 7,
|
|
2731
|
+
sprite: {
|
|
2732
|
+
kind: "streak",
|
|
2733
|
+
length: [0.02, 0.045],
|
|
2734
|
+
width: 12e-4,
|
|
2735
|
+
color: "#ffd9e6"
|
|
2736
|
+
},
|
|
2737
|
+
alpha: [0.1, 0.22],
|
|
2738
|
+
blend: "lighter",
|
|
2739
|
+
motion: { type: "drift", speed: [0.09, 0.14], angle: 100 }
|
|
2740
|
+
},
|
|
2741
|
+
{
|
|
2742
|
+
key: "fireflies",
|
|
2743
|
+
count: 6,
|
|
2744
|
+
sprite: {
|
|
2745
|
+
kind: "circle",
|
|
2746
|
+
radius: [9e-4, 2e-3],
|
|
2747
|
+
color: "#ffe9a8",
|
|
2748
|
+
soft: true
|
|
2749
|
+
},
|
|
2750
|
+
alpha: [0.15, 0.5],
|
|
2751
|
+
blend: "lighter",
|
|
2752
|
+
region: { y: [0.6, 0.9] },
|
|
2753
|
+
pulse: { amp: 0.3, period: 2800 },
|
|
2754
|
+
motion: { type: "wander", speed: [4e-3, 0.01], meander: 0.05 }
|
|
2755
|
+
},
|
|
2756
|
+
{
|
|
2757
|
+
key: "fallen-petals",
|
|
2758
|
+
count: 16,
|
|
2759
|
+
sprite: {
|
|
2760
|
+
kind: "circle",
|
|
2761
|
+
radius: [1389e-6, 3704e-6],
|
|
2762
|
+
color: "#ff9bb5",
|
|
2763
|
+
soft: true
|
|
2764
|
+
},
|
|
2765
|
+
alpha: [0.1, 0.3],
|
|
2766
|
+
blend: "lighter",
|
|
2767
|
+
region: { y: [0.9, 1] },
|
|
2768
|
+
// Settled petals catch the last light in a slow wave along the ground.
|
|
2769
|
+
pulse: { amp: 0.15, period: 3200, wave: { wavelength: 0.3, angle: 0 } },
|
|
2770
|
+
motion: {
|
|
2771
|
+
type: "drift",
|
|
2772
|
+
speed: [2778e-7, 1389e-6],
|
|
2773
|
+
angle: 180,
|
|
2774
|
+
bob: 9259e-7
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
]
|
|
2778
|
+
};
|
|
2779
|
+
var SNOWFALL_SPEC = {
|
|
2780
|
+
schemaVersion: 1,
|
|
2781
|
+
id: "snowfall",
|
|
2782
|
+
label: "Snowfall",
|
|
2783
|
+
seed: 12,
|
|
2784
|
+
motionIntensity: "calm",
|
|
2785
|
+
background: {
|
|
2786
|
+
type: "gradient",
|
|
2787
|
+
stops: [
|
|
2788
|
+
{ at: 0, color: "#0a1628" },
|
|
2789
|
+
{ at: 0.7, color: "#0d1f3c" },
|
|
2790
|
+
{ at: 1, color: "#121212" }
|
|
2791
|
+
]
|
|
2792
|
+
},
|
|
2793
|
+
layers: [
|
|
2794
|
+
{
|
|
2795
|
+
count: 50,
|
|
2796
|
+
sprite: { kind: "circle", radius: [9259e-7, 2315e-6], color: "#8899aa" },
|
|
2797
|
+
motion: { type: "drift", angle: 90, speed: [0.01389, 0.03704], bob: 2778e-6 }
|
|
2798
|
+
},
|
|
2799
|
+
{
|
|
2800
|
+
count: 35,
|
|
2801
|
+
sprite: { kind: "circle", radius: [1852e-6, 4167e-6], color: "#c0cdd8" },
|
|
2802
|
+
motion: { type: "drift", angle: 85, speed: [0.03241, 0.07407], bob: 5556e-6 }
|
|
2803
|
+
},
|
|
2804
|
+
{
|
|
2805
|
+
count: 15,
|
|
2806
|
+
sprite: { kind: "circle", radius: [3241e-6, 6481e-6], color: "#e8eff5" },
|
|
2807
|
+
motion: { type: "drift", angle: 82, speed: [0.05093, 0.1111], bob: 9259e-6 }
|
|
2808
|
+
}
|
|
2809
|
+
]
|
|
2810
|
+
};
|
|
2811
|
+
var WARP_TUNNEL_SPEC = {
|
|
2812
|
+
schemaVersion: 1,
|
|
2813
|
+
id: "warp-tunnel",
|
|
2814
|
+
label: "Warp Tunnel",
|
|
2815
|
+
seed: 1701,
|
|
2816
|
+
motionIntensity: "energetic",
|
|
2817
|
+
ghosting: 0.55,
|
|
2818
|
+
background: { type: "solid", color: "#020208" },
|
|
2819
|
+
layers: [
|
|
2820
|
+
{
|
|
2821
|
+
key: "far-stars",
|
|
2822
|
+
count: 150,
|
|
2823
|
+
sprite: {
|
|
2824
|
+
kind: "streak",
|
|
2825
|
+
length: [8e-3, 0.02],
|
|
2826
|
+
width: 15e-4,
|
|
2827
|
+
color: "#cfd8ff",
|
|
2828
|
+
colors: ["#cfd8ff", "#ffffff", "#8ab4ff", "#ffd9a0"],
|
|
2829
|
+
colorWeights: [5, 3, 1.5, 0.5]
|
|
2830
|
+
},
|
|
2831
|
+
motion: { type: "warp", speed: [0.06, 0.16] },
|
|
2832
|
+
alpha: [0.5, 0.9],
|
|
2833
|
+
blend: "lighter"
|
|
2834
|
+
},
|
|
2835
|
+
{
|
|
2836
|
+
key: "near-stars",
|
|
2837
|
+
count: 50,
|
|
2838
|
+
sprite: {
|
|
2839
|
+
kind: "streak",
|
|
2840
|
+
length: [0.025, 0.06],
|
|
2841
|
+
width: 25e-4,
|
|
2842
|
+
color: "#ffffff",
|
|
2843
|
+
colors: ["#ffffff", "#a8c8ff"],
|
|
2844
|
+
colorWeights: [3, 1]
|
|
2845
|
+
},
|
|
2846
|
+
motion: { type: "warp", speed: [0.3, 0.55] },
|
|
2847
|
+
alpha: [0.7, 1],
|
|
2848
|
+
blend: "lighter"
|
|
2849
|
+
},
|
|
2850
|
+
{
|
|
2851
|
+
key: "core-glow",
|
|
2852
|
+
count: 1,
|
|
2853
|
+
sprite: { kind: "circle", radius: [0.06, 0.06], color: "#3a4a8f", soft: true },
|
|
2854
|
+
motion: { type: "static" },
|
|
2855
|
+
position: { x: 0.5, y: 0.5 },
|
|
2856
|
+
alpha: [0.35, 0.35],
|
|
2857
|
+
pulse: { amp: 0.15, period: 5e3 },
|
|
2858
|
+
blend: "lighter"
|
|
2859
|
+
}
|
|
2860
|
+
]
|
|
2861
|
+
};
|
|
2862
|
+
var SCHEMA_EXAMPLES = [
|
|
2863
|
+
{ id: "aquarium", label: "Aquarium", spec: AQUARIUM_SPEC },
|
|
2864
|
+
{ id: "rain", label: "Rain", spec: RAIN_SPEC },
|
|
2865
|
+
{ id: "snowfall", label: "Snowfall", spec: SNOWFALL_SPEC },
|
|
2866
|
+
{ id: "lanterns", label: "Night Lanterns", spec: LANTERNS_SPEC },
|
|
2867
|
+
{ id: "sakura", label: "Sakura Drift", spec: SAKURA_SPEC },
|
|
2868
|
+
{ id: "dev-dashboard", label: "Control Center", spec: DASHBOARD_SPEC },
|
|
2869
|
+
{ id: "orrery", label: "Orrery", spec: ORRERY_SPEC },
|
|
2870
|
+
{ id: "constellation", label: "Constellation", spec: CONSTELLATION_SPEC },
|
|
2871
|
+
{ id: "comets", label: "Comet Shower", spec: COMETS_SPEC },
|
|
2872
|
+
{ id: "aurora", label: "Aurora", spec: AURORA_SPEC },
|
|
2873
|
+
{ id: "warp-tunnel", label: "Warp Tunnel", spec: WARP_TUNNEL_SPEC },
|
|
2874
|
+
{ id: "polygons", label: "Polygons", spec: POLYGONS_SPEC },
|
|
2875
|
+
{ id: "matrix-rain", label: "Matrix Rain", spec: MATRIX_RAIN_SPEC },
|
|
2876
|
+
{ id: "procession", label: "Night Procession", spec: PROCESSION_SPEC }
|
|
2877
|
+
];
|
|
2878
|
+
var EXAMPLE_SPECS = SCHEMA_EXAMPLES.map((e) => e.spec);
|
|
2879
|
+
var EXAMPLE_BY_ID = Object.fromEntries(
|
|
2880
|
+
SCHEMA_EXAMPLES.map((e) => [e.id, e.spec])
|
|
2881
|
+
);
|
|
2882
|
+
|
|
2883
|
+
// src/idle-worker.ts
|
|
2884
|
+
runIdleWorker(
|
|
2885
|
+
{
|
|
2886
|
+
[warp.manifest.id]: warp,
|
|
2887
|
+
[hardRain.manifest.id]: hardRain,
|
|
2888
|
+
[rainstorm.manifest.id]: rainstorm,
|
|
2889
|
+
[globe.manifest.id]: globe,
|
|
2890
|
+
[spotlight.manifest.id]: spotlight,
|
|
2891
|
+
[mystify.manifest.id]: mystify,
|
|
2892
|
+
[pipes.manifest.id]: pipes,
|
|
2893
|
+
[flurry.manifest.id]: flurry,
|
|
2894
|
+
[fluid.manifest.id]: fluid,
|
|
2895
|
+
[reactionDiffusion.manifest.id]: reactionDiffusion
|
|
2896
|
+
},
|
|
2897
|
+
{ compiler: compileSaver }
|
|
2898
|
+
);
|
|
18
2899
|
//# sourceMappingURL=idle-worker.js.map
|