@idle-screens/savers-classic 3.1.0 → 3.2.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.
@@ -21,6 +21,8 @@ var PARAM_SPACE = {
21
21
  var dvdManifest = {
22
22
  id: "dvd",
23
23
  label: "Bouncing Logo",
24
+ description: "A logo bounces off viewport edges, changing color at each bounce.",
25
+ timeModel: "closed-form",
24
26
  passthrough: false,
25
27
  minBackend: "canvas2d",
26
28
  costTier: "low",
@@ -365,6 +367,8 @@ var PARAM_SPACE2 = {
365
367
  var warpManifest = {
366
368
  id: "warp",
367
369
  label: "Warp",
370
+ description: "Starfield warp speed effect \u2014 stars stream from center.",
371
+ timeModel: "closed-form",
368
372
  passthrough: false,
369
373
  minBackend: "canvas2d",
370
374
  costTier: "low",
@@ -603,6 +607,8 @@ var warpDemoTrack = {
603
607
  var hardRainManifest = {
604
608
  id: "hard-rain",
605
609
  label: "Hard Rain",
610
+ description: "Dense vertical rain with splash effects.",
611
+ timeModel: "closed-form",
606
612
  passthrough: false,
607
613
  minBackend: "canvas2d",
608
614
  costTier: "low",
@@ -894,6 +900,8 @@ var hardRain = {
894
900
  var rainstormManifest = {
895
901
  id: "rainstorm",
896
902
  label: "Rainstorm",
903
+ description: "Diagonal rain streaks with varying speed and opacity.",
904
+ timeModel: "closed-form",
897
905
  passthrough: false,
898
906
  minBackend: "canvas2d",
899
907
  costTier: "low",
@@ -1104,6 +1112,8 @@ var PARAM_SPACE3 = {
1104
1112
  var globeManifest = {
1105
1113
  id: "globe",
1106
1114
  label: "Globe",
1115
+ description: "Wireframe rotating globe with latitude/longitude lines.",
1116
+ timeModel: "closed-form",
1107
1117
  passthrough: false,
1108
1118
  minBackend: "canvas2d",
1109
1119
  costTier: "low",
@@ -1411,6 +1421,8 @@ var globeDemoTrack = {
1411
1421
  var spotlightManifest = {
1412
1422
  id: "spotlight",
1413
1423
  label: "Spotlight",
1424
+ description: "A transparent circle follows a path, revealing the page beneath. Passthrough saver.",
1425
+ timeModel: "closed-form",
1414
1426
  passthrough: true,
1415
1427
  minBackend: "canvas2d",
1416
1428
  costTier: "low",
@@ -1547,14 +1559,34 @@ var spotlight = {
1547
1559
  };
1548
1560
 
1549
1561
  // src/mystify.ts
1562
+ import {
1563
+ sampleTrack as sampleTrack4,
1564
+ defaultParams as defaultParams4
1565
+ } from "@idle-screens/core";
1566
+ var PARAM_SPACE4 = {
1567
+ /** How many polygons perform. Identities are stable per slot (seeded
1568
+ * forks), so steering the count never re-rolls the visible shapes. */
1569
+ shapes: { type: "number", default: 3, min: 1, max: 6 },
1570
+ /** Motion rate multiplier — integrated, so live changes never teleport. */
1571
+ speed: { type: "number", default: 1, min: 0.25, max: 2.5, ease: "smooth" },
1572
+ /** Trail persistence: 0 = crisp outline, 1 = long dreamy ribbons. */
1573
+ trail: { type: "number", default: 0.55, min: 0, max: 1, ease: "smooth" },
1574
+ /** Stroke width, px. */
1575
+ width: { type: "number", default: 2, min: 1, max: 5, ease: "smooth" },
1576
+ /** Additive hue rotation over each shape's seeded base hue, degrees. */
1577
+ hueShift: { type: "number", default: 0, min: 0, max: 360, ease: "smooth" }
1578
+ };
1550
1579
  var mystifyManifest = {
1551
1580
  id: "mystify",
1552
1581
  label: "Mystify",
1582
+ description: "Drifting polygons leave fading trails. Inspired by Windows Mystify.",
1583
+ timeModel: "closed-form",
1553
1584
  passthrough: false,
1554
1585
  minBackend: "canvas2d",
1555
1586
  costTier: "low",
1556
1587
  motionIntensity: "moderate",
1557
1588
  reducedMotionFallback: "static",
1589
+ paramSpace: PARAM_SPACE4,
1558
1590
  attribution: {
1559
1591
  source: 'Windows "Mystify" \u2014 concept only; clean-room reimplementation',
1560
1592
  license: "MIT (original code)"
@@ -1562,18 +1594,39 @@ var mystifyManifest = {
1562
1594
  a11y: { flashSafe: true, notes: "Slow-fade polygon trails on black; no strobing." },
1563
1595
  workerReady: true
1564
1596
  };
1565
- var SHAPE_COUNT = 3;
1566
- var TRAIL_ALPHA = 0.12;
1567
- var MystifyInstance = class {
1597
+ var MAX_SHAPES = 6;
1598
+ var GHOST_MS = 25;
1599
+ var PHASE_BUCKET_MS = 250;
1600
+ var fold = (p, span) => {
1601
+ const period = 2 * span;
1602
+ const m = (p % period + period) % period;
1603
+ return m <= span ? m : period - m;
1604
+ };
1605
+ var MystifyInstance = class _MystifyInstance {
1568
1606
  ctxSaver;
1569
1607
  canvas;
1570
1608
  ctx;
1571
1609
  w = 0;
1572
1610
  h = 0;
1573
- shapes = [];
1611
+ shapes;
1612
+ track = null;
1613
+ baseParams = defaultParams4(PARAM_SPACE4);
1614
+ /** Append-only speed-integral caches, one slot per PHASE_BUCKET_MS. */
1615
+ phiPrefix = [0];
1616
+ phiSpeeds = [];
1574
1617
  frameId = null;
1575
- last = 0;
1576
1618
  paused = false;
1619
+ startT = 0;
1620
+ /** Logical time the next rAF origin resumes from.
1621
+ *
1622
+ * `start()` re-anchors `startT` to the next frame's timestamp, so on its own
1623
+ * `now - startT` always begins at zero. Mount wants that; resuming from a
1624
+ * pause does not — without carrying the frozen `t` forward, every
1625
+ * pause/resume (and every reduced-motion toggle) snaps the scene back to its
1626
+ * opening frame and restarts any applied control track. Set only in
1627
+ * `setPaused(false)`, so first mount still starts at 0. */
1628
+ resumeFrom = 0;
1629
+ t = 0;
1577
1630
  constructor(ctx) {
1578
1631
  this.ctxSaver = ctx;
1579
1632
  let canvas;
@@ -1593,31 +1646,28 @@ var MystifyInstance = class {
1593
1646
  this.w = ctx.width;
1594
1647
  this.h = ctx.height;
1595
1648
  this.sizeCanvas();
1596
- this.shapes = this.buildShapes(ctx.rng);
1597
- this.clearFull();
1649
+ this.shapes = _MystifyInstance.buildShapes(ctx.rng);
1598
1650
  this.paused = ctx.reducedMotion;
1599
1651
  if (this.paused) this.renderStill();
1600
1652
  else this.start();
1601
1653
  }
1602
- buildShapes(rng) {
1654
+ /** The full identity pool, one fork per slot — count-independent. */
1655
+ static buildShapes(rng) {
1603
1656
  const out = [];
1604
- for (let s = 0; s < SHAPE_COUNT; s++) {
1605
- const vertCount = rng.int(3, 5);
1606
- const hue = rng.int(0, 359);
1607
- const verts = [];
1657
+ for (let s = 0; s < MAX_SHAPES; s++) {
1658
+ const f = rng.fork(61469 + s);
1659
+ const vertCount = f.int(3, 5);
1660
+ const hue = f.int(0, 359);
1661
+ const id = { hue, fx: [], fy: [], vx: [], vy: [] };
1608
1662
  for (let v = 0; v < vertCount; v++) {
1609
- const x = rng.range(this.w * 0.15, this.w * 0.85);
1610
- const y = rng.range(this.h * 0.15, this.h * 0.85);
1611
- const dir = rng.range(0, Math.PI * 2);
1612
- const speed = rng.range(70, 150);
1613
- verts.push({
1614
- x,
1615
- y,
1616
- vx: Math.cos(dir) * speed,
1617
- vy: Math.sin(dir) * speed
1618
- });
1663
+ id.fx.push(f.range(0.15, 0.85));
1664
+ id.fy.push(f.range(0.15, 0.85));
1665
+ const dir = f.range(0, Math.PI * 2);
1666
+ const speed = f.range(70, 150);
1667
+ id.vx.push(Math.cos(dir) * speed);
1668
+ id.vy.push(Math.sin(dir) * speed);
1619
1669
  }
1620
- out.push({ hue, verts });
1670
+ out.push(id);
1621
1671
  }
1622
1672
  return out;
1623
1673
  }
@@ -1627,13 +1677,40 @@ var MystifyInstance = class {
1627
1677
  this.canvas.height = Math.max(1, Math.round(this.h * dpr));
1628
1678
  this.ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
1629
1679
  }
1630
- clearFull() {
1631
- this.ctx.fillStyle = "#000";
1632
- this.ctx.fillRect(0, 0, this.w, this.h);
1680
+ /** Params at `t` — track-driven when applied, defaults otherwise. */
1681
+ paramsAt(t) {
1682
+ if (!this.track) return this.baseParams;
1683
+ const p = sampleTrack4(PARAM_SPACE4, this.track, t);
1684
+ const out = { ...this.baseParams };
1685
+ for (const k of Object.keys(PARAM_SPACE4)) {
1686
+ const v = p[k];
1687
+ if (typeof v === "number") out[k] = v;
1688
+ }
1689
+ return out;
1633
1690
  }
1691
+ /** Speed the phase integral uses across one bucket (sampled at its centre). */
1692
+ bucketSpeed(b) {
1693
+ let s = this.phiSpeeds[b];
1694
+ if (s === void 0) {
1695
+ for (let k = this.phiSpeeds.length; k <= b; k++) {
1696
+ this.phiSpeeds[k] = this.paramsAt(k * PHASE_BUCKET_MS + PHASE_BUCKET_MS / 2).speed;
1697
+ this.phiPrefix[k + 1] = this.phiPrefix[k] + this.phiSpeeds[k] * (PHASE_BUCKET_MS / 1e3);
1698
+ }
1699
+ s = this.phiSpeeds[b];
1700
+ }
1701
+ return s;
1702
+ }
1703
+ /** ∫ speed dt in seconds — continuous in t, pure (prefix grounds at 0). */
1704
+ phaseAt(t) {
1705
+ if (t <= 0) return 0;
1706
+ const b = Math.floor(t / PHASE_BUCKET_MS);
1707
+ const s = this.bucketSpeed(b);
1708
+ return this.phiPrefix[b] + s * ((t - b * PHASE_BUCKET_MS) / 1e3);
1709
+ }
1710
+ // ---- loop ----
1634
1711
  start() {
1635
1712
  if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
1636
- this.last = 0;
1713
+ this.startT = 0;
1637
1714
  this.frameId = requestAnimationFrame((now) => this.loop(now));
1638
1715
  }
1639
1716
  stop() {
@@ -1644,66 +1721,58 @@ var MystifyInstance = class {
1644
1721
  }
1645
1722
  loop(now) {
1646
1723
  this.frameId = requestAnimationFrame((n) => this.loop(n));
1647
- if (this.last === 0) this.last = now;
1648
- const dt = Math.min(0.05, (now - this.last) / 1e3);
1649
- this.last = now;
1650
- this.update(dt);
1651
- this.render();
1724
+ if (this.startT === 0) this.startT = now;
1725
+ this.renderFrame(now - this.startT + this.resumeFrom, this.ctxSaver.seed);
1652
1726
  }
1653
- update(dt) {
1654
- for (const shape of this.shapes) {
1655
- for (const v of shape.verts) {
1656
- v.x += v.vx * dt;
1657
- v.y += v.vy * dt;
1658
- if (v.x <= 0) {
1659
- v.x = 0;
1660
- v.vx = Math.abs(v.vx);
1661
- } else if (v.x >= this.w) {
1662
- v.x = this.w;
1663
- v.vx = -Math.abs(v.vx);
1664
- }
1665
- if (v.y <= 0) {
1666
- v.y = 0;
1667
- v.vy = Math.abs(v.vy);
1668
- } else if (v.y >= this.h) {
1669
- v.y = this.h;
1670
- v.vy = -Math.abs(v.vy);
1671
- }
1672
- }
1727
+ renderStill() {
1728
+ const t = this.t === 0 ? 1200 : this.t;
1729
+ this.renderFrame(t, this.ctxSaver.seed);
1730
+ }
1731
+ // ---- draw ----
1732
+ strokeShape(id, phi, alpha, width, hueShift) {
1733
+ const ctx = this.ctx;
1734
+ const sw = Math.max(1, this.w);
1735
+ const sh = Math.max(1, this.h);
1736
+ ctx.strokeStyle = `hsla(${(id.hue + hueShift) % 360}, 90%, 62%, ${alpha.toFixed(3)})`;
1737
+ ctx.lineWidth = width;
1738
+ ctx.beginPath();
1739
+ for (let v = 0; v < id.fx.length; v++) {
1740
+ const x = fold(id.fx[v] * sw + id.vx[v] * phi, sw);
1741
+ const y = fold(id.fy[v] * sh + id.vy[v] * phi, sh);
1742
+ if (v === 0) ctx.moveTo(x, y);
1743
+ else ctx.lineTo(x, y);
1673
1744
  }
1745
+ ctx.closePath();
1746
+ ctx.stroke();
1674
1747
  }
1675
- drawShapes() {
1748
+ /** Pure, frame-addressable render: black field, ghost trail oldest-first,
1749
+ * live outline last. Everything derives from (t, seed, params-at-t). */
1750
+ renderFrame(t, _seed) {
1751
+ this.t = t;
1752
+ const p = this.paramsAt(t);
1676
1753
  const ctx = this.ctx;
1754
+ ctx.fillStyle = "#000";
1755
+ ctx.fillRect(0, 0, this.w, this.h);
1677
1756
  ctx.lineCap = "round";
1678
1757
  ctx.lineJoin = "round";
1679
- for (const shape of this.shapes) {
1680
- const { verts } = shape;
1681
- if (verts.length < 2) continue;
1682
- ctx.strokeStyle = `hsla(${shape.hue}, 90%, 62%, 0.92)`;
1683
- ctx.lineWidth = 2;
1684
- ctx.beginPath();
1685
- ctx.moveTo(verts[0].x, verts[0].y);
1686
- for (let i = 1; i < verts.length; i++) ctx.lineTo(verts[i].x, verts[i].y);
1687
- ctx.closePath();
1688
- ctx.stroke();
1758
+ const n = Math.max(1, Math.min(MAX_SHAPES, Math.round(p.shapes)));
1759
+ const decay = 0.68 + p.trail * 0.29;
1760
+ const ghosts = Math.min(48, Math.max(1, Math.ceil(Math.log(0.03 / 0.92) / Math.log(decay))));
1761
+ for (let k = ghosts - 1; k >= 0; k--) {
1762
+ const tk = t - k * GHOST_MS;
1763
+ if (tk < 0) continue;
1764
+ const phi = this.phaseAt(tk);
1765
+ const alpha = 0.92 * Math.pow(decay, k);
1766
+ for (let s = 0; s < n; s++) this.strokeShape(this.shapes[s], phi, alpha, p.width, p.hueShift);
1689
1767
  }
1690
1768
  }
1691
- render() {
1692
- this.ctx.fillStyle = `rgba(0,0,0,${TRAIL_ALPHA})`;
1693
- this.ctx.fillRect(0, 0, this.w, this.h);
1694
- this.drawShapes();
1695
- }
1696
- renderStill() {
1697
- this.clearFull();
1698
- this.drawShapes();
1699
- }
1700
1769
  setPaused(paused) {
1701
1770
  this.paused = paused;
1702
1771
  if (paused) {
1703
1772
  this.stop();
1704
1773
  this.renderStill();
1705
1774
  } else {
1706
- this.clearFull();
1775
+ this.resumeFrom = this.t;
1707
1776
  this.start();
1708
1777
  }
1709
1778
  }
@@ -1712,14 +1781,13 @@ var MystifyInstance = class {
1712
1781
  this.h = height;
1713
1782
  if (dpr !== void 0) this.ctxSaver.dpr = dpr;
1714
1783
  this.sizeCanvas();
1715
- for (const shape of this.shapes) {
1716
- for (const v of shape.verts) {
1717
- v.x = Math.min(Math.max(v.x, 0), this.w);
1718
- v.y = Math.min(Math.max(v.y, 0), this.h);
1719
- }
1720
- }
1721
1784
  if (this.paused) this.renderStill();
1722
- else this.clearFull();
1785
+ }
1786
+ applyTrack(track) {
1787
+ this.track = track;
1788
+ this.phiPrefix = [0];
1789
+ this.phiSpeeds = [];
1790
+ if (this.paused) this.renderStill();
1723
1791
  }
1724
1792
  dispose() {
1725
1793
  this.stop();
@@ -1732,23 +1800,62 @@ var mystify = {
1732
1800
  manifest: mystifyManifest,
1733
1801
  mount: (ctx) => new MystifyInstance(ctx)
1734
1802
  };
1803
+ var mystifyDemoTrack = {
1804
+ program: "mystify",
1805
+ seed: 5,
1806
+ duration: 24e3,
1807
+ loop: true,
1808
+ deltas: [
1809
+ { t: 0, path: "shapes", value: 3 },
1810
+ { t: 1e4, path: "shapes", value: 6 },
1811
+ { t: 2e4, path: "shapes", value: 3 },
1812
+ { t: 0, path: "speed", value: 0.8 },
1813
+ { t: 12e3, path: "speed", value: 2, ease: "smooth" },
1814
+ { t: 24e3, path: "speed", value: 0.8, ease: "smooth" },
1815
+ { t: 0, path: "trail", value: 0.45 },
1816
+ { t: 12e3, path: "trail", value: 0.85, ease: "smooth" },
1817
+ { t: 24e3, path: "trail", value: 0.45, ease: "smooth" },
1818
+ { t: 0, path: "hueShift", value: 0 },
1819
+ { t: 24e3, path: "hueShift", value: 300, ease: "smooth" }
1820
+ ]
1821
+ };
1735
1822
 
1736
1823
  // src/pipes.ts
1824
+ import {
1825
+ sampleTrack as sampleTrack5,
1826
+ defaultParams as defaultParams5
1827
+ } from "@idle-screens/core";
1828
+ var PARAM_SPACE5 = {
1829
+ /** Growth speed multiplier. Sampled at each epoch's start — a run keeps its
1830
+ * pace for its whole life, so the step clock stays a pure function of t. */
1831
+ tempo: { type: "number", default: 1, min: 0.3, max: 3, ease: "smooth" },
1832
+ /** Fraction of the grid a run fills before the screen clears. Sampled per
1833
+ * epoch, like every param here. */
1834
+ density: { type: "number", default: 0.65, min: 0.3, max: 0.9, ease: "smooth" },
1835
+ /** Grid pitch, px. Small cells read as circuitry; large ones as plumbing. */
1836
+ cell: { type: "number", default: 20, min: 10, max: 40, ease: "smooth" },
1837
+ /** Chance a pipe keeps its heading when it can — the classic bias is 0.65.
1838
+ * Low values grow twisty mazes; high values long straight runs. */
1839
+ straightness: { type: "number", default: 0.65, min: 0, max: 0.95, ease: "smooth" },
1840
+ /** Pipe stroke width, px. */
1841
+ thickness: { type: "number", default: 8, min: 3, max: 14, ease: "smooth" }
1842
+ };
1737
1843
  var pipesManifest = {
1738
1844
  id: "pipes",
1739
1845
  label: "Pipes",
1846
+ description: "Growing pipe network fills the screen with right-angle turns.",
1847
+ timeModel: "closed-form",
1740
1848
  passthrough: false,
1741
1849
  minBackend: "canvas2d",
1742
1850
  costTier: "low",
1743
1851
  motionIntensity: "moderate",
1744
1852
  reducedMotionFallback: "static",
1853
+ paramSpace: PARAM_SPACE5,
1745
1854
  a11y: { flashSafe: true },
1746
1855
  workerReady: true
1747
1856
  };
1748
- var CELL = 20;
1749
- var PIPE_WIDTH = 8;
1750
- var STEPS_PER_FRAME = 3;
1751
- var FILL_THRESHOLD = 0.65;
1857
+ var STEP_MS = 1e3 / 180;
1858
+ var PLAN_CACHE = 4;
1752
1859
  var PALETTE = ["#c0392b", "#2980b9", "#27ae60", "#f39c12", "#8e44ad", "#d4a259", "#7f8c8d"];
1753
1860
  var DX = { 0: 1, 1: 0, 2: -1, 3: 0 };
1754
1861
  var DY = { 0: 0, 1: 1, 2: 0, 3: -1 };
@@ -1758,17 +1865,31 @@ var PipesInstance = class {
1758
1865
  ctx;
1759
1866
  w = 0;
1760
1867
  h = 0;
1761
- cols = 0;
1762
- rows = 0;
1763
- grid = [];
1764
- filled = 0;
1765
- pipe = null;
1766
- rng;
1868
+ /** Prefix-sum of epoch start times (ms); index i = epoch i's start. */
1869
+ epochStarts = [];
1870
+ /** Step counts per compiled-at-least-once epoch (start + count = summary). */
1871
+ epochSteps = [];
1872
+ plans = /* @__PURE__ */ new Map();
1873
+ track = null;
1874
+ baseParams = defaultParams5(PARAM_SPACE5);
1875
+ /** What the canvas currently shows: epoch index + steps drawn. -1 = dirty. */
1876
+ paintedEpoch = -1;
1877
+ paintedSteps = 0;
1767
1878
  frameId = null;
1768
1879
  paused = false;
1880
+ startT = 0;
1881
+ /** Logical time the next rAF origin resumes from.
1882
+ *
1883
+ * `start()` re-anchors `startT` to the next frame's timestamp, so on its own
1884
+ * `now - startT` always begins at zero. Mount wants that; resuming from a
1885
+ * pause does not — without carrying the frozen `t` forward, every
1886
+ * pause/resume (and every reduced-motion toggle) snaps the scene back to its
1887
+ * opening frame and restarts any applied control track. Set only in
1888
+ * `setPaused(false)`, so first mount still starts at 0. */
1889
+ resumeFrom = 0;
1890
+ t = 0;
1769
1891
  constructor(ctx) {
1770
1892
  this.ctxSaver = ctx;
1771
- this.rng = ctx.rng;
1772
1893
  let canvas;
1773
1894
  if (ctx.surface) {
1774
1895
  canvas = ctx.surface;
@@ -1798,121 +1919,171 @@ var PipesInstance = class {
1798
1919
  this.ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
1799
1920
  }
1800
1921
  rebuild() {
1801
- this.cols = Math.max(2, Math.floor(this.w / CELL));
1802
- this.rows = Math.max(2, Math.floor(this.h / CELL));
1803
- this.grid = new Array(this.cols * this.rows).fill(false);
1804
- this.filled = 0;
1805
- this.pipe = null;
1922
+ this.epochStarts = [];
1923
+ this.epochSteps = [];
1924
+ this.plans.clear();
1925
+ this.paintedEpoch = -1;
1926
+ this.paintedSteps = 0;
1806
1927
  this.paintBackground();
1807
1928
  }
1808
1929
  paintBackground() {
1809
1930
  this.ctx.fillStyle = "#111";
1810
1931
  this.ctx.fillRect(0, 0, this.w, this.h);
1811
1932
  }
1812
- idx(col, row) {
1813
- return row * this.cols + col;
1814
- }
1815
- inBounds(col, row) {
1816
- return col >= 0 && col < this.cols && row >= 0 && row < this.rows;
1817
- }
1818
- spawnPipe() {
1819
- const empty = [];
1820
- for (let i = 0; i < this.grid.length; i++) {
1821
- if (!this.grid[i]) empty.push(i);
1822
- }
1823
- if (empty.length === 0) {
1824
- this.clearGrid();
1825
- return;
1933
+ // ---- the compiled plan ----
1934
+ /** Params at `t` — track-driven when a track is applied, defaults otherwise. */
1935
+ paramsAt(t) {
1936
+ if (!this.track) return this.baseParams;
1937
+ const p = sampleTrack5(PARAM_SPACE5, this.track, t);
1938
+ const out = { ...this.baseParams };
1939
+ for (const k of Object.keys(PARAM_SPACE5)) {
1940
+ const v = p[k];
1941
+ if (typeof v === "number") out[k] = v;
1826
1942
  }
1827
- const cell = this.rng.pick(empty);
1828
- const col = cell % this.cols;
1829
- const row = Math.floor(cell / this.cols);
1830
- this.pipe = {
1831
- col,
1832
- row,
1833
- dir: this.rng.int(0, 3),
1834
- color: this.rng.pick(PALETTE)
1835
- };
1836
- this.grid[cell] = true;
1837
- this.filled++;
1838
- this.drawJoint(col, row, this.pipe.color);
1839
- }
1840
- clearGrid() {
1841
- this.grid.fill(false);
1842
- this.filled = 0;
1843
- this.pipe = null;
1844
- this.paintBackground();
1943
+ return out;
1845
1944
  }
1846
- growStep() {
1847
- if (this.filled / this.grid.length > FILL_THRESHOLD) {
1848
- this.clearGrid();
1849
- return;
1850
- }
1851
- if (!this.pipe) {
1852
- this.spawnPipe();
1853
- return;
1854
- }
1855
- const candidates = this.getCandidates(this.pipe);
1856
- if (candidates.length === 0) {
1857
- this.pipe = null;
1858
- return;
1859
- }
1860
- const oldCol = this.pipe.col;
1861
- const oldRow = this.pipe.row;
1862
- const oldDir = this.pipe.dir;
1863
- const newDir = this.rng.pick(candidates);
1864
- this.pipe.dir = newDir;
1865
- const nc = oldCol + DX[newDir];
1866
- const nr = oldRow + DY[newDir];
1867
- this.drawSegment(oldCol, oldRow, nc, nr, this.pipe.color);
1868
- if (newDir !== oldDir) {
1869
- this.drawJoint(oldCol, oldRow, this.pipe.color);
1945
+ /**
1946
+ * Compile one epoch's full growth history. Pure in (seed, epoch, cols,
1947
+ * rows, params-at-epoch-start): the rng is an epoch-keyed fork, and the
1948
+ * walk is exactly the old per-frame algorithm — spawn on an empty cell,
1949
+ * grow with a 0.65 bias to continue straight, die when boxed in, stop at
1950
+ * the fill threshold. tempo/density are sampled once at the epoch's start,
1951
+ * so a run keeps its pace and appetite for its whole life.
1952
+ */
1953
+ compileEpoch(epoch, start) {
1954
+ const p = this.paramsAt(start);
1955
+ const rng = this.ctxSaver.rng.fork(596453 + epoch * 7919);
1956
+ const cell = Math.max(6, p.cell);
1957
+ const cols = Math.max(2, Math.floor(this.w / cell));
1958
+ const rows = Math.max(2, Math.floor(this.h / cell));
1959
+ const size = cols * rows;
1960
+ const grid = new Uint8Array(size);
1961
+ let filled = 0;
1962
+ let pipe = null;
1963
+ const steps = [];
1964
+ while (filled / size <= p.density) {
1965
+ if (!pipe) {
1966
+ const empty = [];
1967
+ for (let i = 0; i < size; i++) if (!grid[i]) empty.push(i);
1968
+ if (empty.length === 0) break;
1969
+ const at = rng.pick(empty);
1970
+ const col = at % cols;
1971
+ const row = Math.floor(at / cols);
1972
+ pipe = { col, row, dir: rng.int(0, 3), color: PALETTE.indexOf(rng.pick(PALETTE)) };
1973
+ grid[at] = 1;
1974
+ filled++;
1975
+ steps.push({ kind: "spawn", col, row, c2: -1, r2: -1, turn: false, color: pipe.color });
1976
+ continue;
1977
+ }
1978
+ const candidates = [];
1979
+ for (let d = 0; d < 4; d++) {
1980
+ const nc2 = pipe.col + DX[d];
1981
+ const nr2 = pipe.row + DY[d];
1982
+ if (nc2 >= 0 && nc2 < cols && nr2 >= 0 && nr2 < rows && !grid[nr2 * cols + nc2]) {
1983
+ candidates.push(d);
1984
+ }
1985
+ }
1986
+ const pool = candidates.includes(pipe.dir) && rng.next() < p.straightness ? [pipe.dir] : candidates;
1987
+ if (pool.length === 0) {
1988
+ pipe = null;
1989
+ steps.push({ kind: "end", col: -1, row: -1, c2: -1, r2: -1, turn: false, color: -1 });
1990
+ continue;
1991
+ }
1992
+ const newDir = rng.pick(pool);
1993
+ const turn = newDir !== pipe.dir;
1994
+ const nc = pipe.col + DX[newDir];
1995
+ const nr = pipe.row + DY[newDir];
1996
+ steps.push({ kind: "seg", col: pipe.col, row: pipe.row, c2: nc, r2: nr, turn, color: pipe.color });
1997
+ pipe.col = nc;
1998
+ pipe.row = nr;
1999
+ pipe.dir = newDir;
2000
+ grid[nr * cols + nc] = 1;
2001
+ filled++;
1870
2002
  }
1871
- this.pipe.col = nc;
1872
- this.pipe.row = nr;
1873
- this.grid[this.idx(nc, nr)] = true;
1874
- this.filled++;
2003
+ return {
2004
+ steps,
2005
+ stepMs: STEP_MS / Math.max(0.05, p.tempo),
2006
+ cell,
2007
+ thickness: Math.min(p.thickness, cell * 0.7),
2008
+ cols,
2009
+ rows
2010
+ };
1875
2011
  }
1876
- getCandidates(pipe) {
1877
- const out = [];
1878
- for (let d = 0; d < 4; d++) {
1879
- const nc = pipe.col + DX[d];
1880
- const nr = pipe.row + DY[d];
1881
- if (this.inBounds(nc, nr) && !this.grid[this.idx(nc, nr)]) {
1882
- out.push(d);
2012
+ /** The plan for an epoch, via the small cache. Recompiles are bit-identical. */
2013
+ planFor(epoch, start) {
2014
+ let plan = this.plans.get(epoch);
2015
+ if (!plan) {
2016
+ plan = this.compileEpoch(epoch, start);
2017
+ this.plans.set(epoch, plan);
2018
+ if (this.plans.size > PLAN_CACHE) {
2019
+ let worst = epoch;
2020
+ let worstD = -1;
2021
+ for (const k of this.plans.keys()) {
2022
+ const d = Math.abs(k - epoch);
2023
+ if (d > worstD) {
2024
+ worstD = d;
2025
+ worst = k;
2026
+ }
2027
+ }
2028
+ this.plans.delete(worst);
1883
2029
  }
1884
2030
  }
1885
- if (out.includes(pipe.dir) && this.rng.next() < 0.65) {
1886
- return [pipe.dir];
2031
+ if (this.epochSteps.length === epoch) this.epochSteps.push(plan.steps.length);
2032
+ return plan;
2033
+ }
2034
+ /** Epoch containing `t`, extending the prefix sum as needed. */
2035
+ epochAt(t) {
2036
+ if (this.epochStarts.length === 0) this.epochStarts.push(0);
2037
+ let e = 0;
2038
+ for (e = this.epochStarts.length - 1; e > 0; e--) {
2039
+ if (t >= this.epochStarts[e]) break;
2040
+ }
2041
+ for (; ; ) {
2042
+ const start = this.epochStarts[e];
2043
+ const plan = this.planFor(e, start);
2044
+ const dur = Math.max(1, plan.steps.length) * plan.stepMs;
2045
+ if (t < start + dur) return { epoch: e, start, plan };
2046
+ if (this.epochStarts.length === e + 1) this.epochStarts.push(start + dur);
2047
+ e++;
1887
2048
  }
1888
- return out;
1889
- }
1890
- cellCenter(col, row) {
1891
- return [col * CELL + CELL / 2, row * CELL + CELL / 2];
1892
2049
  }
1893
- drawSegment(c1, r1, c2, r2, color) {
1894
- const [x1, y1] = this.cellCenter(c1, r1);
1895
- const [x2, y2] = this.cellCenter(c2, r2);
2050
+ // ---- drawing (identical marks to the accumulative version; geometry from
2051
+ // the epoch's own plan, since cell/thickness are epoch-sampled params) ----
2052
+ drawSegment(plan, c1, r1, c2, r2, color) {
2053
+ const half = plan.cell / 2;
1896
2054
  const ctx = this.ctx;
1897
2055
  ctx.strokeStyle = color;
1898
- ctx.lineWidth = PIPE_WIDTH;
2056
+ ctx.lineWidth = plan.thickness;
1899
2057
  ctx.lineCap = "round";
1900
2058
  ctx.beginPath();
1901
- ctx.moveTo(x1, y1);
1902
- ctx.lineTo(x2, y2);
2059
+ ctx.moveTo(c1 * plan.cell + half, r1 * plan.cell + half);
2060
+ ctx.lineTo(c2 * plan.cell + half, r2 * plan.cell + half);
1903
2061
  ctx.stroke();
1904
2062
  }
1905
- drawJoint(col, row, color) {
1906
- const [x, y] = this.cellCenter(col, row);
2063
+ drawJoint(plan, col, row, color) {
2064
+ const half = plan.cell / 2;
1907
2065
  const ctx = this.ctx;
1908
2066
  ctx.fillStyle = color;
1909
2067
  ctx.beginPath();
1910
- ctx.arc(x, y, PIPE_WIDTH * 0.65, 0, Math.PI * 2);
2068
+ ctx.arc(col * plan.cell + half, row * plan.cell + half, plan.thickness * 0.65, 0, Math.PI * 2);
1911
2069
  ctx.fill();
1912
2070
  }
2071
+ drawSteps(plan, from, to) {
2072
+ for (let i = from; i < to; i++) {
2073
+ const s = plan.steps[i];
2074
+ if (s.kind === "spawn") {
2075
+ this.drawJoint(plan, s.col, s.row, PALETTE[s.color]);
2076
+ } else if (s.kind === "seg") {
2077
+ this.drawSegment(plan, s.col, s.row, s.c2, s.r2, PALETTE[s.color]);
2078
+ if (s.turn) this.drawJoint(plan, s.col, s.row, PALETTE[s.color]);
2079
+ }
2080
+ }
2081
+ }
2082
+ // ---- loop ----
1913
2083
  start() {
1914
2084
  if (this.frameId !== null || typeof requestAnimationFrame === "undefined") return;
1915
- this.loop();
2085
+ this.startT = 0;
2086
+ this.frameId = requestAnimationFrame((now) => this.loop(now));
1916
2087
  }
1917
2088
  stop() {
1918
2089
  if (this.frameId !== null) {
@@ -1920,22 +2091,53 @@ var PipesInstance = class {
1920
2091
  this.frameId = null;
1921
2092
  }
1922
2093
  }
1923
- loop() {
1924
- this.frameId = requestAnimationFrame(() => this.loop());
1925
- for (let i = 0; i < STEPS_PER_FRAME; i++) this.growStep();
2094
+ loop(now) {
2095
+ this.frameId = requestAnimationFrame((n) => this.loop(n));
2096
+ if (this.startT === 0) this.startT = now;
2097
+ this.renderFrame(now - this.startT + this.resumeFrom, this.ctxSaver.seed);
1926
2098
  }
1927
2099
  renderStill() {
1928
- this.rebuild();
1929
- for (let i = 0; i < 80; i++) this.growStep();
2100
+ const t = this.t === 0 ? 80 * STEP_MS : this.t;
2101
+ this.renderFrame(t, this.ctxSaver.seed);
2102
+ }
2103
+ /**
2104
+ * Pure, frame-addressable render: the canvas after this call is a function
2105
+ * of (t, seed, size) only. Forward motion within an epoch appends new
2106
+ * steps; anything else repaints and replays the prefix.
2107
+ */
2108
+ renderFrame(t, _seed) {
2109
+ this.t = t;
2110
+ const { epoch, start, plan } = this.epochAt(Math.max(0, t));
2111
+ const stepsDone = Math.min(plan.steps.length, Math.floor((t - start) / plan.stepMs));
2112
+ if (epoch === this.paintedEpoch && stepsDone >= this.paintedSteps) {
2113
+ this.drawSteps(plan, this.paintedSteps, stepsDone);
2114
+ } else {
2115
+ this.paintBackground();
2116
+ this.drawSteps(plan, 0, stepsDone);
2117
+ }
2118
+ this.paintedEpoch = epoch;
2119
+ this.paintedSteps = stepsDone;
1930
2120
  }
1931
2121
  setPaused(paused) {
1932
2122
  this.paused = paused;
1933
2123
  if (paused) {
1934
2124
  this.stop();
2125
+ this.renderStill();
1935
2126
  } else {
2127
+ this.resumeFrom = this.t;
1936
2128
  this.start();
1937
2129
  }
1938
2130
  }
2131
+ applyTrack(track) {
2132
+ this.track = track;
2133
+ this.epochStarts = [];
2134
+ this.epochSteps = [];
2135
+ this.plans.clear();
2136
+ this.paintedEpoch = -1;
2137
+ this.paintedSteps = 0;
2138
+ this.paintBackground();
2139
+ if (this.paused) this.renderStill();
2140
+ }
1939
2141
  resize(width, height, dpr) {
1940
2142
  this.w = width;
1941
2143
  this.h = height;
@@ -1953,11 +2155,25 @@ var pipes = {
1953
2155
  manifest: pipesManifest,
1954
2156
  mount: (ctx) => new PipesInstance(ctx)
1955
2157
  };
2158
+ var pipesDemoTrack = {
2159
+ program: "pipes",
2160
+ seed: 7,
2161
+ duration: 3e4,
2162
+ loop: true,
2163
+ deltas: [
2164
+ { t: 0, path: "tempo", value: 0.8 },
2165
+ { t: 15e3, path: "tempo", value: 2.4, ease: "smooth" },
2166
+ { t: 3e4, path: "tempo", value: 0.8, ease: "smooth" },
2167
+ { t: 0, path: "density", value: 0.55 },
2168
+ { t: 15e3, path: "density", value: 0.8, ease: "smooth" },
2169
+ { t: 3e4, path: "density", value: 0.55, ease: "smooth" }
2170
+ ]
2171
+ };
1956
2172
 
1957
2173
  // src/flurry.ts
1958
2174
  import {
1959
- sampleTrack as sampleTrack4,
1960
- defaultParams as defaultParams4
2175
+ sampleTrack as sampleTrack6,
2176
+ defaultParams as defaultParams6
1961
2177
  } from "@idle-screens/core";
1962
2178
  var STREAM_COUNT = 5;
1963
2179
  var PARTICLES_PER_ARM = 56;
@@ -1967,7 +2183,7 @@ var TRAIL_FRAC_MIN = 0.12;
1967
2183
  var TRAIL_FRAC_MAX = 0.42;
1968
2184
  var TAIL_SIZE_FLOOR = 0.45;
1969
2185
  var TAIL_ALPHA_POWER = 1.4;
1970
- var PARAM_SPACE4 = {
2186
+ var PARAM_SPACE6 = {
1971
2187
  /** Arm count. Build-time: rebuilt (deterministically, from the same seeded
1972
2188
  * RNG forks) whenever this changes rather than smoothly animated — more
1973
2189
  * arms means re-deriving the whole cast, not interpolating between two. */
@@ -1986,12 +2202,14 @@ var PARAM_SPACE4 = {
1986
2202
  var flurryManifest = {
1987
2203
  id: "flurry",
1988
2204
  label: "Flurry",
2205
+ description: "Smooth flowing particle trails like macOS Flurry.",
2206
+ timeModel: "closed-form",
1989
2207
  passthrough: false,
1990
2208
  minBackend: "canvas2d",
1991
2209
  costTier: "low",
1992
2210
  motionIntensity: "calm",
1993
2211
  reducedMotionFallback: "static",
1994
- paramSpace: PARAM_SPACE4,
2212
+ paramSpace: PARAM_SPACE6,
1995
2213
  a11y: {
1996
2214
  flashSafe: true,
1997
2215
  notes: "Softly glowing arms drifting on black. The spectrum palette rotates hue over ~20s; no flashing."
@@ -2053,7 +2271,7 @@ var FlurryInstance = class {
2053
2271
  resumeFrom = 0;
2054
2272
  t = STILL_T;
2055
2273
  // anchor frame until the loop (or a seek) moves it
2056
- params = defaultParams4(PARAM_SPACE4);
2274
+ params = defaultParams6(PARAM_SPACE6);
2057
2275
  track = null;
2058
2276
  constructor(ctx) {
2059
2277
  this.ctxSaver = ctx;
@@ -2082,8 +2300,8 @@ var FlurryInstance = class {
2082
2300
  }
2083
2301
  }
2084
2302
  applyParams(t) {
2085
- const p = this.track ? sampleTrack4(PARAM_SPACE4, this.track, t) : this.params;
2086
- for (const k of Object.keys(PARAM_SPACE4)) {
2303
+ const p = this.track ? sampleTrack6(PARAM_SPACE6, this.track, t) : this.params;
2304
+ for (const k of Object.keys(PARAM_SPACE6)) {
2087
2305
  const v = p[k];
2088
2306
  if (v !== void 0) this.params[k] = v;
2089
2307
  }
@@ -2998,6 +3216,8 @@ function gpuMainThreadEligible(ctx) {
2998
3216
  var fluidManifest = {
2999
3217
  id: "fluid",
3000
3218
  label: "Fluid",
3219
+ description: "Fluid dynamics simulation with emitters. WebGPU-accelerated with canvas2d fallback.",
3220
+ timeModel: "simulated",
3001
3221
  passthrough: false,
3002
3222
  minBackend: "canvas2d",
3003
3223
  costTier: "low",
@@ -3754,6 +3974,8 @@ var ReactionDiffusionGPU = class {
3754
3974
  var reactionDiffusionManifest = {
3755
3975
  id: "reaction-diffusion",
3756
3976
  label: "Reaction Diffusion",
3977
+ description: "Gray-Scott reaction-diffusion patterns. WebGPU-accelerated with canvas2d fallback.",
3978
+ timeModel: "simulated",
3757
3979
  passthrough: false,
3758
3980
  minBackend: "canvas2d",
3759
3981
  costTier: "low",
@@ -3926,8 +4148,8 @@ var reactionDiffusion = {
3926
4148
 
3927
4149
  // src/messages.ts
3928
4150
  import {
3929
- sampleTrack as sampleTrack5,
3930
- defaultParams as defaultParams5
4151
+ sampleTrack as sampleTrack7,
4152
+ defaultParams as defaultParams7
3931
4153
  } from "@idle-screens/core";
3932
4154
  var PHRASES = {
3933
4155
  "out-to-lunch": "OUT TO LUNCH",
@@ -3936,7 +4158,7 @@ var PHRASES = {
3936
4158
  "gone-idle": "gone idle \u2014 leave a message",
3937
4159
  "ship-it": "SHIP IT IN THE MORNING"
3938
4160
  };
3939
- var PARAM_SPACE5 = {
4161
+ var PARAM_SPACE7 = {
3940
4162
  /** Which line the screen mutters. */
3941
4163
  phrase: { type: "enum", default: "out-to-lunch", options: Object.keys(PHRASES) },
3942
4164
  /** 'marquee' = the Out-to-Lunch crawl (steps down the page);
@@ -3954,12 +4176,14 @@ var PARAM_SPACE5 = {
3954
4176
  var messagesManifest = {
3955
4177
  id: "messages",
3956
4178
  label: "Messages",
4179
+ description: 'Typeset phrases cross the screen. Two modes: "fade" (appear and dissolve) and "drift" (travelling text \u2014 the former Messages II). Steerable: phrase, mode, speed, textScale, ink, glow, trail.',
4180
+ timeModel: "closed-form",
3957
4181
  passthrough: false,
3958
4182
  minBackend: "canvas2d",
3959
4183
  costTier: "low",
3960
4184
  motionIntensity: "calm",
3961
4185
  reducedMotionFallback: "static",
3962
- paramSpace: PARAM_SPACE5,
4186
+ paramSpace: PARAM_SPACE7,
3963
4187
  attribution: {
3964
4188
  source: 'After Dark "Messages" \u2014 concepts by Berkeley Systems',
3965
4189
  license: "MIT port; reference CSS MIT (Bryan Braun)",
@@ -3982,7 +4206,7 @@ var MessagesInstance = class {
3982
4206
  paused = false;
3983
4207
  startT = 0;
3984
4208
  t = 0;
3985
- params = defaultParams5(PARAM_SPACE5);
4209
+ params = defaultParams7(PARAM_SPACE7);
3986
4210
  track = null;
3987
4211
  constructor(ctx) {
3988
4212
  this.ctxSaver = ctx;
@@ -4005,8 +4229,8 @@ var MessagesInstance = class {
4005
4229
  else this.start();
4006
4230
  }
4007
4231
  applyParams(t) {
4008
- const p = this.track ? sampleTrack5(PARAM_SPACE5, this.track, t) : this.params;
4009
- for (const k of Object.keys(PARAM_SPACE5)) {
4232
+ const p = this.track ? sampleTrack7(PARAM_SPACE7, this.track, t) : this.params;
4233
+ for (const k of Object.keys(PARAM_SPACE7)) {
4010
4234
  const v = p[k];
4011
4235
  if (v !== void 0) this.params[k] = v;
4012
4236
  }
@@ -4153,7 +4377,9 @@ export {
4153
4377
  globeDemoTrack,
4154
4378
  spotlight,
4155
4379
  mystify,
4380
+ mystifyDemoTrack,
4156
4381
  pipes,
4382
+ pipesDemoTrack,
4157
4383
  flurry,
4158
4384
  flurryDemoTrack,
4159
4385
  fluid,
@@ -4161,4 +4387,4 @@ export {
4161
4387
  messages,
4162
4388
  messagesDemoTrack
4163
4389
  };
4164
- //# sourceMappingURL=chunk-PU6BQ5S3.js.map
4390
+ //# sourceMappingURL=chunk-ZF4KJIVM.js.map