diff --git a/AGENTS.md b/AGENTS.md index ad43d8a..33af165 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,14 +8,14 @@ Use the `loop` CLI (`npx loop` or `node tool/bin/loop.js`) for every stage of th | Command | Purpose | Output | | :--- | :--- | :--- | -| `loop new [--mode showcase\|ambient] [--style ] [--scene ]` | Scaffold a loop project with `brief.json` / `showcase.json`, `sketch.js`, and preview HTML | `/sketch.js`, `/index.html` | +| `loop new [--mode showcase\|ambient] [--style ] [--scene ] [--fps ]` | Scaffold a loop project with `brief.json` / `showcase.json`, `sketch.js`, and preview HTML | `/sketch.js`, `/index.html` | | `loop sheet [--cols 4] [--every 8]` | Render every Nth frame into a numbered contact sheet for visual critique | `/sheet.png` | | `loop story ` | Render Frame `0` plus the midpoint frame of each step in `showcase.json` | `/storyboard.png` | | `loop seam ` | Measure frame-to-frame pixel deltas, last-to-first seam ratio, duplicate frames, and flicker | `/seam.json` | | `loop legible ` | Audit caption reading time, WCAG contrast (`>= 4.5:1`), safe margins, and phone-width readability | `/legible.json` | | `loop source-check [--repo ]` | Verify every `file:line` citation in `showcase.json` exists in the target repository | `/sources.json` | | `loop audit ` | Run `seam`, `legible`, and `source-check` together as a unified quality gate | `/audit.json` | -| `loop render [--formats gif,mp4,webm,png]` | Render full-resolution `loop.gif` / `showcase.gif`, `poster.png`, and (when FFmpeg is available) `loop.mp4` & `loop.webm` | `/loop.gif`, `/poster.png` | +| `loop render [--fps ] [--formats gif,mp4,webp,webm,png\|all]` | Render full-resolution `loop.gif` / `showcase.gif`, `poster.png`, `loop.mp4` (FFmpeg or macOS AVFoundation), Animated WebP, and WebM at up to `60–120 fps` | `/loop.gif`, `/loop.mp4`, `/poster.png` | | `loop serve [--port 4173]` | Launch interactive browser workbench with phase scrubber, seam oscilloscope, and mobile preview | `http://localhost:4173` | | `loop doctor` | Check runtime capabilities (Pure-JS engine, Headless Chrome/Chromium, FFmpeg) | JSON / terminal diagnostic | diff --git a/README.md b/README.md index 406cea9..7122234 100644 --- a/README.md +++ b/README.md @@ -9,34 +9,44 @@

- Animated showcase diagram: Loop Studio turns a one-line request into a checked, seamless loop. + Animated showcase diagram: Loop Studio turns a one-line request into a checked, seamless 60 fps loop.

- Above: gallery/loop-studio/showcase.gif — a 10-second, 160-frame showcase loop rendered directly by the loop CLI (`seamScore: 1.00`, `duplicateFrames: 0`, `WCAG contrast: 13.7:1`). + Above: gallery/loop-studio/showcase.webp — an 8-second, 480-frame 60 fps showcase loop rendered directly by the loop CLI (`seamScore: 1.083`, `duplicateFrames: 0`, `PASS`).

--- ## Gallery -Every animation below is pure deterministic code (`sketch.js`), measured by `loop audit`, and committed with its exact `showcase.json` or `brief.json`, contact sheet (`sheet.png`), storyboard (`storyboard.png`), and `seam.json`. Pick any folder in [`gallery/`](./gallery), change one number, and re-render. +Every animation below is pure deterministic code (`sketch.js`), measured by `loop audit`, and committed with its exact `showcase.json` or `brief.json`, contact sheet (`sheet.png`), storyboard (`storyboard.png`), and `seam.json`. Pick any folder in [`gallery/`](./gallery), change one number, and re-render (including `30–60 fps` Animated WebP & MP4). ### Showcase Loops (What a Repository Does) -| Preview | Subject & Scene Pack | Seam & Audit | Artifacts | +| Preview | Subject, Scene Pack & Real Use Case | Seam & Audit | Artifacts | | :--- | :--- | :--- | :--- | -| Loop Studio Flow Showcase | **Loop Studio Pipeline** (`scenes/flow` · `studio-dark`)
"Loop Studio turns a one-line request into a checked, seamless loop." | `seamScore: 1.00`
`dups: 0` · `PASS` | [showcase.json](./gallery/loop-studio/showcase.json) · [sketch.js](./gallery/loop-studio/sketch.js) · [storyboard.png](./gallery/loop-studio/storyboard.png) · [audit.json](./gallery/loop-studio/audit.json) | -| Loop CLI Terminal Showcase | **Loop CLI Audit Session** (`scenes/terminal` · `phosphor`)
"The loop CLI audits any sketch for seam jumps, caption legibility, and source citations." | `seamScore: 1.02`
`dups: 0` · `PASS` | [showcase.json](./gallery/cli-audit-session/showcase.json) · [sketch.js](./gallery/cli-audit-session/sketch.js) · [storyboard.png](./gallery/cli-audit-session/storyboard.png) · [audit.json](./gallery/cli-audit-session/audit.json) | +| Loop Studio Flow Showcase | **Loop Studio Pipeline** (`scenes/flow` · `studio-dark`)
**Use case**: README hero diagram explaining an end-to-end tool or compiler pipeline.
"Loop Studio turns a one-line request into a checked, seamless loop." | `8s · 60fps · 480f` (WebP)
`seamScore: 1.083` (`PASS`) | [showcase.webp](./gallery/loop-studio/showcase.webp) · [showcase.gif](./gallery/loop-studio/showcase.gif) · [sketch.js](./gallery/loop-studio/sketch.js) · [storyboard.png](./gallery/loop-studio/storyboard.png) | +| Loop CLI Terminal Showcase | **Loop CLI Audit Session** (`scenes/terminal` · `phosphor`)
**Use case**: CLI documentation showing real flags, terminal telemetry, and pass/fail checks.
"The loop CLI audits any sketch for seam jumps, caption legibility, and source citations." | `10s · 16fps`
`seamScore: 0.989` (`PASS`) | [showcase.json](./gallery/cli-audit-session/showcase.json) · [sketch.js](./gallery/cli-audit-session/sketch.js) · [storyboard.png](./gallery/cli-audit-session/storyboard.png) · [audit.json](./gallery/cli-audit-session/audit.json) | +| Phase Contract SDK Code Showcase | **Phase Contract SDK** (`scenes/code` · `studio-dark`)
**Use case**: Library & SDK docs pairing live-stepping code lines with a synchronized state monitor.
"Every Loop Studio sketch exports meta and a pure render(ctx, phase) function." | `10s · 20fps`
`seamScore: 1.006` (`PASS`) | [showcase.json](./gallery/api-pipeline-code/showcase.json) · [sketch.js](./gallery/api-pipeline-code/sketch.js) · [storyboard.png](./gallery/api-pipeline-code/storyboard.png) · [audit.json](./gallery/api-pipeline-code/audit.json) | +| Agent Orchestrator Architecture Showcase | **Agent Orchestrator Mesh** (`scenes/architecture` · `aurora`)
**Use case**: System architecture & multi-agent / MCP service topology diagrams for RFCs & READMEs.
"The Loop Studio orchestrator coordinates the CLI renderer, seam analyzer, and cold-read subagent." | `10s · 20fps`
`seamScore: 0.985` (`PASS`) | [showcase.json](./gallery/mcp-mesh-topology/showcase.json) · [sketch.js](./gallery/mcp-mesh-topology/sketch.js) · [storyboard.png](./gallery/mcp-mesh-topology/storyboard.png) · [audit.json](./gallery/mcp-mesh-topology/audit.json) | +| Protected Git Workflow 60fps Showcase | **Protected Git Workflow** (`60 fps` WebP · `studio-dark`)
**Use case**: CI/CD & branch-protection explainer animating `feat/*` -> `PR + CI` -> `dev` -> `main`.
"Branch guardrails block direct pushes and require passing CI evals before merging." | `8s · 60fps · 480f`
`seamScore: 1.148` (`PASS`) | [showcase.webp](./gallery/git-pr-guardrails/showcase.webp) · [sketch.js](./gallery/git-pr-guardrails/sketch.js) · [storyboard.png](./gallery/git-pr-guardrails/storyboard.png) · [audit.json](./gallery/git-pr-guardrails/audit.json) | +| 60fps Video Transformer Showcase | **60 fps Video Transformer** (`60 fps` WebP · `abyss`)
**Use case**: Compiler, build pipeline, or media-processing diagram converting specs into `480` frames.
"Converts brief.json into 480 phase-exact frames and encodes MP4 & WebP." | `8s · 60fps · 480f`
`seamScore: 1.005` (`PASS`) | [showcase.webp](./gallery/json-to-gif-transform/showcase.webp) · [sketch.js](./gallery/json-to-gif-transform/sketch.js) · [storyboard.png](./gallery/json-to-gif-transform/storyboard.png) · [audit.json](./gallery/json-to-gif-transform/audit.json) | -### Ambient Loops (Mood, Backgrounds & Generative Motion) +### Ambient Loops (Mood, Backgrounds, 30–60 fps UI & Social Motion) -| Preview | Style Pack & Prompt | Specs & Seam Score | Artifacts | +| Preview | Style Pack & Real Use Case | Specs & Seam Score | Artifacts | | :--- | :--- | :--- | :--- | -| Abyssal Bioluminescence | **`styles/particle-orbit`** (`abyss`)
"Make a 4-second square loop. Deep sea, slow, bioluminescent." | `4s · 20fps · 320×320`
`seamScore: 1.00` (`PASS`) | [brief.json](./gallery/deep-sea-orbits/brief.json) · [sketch.js](./gallery/deep-sea-orbits/sketch.js) · [sheet.png](./gallery/deep-sea-orbits/sheet.png) · [seam.json](./gallery/deep-sea-orbits/seam.json) | -| Arctic Currents Flow Field | **`styles/flow-field`** (`aurora`)
"Drifting aurora currents, organic silk streamlines, 4-second loop." | `4s · 20fps · 320×320`
`seamScore: 1.02` (`PASS`) | [brief.json](./gallery/aurora-flow-field/brief.json) · [sketch.js](./gallery/aurora-flow-field/sketch.js) · [sheet.png](./gallery/aurora-flow-field/sheet.png) · [seam.json](./gallery/aurora-flow-field/seam.json) | -| Harmonic Architecture Isometric Grid | **`styles/isometric-grid`** (`nordic`)
"Clean architectural blocks on an isometric grid rising and falling in waves." | `4s · 20fps · 320×320`
`seamScore: 1.00` (`PASS`) | [brief.json](./gallery/nordic-isometric/brief.json) · [sketch.js](./gallery/nordic-isometric/sketch.js) · [sheet.png](./gallery/nordic-isometric/sheet.png) · [seam.json](./gallery/nordic-isometric/seam.json) | -| Epicyclic Telemetry Blueprint CAD | **`styles/blueprint-cad`** (`blueprint`)
"Precision engineering blueprint with planetary gear linkages at 1x and -2x speeds." | `4s · 20fps · 320×320`
`seamScore: 1.00` (`PASS`) | [brief.json](./gallery/cad-planetary/brief.json) · [sketch.js](./gallery/cad-planetary/sketch.js) · [sheet.png](./gallery/cad-planetary/sheet.png) · [seam.json](./gallery/cad-planetary/seam.json) | +| Abyssal Bioluminescence | **`styles/particle-orbit`** (`abyss`)
**Use case**: Calm dark-mode app background, stream overlay, or loading state.
"Deep sea, slow, bioluminescent particle orbits." | `4s · 20fps · 320×320`
`seamScore: 0.972` (`PASS`) | [brief.json](./gallery/deep-sea-orbits/brief.json) · [sketch.js](./gallery/deep-sea-orbits/sketch.js) · [sheet.png](./gallery/deep-sea-orbits/sheet.png) · [seam.json](./gallery/deep-sea-orbits/seam.json) | +| Arctic Currents Flow Field | **`styles/flow-field`** (`aurora`)
**Use case**: Organic generative header for landing pages and music visualizers.
"Drifting aurora currents, organic silk streamlines." | `4s · 20fps · 320×320`
`seamScore: 1.037` (`PASS`) | [brief.json](./gallery/aurora-flow-field/brief.json) · [sketch.js](./gallery/aurora-flow-field/sketch.js) · [sheet.png](./gallery/aurora-flow-field/sheet.png) · [seam.json](./gallery/aurora-flow-field/seam.json) | +| Harmonic Architecture Isometric Grid | **`styles/isometric-grid`** (`nordic`)
**Use case**: Cloud platform, cluster orchestration, or modular infrastructure tile.
"Architectural blocks on an isometric grid rising in waves." | `4s · 20fps · 320×320`
`seamScore: 0.927` (`PASS`) | [brief.json](./gallery/nordic-isometric/brief.json) · [sketch.js](./gallery/nordic-isometric/sketch.js) · [sheet.png](./gallery/nordic-isometric/sheet.png) · [seam.json](./gallery/nordic-isometric/seam.json) | +| Epicyclic Telemetry Blueprint CAD | **`styles/blueprint-cad`** (`blueprint`)
**Use case**: Robotics, hardware, CAD, and precision engineering project badges.
"Planetary gear linkages rotating at 1x and -2x harmonic speeds." | `4s · 20fps · 320×320`
`seamScore: 1.023` (`PASS`) | [brief.json](./gallery/cad-planetary/brief.json) · [sketch.js](./gallery/cad-planetary/sketch.js) · [sheet.png](./gallery/cad-planetary/sheet.png) · [seam.json](./gallery/cad-planetary/seam.json) | +| Nebula 3D Raymarched Sculpture | **`styles/sdf-raymarch`** (`nebula`)
**Use case**: Zero-dependency 3D product hero & smooth WebP/MP4 shader sculpture.
"30 fps 3D raymarched smooth-union torus and orbiting spheres." | `3s · 30fps · 280×280` (WebP)
`seamScore: 1.061` (`PASS`) | [loop.webp](./gallery/readme-hero-3d/loop.webp) · [loop.gif](./gallery/readme-hero-3d/loop.gif) · [sketch.js](./gallery/readme-hero-3d/sketch.js) · [sheet.png](./gallery/readme-hero-3d/sheet.png) | +| Amber CRT Bayer Dither Radar | **`styles/dither-mono`** (`amber-crt`)
**Use case**: Low-bandwidth CLI/game splash screen & zero-shimmer retro loader.
"30 fps amber CRT sphere and radar sweep via ordered 4×4 Bayer dithering." | `3s · 30fps · 280×280`
`seamScore: 1.005` (`PASS`) | [loop.gif](./gallery/retro-crt-loader/loop.gif) · [loop.webp](./gallery/retro-crt-loader/loop.webp) · [sketch.js](./gallery/retro-crt-loader/sketch.js) · [sheet.png](./gallery/retro-crt-loader/sheet.png) | +| 60 fps Editorial Kinetic Wave | **`styles/kinetic-type`** (`editorial`)
**Use case**: Silky **60 fps** social release announcement card & talk title slide.
"60 fps 4-second editorial kinetic typography wave with WCAG-verified focal pill." | `4s · 60fps · 240f` (WebP)
`seamScore: 0.968` (`PASS`) | [loop.webp](./gallery/kinetic-release-banner/loop.webp) · [loop.gif](./gallery/kinetic-release-banner/loop.gif) · [sketch.js](./gallery/kinetic-release-banner/sketch.js) · [sheet.png](./gallery/kinetic-release-banner/sheet.png) | +| Abyssal Bathymetry Topographic Isolines | **`styles/topographic-contour`** (`abyss`)
**Use case**: Geospatial, weather, sonar, and telemetry elevation backgrounds.
"30 fps bathymetric contour isolines over a cyclic scalar noise field." | `3s · 30fps · 280×280`
`seamScore: 0.951` (`PASS`) | [loop.gif](./gallery/sonar-bathymetry/loop.gif) · [loop.webp](./gallery/sonar-bathymetry/loop.webp) · [sketch.js](./gallery/sonar-bathymetry/sketch.js) · [sheet.png](./gallery/sonar-bathymetry/sheet.png) | +| 120 BPM 60fps Audio Spectrum | **`120 BPM Harmonic Spectrum`** (`ember`)
**Use case**: Music release visual, podcast player, & WebAudio/VST visualizer (3 bars of 4/4).
"6-second 60 fps 120 BPM harmonic equalizer with macro swell and oscilloscope." | `6s · 60fps · 360f` (WebP)
`seamScore: 1.05` (`PASS`) | [loop.webp](./gallery/live-audio-spectrum/loop.webp) · [loop.gif](./gallery/live-audio-spectrum/loop.gif) · [sketch.js](./gallery/live-audio-spectrum/sketch.js) · [sheet.png](./gallery/live-audio-spectrum/sheet.png) | +| 8s 60fps Orbital Radar Telemetry | **`Orbital Radar Telemetry`** (`blueprint`)
**Use case**: Aerospace HUD, satellite tracker, & DevOps live observability splash.
"8-second 60 fps radar sweep tracking 3 satellites on tilted elliptical orbits." | `8s · 60fps · 480f` (WebP)
`seamScore: 1.037` (`PASS`) | [loop.webp](./gallery/orbital-telemetry-watch/loop.webp) · [loop.gif](./gallery/orbital-telemetry-watch/loop.gif) · [sketch.js](./gallery/orbital-telemetry-watch/sketch.js) · [sheet.png](./gallery/orbital-telemetry-watch/sheet.png) | --- @@ -188,7 +198,7 @@ loop-studio/ │ ├─ lib/ # loop-kit, soft-canvas, encoders, analyzers, compositor, server │ ├─ scripts/build-gallery.js │ └─ test/run-evals.js -├─ gallery/ # 6 reproducible showcase & ambient loops with full artifacts +├─ gallery/ # 16 reproducible showcase & ambient loops (up to 60 fps) with full artifacts ├─ evals/ # Automated positive & negative verification gates └─ docs/ # Phase contract, CLI manual, and renderer ADR ``` @@ -206,9 +216,9 @@ loop-studio/ | `loop legible ` | Verify reading duration (`>= 0.5 + 0.3*words`), WCAG `4.5:1` contrast & phone margins | `legible.json` | | `loop source-check [--repo ]` | Verify every `file:line` source citation in `showcase.json` exists | `sources.json` | | `loop audit [--repo ]` | Run `seam`, `legible`, and `source-check` together as a single gate | `audit.json` | -| `loop render ` | Render full-resolution `showcase.gif` / `loop.gif` and `poster.png` | `loop.gif`, `poster.png`, `seam.json` | +| `loop render [--fps ] [--formats gif,mp4,webp,webm,png\|all]` | Render full-resolution `showcase.gif` / `loop.gif`, `poster.png`, `loop.mp4` (`30–120 fps` via FFmpeg or macOS AVFoundation), Animated `.webp`, and `.webm` | `loop.gif`, `loop.mp4`, `poster.png`, `seam.json` | | `loop serve [--port 4173]` | Launch interactive browser workbench with phase scrubber & 400px phone view | `http://localhost:4173` | -| `loop doctor` | Check runtime engines (SoftCanvas2D, GIF89a, PNG, FFmpeg, Chrome) | JSON diagnostic | +| `loop doctor` | Check runtime engines (SoftCanvas2D, GIF89a, PNG, macOS AVFoundation, Animated WebP, FFmpeg, Chrome) | JSON diagnostic | --- diff --git a/docs/tool.md b/docs/tool.md index 252ecde..09c2ac9 100644 --- a/docs/tool.md +++ b/docs/tool.md @@ -18,8 +18,8 @@ The `loop` command (`tool/bin/loop.js`) drives project scaffolding, preview cont Verifies every `"source": "file:line"` in `showcase.json` exists in the repository and writes `/sources.json`. 7. `loop audit [--repo ]` Runs `seam`, `legible`, and `source-check` together and writes `/audit.json`. -8. `loop render ` - Renders all frames `0..N-1` at full resolution and outputs `showcase.gif` / `loop.gif` and `poster.png` (plus `loop.mp4` / `loop.webm` when FFmpeg is present). +8. `loop render [--fps ] [--formats gif,mp4,webp,webm,png|all] [--width ] [--height ]` + Renders all frames `0..N-1` at full resolution and outputs `showcase.gif` / `loop.gif`, `poster.png`, `loop.mp4` (via FFmpeg or native macOS AVFoundation at `30/60/120 fps`), Animated `.webp` (via `cwebp`+`webpmux` or FFmpeg), and `.webm` (when FFmpeg is present). 9. `loop serve [--port 4173]` Opens the interactive browser workbench with phase scrubber and mobile width toggle. 10. `loop doctor` diff --git a/gallery/api-pipeline-code/audit.json b/gallery/api-pipeline-code/audit.json new file mode 100644 index 0000000..de6136a --- /dev/null +++ b/gallery/api-pipeline-code/audit.json @@ -0,0 +1,15 @@ +{ + "id": "api-pipeline-code", + "title": "Phase Contract SDK Showcase (Code)", + "mode": "showcase", + "useCase": "SDK / library docs pairing live-stepping code with a synchronized state monitor", + "fps": 20, + "pass": true, + "seamScore": 1.006, + "duplicateFrames": 0, + "flickerScore": 0.08, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 2343.8, + "totalFrames": 200 +} diff --git a/gallery/api-pipeline-code/index.html b/gallery/api-pipeline-code/index.html new file mode 100644 index 0000000..fc9009b --- /dev/null +++ b/gallery/api-pipeline-code/index.html @@ -0,0 +1,120 @@ + + + + + + Phase Contract SDK Showcase (Code) · Loop Studio + + + +
+
+

Phase Contract SDK Showcase (Code)

+ loading sketch.js... +
+
+
+ +
+
+ + + frame 000 / 120 · phase 0.00 + +
+
+
+ + + \ No newline at end of file diff --git a/gallery/api-pipeline-code/legible.json b/gallery/api-pipeline-code/legible.json new file mode 100644 index 0000000..9328bdd --- /dev/null +++ b/gallery/api-pipeline-code/legible.json @@ -0,0 +1,71 @@ +{ + "pass": true, + "width": 800, + "height": 320, + "phoneWidth": 400, + "frame0ShowsAllStageLabels": true, + "stageLabelsChecked": 4, + "captions": [ + { + "step": 1, + "caption": "declare duration and fps in meta", + "words": 6, + "chars": 32, + "windowSeconds": 2.5, + "requiredSeconds": 2.3, + "passReadingTime": true, + "contrastRatio": 14.25, + "passContrast": true, + "minEdgeMarginPx": 37, + "phoneFontPx": 6.5, + "passMobileWidth": true, + "pass": true + }, + { + "step": 2, + "caption": "pass normalized phase to render()", + "words": 5, + "chars": 33, + "windowSeconds": 2.5, + "requiredSeconds": 2, + "passReadingTime": true, + "contrastRatio": 14.25, + "passContrast": true, + "minEdgeMarginPx": 37, + "phoneFontPx": 6.5, + "passMobileWidth": true, + "pass": true + }, + { + "step": 3, + "caption": "convert phase to integer cycles", + "words": 5, + "chars": 31, + "windowSeconds": 2.5, + "requiredSeconds": 2, + "passReadingTime": true, + "contrastRatio": 14.25, + "passContrast": true, + "minEdgeMarginPx": 37, + "phoneFontPx": 6.5, + "passMobileWidth": true, + "pass": true + }, + { + "step": 4, + "caption": "last frame meets frame 0 cleanly", + "words": 6, + "chars": 32, + "windowSeconds": 2.5, + "requiredSeconds": 2.3, + "passReadingTime": true, + "contrastRatio": 14.25, + "passContrast": true, + "minEdgeMarginPx": 37, + "phoneFontPx": 6.5, + "passMobileWidth": true, + "pass": true + } + ], + "reasons": [] +} diff --git a/gallery/api-pipeline-code/loop.gif b/gallery/api-pipeline-code/loop.gif new file mode 100644 index 0000000..a934b14 Binary files /dev/null and b/gallery/api-pipeline-code/loop.gif differ diff --git a/gallery/api-pipeline-code/poster.png b/gallery/api-pipeline-code/poster.png new file mode 100644 index 0000000..1053b88 Binary files /dev/null and b/gallery/api-pipeline-code/poster.png differ diff --git a/gallery/api-pipeline-code/seam.json b/gallery/api-pipeline-code/seam.json new file mode 100644 index 0000000..c12908c --- /dev/null +++ b/gallery/api-pipeline-code/seam.json @@ -0,0 +1,215 @@ +{ + "pass": true, + "totalFrames": 200, + "seamScore": 1.006, + "maxSeamScore": 1.5, + "duplicateFrames": 0, + "duplicatePairs": [], + "flickerScore": 0.08, + "maxFlickerScore": 2.5, + "medianStepDelta": 0.016208, + "seamStepDelta": 0.016312, + "normalizedSteps": [ + 1.006, + 0.997, + 0.997, + 1.001, + 1.003, + 0.997, + 0.997, + 0.995, + 0.999, + 0.999, + 1.003, + 0.999, + 0.997, + 1.001, + 1, + 1, + 0.994, + 0.996, + 1.072, + 1.072, + 1.061, + 1.071, + 1.068, + 1.026, + 1.726, + 1.001, + 1.027, + 1.071, + 1.075, + 1.064, + 1.076, + 1.076, + 0.996, + 0.994, + 1, + 1, + 1.001, + 0.997, + 0.999, + 1.003, + 0.999, + 0.999, + 0.995, + 0.997, + 0.997, + 1.003, + 1.001, + 0.997, + 0.997, + 1.006, + 1.006, + 0.997, + 0.997, + 1.001, + 1.003, + 0.997, + 0.997, + 0.995, + 0.999, + 0.999, + 1.003, + 0.999, + 0.997, + 1.001, + 1, + 1, + 0.994, + 0.996, + 1.076, + 1.076, + 1.064, + 1.075, + 1.071, + 1.027, + 1.658, + 1.001, + 1.024, + 1.063, + 1.067, + 1.057, + 1.068, + 1.068, + 0.996, + 0.994, + 1, + 1, + 1.001, + 0.997, + 0.999, + 1.003, + 0.999, + 0.999, + 0.995, + 0.997, + 0.997, + 1.003, + 1.001, + 0.997, + 0.997, + 1.006, + 1.006, + 0.997, + 0.997, + 1.001, + 1.003, + 0.997, + 0.997, + 0.995, + 0.999, + 0.999, + 1.003, + 0.999, + 0.997, + 1.001, + 1, + 1, + 0.994, + 0.996, + 1.068, + 1.068, + 1.057, + 1.067, + 1.063, + 1.024, + 1.654, + 1.001, + 1.025, + 1.066, + 1.069, + 1.059, + 1.071, + 1.071, + 0.996, + 0.994, + 1, + 1, + 1.001, + 0.997, + 0.999, + 1.003, + 0.999, + 0.999, + 0.995, + 0.997, + 0.997, + 1.003, + 1.001, + 0.997, + 0.997, + 1.006, + 1.006, + 0.997, + 0.997, + 1.001, + 1.003, + 0.997, + 0.997, + 0.995, + 0.999, + 0.999, + 1.003, + 0.999, + 0.997, + 1.001, + 1, + 1, + 0.994, + 0.996, + 1.071, + 1.071, + 1.059, + 1.069, + 1.066, + 1.025, + 1.646, + 1.001, + 1.026, + 1.068, + 1.071, + 1.061, + 1.072, + 1.072, + 0.996, + 0.994, + 1, + 1, + 1.001, + 0.997, + 0.999, + 1.003, + 0.999, + 0.999, + 0.995, + 0.997, + 0.997, + 1.003, + 1.001, + 0.997, + 0.997, + 1.006 + ], + "reasons": [] +} diff --git a/gallery/api-pipeline-code/sheet.png b/gallery/api-pipeline-code/sheet.png new file mode 100644 index 0000000..0c5a90f Binary files /dev/null and b/gallery/api-pipeline-code/sheet.png differ diff --git a/gallery/api-pipeline-code/showcase.gif b/gallery/api-pipeline-code/showcase.gif new file mode 100644 index 0000000..a934b14 Binary files /dev/null and b/gallery/api-pipeline-code/showcase.gif differ diff --git a/gallery/api-pipeline-code/showcase.json b/gallery/api-pipeline-code/showcase.json new file mode 100644 index 0000000..466884e --- /dev/null +++ b/gallery/api-pipeline-code/showcase.json @@ -0,0 +1,42 @@ +{ + "title": "Phase Contract SDK Showcase", + "says": "Every Loop Studio sketch exports meta and a pure render(ctx, phase) function.", + "seconds": 10, + "fps": 20, + "width": 800, + "height": 320, + "palette": "studio-dark", + "scene": "code", + "stage": [ + "export const meta = { seconds: 4 };", + "export function render(ctx, phase) {", + " const a = phase * Math.PI * 2;", + " drawOrbit(ctx, a); // seam 1.00" + ], + "steps": [ + { + "from": 8.75, + "to": 1.25, + "caption": "declare duration and fps in meta", + "source": "rules/AGENTS.md:8" + }, + { + "from": 1.25, + "to": 3.75, + "caption": "pass normalized phase to render()", + "source": "rules/AGENTS.md:17" + }, + { + "from": 3.75, + "to": 6.25, + "caption": "convert phase to integer cycles", + "source": "skills/loop-math/SKILL.md:22" + }, + { + "from": 6.25, + "to": 8.75, + "caption": "last frame meets frame 0 cleanly", + "source": "skills/loop-render/SKILL.md:30" + } + ] +} diff --git a/gallery/api-pipeline-code/sketch.js b/gallery/api-pipeline-code/sketch.js new file mode 100644 index 0000000..ecc4ff8 --- /dev/null +++ b/gallery/api-pipeline-code/sketch.js @@ -0,0 +1,127 @@ +// Scene Pack: code — Stepping code editor + live inspector pane +export const meta = { + mode: "showcase", + scene: "code", + seconds: 10, + fps: 20, + width: 800, + height: 320, + seed: 29, + palette: "studio-dark" +}; + +export const showcase = { + says: "Every Loop Studio sketch exports meta and a pure render(ctx, phase) function.", + seconds: 10, + scene: "code", + stage: [ + "export const meta = { seconds: 4 };", + "export function render(ctx, phase) {", + " const a = phase * Math.PI * 2;", + " drawOrbit(ctx, a); // seam 1.00" + ], + steps: [ + { from: 8.75, to: 1.25, caption: "declare duration and fps in meta", source: "rules/AGENTS.md:8" }, + { from: 1.25, to: 3.75, caption: "pass normalized phase to render()", source: "rules/AGENTS.md:17" }, + { from: 3.75, to: 6.25, caption: "convert phase to integer cycles", source: "skills/loop-math/SKILL.md:22" }, + { from: 6.25, to: 8.75, caption: "last frame meets frame 0 cleanly", source: "skills/loop-render/SKILL.md:30" } + ] +}; + +export function render(ctx, phase, kit) { + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; + const C = kit.palettes[meta.palette] || kit.palettes["studio-dark"]; + const S = kit.showcase || showcase; + const codeLines = S.stage || showcase.stage; + const steps = S.steps || showcase.steps; + const SECONDS = S.seconds || meta.seconds; + const t = phase * SECONDS; + const TAU = Math.PI * 2; + + ctx.fillStyle = C.ground; + ctx.fillRect(0, 0, W, H); + + const codeW = Math.round(W * 0.56); + const paneH = Math.round(H * 0.60); + const codeX = Math.round(W * 0.06); + const paneY = Math.round(H * 0.08); + const inspW = Math.round(W * 0.29); + const inspX = codeX + codeW + Math.round(W * 0.03); + + kit.roundRect(ctx, codeX, paneY, codeW, paneH, 10); + ctx.fillStyle = C.surface; + ctx.fill(); + ctx.strokeStyle = C.line; + ctx.lineWidth = 1.5; + ctx.stroke(); + + const rowStep = (paneH - 36) / Math.max(1, codeLines.length); + let activeLine = 0; + if (t >= 1.25 && t < 3.75) activeLine = 1; + else if (t >= 3.75 && t < 6.25) activeLine = 2; + else if (t >= 6.25 && t < 8.75) activeLine = 3; + + ctx.font = "500 12.5px monospace"; + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + codeLines.forEach((line, idx) => { + const ly = paneY + 24 + (idx + 0.4) * rowStep; + ctx.globalAlpha = 1; + ctx.fillStyle = idx === activeLine ? C.body : C.muted; + ctx.fillText(line, codeX + 18, ly); + }); + + // Inspector pane with constant-speed orbital particles + ctx.globalAlpha = 1; + kit.roundRect(ctx, inspX, paneY, inspW, paneH, 10); + ctx.fillStyle = C.surface; + ctx.fill(); + ctx.strokeStyle = C.spark; + ctx.lineWidth = 1.5; + ctx.stroke(); + + const cx = inspX + inspW / 2; + const cy = paneY + paneH * 0.5; + const r = Math.min(inspW, paneH) * 0.30; + ctx.strokeStyle = C.line; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.arc(cx, cy, r, 0, TAU); + ctx.stroke(); + + for (let k = 0; k < 3; k++) { + const ang = phase * TAU + (k * TAU) / 3; + const px = cx + Math.cos(ang) * r; + const py = cy + Math.sin(ang) * r; + ctx.fillStyle = k === 0 ? C.accent : C.spark; + ctx.beginPath(); + ctx.arc(px, py, Math.max(5, r * 0.2), 0, TAU); + ctx.fill(); + } + + // Fixed caption pill + cross-faded text + const capY = Math.round(H * 0.86); + const pillW = Math.round(W * 0.62); + kit.roundRect(ctx, W / 2 - pillW / 2, capY - 16, pillW, 32, 6); + ctx.globalAlpha = 0.95; + ctx.fillStyle = C.surface; + ctx.fill(); + ctx.strokeStyle = C.line; + ctx.lineWidth = 1; + ctx.stroke(); + + ctx.font = "500 13px monospace"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + steps.forEach((c) => { + const len = ((c.to - c.from) % SECONDS + SECONDS) % SECONDS || SECONDS; + const u = ((t - c.from) % SECONDS + SECONDS) % SECONDS; + if (u >= len) return; + const fade = Math.max(0.2, Math.min(1, u / 0.35, (len - u) / 0.35)); + ctx.globalAlpha = fade; + ctx.fillStyle = C.body; + ctx.fillText(c.caption, W / 2, capY); + }); + ctx.globalAlpha = 1; +} diff --git a/gallery/api-pipeline-code/sources.json b/gallery/api-pipeline-code/sources.json new file mode 100644 index 0000000..bbeb576 --- /dev/null +++ b/gallery/api-pipeline-code/sources.json @@ -0,0 +1,40 @@ +{ + "pass": true, + "repoRoot": "/Users/marcusk/.gemini/antigravity/scratch/loop-studio", + "checked": 4, + "citations": [ + { + "step": 1, + "source": "rules/AGENTS.md:8", + "file": "rules/AGENTS.md", + "line": 8, + "excerpt": "", + "valid": true + }, + { + "step": 2, + "source": "rules/AGENTS.md:17", + "file": "rules/AGENTS.md", + "line": 17, + "excerpt": "palette: \"abyss\"", + "valid": true + }, + { + "step": 3, + "source": "skills/loop-math/SKILL.md:22", + "file": "skills/loop-math/SKILL.md", + "line": 22, + "excerpt": "", + "valid": true + }, + { + "step": 4, + "source": "skills/loop-render/SKILL.md:30", + "file": "skills/loop-render/SKILL.md", + "line": 30, + "excerpt": "### 4. Seam Analysis (`loop seam`)", + "valid": true + } + ], + "reasons": [] +} diff --git a/gallery/api-pipeline-code/storyboard.png b/gallery/api-pipeline-code/storyboard.png new file mode 100644 index 0000000..91e92d9 Binary files /dev/null and b/gallery/api-pipeline-code/storyboard.png differ diff --git a/gallery/aurora-flow-field/audit.json b/gallery/aurora-flow-field/audit.json index 457b3da..6caa210 100644 --- a/gallery/aurora-flow-field/audit.json +++ b/gallery/aurora-flow-field/audit.json @@ -2,12 +2,14 @@ "id": "aurora-flow-field", "title": "Arctic Currents (Flow Field)", "mode": "ambient", + "useCase": "Organic generative header for landing pages, music visualizers, and project banners", + "fps": 20, "pass": true, - "seamScore": 1.013, + "seamScore": 1.037, "duplicateFrames": 0, - "flickerScore": 0.025, + "flickerScore": 0.028, "legiblePass": true, "sourcesPass": true, - "gifKB": 1674.1, + "gifKB": 3076.4, "totalFrames": 80 } diff --git a/gallery/aurora-flow-field/loop.gif b/gallery/aurora-flow-field/loop.gif index c21884f..0ece294 100644 Binary files a/gallery/aurora-flow-field/loop.gif and b/gallery/aurora-flow-field/loop.gif differ diff --git a/gallery/aurora-flow-field/poster.png b/gallery/aurora-flow-field/poster.png index 7240b22..73d8fdf 100644 Binary files a/gallery/aurora-flow-field/poster.png and b/gallery/aurora-flow-field/poster.png differ diff --git a/gallery/aurora-flow-field/seam.json b/gallery/aurora-flow-field/seam.json index 72d413e..5f9b6a5 100644 --- a/gallery/aurora-flow-field/seam.json +++ b/gallery/aurora-flow-field/seam.json @@ -1,95 +1,95 @@ { "pass": true, "totalFrames": 80, - "seamScore": 1.013, + "seamScore": 1.037, "maxSeamScore": 1.5, "duplicateFrames": 0, "duplicatePairs": [], - "flickerScore": 0.025, + "flickerScore": 0.028, "maxFlickerScore": 2.5, - "medianStepDelta": 0.235275, - "seamStepDelta": 0.238384, + "medianStepDelta": 0.199618, + "seamStepDelta": 0.207054, "normalizedSteps": [ - 1.014, - 1.015, - 1.007, - 1.004, - 0.99, - 0.998, - 1.005, - 1.006, - 1.014, - 0.989, - 0.973, - 0.989, - 1, + 1.042, + 1.051, + 1.033, 1.023, - 1.044, - 1.059, - 1.046, - 1.04, - 1.018, - 0.999, 0.993, - 0.989, - 0.968, - 0.969, - 0.987, + 1.002, + 1.002, 1, - 0.992, - 0.985, - 0.989, - 1.014, + 1.001, + 0.979, + 0.964, + 0.986, + 0.994, + 1.015, + 1.028, + 1.04, + 1.019, + 1.024, + 1.002, + 0.99, + 0.987, + 0.979, + 0.966, + 0.97, + 0.99, + 1.011, 0.995, - 0.981, 0.984, - 0.982, - 0.991, - 0.974, - 0.972, - 0.96, - 0.961, - 0.971, - 0.981, 0.989, - 0.976, - 0.969, - 0.964, - 0.971, - 0.976, - 0.993, - 1.012, - 1.012, - 1.015, 1.017, - 1.01, - 1.021, - 1.045, - 1.021, - 1.024, - 1.041, - 1.065, - 1.066, - 1.033, - 1.04, - 1.04, - 1.037, - 1.031, - 1.007, - 0.993, - 0.991, - 1.001, - 1.005, - 0.997, + 1, + 0.987, + 0.979, + 0.972, 0.983, - 0.98, - 0.971, - 0.999, - 1.021, - 1.036, + 0.957, + 0.947, + 0.948, + 0.945, + 0.96, + 0.965, + 0.968, + 0.957, + 0.947, + 0.954, + 0.965, + 0.979, + 1.006, + 1.034, + 1.035, + 1.034, 1.031, + 1.025, + 1.036, + 1.061, + 1.036, + 1.048, + 1.052, + 1.061, + 1.058, + 1.034, + 1.028, + 1.027, 1.023, - 1.013 + 1.024, + 0.997, + 0.974, + 0.968, + 0.98, + 0.986, + 0.981, + 0.968, + 0.968, + 0.967, + 1.003, + 1.034, + 1.054, + 1.055, + 1.044, + 1.037 ], "reasons": [] } diff --git a/gallery/aurora-flow-field/sheet.png b/gallery/aurora-flow-field/sheet.png index 836d054..2ecb38e 100644 Binary files a/gallery/aurora-flow-field/sheet.png and b/gallery/aurora-flow-field/sheet.png differ diff --git a/gallery/cad-planetary/audit.json b/gallery/cad-planetary/audit.json index 6e2f34f..ad3853a 100644 --- a/gallery/cad-planetary/audit.json +++ b/gallery/cad-planetary/audit.json @@ -2,12 +2,14 @@ "id": "cad-planetary", "title": "Epicyclic Telemetry (Blueprint CAD)", "mode": "ambient", + "useCase": "Robotics, hardware, CAD, and precision engineering repo badges", + "fps": 20, "pass": true, - "seamScore": 1.016, + "seamScore": 1.023, "duplicateFrames": 0, "flickerScore": 0.031, "legiblePass": true, "sourcesPass": true, - "gifKB": 762.6, + "gifKB": 1193.9, "totalFrames": 80 } diff --git a/gallery/cad-planetary/legible.json b/gallery/cad-planetary/legible.json index 06f4df6..bcd5604 100644 --- a/gallery/cad-planetary/legible.json +++ b/gallery/cad-planetary/legible.json @@ -5,14 +5,14 @@ "captions": [ { "text": "CAD // HARMONIC-3X", - "contrastRatio": 14.93, - "minMarginPx": 18, + "contrastRatio": 11.34, + "minMarginPx": 13, "passContrast": true }, { "text": "THETA: 0 DEG", - "contrastRatio": 10.36, - "minMarginPx": 15, + "contrastRatio": 7.86, + "minMarginPx": 13, "passContrast": true } ], diff --git a/gallery/cad-planetary/loop.gif b/gallery/cad-planetary/loop.gif index 2855cf4..c265556 100644 Binary files a/gallery/cad-planetary/loop.gif and b/gallery/cad-planetary/loop.gif differ diff --git a/gallery/cad-planetary/poster.png b/gallery/cad-planetary/poster.png index d5f395a..9e0445b 100644 Binary files a/gallery/cad-planetary/poster.png and b/gallery/cad-planetary/poster.png differ diff --git a/gallery/cad-planetary/seam.json b/gallery/cad-planetary/seam.json index 444a68d..04a2d9f 100644 --- a/gallery/cad-planetary/seam.json +++ b/gallery/cad-planetary/seam.json @@ -1,95 +1,95 @@ { "pass": true, "totalFrames": 80, - "seamScore": 1.016, + "seamScore": 1.023, "maxSeamScore": 1.5, "duplicateFrames": 0, "duplicatePairs": [], "flickerScore": 0.031, "maxFlickerScore": 2.5, - "medianStepDelta": 0.115335, - "seamStepDelta": 0.117167, + "medianStepDelta": 0.094522, + "seamStepDelta": 0.096689, "normalizedSteps": [ - 1.024, - 1.036, - 1.027, - 1.007, - 1.009, + 1.01, + 1.02, + 1.035, + 1, + 1.006, 0.998, + 1.002, + 0.994, 1.004, - 0.985, - 0.992, - 0.986, - 0.999, + 0.993, + 0.998, 1.001, - 1.009, + 1.007, 1.008, - 1.006, - 1.037, + 0.999, 1.028, - 1.017, - 0.988, + 1.011, + 1.008, + 0.978, + 0.954, 0.964, - 0.977, + 0.956, + 0.987, + 0.959, + 0.952, 0.974, - 0.985, - 0.983, - 0.977, + 1, + 1.014, + 1.027, + 1.001, + 1.01, + 1.006, + 1.003, + 1.001, + 0.993, + 1, 0.988, + 1.005, + 0.998, 1.012, - 1.03, - 1.033, - 1.01, + 1.004, 1.007, + 1.023, 1.005, - 1.001, - 1.001, - 0.988, - 0.995, - 0.986, - 1.003, - 0.997, - 1.008, - 1.008, - 1.02, - 1.039, - 1.027, - 1.013, - 0.973, - 0.974, - 0.977, - 0.971, - 0.972, - 0.972, - 0.962, - 0.99, + 0.991, + 0.959, + 0.957, + 0.964, + 0.96, + 0.959, + 0.959, + 0.955, + 0.98, + 1.005, + 1.015, + 1.019, + 0.996, 1.017, - 1.031, - 1.03, - 1.002, - 1.007, - 1, + 1.004, + 1.016, + 0.997, + 0.991, + 0.997, + 0.991, + 1.004, 1.003, - 0.985, + 1.019, + 1.001, + 1.02, + 1.018, + 1.005, 0.983, - 0.988, - 0.993, - 1.003, - 0.999, - 1.007, - 1, - 1.026, - 1.033, - 1.021, - 0.994, + 0.952, + 0.959, + 0.956, + 0.959, 0.962, - 0.974, - 0.97, - 0.97, - 0.977, - 0.976, - 0.971, - 1.016 + 0.964, + 0.957, + 1.023 ], "reasons": [] } diff --git a/gallery/cad-planetary/sheet.png b/gallery/cad-planetary/sheet.png index ca8edfe..5e38cb1 100644 Binary files a/gallery/cad-planetary/sheet.png and b/gallery/cad-planetary/sheet.png differ diff --git a/gallery/cli-audit-session/audit.json b/gallery/cli-audit-session/audit.json index f0c8f51..9a45b0c 100644 --- a/gallery/cli-audit-session/audit.json +++ b/gallery/cli-audit-session/audit.json @@ -2,12 +2,14 @@ "id": "cli-audit-session", "title": "Loop CLI Audit Showcase (Terminal)", "mode": "showcase", + "useCase": "CLI documentation showing commands, flags, and pass/fail audit output", + "fps": 16, "pass": true, - "seamScore": 0.998, + "seamScore": 0.989, "duplicateFrames": 0, - "flickerScore": 1.366, + "flickerScore": 0.89, "legiblePass": true, "sourcesPass": true, - "gifKB": 805, + "gifKB": 1371.6, "totalFrames": 160 } diff --git a/gallery/cli-audit-session/legible.json b/gallery/cli-audit-session/legible.json index 9148b20..a6c2f38 100644 --- a/gallery/cli-audit-session/legible.json +++ b/gallery/cli-audit-session/legible.json @@ -16,7 +16,7 @@ "passReadingTime": true, "contrastRatio": 16.56, "passContrast": true, - "minEdgeMarginPx": 38, + "minEdgeMarginPx": 37, "phoneFontPx": 6.5, "passMobileWidth": true, "pass": true @@ -31,7 +31,7 @@ "passReadingTime": true, "contrastRatio": 16.56, "passContrast": true, - "minEdgeMarginPx": 38, + "minEdgeMarginPx": 37, "phoneFontPx": 6.5, "passMobileWidth": true, "pass": true @@ -46,7 +46,7 @@ "passReadingTime": true, "contrastRatio": 16.56, "passContrast": true, - "minEdgeMarginPx": 38, + "minEdgeMarginPx": 37, "phoneFontPx": 6.5, "passMobileWidth": true, "pass": true @@ -61,7 +61,7 @@ "passReadingTime": true, "contrastRatio": 16.56, "passContrast": true, - "minEdgeMarginPx": 38, + "minEdgeMarginPx": 37, "phoneFontPx": 6.5, "passMobileWidth": true, "pass": true diff --git a/gallery/cli-audit-session/loop.gif b/gallery/cli-audit-session/loop.gif index 19f9eae..6511cf9 100644 Binary files a/gallery/cli-audit-session/loop.gif and b/gallery/cli-audit-session/loop.gif differ diff --git a/gallery/cli-audit-session/poster.png b/gallery/cli-audit-session/poster.png index 0b8a4e6..6ec2d72 100644 Binary files a/gallery/cli-audit-session/poster.png and b/gallery/cli-audit-session/poster.png differ diff --git a/gallery/cli-audit-session/seam.json b/gallery/cli-audit-session/seam.json index a99491c..2182486 100644 --- a/gallery/cli-audit-session/seam.json +++ b/gallery/cli-audit-session/seam.json @@ -1,175 +1,175 @@ { "pass": true, "totalFrames": 160, - "seamScore": 0.998, + "seamScore": 0.989, "maxSeamScore": 1.5, "duplicateFrames": 0, "duplicatePairs": [], - "flickerScore": 1.366, + "flickerScore": 0.89, "maxFlickerScore": 2.5, - "medianStepDelta": 0.009208, - "seamStepDelta": 0.009187, + "medianStepDelta": 0.009432, + "seamStepDelta": 0.009329, "normalizedSteps": [ - 0.998, - 0.994, + 0.989, + 0.997, + 1.009, + 0.995, + 1, + 1, + 0.995, + 0.996, + 0.99, + 1.003, + 0.987, + 0.988, + 0.997, + 1.004, + 1.141, + 1.313, + 1.298, + 1.31, + 1.245, + 2.136, + 1.004, + 1.271, + 1.343, + 1.33, + 1.346, + 1.159, + 1.004, + 0.997, + 0.988, + 0.987, + 1.003, + 0.99, + 0.996, + 0.995, + 1, + 1, + 0.995, + 1.009, + 0.997, + 0.989, + 0.989, + 0.997, + 1.009, + 0.995, + 1, + 1, + 0.995, + 0.996, + 0.99, + 1.003, + 0.987, + 0.988, + 0.997, + 1.004, + 1.159, + 1.346, + 1.33, + 1.343, + 1.271, + 2.599, 1.004, - 1.002, - 0.998, - 0.998, - 0.995, - 0.994, - 0.992, - 1, - 0.986, - 0.994, - 0.995, - 1.005, - 1.238, - 1.529, - 1.51, - 1.526, - 1.42, - 2.857, - 1.006, - 1.479, - 1.598, - 1.579, - 1.601, - 1.274, - 1.005, - 0.995, - 0.994, - 0.986, - 1, - 0.992, - 0.994, - 0.995, - 0.998, - 0.998, - 1.002, + 1.252, + 1.319, + 1.306, + 1.322, + 1.146, 1.004, - 0.994, - 0.998, - 0.998, - 0.994, + 0.997, + 0.988, + 0.987, + 1.003, + 0.99, + 0.996, + 0.995, + 1, + 1, + 0.995, + 1.009, + 0.997, + 0.989, + 0.989, + 0.997, + 1.009, + 0.995, + 1, + 1, + 0.995, + 0.996, + 0.99, + 1.003, + 0.987, + 0.988, + 0.997, 1.004, - 1.002, - 0.998, - 0.998, - 0.995, - 0.994, - 0.992, - 1, - 0.986, - 0.994, - 0.995, - 1.005, - 1.274, - 1.601, - 1.579, - 1.598, - 1.479, - 3.598, - 1.006, - 1.454, - 1.568, - 1.549, - 1.57, - 1.258, - 1.005, - 0.995, - 0.994, - 0.986, - 1, - 0.992, - 0.994, - 0.995, - 0.998, - 0.998, - 1.002, + 1.146, + 1.322, + 1.306, + 1.319, + 1.252, + 2.634, 1.004, - 0.994, - 0.998, - 0.998, - 0.994, + 1.27, + 1.341, + 1.328, + 1.344, + 1.156, 1.004, - 1.002, - 0.998, - 0.998, - 0.995, - 0.994, - 0.992, - 1, - 0.986, - 0.994, - 0.995, - 1.005, - 1.258, - 1.57, - 1.549, - 1.568, - 1.454, - 3.624, - 1.006, - 1.464, - 1.58, - 1.561, - 1.582, - 1.264, - 1.005, - 0.995, - 0.994, - 0.986, - 1, - 0.992, - 0.994, - 0.995, - 0.998, - 0.998, - 1.002, + 0.997, + 0.988, + 0.987, + 1.003, + 0.99, + 0.996, + 0.995, + 1, + 1, + 0.995, + 1.009, + 0.997, + 0.989, + 0.989, + 0.997, + 1.009, + 0.995, + 1, + 1, + 0.995, + 0.996, + 0.99, + 1.003, + 0.987, + 0.988, + 0.997, 1.004, - 0.994, - 0.998, - 0.998, - 0.994, + 1.156, + 1.344, + 1.328, + 1.341, + 1.27, + 2.16, 1.004, - 1.002, - 0.998, - 0.998, - 0.995, - 0.994, - 0.992, - 1, - 0.986, - 0.994, - 0.995, - 1.005, - 1.264, - 1.582, - 1.561, - 1.58, - 1.464, - 2.83, - 1.006, - 1.42, - 1.526, - 1.51, - 1.529, - 1.238, - 1.005, - 0.995, - 0.994, - 0.986, - 1, - 0.992, - 0.994, - 0.995, - 0.998, - 0.998, - 1.002, + 1.245, + 1.31, + 1.298, + 1.313, + 1.141, 1.004, - 0.994, - 0.998 + 0.997, + 0.988, + 0.987, + 1.003, + 0.99, + 0.996, + 0.995, + 1, + 1, + 0.995, + 1.009, + 0.997, + 0.989 ], "reasons": [] } diff --git a/gallery/cli-audit-session/sheet.png b/gallery/cli-audit-session/sheet.png index eb53893..dcc4aaa 100644 Binary files a/gallery/cli-audit-session/sheet.png and b/gallery/cli-audit-session/sheet.png differ diff --git a/gallery/cli-audit-session/showcase.gif b/gallery/cli-audit-session/showcase.gif index 19f9eae..6511cf9 100644 Binary files a/gallery/cli-audit-session/showcase.gif and b/gallery/cli-audit-session/showcase.gif differ diff --git a/gallery/cli-audit-session/sources.json b/gallery/cli-audit-session/sources.json index be2a598..1cd3ef8 100644 --- a/gallery/cli-audit-session/sources.json +++ b/gallery/cli-audit-session/sources.json @@ -8,7 +8,7 @@ "source": "docs/tool.md:22", "file": "docs/tool.md", "line": 22, - "excerpt": "Renders all frames `0..N-1` at full resolution and outputs `showcase.gif` / `loop.gif` and `poster.png` (plus `loop.mp4`", + "excerpt": "Renders all frames `0..N-1` at full resolution and outputs `showcase.gif` / `loop.gif`, `poster.png`, `loop.mp4` (via FF", "valid": true }, { diff --git a/gallery/cli-audit-session/storyboard.png b/gallery/cli-audit-session/storyboard.png index 4f9650a..a615eed 100644 Binary files a/gallery/cli-audit-session/storyboard.png and b/gallery/cli-audit-session/storyboard.png differ diff --git a/gallery/deep-sea-orbits/audit.json b/gallery/deep-sea-orbits/audit.json index 5568293..371c177 100644 --- a/gallery/deep-sea-orbits/audit.json +++ b/gallery/deep-sea-orbits/audit.json @@ -2,12 +2,14 @@ "id": "deep-sea-orbits", "title": "Abyssal Bioluminescence (Particle Orbit)", "mode": "ambient", + "useCase": "Calm ambient background for dark-mode apps, streams, and loading states", + "fps": 20, "pass": true, - "seamScore": 0.974, + "seamScore": 0.972, "duplicateFrames": 0, "flickerScore": 0.024, "legiblePass": true, "sourcesPass": true, - "gifKB": 1173.2, + "gifKB": 1247.8, "totalFrames": 80 } diff --git a/gallery/deep-sea-orbits/loop.gif b/gallery/deep-sea-orbits/loop.gif index 35c8ff0..cb945b7 100644 Binary files a/gallery/deep-sea-orbits/loop.gif and b/gallery/deep-sea-orbits/loop.gif differ diff --git a/gallery/deep-sea-orbits/poster.png b/gallery/deep-sea-orbits/poster.png index f0d90cf..4414e28 100644 Binary files a/gallery/deep-sea-orbits/poster.png and b/gallery/deep-sea-orbits/poster.png differ diff --git a/gallery/deep-sea-orbits/seam.json b/gallery/deep-sea-orbits/seam.json index ee63085..d7defbc 100644 --- a/gallery/deep-sea-orbits/seam.json +++ b/gallery/deep-sea-orbits/seam.json @@ -1,95 +1,95 @@ { "pass": true, "totalFrames": 80, - "seamScore": 0.974, + "seamScore": 0.972, "maxSeamScore": 1.5, "duplicateFrames": 0, "duplicatePairs": [], "flickerScore": 0.024, "maxFlickerScore": 2.5, - "medianStepDelta": 0.125274, - "seamStepDelta": 0.121981, + "medianStepDelta": 0.128576, + "seamStepDelta": 0.125015, "normalizedSteps": [ - 0.971, - 0.948, 0.969, - 0.962, - 0.965, + 0.945, 0.967, - 0.982, - 0.971, - 0.955, - 0.989, - 0.985, + 0.96, + 0.963, + 0.965, 0.98, - 0.999, - 0.986, - 0.995, - 1.001, + 0.97, + 0.954, + 0.987, + 0.983, + 0.98, + 0.998, + 0.984, + 0.994, + 1, 1.014, - 1.009, + 1.008, 0.993, - 1.022, - 1.019, + 1.021, + 1.018, 1.013, - 1.028, - 1.015, - 1.029, - 1.02, - 1.035, - 1.028, - 1.023, 1.029, + 1.016, + 1.03, + 1.021, 1.037, 1.03, + 1.024, + 1.031, 1.039, - 1.029, - 1.036, - 1.035, - 1.042, - 1.036, - 1.034, - 1.042, - 1.046, - 1.044, - 1.047, - 1.034, - 1.036, + 1.032, 1.041, - 1.042, - 1.036, - 1.019, - 1.019, - 1.027, 1.03, + 1.038, + 1.037, + 1.044, + 1.039, + 1.037, + 1.046, + 1.049, + 1.048, + 1.05, + 1.036, + 1.038, + 1.044, + 1.046, + 1.039, 1.022, - 0.998, - 0.995, - 1.01, 1.021, + 1.029, + 1.032, + 1.023, 0.999, - 0.983, 0.996, + 1.011, + 1.022, 1, - 1, - 0.993, - 0.987, - 0.988, + 0.984, + 0.996, + 1.001, + 0.999, 0.992, - 1, + 0.987, + 0.987, + 0.991, + 0.998, + 0.974, + 0.964, + 0.984, 0.975, - 0.965, - 0.985, - 0.976, - 0.957, - 0.961, + 0.956, 0.961, 0.96, + 0.96, + 0.961, + 0.974, 0.962, - 0.975, - 0.963, - 0.941, - 0.974 + 0.939, + 0.972 ], "reasons": [] } diff --git a/gallery/deep-sea-orbits/sheet.png b/gallery/deep-sea-orbits/sheet.png index 40c947a..15b5a82 100644 Binary files a/gallery/deep-sea-orbits/sheet.png and b/gallery/deep-sea-orbits/sheet.png differ diff --git a/gallery/git-pr-guardrails/audit.json b/gallery/git-pr-guardrails/audit.json new file mode 100644 index 0000000..8c36c69 --- /dev/null +++ b/gallery/git-pr-guardrails/audit.json @@ -0,0 +1,16 @@ +{ + "id": "git-pr-guardrails", + "title": "Protected Git Workflow (8s @ 60fps)", + "mode": "showcase", + "useCase": "GitHub workflow & CI/CD guardrails explainer showing branch protection, evals, and PR merges", + "fps": 60, + "pass": true, + "seamScore": 1.148, + "duplicateFrames": 0, + "flickerScore": 0.736, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 6539.7, + "webpKB": 3114.5, + "totalFrames": 480 +} diff --git a/gallery/git-pr-guardrails/index.html b/gallery/git-pr-guardrails/index.html new file mode 100644 index 0000000..d1d42b5 --- /dev/null +++ b/gallery/git-pr-guardrails/index.html @@ -0,0 +1,120 @@ + + + + + + Protected Git Workflow (8s @ 60fps) · Loop Studio + + + +
+
+

Protected Git Workflow (8s @ 60fps)

+ loading sketch.js... +
+
+
+ +
+
+ + + frame 000 / 120 · phase 0.00 + +
+
+
+ + + \ No newline at end of file diff --git a/gallery/git-pr-guardrails/legible.json b/gallery/git-pr-guardrails/legible.json new file mode 100644 index 0000000..63ee006 --- /dev/null +++ b/gallery/git-pr-guardrails/legible.json @@ -0,0 +1,71 @@ +{ + "pass": true, + "width": 640, + "height": 270, + "phoneWidth": 400, + "frame0ShowsAllStageLabels": true, + "stageLabelsChecked": 4, + "captions": [ + { + "step": 1, + "caption": "branch feat/* forks from dev", + "words": 5, + "chars": 28, + "windowSeconds": 2, + "requiredSeconds": 2, + "passReadingTime": true, + "contrastRatio": 14.23, + "passContrast": true, + "minEdgeMarginPx": 30, + "phoneFontPx": 7.81, + "passMobileWidth": true, + "pass": true + }, + { + "step": 2, + "caption": "CI runs 34 eval checks", + "words": 5, + "chars": 22, + "windowSeconds": 2, + "requiredSeconds": 2, + "passReadingTime": true, + "contrastRatio": 14.23, + "passContrast": true, + "minEdgeMarginPx": 30, + "phoneFontPx": 7.81, + "passMobileWidth": true, + "pass": true + }, + { + "step": 3, + "caption": "CODEOWNERS approves the PR", + "words": 4, + "chars": 26, + "windowSeconds": 2, + "requiredSeconds": 1.7, + "passReadingTime": true, + "contrastRatio": 14.23, + "passContrast": true, + "minEdgeMarginPx": 30, + "phoneFontPx": 7.81, + "passMobileWidth": true, + "pass": true + }, + { + "step": 4, + "caption": "merged into dev & main", + "words": 5, + "chars": 22, + "windowSeconds": 2, + "requiredSeconds": 2, + "passReadingTime": true, + "contrastRatio": 14.23, + "passContrast": true, + "minEdgeMarginPx": 30, + "phoneFontPx": 7.81, + "passMobileWidth": true, + "pass": true + } + ], + "reasons": [] +} diff --git a/gallery/git-pr-guardrails/loop.gif b/gallery/git-pr-guardrails/loop.gif new file mode 100644 index 0000000..ba4180d Binary files /dev/null and b/gallery/git-pr-guardrails/loop.gif differ diff --git a/gallery/git-pr-guardrails/poster.png b/gallery/git-pr-guardrails/poster.png new file mode 100644 index 0000000..be84ca8 Binary files /dev/null and b/gallery/git-pr-guardrails/poster.png differ diff --git a/gallery/git-pr-guardrails/seam.json b/gallery/git-pr-guardrails/seam.json new file mode 100644 index 0000000..2b621c9 --- /dev/null +++ b/gallery/git-pr-guardrails/seam.json @@ -0,0 +1,495 @@ +{ + "pass": true, + "totalFrames": 480, + "seamScore": 1.148, + "maxSeamScore": 1.5, + "duplicateFrames": 0, + "duplicatePairs": [], + "flickerScore": 0.736, + "maxFlickerScore": 2.5, + "medianStepDelta": 0.010235, + "seamStepDelta": 0.011745, + "normalizedSteps": [ + 1.042, + 0.986, + 1.061, + 1.053, + 1.058, + 1, + 1.056, + 1.052, + 1.06, + 0.999, + 0.982, + 1.107, + 1.04, + 0.991, + 0.973, + 1.018, + 1.026, + 1.022, + 0.979, + 1.017, + 0.958, + 1.009, + 0.942, + 1.002, + 0.946, + 0.981, + 0.93, + 0.911, + 0.907, + 0.96, + 0.965, + 0.872, + 0.872, + 0.859, + 0.771, + 0.907, + 0.835, + 0.811, + 0.707, + 0.776, + 0.753, + 0.767, + 0.885, + 0.7, + 0.853, + 0.689, + 0.82, + 0.746, + 0.72, + 0.723, + 0.692, + 0.711, + 0.752, + 0.584, + 0.658, + 0.62, + 0.584, + 0.577, + 0.469, + 1.377, + 0.585, + 0.59, + 0.516, + 0.62, + 0.721, + 0.68, + 0.692, + 0.778, + 0.728, + 0.727, + 0.812, + 0.755, + 0.769, + 0.838, + 0.78, + 0.85, + 0.782, + 0.896, + 0.931, + 0.808, + 0.896, + 0.83, + 0.842, + 0.988, + 0.952, + 0.879, + 0.887, + 0.964, + 0.952, + 0.971, + 0.996, + 0.933, + 1.05, + 0.954, + 1.007, + 1.012, + 0.966, + 1.03, + 0.981, + 1.027, + 1.045, + 0.995, + 0.991, + 1.095, + 0.988, + 0.991, + 0.997, + 1.057, + 1.064, + 1.004, + 1.015, + 1.019, + 1.11, + 3.89, + 1.021, + 1.067, + 1.067, + 1.011, + 1.059, + 1.537, + 1.62, + 1.061, + 1.016, + 1.119, + 1.001, + 1.064, + 4.337, + 1.062, + 1.058, + 0.994, + 1.015, + 1.044, + 1.087, + 0.972, + 0.995, + 1.041, + 0.988, + 1.084, + 1.023, + 0.977, + 1.016, + 0.969, + 1.001, + 0.958, + 0.95, + 0.981, + 0.938, + 0.93, + 0.954, + 0.899, + 0.895, + 0.94, + 0.881, + 0.823, + 0.87, + 0.857, + 0.895, + 0.771, + 0.833, + 0.828, + 0.812, + 0.802, + 0.774, + 0.851, + 0.797, + 0.784, + 0.733, + 0.748, + 0.74, + 0.776, + 0.631, + 0.761, + 0.601, + 0.726, + 2.896, + 0.65, + 0.604, + 0.529, + 0.56, + 1.324, + 0.637, + 0.496, + 0.589, + 0.597, + 0.636, + 0.756, + 0.788, + 0.717, + 0.772, + 0.768, + 0.839, + 0.817, + 0.882, + 0.826, + 0.909, + 0.861, + 0.926, + 0.919, + 0.943, + 0.938, + 0.977, + 0.929, + 0.942, + 1.014, + 1.073, + 0.992, + 1.004, + 1.062, + 1.068, + 1.088, + 1.049, + 1.11, + 1.104, + 1.128, + 1.085, + 1.145, + 1.14, + 1.149, + 1.115, + 1.158, + 1.13, + 1.186, + 1.187, + 1.18, + 1.154, + 1.153, + 1.161, + 1.214, + 1.205, + 1.172, + 1.178, + 1.18, + 1.224, + 4.285, + 1.234, + 1.184, + 1.231, + 1.186, + 1.235, + 1.761, + 1.637, + 1.187, + 1.239, + 1.239, + 1.232, + 1.187, + 3.953, + 1.226, + 1.233, + 1.197, + 1.179, + 1.277, + 1.224, + 1.18, + 1.167, + 1.215, + 1.222, + 1.207, + 1.161, + 1.199, + 1.148, + 1.186, + 1.132, + 1.172, + 1.127, + 1.154, + 1.108, + 1.096, + 1.089, + 1.124, + 1.125, + 1.056, + 1.043, + 1.039, + 0.96, + 1.071, + 0.993, + 0.98, + 0.898, + 0.96, + 0.937, + 0.924, + 1.014, + 0.848, + 0.979, + 0.83, + 0.927, + 0.865, + 0.845, + 0.829, + 0.794, + 0.815, + 0.83, + 0.681, + 0.727, + 0.686, + 0.635, + 0.628, + 0.51, + 1.367, + 0.591, + 0.602, + 0.543, + 0.641, + 0.747, + 0.719, + 0.734, + 0.825, + 0.787, + 0.784, + 0.883, + 0.834, + 0.841, + 0.919, + 0.886, + 0.962, + 0.909, + 1.011, + 1.041, + 0.939, + 1.02, + 0.969, + 0.981, + 1.098, + 1.069, + 1.023, + 1.043, + 1.103, + 1.098, + 1.122, + 1.134, + 1.088, + 1.197, + 1.116, + 1.169, + 1.174, + 1.139, + 1.193, + 1.154, + 1.197, + 1.221, + 1.172, + 1.176, + 1.274, + 1.186, + 1.188, + 1.183, + 1.233, + 1.252, + 1.204, + 1.209, + 1.207, + 1.301, + 4.294, + 1.216, + 1.264, + 1.268, + 1.222, + 1.265, + 1.767, + 1.722, + 1.262, + 1.221, + 1.317, + 1.215, + 1.274, + 4.298, + 1.265, + 1.264, + 1.215, + 1.219, + 1.253, + 1.306, + 1.194, + 1.199, + 1.24, + 1.193, + 1.283, + 1.231, + 1.184, + 1.218, + 1.171, + 1.203, + 1.158, + 1.152, + 1.179, + 1.136, + 1.122, + 1.153, + 1.108, + 1.089, + 1.132, + 1.072, + 0.997, + 1.043, + 1.038, + 1.074, + 0.938, + 0.982, + 0.969, + 0.952, + 0.936, + 0.893, + 0.973, + 0.908, + 0.901, + 0.862, + 0.874, + 0.853, + 0.882, + 0.73, + 0.866, + 0.675, + 0.822, + 0.716, + 0.686, + 0.643, + 0.545, + 0.602, + 1.338, + 0.674, + 0.54, + 0.713, + 0.787, + 0.886, + 1.044, + 1.111, + 1.098, + 1.15, + 1.176, + 1.253, + 1.239, + 1.303, + 1.264, + 1.325, + 1.27, + 1.312, + 1.266, + 1.276, + 1.227, + 1.245, + 1.167, + 1.147, + 1.175, + 1.188, + 1.072, + 1.581, + 1.063, + 1.023, + 1.018, + 4.219, + 0.97, + 0.929, + 0.919, + 0.818, + 0.924, + 0.89, + 0.896, + 0.83, + 0.888, + 0.812, + 0.884, + 0.868, + 0.852, + 0.803, + 0.817, + 0.836, + 0.951, + 1.012, + 4.314, + 0.977, + 0.99, + 1.057, + 1.049, + 1.059, + 1.581, + 1.059, + 0.997, + 1.057, + 1.148 + ], + "reasons": [] +} diff --git a/gallery/git-pr-guardrails/sheet.png b/gallery/git-pr-guardrails/sheet.png new file mode 100644 index 0000000..9c5e767 Binary files /dev/null and b/gallery/git-pr-guardrails/sheet.png differ diff --git a/gallery/git-pr-guardrails/showcase.gif b/gallery/git-pr-guardrails/showcase.gif new file mode 100644 index 0000000..ba4180d Binary files /dev/null and b/gallery/git-pr-guardrails/showcase.gif differ diff --git a/gallery/git-pr-guardrails/showcase.json b/gallery/git-pr-guardrails/showcase.json new file mode 100644 index 0000000..682932f --- /dev/null +++ b/gallery/git-pr-guardrails/showcase.json @@ -0,0 +1,42 @@ +{ + "title": "Protected Git Workflow (60fps)", + "says": "Branch guardrails block direct pushes and require passing CI evals before merging into dev and main.", + "seconds": 8, + "fps": 60, + "width": 640, + "height": 270, + "palette": "studio-dark", + "scene": "flow", + "stage": [ + "feat/*", + "PR + CI", + "dev", + "main" + ], + "steps": [ + { + "from": 7, + "to": 1, + "caption": "branch feat/* forks from dev", + "source": ".github/workflows/ci.yml:5" + }, + { + "from": 1, + "to": 3, + "caption": "CI runs 34 eval checks", + "source": ".github/workflows/ci.yml:19" + }, + { + "from": 3, + "to": 5, + "caption": "CODEOWNERS approves the PR", + "source": ".github/CODEOWNERS:2" + }, + { + "from": 5, + "to": 7, + "caption": "merged into dev & main", + "source": ".github/workflows/ci.yml:4" + } + ] +} diff --git a/gallery/git-pr-guardrails/showcase.webp b/gallery/git-pr-guardrails/showcase.webp new file mode 100644 index 0000000..b94f945 Binary files /dev/null and b/gallery/git-pr-guardrails/showcase.webp differ diff --git a/gallery/git-pr-guardrails/sketch.js b/gallery/git-pr-guardrails/sketch.js new file mode 100644 index 0000000..910cf72 --- /dev/null +++ b/gallery/git-pr-guardrails/sketch.js @@ -0,0 +1,252 @@ +// Custom 60fps Showcase: git-pr-guardrails — Shows branch fork -> direct push shield -> CI evals -> PR merge +export const meta = { + mode: "showcase", + scene: "flow", + seconds: 8, + fps: 60, + width: 640, + height: 270, + seed: 91, + palette: "studio-dark" +}; + +export const showcase = { + title: "Protected Git Workflow (60fps)", + says: "Branch guardrails block direct pushes and require passing CI evals before merging into dev and main.", + seconds: 8, + fps: 60, + width: 640, + height: 270, + palette: "studio-dark", + scene: "flow", + stage: ["feat/*", "PR + CI", "dev", "main"], + steps: [ + { from: 7.0, to: 1.0, caption: "branch feat/* forks from dev", source: ".github/workflows/ci.yml:5" }, + { from: 1.0, to: 3.0, caption: "CI runs 34 eval checks", source: ".github/workflows/ci.yml:19" }, + { from: 3.0, to: 5.0, caption: "CODEOWNERS approves the PR", source: ".github/CODEOWNERS:2" }, + { from: 5.0, to: 7.0, caption: "merged into dev & main", source: ".github/workflows/ci.yml:4" } + ] +}; + +function ease(x) { + return x <= 0 ? 0 : x >= 1 ? 1 : x * x * (3 - 2 * x); +} + +function placeCommit(age, xs, W) { + const left = -0.06 * W; + const right = 1.06 * W; + let x = left; + let alpha = 1; + if (age < 2.0) { + x = left + (xs[0] - left) * ease(age / 2.0); + } else if (age < 4.0) { + const u = (age - 2.0) / 2.0; + x = xs[0] + (xs[1] - xs[0]) * (0.15 * u + 0.85 * ease(u)); + } else if (age < 6.0) { + const u = (age - 4.0) / 2.0; + x = xs[1] + (xs[2] - xs[1]) * (0.15 * u + 0.85 * ease(u)); + } else if (age < 8.0) { + const u = (age - 6.0) / 2.0; + x = xs[2] + (xs[3] - xs[2]) * (0.15 * u + 0.85 * ease(u)); + } else { + const e = ease((age - 8.0) / 1.0); + x = xs[3] + (right - xs[3]) * e; + alpha = 1 - e; + } + return { + x, + alpha, + verified: ease((age - 3.6) / 0.6) + }; +} + +export function render(ctx, phase, kit) { + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; + const C = kit.palettes[meta.palette] || kit.palettes["studio-dark"]; + const S = kit.showcase || showcase; + const labels = S.stage || showcase.stage; + const steps = S.steps || showcase.steps; + const SECONDS = S.seconds || meta.seconds; + const t = phase * SECONDS; + const TAU = Math.PI * 2; + const cyan = "#00E5B0"; + + // Layer 1: Radial gradient ground + harmonic wave lattice + if (ctx.createRadialGradient) { + const bg = ctx.createRadialGradient(W * 0.5, H * 0.4, 15, W * 0.5, H * 0.5, W * 0.65); + bg.addColorStop(0, "#141A33"); + bg.addColorStop(1, C.ground); + ctx.fillStyle = bg; + } else { + ctx.fillStyle = C.ground; + } + ctx.fillRect(0, 0, W, H); + + const count = 4; + const margin = W * 0.05; + const gap = W * 0.03; + const bw = (W - 2 * margin - (count - 1) * gap) / count; + const bh = Math.round(H * 0.42); + const by = Math.round(H * 0.30); + const railY = Math.round(H * 0.66); + const capY = Math.round(H * 0.86); + + const xs = [0, 1, 2, 3].map((i) => margin + i * (bw + gap) + bw / 2); + const items = [placeCommit(t + 1.0, xs, W)]; + if (t >= 7.0) items.push(placeCommit(t - 7.0, xs, W)); + + // Git rail + continuous commit ticks + ctx.strokeStyle = C.line; + ctx.lineWidth = 2.5; + ctx.beginPath(); + ctx.moveTo(0, railY); + ctx.lineTo(W, railY); + ctx.stroke(); + + const tickSpace = W / 16; + const tickShift = (phase * 4 * tickSpace) % tickSpace; + for (let i = 0; i <= 16; i++) { + ctx.globalAlpha = 0.4; + ctx.fillStyle = i % 2 === 0 ? C.spark : C.accent; + ctx.beginPath(); + ctx.arc(i * tickSpace + tickShift, railY, 1.8, 0, TAU); + ctx.fill(); + } + + xs.forEach((cx, i) => { + let near = 0; + items.forEach((it) => { + near = Math.max(near, it.alpha * Math.max(0, 1 - Math.abs(it.x - cx) / (bw * 0.78))); + }); + + const left = cx - bw / 2; + const top = by - bh / 2; + const activeCol = i === 1 ? cyan : i >= 2 ? C.spark : C.accent; + + ctx.globalAlpha = 1; + ctx.strokeStyle = near > 0.25 ? activeCol : C.line; + ctx.lineWidth = near > 0.25 ? 2.2 : 1.4; + ctx.beginPath(); + ctx.moveTo(cx, top + bh); + ctx.lineTo(cx, railY); + ctx.stroke(); + + kit.roundRect(ctx, left, top, bw, bh, 9); + ctx.fillStyle = C.surface; + ctx.fill(); + if (near > 0.02) { + ctx.globalAlpha = 0.16 * near; + ctx.fillStyle = activeCol; + ctx.fill(); + } + ctx.globalAlpha = 1; + ctx.strokeStyle = near > 0.15 ? activeCol : C.line; + ctx.lineWidth = near > 0.15 ? 2.2 : 1.3; + ctx.stroke(); + + // Stage label + ctx.font = "700 12px monospace"; + ctx.fillStyle = C.body; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillText(labels[i], cx, top + 20); + + // Rich card graphic per git stage + const cy = top + bh * 0.63; + if (i === 0) { + // Forking branch curve + ctx.strokeStyle = C.accent; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(left + 16, cy + 12); + ctx.bezierCurveTo(cx - 10, cy + 12, cx - 10, cy - 12, left + bw - 16, cy - 12); + ctx.stroke(); + const u = (phase * 2) % 1; + const dotX = left + 16 + (bw - 32) * u; + const dotY = cy + 12 - 24 * ease(u); + ctx.globalAlpha = Math.sin(Math.PI * u); + ctx.fillStyle = C.spark; + ctx.beginPath(); + ctx.arc(dotX, dotY, 4, 0, TAU); + ctx.fill(); + ctx.globalAlpha = 1; + } else if (i === 1) { + // CI Eval progress bars + for (let b = 0; b < 3; b++) { + const bwBar = (bw - 32) * (0.5 + 0.5 * Math.sin(TAU * (phase * 2 - b * 0.2))); + ctx.fillStyle = b === 2 ? cyan : C.spark; + ctx.fillRect(left + 16, cy - 14 + b * 12, bwBar, 6); + } + } else { + // Protected Shield Lock Ring on dev & main + const r = 18; + ctx.strokeStyle = i === 3 ? C.accent : cyan; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.arc(cx, cy, r, 0, TAU); + ctx.stroke(); + + const ang = phase * TAU * 2 * (i === 3 ? -1 : 1); + ctx.fillStyle = C.spark; + ctx.beginPath(); + ctx.arc(cx + Math.cos(ang) * r, cy + Math.sin(ang) * r, 3.5, 0, TAU); + ctx.fill(); + + ctx.font = "600 9px monospace"; + ctx.fillStyle = C.muted; + ctx.fillText("PROTECTED", cx, cy); + } + }); + + // Moving commit orb + items.forEach((it) => { + const r = 10; + const col = it.verified > 0.5 ? cyan : C.accent; + ctx.globalAlpha = it.alpha * 0.28; + ctx.fillStyle = col; + ctx.beginPath(); + ctx.arc(it.x, railY, r * 1.6, 0, TAU); + ctx.fill(); + + ctx.globalAlpha = it.alpha; + ctx.fillStyle = col; + ctx.beginPath(); + ctx.arc(it.x, railY, r, 0, TAU); + ctx.fill(); + + if (it.verified > 0.5) { + ctx.strokeStyle = C.ground; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(it.x - 4, railY); + ctx.lineTo(it.x - 1, railY + 3.5); + ctx.lineTo(it.x + 4.5, railY - 3.5); + ctx.stroke(); + } + }); + + // Caption pill + const pillW = Math.round(W * 0.66); + kit.roundRect(ctx, W / 2 - pillW / 2, capY - 16, pillW, 32, 7); + ctx.globalAlpha = 0.96; + ctx.fillStyle = C.surface; + ctx.fill(); + ctx.strokeStyle = C.line; + ctx.lineWidth = 1.2; + ctx.stroke(); + + ctx.font = "500 12.5px monospace"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + steps.forEach((c) => { + const len = ((c.to - c.from) % SECONDS + SECONDS) % SECONDS || SECONDS; + const u = ((t - c.from) % SECONDS + SECONDS) % SECONDS; + if (u >= len) return; + const fade = Math.max(0.25, Math.min(1, u / 0.3, (len - u) / 0.3)); + ctx.globalAlpha = fade; + ctx.fillStyle = C.body; + ctx.fillText(c.caption, W / 2, capY); + }); + ctx.globalAlpha = 1; +} diff --git a/gallery/git-pr-guardrails/sources.json b/gallery/git-pr-guardrails/sources.json new file mode 100644 index 0000000..8c1e0ed --- /dev/null +++ b/gallery/git-pr-guardrails/sources.json @@ -0,0 +1,40 @@ +{ + "pass": true, + "repoRoot": "/Users/marcusk/.gemini/antigravity/scratch/loop-studio", + "checked": 4, + "citations": [ + { + "step": 1, + "source": ".github/workflows/ci.yml:5", + "file": ".github/workflows/ci.yml", + "line": 5, + "excerpt": "branches: [main, dev]", + "valid": true + }, + { + "step": 2, + "source": ".github/workflows/ci.yml:19", + "file": ".github/workflows/ci.yml", + "line": 19, + "excerpt": "- name: Rebuild & Audit Gallery Loops", + "valid": true + }, + { + "step": 3, + "source": ".github/CODEOWNERS:2", + "file": ".github/CODEOWNERS", + "line": 2, + "excerpt": "* @MarcusK00", + "valid": true + }, + { + "step": 4, + "source": ".github/workflows/ci.yml:4", + "file": ".github/workflows/ci.yml", + "line": 4, + "excerpt": "push:", + "valid": true + } + ], + "reasons": [] +} diff --git a/gallery/git-pr-guardrails/storyboard.png b/gallery/git-pr-guardrails/storyboard.png new file mode 100644 index 0000000..bdea0c2 Binary files /dev/null and b/gallery/git-pr-guardrails/storyboard.png differ diff --git a/gallery/json-to-gif-transform/audit.json b/gallery/json-to-gif-transform/audit.json new file mode 100644 index 0000000..4933b4e --- /dev/null +++ b/gallery/json-to-gif-transform/audit.json @@ -0,0 +1,16 @@ +{ + "id": "json-to-gif-transform", + "title": "60fps Video Transformer (8s @ 60fps)", + "mode": "showcase", + "useCase": "Compiler, build pipeline, or media-processing explainer showing specs transforming into 60fps video", + "fps": 60, + "pass": true, + "seamScore": 1.005, + "duplicateFrames": 0, + "flickerScore": 0.103, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 5008.7, + "webpKB": 3798.9, + "totalFrames": 480 +} diff --git a/gallery/json-to-gif-transform/index.html b/gallery/json-to-gif-transform/index.html new file mode 100644 index 0000000..a212a09 --- /dev/null +++ b/gallery/json-to-gif-transform/index.html @@ -0,0 +1,120 @@ + + + + + + 60fps Video Transformer (8s @ 60fps) · Loop Studio + + + +
+
+

60fps Video Transformer (8s @ 60fps)

+ loading sketch.js... +
+
+
+ +
+
+ + + frame 000 / 120 · phase 0.00 + +
+
+
+ + + \ No newline at end of file diff --git a/gallery/json-to-gif-transform/legible.json b/gallery/json-to-gif-transform/legible.json new file mode 100644 index 0000000..7c098c5 --- /dev/null +++ b/gallery/json-to-gif-transform/legible.json @@ -0,0 +1,71 @@ +{ + "pass": true, + "width": 640, + "height": 270, + "phoneWidth": 400, + "frame0ShowsAllStageLabels": true, + "stageLabelsChecked": 3, + "captions": [ + { + "step": 1, + "caption": "brief.json sets 60fps target", + "words": 4, + "chars": 28, + "windowSeconds": 2, + "requiredSeconds": 1.7, + "passReadingTime": true, + "contrastRatio": 15.28, + "passContrast": true, + "minEdgeMarginPx": 30, + "phoneFontPx": 7.81, + "passMobileWidth": true, + "pass": true + }, + { + "step": 2, + "caption": "renders 480 phase-exact frames", + "words": 4, + "chars": 30, + "windowSeconds": 2, + "requiredSeconds": 1.7, + "passReadingTime": true, + "contrastRatio": 15.28, + "passContrast": true, + "minEdgeMarginPx": 30, + "phoneFontPx": 7.81, + "passMobileWidth": true, + "pass": true + }, + { + "step": 3, + "caption": "verifies seam score & contrast", + "words": 5, + "chars": 30, + "windowSeconds": 2, + "requiredSeconds": 2, + "passReadingTime": true, + "contrastRatio": 15.28, + "passContrast": true, + "minEdgeMarginPx": 30, + "phoneFontPx": 7.81, + "passMobileWidth": true, + "pass": true + }, + { + "step": 4, + "caption": "encodes 60fps MP4 & WebP", + "words": 5, + "chars": 24, + "windowSeconds": 2, + "requiredSeconds": 2, + "passReadingTime": true, + "contrastRatio": 15.28, + "passContrast": true, + "minEdgeMarginPx": 30, + "phoneFontPx": 7.81, + "passMobileWidth": true, + "pass": true + } + ], + "reasons": [] +} diff --git a/gallery/json-to-gif-transform/loop.gif b/gallery/json-to-gif-transform/loop.gif new file mode 100644 index 0000000..21407f6 Binary files /dev/null and b/gallery/json-to-gif-transform/loop.gif differ diff --git a/gallery/json-to-gif-transform/poster.png b/gallery/json-to-gif-transform/poster.png new file mode 100644 index 0000000..ef98600 Binary files /dev/null and b/gallery/json-to-gif-transform/poster.png differ diff --git a/gallery/json-to-gif-transform/seam.json b/gallery/json-to-gif-transform/seam.json new file mode 100644 index 0000000..d1a666e --- /dev/null +++ b/gallery/json-to-gif-transform/seam.json @@ -0,0 +1,495 @@ +{ + "pass": true, + "totalFrames": 480, + "seamScore": 1.005, + "maxSeamScore": 1.5, + "duplicateFrames": 0, + "duplicatePairs": [], + "flickerScore": 0.103, + "maxFlickerScore": 2.5, + "medianStepDelta": 0.017136, + "seamStepDelta": 0.017224, + "normalizedSteps": [ + 0.914, + 0.929, + 0.949, + 0.975, + 0.976, + 0.98, + 0.989, + 0.992, + 0.997, + 1, + 1.017, + 1.01, + 1.007, + 1.007, + 1.008, + 1.001, + 1.012, + 1.011, + 1.012, + 1.02, + 1.012, + 1.018, + 1.007, + 0.992, + 0.975, + 0.974, + 1.068, + 0.953, + 0.936, + 0.924, + 0.946, + 0.961, + 0.98, + 1.001, + 0.993, + 0.992, + 1.001, + 1.018, + 1.012, + 1.007, + 1.013, + 1.012, + 1.037, + 1.024, + 1.026, + 1.019, + 1.021, + 1.026, + 1.023, + 1.011, + 0.995, + 0.992, + 0.982, + 1.079, + 0.971, + 0.96, + 0.968, + 0.967, + 0.949, + 1.154, + 0.934, + 0.947, + 0.961, + 0.988, + 0.989, + 1.002, + 1.013, + 1.013, + 1.027, + 1.031, + 1.038, + 1.024, + 1.023, + 1.025, + 1.024, + 1.017, + 1.004, + 1.007, + 0.987, + 1.093, + 0.981, + 0.987, + 0.984, + 0.987, + 0.991, + 0.989, + 0.997, + 0.974, + 0.956, + 0.949, + 0.963, + 0.978, + 0.985, + 1.009, + 1.002, + 1.012, + 1.021, + 1.016, + 1.02, + 1.015, + 1.024, + 1.018, + 1.003, + 0.985, + 0.979, + 0.977, + 1.076, + 0.971, + 0.973, + 0.983, + 0.991, + 0.996, + 0.991, + 0.986, + 0.98, + 0.977, + 0.991, + 0.984, + 0.961, + 0.94, + 0.94, + 0.966, + 0.989, + 1, + 0.99, + 0.99, + 0.998, + 1.003, + 1.006, + 0.984, + 0.985, + 0.978, + 0.977, + 1.074, + 0.975, + 0.973, + 0.981, + 1.005, + 1.008, + 1.013, + 1.004, + 1.01, + 1.006, + 1.014, + 1.011, + 1.003, + 1.01, + 0.985, + 0.979, + 0.97, + 0.962, + 0.968, + 0.984, + 1.007, + 0.997, + 0.993, + 0.985, + 0.988, + 0.989, + 1.085, + 0.988, + 0.983, + 1.003, + 1.006, + 1.015, + 1.013, + 1.016, + 1.015, + 1.015, + 1.028, + 1.027, + 1.027, + 1.015, + 1.012, + 1.006, + 0.993, + 0.996, + 0.972, + 0.957, + 1.175, + 0.944, + 0.96, + 0.964, + 0.969, + 0.961, + 0.973, + 1.082, + 0.977, + 0.987, + 0.993, + 1.017, + 1.015, + 1.017, + 1.013, + 1.012, + 1.013, + 1.015, + 1.035, + 1.009, + 1.013, + 1.008, + 1.016, + 1.022, + 1.008, + 1.005, + 1.004, + 1.011, + 0.99, + 0.97, + 0.939, + 0.928, + 0.942, + 0.959, + 1.067, + 0.97, + 0.971, + 0.992, + 1.008, + 1.009, + 1.002, + 1.012, + 1.003, + 1.003, + 1.006, + 1.001, + 1.004, + 1.007, + 1.008, + 1.012, + 1.024, + 1.011, + 1.008, + 1, + 0.998, + 0.991, + 0.98, + 0.975, + 0.953, + 0.93, + 1.006, + 0.913, + 0.927, + 0.946, + 0.973, + 0.973, + 0.977, + 0.986, + 0.989, + 0.994, + 0.998, + 1.017, + 1.01, + 1.009, + 1.01, + 1.011, + 1.004, + 1.016, + 1.015, + 1.016, + 1.023, + 1.014, + 1.02, + 1.008, + 0.992, + 0.974, + 0.972, + 1.061, + 0.949, + 0.934, + 0.923, + 0.943, + 0.959, + 0.979, + 1, + 0.994, + 0.993, + 1.003, + 1.022, + 1.016, + 1.011, + 1.016, + 1.015, + 1.041, + 1.026, + 1.028, + 1.02, + 1.021, + 1.024, + 1.021, + 1.01, + 0.993, + 0.989, + 0.979, + 1.074, + 0.971, + 0.959, + 0.967, + 0.967, + 0.951, + 1.216, + 0.938, + 0.951, + 0.965, + 0.992, + 0.992, + 1.003, + 1.013, + 1.013, + 1.025, + 1.028, + 1.033, + 1.019, + 1.018, + 1.02, + 1.018, + 1.011, + 0.999, + 1.002, + 0.985, + 1.093, + 0.981, + 0.989, + 0.987, + 0.99, + 0.995, + 0.992, + 1.001, + 0.977, + 0.958, + 0.951, + 0.964, + 0.978, + 0.984, + 1.006, + 1, + 1.009, + 1.018, + 1.013, + 1.016, + 1.012, + 1.022, + 1.016, + 1.002, + 0.985, + 0.981, + 0.981, + 1.079, + 0.974, + 0.976, + 0.986, + 0.994, + 0.999, + 0.993, + 0.987, + 0.979, + 0.976, + 0.989, + 0.982, + 0.958, + 0.936, + 0.937, + 0.962, + 0.986, + 0.998, + 0.988, + 0.99, + 0.999, + 1.005, + 1.009, + 0.988, + 0.989, + 0.981, + 0.98, + 1.077, + 0.978, + 0.975, + 0.982, + 1.004, + 1.006, + 1.011, + 1.002, + 1.007, + 1.002, + 1.011, + 1.007, + 1, + 1.007, + 0.984, + 0.979, + 0.971, + 0.964, + 0.97, + 0.988, + 1.01, + 1, + 0.996, + 0.988, + 0.991, + 0.99, + 1.085, + 0.987, + 0.982, + 0.998, + 1.001, + 1.01, + 1.007, + 1.01, + 1.009, + 1.01, + 1.023, + 1.023, + 1.025, + 1.014, + 1.012, + 1.006, + 0.996, + 1, + 0.975, + 0.96, + 1.198, + 0.946, + 0.96, + 0.964, + 0.968, + 0.961, + 0.973, + 1.076, + 0.974, + 0.985, + 0.99, + 1.014, + 1.012, + 1.014, + 1.012, + 1.012, + 1.015, + 1.017, + 1.037, + 1.012, + 1.017, + 1.011, + 1.018, + 1.025, + 1.01, + 1.006, + 1.004, + 1.01, + 0.988, + 0.967, + 0.935, + 0.926, + 0.939, + 0.954, + 1.059, + 0.968, + 0.969, + 0.991, + 1.008, + 1.01, + 1.004, + 1.014, + 1.006, + 1.006, + 1.009, + 1.003, + 1.006, + 1.009, + 1.009, + 1.012, + 1.023, + 1.008, + 1.004, + 0.997, + 0.994, + 0.987, + 0.976, + 0.972, + 0.949, + 0.927, + 1.005 + ], + "reasons": [] +} diff --git a/gallery/json-to-gif-transform/sheet.png b/gallery/json-to-gif-transform/sheet.png new file mode 100644 index 0000000..caa1516 Binary files /dev/null and b/gallery/json-to-gif-transform/sheet.png differ diff --git a/gallery/json-to-gif-transform/showcase.gif b/gallery/json-to-gif-transform/showcase.gif new file mode 100644 index 0000000..21407f6 Binary files /dev/null and b/gallery/json-to-gif-transform/showcase.gif differ diff --git a/gallery/json-to-gif-transform/showcase.json b/gallery/json-to-gif-transform/showcase.json new file mode 100644 index 0000000..a35c12c --- /dev/null +++ b/gallery/json-to-gif-transform/showcase.json @@ -0,0 +1,41 @@ +{ + "title": "60fps Video Transformer", + "says": "The Loop Studio transformer converts brief.json into 480 audited 60fps video frames.", + "seconds": 8, + "fps": 60, + "width": 640, + "height": 270, + "palette": "abyss", + "scene": "transform", + "stage": [ + "brief.json", + "60 FPS", + "MP4 + WebP" + ], + "steps": [ + { + "from": 7, + "to": 1, + "caption": "brief.json sets 60fps target", + "source": "skills/loop-brief/SKILL.md:31" + }, + { + "from": 1, + "to": 3, + "caption": "renders 480 phase-exact frames", + "source": "rules/AGENTS.md:8" + }, + { + "from": 3, + "to": 5, + "caption": "verifies seam score & contrast", + "source": "skills/loop-audit/SKILL.md:14" + }, + { + "from": 5, + "to": 7, + "caption": "encodes 60fps MP4 & WebP", + "source": "skills/loop-render/SKILL.md:62" + } + ] +} diff --git a/gallery/json-to-gif-transform/showcase.webp b/gallery/json-to-gif-transform/showcase.webp new file mode 100644 index 0000000..2f99941 Binary files /dev/null and b/gallery/json-to-gif-transform/showcase.webp differ diff --git a/gallery/json-to-gif-transform/sketch.js b/gallery/json-to-gif-transform/sketch.js new file mode 100644 index 0000000..3be591f --- /dev/null +++ b/gallery/json-to-gif-transform/sketch.js @@ -0,0 +1,173 @@ +// Custom 60fps Showcase: json-to-gif-transform — Multi-stage transformer converting brief.json -> 480 frames -> MP4/WebP +export const meta = { + mode: "showcase", + scene: "transform", + seconds: 8, + fps: 60, + width: 640, + height: 270, + seed: 97, + palette: "abyss" +}; + +export const showcase = { + title: "60fps Video Transformer", + says: "The Loop Studio transformer converts brief.json into 480 audited 60fps video frames.", + seconds: 8, + fps: 60, + width: 640, + height: 270, + palette: "abyss", + scene: "transform", + stage: ["brief.json", "60 FPS", "MP4 + WebP"], + steps: [ + { from: 7.0, to: 1.0, caption: "brief.json sets 60fps target", source: "skills/loop-brief/SKILL.md:31" }, + { from: 1.0, to: 3.0, caption: "renders 480 phase-exact frames", source: "rules/AGENTS.md:8" }, + { from: 3.0, to: 5.0, caption: "verifies seam score & contrast", source: "skills/loop-audit/SKILL.md:14" }, + { from: 5.0, to: 7.0, caption: "encodes 60fps MP4 & WebP", source: "skills/loop-render/SKILL.md:62" } + ] +}; + +export function render(ctx, phase, kit) { + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; + const C = kit.palettes[meta.palette] || kit.palettes["abyss"]; + const S = kit.showcase || showcase; + const labels = S.stage || showcase.stage; + const steps = S.steps || showcase.steps; + const SECONDS = S.seconds || meta.seconds; + const t = phase * SECONDS; + const TAU = Math.PI * 2; + + ctx.fillStyle = C.ground; + ctx.fillRect(0, 0, W, H); + + const cardW = Math.round(W * 0.27); + const cardH = Math.round(H * 0.50); + const cy = Math.round(H * 0.40); + const leftX = Math.round(W * 0.20); + const midX = Math.round(W * 0.50); + const rightX = Math.round(W * 0.80); + + // Beam + 60fps streaming tokens + ctx.strokeStyle = C.line; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(leftX + cardW / 2, cy); + ctx.lineTo(rightX - cardW / 2, cy); + ctx.stroke(); + + for (let i = 0; i < 6; i++) { + const u = (phase * 3 + i / 6) % 1; + const px = (leftX + cardW / 2) + ((rightX - cardW / 2) - (leftX + cardW / 2)) * u; + const py = cy + Math.sin(TAU * (u * 2 + phase)) * 6; + ctx.fillStyle = u < 0.5 ? C.accent : C.spark; + ctx.beginPath(); + ctx.arc(px, py, 3.8, 0, TAU); + ctx.fill(); + } + + // Left Card: brief.json + kit.roundRect(ctx, leftX - cardW / 2, cy - cardH / 2, cardW, cardH, 10); + ctx.fillStyle = C.surface; + ctx.fill(); + ctx.strokeStyle = C.accent; + ctx.lineWidth = 2; + ctx.stroke(); + + ctx.font = "700 12px monospace"; + ctx.fillStyle = C.accent; + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillText(labels[0], leftX - cardW / 2 + 12, cy - cardH / 2 + 20); + + const specLines = ["fps: 60", "sec: 8", "480 frames", "seam <= 1.5"]; + ctx.font = "500 11px monospace"; + specLines.forEach((line, idx) => { + const pulse = 0.5 + 0.5 * Math.sin(TAU * (phase * 2 - idx * 0.2)); + ctx.globalAlpha = 0.55 + 0.45 * pulse; + ctx.fillStyle = idx === 0 ? C.spark : C.body; + ctx.fillText(line, leftX - cardW / 2 + 12, cy - 16 + idx * 18); + }); + + // Center Dual-Counter-Rotating 60fps Turbine + ctx.globalAlpha = 1; + const coreR = Math.round(H * 0.19); + ctx.fillStyle = C.surface; + ctx.beginPath(); + ctx.arc(midX, cy, coreR, 0, TAU); + ctx.fill(); + ctx.strokeStyle = C.line; + ctx.lineWidth = 2; + ctx.stroke(); + + const a1 = phase * TAU * 3; + const a2 = -phase * TAU * 4; + ctx.strokeStyle = C.accent; + ctx.lineWidth = 3; + ctx.beginPath(); + ctx.arc(midX, cy, coreR - 7, a1, a1 + Math.PI * 1.15); + ctx.stroke(); + + ctx.strokeStyle = C.spark; + ctx.lineWidth = 2.5; + ctx.beginPath(); + ctx.arc(midX, cy, coreR - 15, a2, a2 + Math.PI * 1.15); + ctx.stroke(); + + ctx.font = "700 11px monospace"; + ctx.fillStyle = C.body; + ctx.textAlign = "center"; + ctx.fillText("60 FPS", midX, cy); + + // Right Card: Live 60fps Output Preview + kit.roundRect(ctx, rightX - cardW / 2, cy - cardH / 2, cardW, cardH, 10); + ctx.fillStyle = C.surface; + ctx.fill(); + ctx.strokeStyle = C.spark; + ctx.lineWidth = 2; + ctx.stroke(); + + ctx.font = "700 12px monospace"; + ctx.fillStyle = C.spark; + ctx.textAlign = "left"; + ctx.fillText(labels[2], rightX - cardW / 2 + 12, cy - cardH / 2 + 20); + + // Miniature orbiting wave inside output card + const outCx = rightX; + const outCy = cy + 10; + for (let k = 0; k < 8; k++) { + const a = TAU * (phase * 2 + k / 8); + const ox = outCx + Math.cos(a) * (cardW * 0.28); + const oy = outCy + Math.sin(a * 2) * (cardH * 0.16); + ctx.fillStyle = k % 2 === 0 ? C.accent : C.spark; + ctx.beginPath(); + ctx.arc(ox, oy, 3.6, 0, TAU); + ctx.fill(); + } + + // Bottom caption pill + const capY = Math.round(H * 0.86); + const pillW = Math.round(W * 0.64); + kit.roundRect(ctx, W / 2 - pillW / 2, capY - 16, pillW, 32, 7); + ctx.globalAlpha = 0.96; + ctx.fillStyle = C.surface; + ctx.fill(); + ctx.strokeStyle = C.line; + ctx.lineWidth = 1.2; + ctx.stroke(); + + ctx.font = "500 12.5px monospace"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + steps.forEach((c) => { + const len = ((c.to - c.from) % SECONDS + SECONDS) % SECONDS || SECONDS; + const u = ((t - c.from) % SECONDS + SECONDS) % SECONDS; + if (u >= len) return; + const fade = Math.max(0.25, Math.min(1, u / 0.3, (len - u) / 0.3)); + ctx.globalAlpha = fade; + ctx.fillStyle = C.body; + ctx.fillText(c.caption, W / 2, capY); + }); + ctx.globalAlpha = 1; +} diff --git a/gallery/json-to-gif-transform/sources.json b/gallery/json-to-gif-transform/sources.json new file mode 100644 index 0000000..160568c --- /dev/null +++ b/gallery/json-to-gif-transform/sources.json @@ -0,0 +1,40 @@ +{ + "pass": true, + "repoRoot": "/Users/marcusk/.gemini/antigravity/scratch/loop-studio", + "checked": 4, + "citations": [ + { + "step": 1, + "source": "skills/loop-brief/SKILL.md:31", + "file": "skills/loop-brief/SKILL.md", + "line": 31, + "excerpt": "", + "valid": true + }, + { + "step": 2, + "source": "rules/AGENTS.md:8", + "file": "rules/AGENTS.md", + "line": 8, + "excerpt": "", + "valid": true + }, + { + "step": 3, + "source": "skills/loop-audit/SKILL.md:14", + "file": "skills/loop-audit/SKILL.md", + "line": 14, + "excerpt": "## What `loop audit` Measures", + "valid": true + }, + { + "step": 4, + "source": "skills/loop-render/SKILL.md:62", + "file": "skills/loop-render/SKILL.md", + "line": 62, + "excerpt": "- `loop.gif` (or `showcase.gif` in showcase mode) using adaptive 256-color quantization + LZW encoding (GIF89a frame del", + "valid": true + } + ], + "reasons": [] +} diff --git a/gallery/json-to-gif-transform/storyboard.png b/gallery/json-to-gif-transform/storyboard.png new file mode 100644 index 0000000..5e25d16 Binary files /dev/null and b/gallery/json-to-gif-transform/storyboard.png differ diff --git a/gallery/kinetic-release-banner/audit.json b/gallery/kinetic-release-banner/audit.json new file mode 100644 index 0000000..c9ddd17 --- /dev/null +++ b/gallery/kinetic-release-banner/audit.json @@ -0,0 +1,16 @@ +{ + "id": "kinetic-release-banner", + "title": "Editorial Kinetic Wave (60 fps Type)", + "mode": "ambient", + "useCase": "60 fps social release announcement card, talk title slide, and launch banner", + "fps": 60, + "pass": true, + "seamScore": 0.968, + "duplicateFrames": 0, + "flickerScore": 0.456, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 1408.1, + "webpKB": 1134.1, + "totalFrames": 240 +} diff --git a/gallery/kinetic-release-banner/brief.json b/gallery/kinetic-release-banner/brief.json new file mode 100644 index 0000000..c273b06 --- /dev/null +++ b/gallery/kinetic-release-banner/brief.json @@ -0,0 +1,12 @@ +{ + "title": "Editorial Kinetic Wave", + "prompt": "Silky 60 fps 4-second editorial kinetic typography wave repeating PHASE 0→1.", + "mode": "ambient", + "style": "kinetic-type", + "palette": "editorial", + "seconds": 4, + "fps": 60, + "width": 280, + "height": 280, + "seed": 61 +} diff --git a/gallery/kinetic-release-banner/index.html b/gallery/kinetic-release-banner/index.html new file mode 100644 index 0000000..6a89319 --- /dev/null +++ b/gallery/kinetic-release-banner/index.html @@ -0,0 +1,120 @@ + + + + + + Editorial Kinetic Wave (60 fps Type) · Loop Studio + + + +
+
+

Editorial Kinetic Wave (60 fps Type)

+ loading sketch.js... +
+
+
+ +
+
+ + + frame 000 / 120 · phase 0.00 + +
+
+
+ + + \ No newline at end of file diff --git a/gallery/kinetic-release-banner/legible.json b/gallery/kinetic-release-banner/legible.json new file mode 100644 index 0000000..1d763f0 --- /dev/null +++ b/gallery/kinetic-release-banner/legible.json @@ -0,0 +1,62 @@ +{ + "pass": true, + "mode": "ambient", + "textElementsChecked": 9, + "captions": [ + { + "text": "PHASE 0→1", + "contrastRatio": 5.19, + "minMarginPx": 30, + "passContrast": true + }, + { + "text": "PHASE 0→1", + "contrastRatio": 17.65, + "minMarginPx": 56, + "passContrast": true + }, + { + "text": "PHASE 0→1", + "contrastRatio": 5.15, + "minMarginPx": 71, + "passContrast": true + }, + { + "text": "PHASE 0→1", + "contrastRatio": 17.34, + "minMarginPx": 76, + "passContrast": true + }, + { + "text": "PHASE 0→1", + "contrastRatio": 16.32, + "minMarginPx": 96, + "passContrast": true + }, + { + "text": "PHASE 0→1", + "contrastRatio": 17.34, + "minMarginPx": 96, + "passContrast": true + }, + { + "text": "PHASE 0→1", + "contrastRatio": 5.15, + "minMarginPx": 76, + "passContrast": true + }, + { + "text": "PHASE 0→1", + "contrastRatio": 17.65, + "minMarginPx": 55, + "passContrast": true + }, + { + "text": "PHASE 0→1", + "contrastRatio": 5.19, + "minMarginPx": 29, + "passContrast": true + } + ], + "reasons": [] +} diff --git a/gallery/kinetic-release-banner/loop.gif b/gallery/kinetic-release-banner/loop.gif new file mode 100644 index 0000000..89decbf Binary files /dev/null and b/gallery/kinetic-release-banner/loop.gif differ diff --git a/gallery/kinetic-release-banner/loop.webp b/gallery/kinetic-release-banner/loop.webp new file mode 100644 index 0000000..0d1f1a5 Binary files /dev/null and b/gallery/kinetic-release-banner/loop.webp differ diff --git a/gallery/kinetic-release-banner/poster.png b/gallery/kinetic-release-banner/poster.png new file mode 100644 index 0000000..a91f7d5 Binary files /dev/null and b/gallery/kinetic-release-banner/poster.png differ diff --git a/gallery/kinetic-release-banner/seam.json b/gallery/kinetic-release-banner/seam.json new file mode 100644 index 0000000..ff2d4a0 --- /dev/null +++ b/gallery/kinetic-release-banner/seam.json @@ -0,0 +1,255 @@ +{ + "pass": true, + "totalFrames": 240, + "seamScore": 0.968, + "maxSeamScore": 1.5, + "duplicateFrames": 0, + "duplicatePairs": [], + "flickerScore": 0.456, + "maxFlickerScore": 2.5, + "medianStepDelta": 0.051173, + "seamStepDelta": 0.049535, + "normalizedSteps": [ + 0.685, + 0.899, + 1.061, + 0.97, + 0.965, + 0.907, + 1.138, + 0.867, + 0.996, + 0.864, + 0.783, + 1.211, + 0.892, + 0.999, + 0.784, + 1.214, + 1.085, + 0.891, + 1.003, + 1.109, + 0.85, + 1.134, + 1.059, + 0.911, + 1.212, + 0.823, + 1.102, + 0.913, + 1.181, + 1.018, + 1.039, + 1.097, + 0.896, + 1.126, + 0.922, + 1.105, + 1.125, + 1.026, + 0.93, + 0.885, + 1.085, + 1.03, + 1.043, + 1.104, + 1.121, + 1.12, + 1.103, + 1.054, + 1.025, + 0.931, + 0.961, + 1.256, + 1.056, + 1.002, + 0.961, + 1.191, + 1.13, + 0.83, + 1.181, + 1.149, + 0.954, + 1.129, + 0.841, + 1.279, + 1.192, + 0.882, + 1.061, + 0.932, + 1.214, + 0.879, + 0.845, + 1.222, + 0.992, + 0.911, + 1.149, + 0.979, + 0.909, + 1.283, + 0.91, + 0.875, + 0.655, + 0.905, + 1.14, + 0.989, + 0.911, + 0.965, + 1.141, + 0.813, + 0.954, + 0.971, + 0.993, + 1.057, + 0.891, + 0.954, + 0.797, + 1.378, + 0.964, + 0.78, + 1.211, + 1.038, + 0.776, + 1.171, + 0.982, + 0.964, + 1.241, + 0.646, + 1.245, + 0.901, + 1.185, + 0.623, + 1.234, + 1.083, + 0.683, + 1.106, + 1.132, + 0.936, + 1.106, + 0.948, + 1.095, + 0.854, + 1.006, + 0.89, + 1.171, + 0.907, + 1.114, + 0.973, + 1.083, + 1.086, + 1, + 0.681, + 0.832, + 1.342, + 0.885, + 0.991, + 0.829, + 1.045, + 1.129, + 0.882, + 0.988, + 1.13, + 1.17, + 1.02, + 1.05, + 0.955, + 1.044, + 0.916, + 0.94, + 0.952, + 1.227, + 1.094, + 0.836, + 0.946, + 1.138, + 1.023, + 0.948, + 1.201, + 1.027, + 1.033, + 0.947, + 1.11, + 0.908, + 1.027, + 0.988, + 1.203, + 1.036, + 1.04, + 1.201, + 0.82, + 1.157, + 1.118, + 0.787, + 1.243, + 1.022, + 1.155, + 0.788, + 1.233, + 1.028, + 0.92, + 1.228, + 0.814, + 1.101, + 1.023, + 0.933, + 1.183, + 1.235, + 0.868, + 0.99, + 0.968, + 1.043, + 0.872, + 0.93, + 1.151, + 0.912, + 0.959, + 1.032, + 0.899, + 0.963, + 1.114, + 0.964, + 0.495, + 0.922, + 0.882, + 1.323, + 0.914, + 0.969, + 1.112, + 1.085, + 0.947, + 0.962, + 0.911, + 1.048, + 1.208, + 0.902, + 0.94, + 0.867, + 1.323, + 1.118, + 0.624, + 1.284, + 0.93, + 1.028, + 1.162, + 0.863, + 1.122, + 1.185, + 0.803, + 1.15, + 0.892, + 1.241, + 0.785, + 1.074, + 0.997, + 0.904, + 0.949, + 1.253, + 0.983, + 0.948, + 1.122, + 1.058, + 0.968 + ], + "reasons": [] +} diff --git a/gallery/kinetic-release-banner/sheet.png b/gallery/kinetic-release-banner/sheet.png new file mode 100644 index 0000000..dbd935f Binary files /dev/null and b/gallery/kinetic-release-banner/sheet.png differ diff --git a/gallery/kinetic-release-banner/sketch.js b/gallery/kinetic-release-banner/sketch.js new file mode 100644 index 0000000..030671b --- /dev/null +++ b/gallery/kinetic-release-banner/sketch.js @@ -0,0 +1,53 @@ +// Style Pack: kinetic-type — Silky 60fps harmonic wave typography poster +export const meta = { + mode: "ambient", + style: "kinetic-type", + seconds: 4, + fps: 60, + width: 280, + height: 280, + seed: 61, + palette: "editorial", + word: "PHASE 0→1" +}; + +export function render(ctx, phase, kit) { + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; + const C = kit.palettes[meta.palette] || kit.palettes["editorial"]; + const TAU = Math.PI * 2; + const word = meta.word || "LOOP STUDIO"; + + ctx.fillStyle = C.ground; + ctx.fillRect(0, 0, W, H); + + const rows = 9; + const rowH = (H - 44) / rows; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + + for (let r = 0; r < rows; r++) { + const isCenter = r === Math.floor(rows / 2); + const dist = Math.abs(r - Math.floor(rows / 2)); + const wave = Math.sin(TAU * (phase - r / rows)); + const x = W / 2 + wave * (isCenter ? 10 : 38); + const y = 22 + (r + 0.5) * rowH; + + const pillW = W * (0.68 + 0.14 * (0.5 + 0.5 * Math.cos(TAU * (phase + r / rows)))); + kit.roundRect(ctx, x - pillW / 2, y - rowH * 0.37, pillW, rowH * 0.74, 6); + ctx.globalAlpha = isCenter ? 0.98 : 0.3 + 0.45 * (1 - dist / rows); + ctx.fillStyle = isCenter ? C.spark : C.surface; + ctx.fill(); + ctx.strokeStyle = isCenter ? C.accent : C.line; + ctx.lineWidth = isCenter ? 2 : 1; + ctx.stroke(); + + const fontPx = Math.max(10, Math.round(W * (isCenter ? 0.044 : 0.036))); + ctx.font = (isCenter ? "700 " : "600 ") + fontPx + "px monospace"; + ctx.globalAlpha = isCenter ? 1 : 0.5 + 0.5 * (0.5 + 0.5 * wave); + ctx.fillStyle = isCenter ? C.ground : r % 2 === 0 ? C.accent : C.body; + ctx.fillText(word, x, y); + } + + ctx.globalAlpha = 1; +} diff --git a/gallery/kinetic-release-banner/sources.json b/gallery/kinetic-release-banner/sources.json new file mode 100644 index 0000000..3fe0e95 --- /dev/null +++ b/gallery/kinetic-release-banner/sources.json @@ -0,0 +1,6 @@ +{ + "pass": true, + "checked": 0, + "citations": [], + "reasons": [] +} diff --git a/gallery/live-audio-spectrum/audit.json b/gallery/live-audio-spectrum/audit.json new file mode 100644 index 0000000..3ff9382 --- /dev/null +++ b/gallery/live-audio-spectrum/audit.json @@ -0,0 +1,16 @@ +{ + "id": "live-audio-spectrum", + "title": "120 BPM Harmonic Spectrum (6s @ 60fps)", + "mode": "ambient", + "useCase": "Music release loop, podcast player, and WebAudio/VST visualizer synced to 120 BPM (3 bars)", + "fps": 60, + "pass": true, + "seamScore": 1.05, + "duplicateFrames": 0, + "flickerScore": 0.261, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 1804, + "webpKB": 1688.8, + "totalFrames": 360 +} diff --git a/gallery/live-audio-spectrum/brief.json b/gallery/live-audio-spectrum/brief.json new file mode 100644 index 0000000..2b8aee6 --- /dev/null +++ b/gallery/live-audio-spectrum/brief.json @@ -0,0 +1,13 @@ +{ + "title": "120 BPM Harmonic Spectrum", + "prompt": "6-second 60fps 120 BPM harmonic spectrum visualizer with macro phrase swell and oscilloscope wave.", + "mode": "ambient", + "style": "kinetic-audio", + "palette": "ember", + "seconds": 6, + "fps": 60, + "width": 340, + "height": 240, + "bpm": 120, + "seed": 120 +} diff --git a/gallery/live-audio-spectrum/index.html b/gallery/live-audio-spectrum/index.html new file mode 100644 index 0000000..5d43ad6 --- /dev/null +++ b/gallery/live-audio-spectrum/index.html @@ -0,0 +1,120 @@ + + + + + + 120 BPM Harmonic Spectrum (6s @ 60fps) · Loop Studio + + + +
+
+

120 BPM Harmonic Spectrum (6s @ 60fps)

+ loading sketch.js... +
+
+
+ +
+
+ + + frame 000 / 120 · phase 0.00 + +
+
+
+ + + \ No newline at end of file diff --git a/gallery/live-audio-spectrum/legible.json b/gallery/live-audio-spectrum/legible.json new file mode 100644 index 0000000..bb6b469 --- /dev/null +++ b/gallery/live-audio-spectrum/legible.json @@ -0,0 +1,20 @@ +{ + "pass": true, + "mode": "ambient", + "textElementsChecked": 2, + "captions": [ + { + "text": "120 BPM · 60 FPS", + "contrastRatio": 5.88, + "minMarginPx": 14, + "passContrast": true + }, + { + "text": "6.0s LOOP", + "contrastRatio": 6.83, + "minMarginPx": 14, + "passContrast": true + } + ], + "reasons": [] +} diff --git a/gallery/live-audio-spectrum/loop.gif b/gallery/live-audio-spectrum/loop.gif new file mode 100644 index 0000000..27d9afc Binary files /dev/null and b/gallery/live-audio-spectrum/loop.gif differ diff --git a/gallery/live-audio-spectrum/loop.webp b/gallery/live-audio-spectrum/loop.webp new file mode 100644 index 0000000..a5c19ac Binary files /dev/null and b/gallery/live-audio-spectrum/loop.webp differ diff --git a/gallery/live-audio-spectrum/poster.png b/gallery/live-audio-spectrum/poster.png new file mode 100644 index 0000000..3dd003e Binary files /dev/null and b/gallery/live-audio-spectrum/poster.png differ diff --git a/gallery/live-audio-spectrum/seam.json b/gallery/live-audio-spectrum/seam.json new file mode 100644 index 0000000..fc7b18d --- /dev/null +++ b/gallery/live-audio-spectrum/seam.json @@ -0,0 +1,375 @@ +{ + "pass": true, + "totalFrames": 360, + "seamScore": 1.05, + "maxSeamScore": 1.5, + "duplicateFrames": 0, + "duplicatePairs": [], + "flickerScore": 0.261, + "maxFlickerScore": 2.5, + "medianStepDelta": 0.033034, + "seamStepDelta": 0.034702, + "normalizedSteps": [ + 1.052, + 1.113, + 1.181, + 1.246, + 1.136, + 1.117, + 1.048, + 1.037, + 1.028, + 0.998, + 1.023, + 1.109, + 1.125, + 1.006, + 0.983, + 1, + 1, + 0.948, + 1.126, + 1.028, + 1.044, + 1.096, + 1.026, + 1.122, + 1.062, + 1.023, + 1.112, + 1.139, + 1.172, + 1.274, + 1.363, + 1.387, + 1.517, + 1.654, + 1.456, + 1.72, + 1.304, + 1.632, + 1.108, + 1.169, + 1.248, + 1.303, + 1.237, + 1.434, + 1.186, + 1.207, + 1.34, + 1.128, + 1.118, + 1.097, + 1.349, + 1.137, + 1.143, + 1.38, + 1.364, + 1.125, + 1.187, + 1.417, + 1.221, + 1.293, + 1.355, + 1.608, + 1.462, + 1.506, + 1.76, + 1.786, + 1.386, + 1.328, + 1.38, + 1.423, + 1.827, + 1.889, + 1.45, + 1.46, + 1.382, + 1.521, + 1.199, + 1.225, + 1.242, + 1.411, + 1.185, + 1.214, + 1.235, + 1.474, + 1.207, + 1.233, + 1.196, + 1.466, + 1.272, + 1.259, + 1.334, + 1.595, + 1.468, + 1.518, + 1.419, + 2.172, + 1.317, + 1.545, + 1.429, + 1.481, + 1.507, + 1.923, + 1.514, + 1.839, + 1.378, + 1.345, + 1.45, + 1.221, + 1.217, + 1.184, + 1.227, + 1.174, + 1.205, + 1.227, + 1.183, + 1.177, + 1.19, + 1.168, + 1.204, + 1.14, + 1.205, + 1.441, + 1.286, + 1.333, + 1.258, + 1.629, + 1.431, + 1.411, + 1.261, + 1.493, + 1.325, + 1.409, + 1.334, + 1.308, + 1.212, + 1.148, + 1.115, + 1.123, + 1.026, + 1.106, + 1.046, + 1.038, + 1.104, + 1.068, + 1.065, + 1.081, + 1.012, + 1.105, + 1.026, + 1.15, + 1.173, + 1.238, + 1.239, + 1.298, + 1.215, + 1.104, + 1.146, + 1.059, + 1.096, + 1.149, + 1.238, + 1.373, + 1.248, + 1.219, + 1.186, + 1.157, + 1.024, + 1.016, + 1.032, + 0.995, + 0.947, + 1.032, + 0.983, + 0.943, + 0.941, + 0.96, + 0.925, + 0.919, + 0.947, + 0.893, + 0.977, + 0.974, + 0.987, + 1.067, + 0.921, + 0.893, + 1.029, + 0.982, + 1.043, + 1.119, + 1.179, + 1.281, + 1.154, + 1.115, + 1.104, + 0.997, + 1.016, + 0.872, + 0.907, + 0.805, + 0.865, + 0.882, + 0.848, + 0.829, + 0.722, + 0.86, + 0.805, + 0.794, + 0.732, + 0.724, + 0.82, + 0.771, + 0.81, + 0.877, + 0.784, + 0.818, + 0.785, + 0.797, + 0.831, + 0.934, + 0.978, + 1.069, + 0.943, + 0.926, + 0.849, + 0.812, + 0.802, + 0.802, + 0.634, + 0.745, + 0.769, + 0.637, + 0.638, + 0.685, + 0.7, + 0.703, + 0.658, + 0.625, + 0.678, + 0.529, + 0.624, + 0.608, + 0.693, + 0.687, + 0.761, + 0.591, + 0.622, + 0.622, + 0.725, + 0.626, + 0.745, + 0.838, + 0.69, + 0.732, + 0.61, + 0.661, + 0.597, + 0.508, + 0.525, + 0.493, + 0.581, + 0.516, + 0.571, + 0.576, + 0.525, + 0.598, + 0.543, + 0.53, + 0.542, + 0.639, + 0.694, + 0.755, + 0.749, + 0.859, + 0.795, + 0.623, + 0.721, + 0.51, + 0.647, + 0.648, + 0.627, + 0.761, + 0.685, + 0.613, + 0.607, + 0.569, + 0.633, + 0.573, + 0.541, + 0.579, + 0.585, + 0.644, + 0.642, + 0.469, + 0.682, + 0.543, + 0.642, + 0.605, + 0.711, + 0.651, + 0.812, + 0.859, + 0.801, + 0.934, + 0.936, + 0.794, + 0.709, + 0.732, + 0.678, + 0.688, + 0.751, + 0.869, + 0.828, + 0.759, + 0.683, + 0.693, + 0.797, + 0.633, + 0.661, + 0.791, + 0.722, + 0.759, + 0.734, + 0.663, + 0.841, + 0.699, + 0.726, + 0.85, + 0.773, + 0.906, + 0.9, + 0.997, + 1.016, + 1.133, + 0.994, + 0.96, + 0.932, + 0.781, + 0.893, + 0.837, + 0.895, + 1.03, + 0.9, + 0.903, + 0.919, + 0.798, + 0.885, + 0.878, + 0.927, + 0.898, + 0.883, + 0.868, + 0.939, + 0.919, + 0.825, + 0.924, + 0.861, + 0.963, + 0.915, + 1.05 + ], + "reasons": [] +} diff --git a/gallery/live-audio-spectrum/sheet.png b/gallery/live-audio-spectrum/sheet.png new file mode 100644 index 0000000..ec27521 Binary files /dev/null and b/gallery/live-audio-spectrum/sheet.png differ diff --git a/gallery/live-audio-spectrum/sketch.js b/gallery/live-audio-spectrum/sketch.js new file mode 100644 index 0000000..be5d71f --- /dev/null +++ b/gallery/live-audio-spectrum/sketch.js @@ -0,0 +1,86 @@ +// Custom 60fps Ambient Loop: live-audio-spectrum — 6s (3 bars @ 120 BPM) 60fps harmonic equalizer & waveform +export const meta = { + mode: "ambient", + style: "kinetic-audio", + seconds: 6, + fps: 60, + width: 340, + height: 240, + seed: 120, + palette: "ember" +}; + +export function render(ctx, phase, kit) { + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; + const C = kit.palettes[meta.palette] || kit.palettes["ember"]; + const TAU = Math.PI * 2; + + if (ctx.createLinearGradient) { + const bg = ctx.createLinearGradient(0, 0, 0, H); + bg.addColorStop(0, C.ground); + bg.addColorStop(1, C.surface); + ctx.fillStyle = bg; + } else { + ctx.fillStyle = C.ground; + } + ctx.fillRect(0, 0, W, H); + + // 120 BPM over 6 seconds = 12 beats (3 bars of 4/4); macro phrase swells over 1 cycle while beats pulse 12x + const beatPulse = Math.pow(0.5 + 0.5 * Math.sin(TAU * phase * 12), 2.5); + const macroEnergy = 0.65 + 0.35 * Math.sin(TAU * phase); + + // Top telemetry header + ctx.font = "600 10.5px monospace"; + ctx.fillStyle = C.muted; + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillText("120 BPM · 60 FPS", 18, 20); + ctx.textAlign = "right"; + ctx.fillStyle = beatPulse > 0.65 ? C.spark : C.accent; + ctx.fillText("6.0s LOOP", W - 18, 20); + + // 24 harmonic spectrum bars + const bars = 24; + const margin = 20; + const step = (W - margin * 2) / bars; + const bw = Math.max(5, step - 3); + const baseY = H * 0.72; + const maxH = H * 0.44; + + for (let i = 0; i < bars; i++) { + const norm = i / (bars - 1); + const w1 = 0.5 + 0.5 * Math.sin(TAU * (phase * 3 - norm * 1.5)); + const w2 = 0.5 + 0.5 * Math.cos(TAU * (phase * 6 + norm * 2.5)); + const amp = (0.18 + 0.52 * w1 + 0.30 * w2) * macroEnergy * (0.82 + 0.18 * beatPulse); + const bh = Math.max(6, amp * maxH); + const bx = margin + i * step; + + ctx.globalAlpha = 0.25; + ctx.fillStyle = C.accent; + ctx.fillRect(bx, baseY + 4, bw, bh * 0.22); // subtle floor reflection + + ctx.globalAlpha = 0.92; + ctx.fillStyle = amp > 0.72 ? C.spark : C.accent; + kit.roundRect(ctx, bx, baseY - bh, bw, bh, 2); + ctx.fill(); + } + + // Smooth continuous phase oscilloscope wave across bottom + ctx.globalAlpha = 0.95; + ctx.strokeStyle = C.spark; + ctx.lineWidth = 2; + ctx.beginPath(); + const samples = 60; + for (let s = 0; s <= samples; s++) { + const u = s / samples; + const wx = margin + u * (W - margin * 2); + const env = Math.sin(Math.PI * u); + const wy = H * 0.87 + Math.sin(TAU * (u * 3 - phase * 6)) * 10 * env * macroEnergy; + if (s === 0) ctx.moveTo(wx, wy); + else ctx.lineTo(wx, wy); + } + ctx.stroke(); + + ctx.globalAlpha = 1; +} diff --git a/gallery/live-audio-spectrum/sources.json b/gallery/live-audio-spectrum/sources.json new file mode 100644 index 0000000..3fe0e95 --- /dev/null +++ b/gallery/live-audio-spectrum/sources.json @@ -0,0 +1,6 @@ +{ + "pass": true, + "checked": 0, + "citations": [], + "reasons": [] +} diff --git a/gallery/loop-studio/audit.json b/gallery/loop-studio/audit.json index 40d20f2..8517a98 100644 --- a/gallery/loop-studio/audit.json +++ b/gallery/loop-studio/audit.json @@ -2,12 +2,15 @@ "id": "loop-studio", "title": "Loop Studio Showcase (Flow Pipeline)", "mode": "showcase", + "useCase": "README hero diagram explaining what a repo or workflow does end-to-end", + "fps": 60, "pass": true, - "seamScore": 1.066, + "seamScore": 1.117, "duplicateFrames": 0, - "flickerScore": 0.307, + "flickerScore": 0.525, "legiblePass": true, "sourcesPass": true, - "gifKB": 779.9, - "totalFrames": 160 + "gifKB": 9476.8, + "webpKB": 5622.2, + "totalFrames": 480 } diff --git a/gallery/loop-studio/legible.json b/gallery/loop-studio/legible.json index 4b33cf0..755582f 100644 --- a/gallery/loop-studio/legible.json +++ b/gallery/loop-studio/legible.json @@ -1,68 +1,68 @@ { "pass": true, - "width": 800, - "height": 320, + "width": 640, + "height": 288, "phoneWidth": 400, "frame0ShowsAllStageLabels": true, "stageLabelsChecked": 4, "captions": [ { "step": 1, - "caption": "a request arrives: \"deep sea, square\"", - "words": 6, - "chars": 37, - "windowSeconds": 2.5, - "requiredSeconds": 2.3, + "caption": "request arrives: \"deep sea, square\"", + "words": 5, + "chars": 35, + "windowSeconds": 2, + "requiredSeconds": 2, "passReadingTime": true, - "contrastRatio": 14.25, + "contrastRatio": 14.23, "passContrast": true, - "minEdgeMarginPx": 44, - "phoneFontPx": 6.5, + "minEdgeMarginPx": 29, + "phoneFontPx": 7.5, "passMobileWidth": true, "pass": true }, { "step": 2, - "caption": "sketch is drawn from the phase", - "words": 6, - "chars": 30, - "windowSeconds": 2.5, - "requiredSeconds": 2.3, + "caption": "sketch draws from phase", + "words": 4, + "chars": 23, + "windowSeconds": 2, + "requiredSeconds": 1.7, "passReadingTime": true, - "contrastRatio": 14.25, + "contrastRatio": 14.23, "passContrast": true, - "minEdgeMarginPx": 44, - "phoneFontPx": 6.5, + "minEdgeMarginPx": 29, + "phoneFontPx": 7.5, "passMobileWidth": true, "pass": true }, { "step": 3, - "caption": "seam and legibility are measured", - "words": 5, - "chars": 32, - "windowSeconds": 2.5, - "requiredSeconds": 2, + "caption": "seam and contrast measured", + "words": 4, + "chars": 26, + "windowSeconds": 2, + "requiredSeconds": 1.7, "passReadingTime": true, - "contrastRatio": 14.25, + "contrastRatio": 14.23, "passContrast": true, - "minEdgeMarginPx": 44, - "phoneFontPx": 6.5, + "minEdgeMarginPx": 29, + "phoneFontPx": 7.5, "passMobileWidth": true, "pass": true }, { "step": 4, - "caption": "the verified loop drops out", + "caption": "verified 60fps loop drops out", "words": 5, - "chars": 27, - "windowSeconds": 2.5, + "chars": 29, + "windowSeconds": 2, "requiredSeconds": 2, "passReadingTime": true, - "contrastRatio": 14.25, + "contrastRatio": 14.23, "passContrast": true, - "minEdgeMarginPx": 44, - "phoneFontPx": 6.5, + "minEdgeMarginPx": 29, + "phoneFontPx": 7.5, "passMobileWidth": true, "pass": true } diff --git a/gallery/loop-studio/loop.gif b/gallery/loop-studio/loop.gif index 8203325..f5e2ed2 100644 Binary files a/gallery/loop-studio/loop.gif and b/gallery/loop-studio/loop.gif differ diff --git a/gallery/loop-studio/poster.png b/gallery/loop-studio/poster.png index 15c2a64..c41af90 100644 Binary files a/gallery/loop-studio/poster.png and b/gallery/loop-studio/poster.png differ diff --git a/gallery/loop-studio/seam.json b/gallery/loop-studio/seam.json index 3f535ea..ccc4116 100644 --- a/gallery/loop-studio/seam.json +++ b/gallery/loop-studio/seam.json @@ -1,175 +1,495 @@ { "pass": true, - "totalFrames": 160, - "seamScore": 1.066, + "totalFrames": 480, + "seamScore": 1.117, "maxSeamScore": 1.5, "duplicateFrames": 0, "duplicatePairs": [], - "flickerScore": 0.307, + "flickerScore": 0.525, "maxFlickerScore": 2.5, - "medianStepDelta": 0.017591, - "seamStepDelta": 0.018748, + "medianStepDelta": 0.013848, + "seamStepDelta": 0.015467, "normalizedSteps": [ - 1.349, - 1.069, - 1.032, + 1.021, + 1.023, + 1.013, + 1.033, + 1.014, + 1.017, + 1.056, + 1.021, + 1.014, + 1.011, + 1.024, + 1.005, 1.02, - 1, - 1.009, - 0.974, + 1.025, + 1.005, + 1.028, + 0.993, + 1.02, + 0.997, + 0.989, + 1.014, + 0.984, + 0.99, + 0.972, + 0.991, + 0.992, + 0.971, + 0.973, + 0.964, + 0.954, 0.955, - 0.929, - 0.918, - 0.869, - 0.835, - 0.795, - 0.756, - 0.772, + 0.939, + 0.935, + 0.93, + 0.925, + 0.917, + 0.931, + 0.92, + 0.912, + 0.925, + 0.914, + 0.906, + 0.886, + 0.882, + 0.879, 0.882, - 0.835, - 0.804, - 0.651, - 0.82, - 0.365, - 0.712, - 0.791, + 0.879, + 0.874, + 0.878, + 0.887, + 0.852, + 0.858, + 0.853, + 0.848, + 0.836, + 0.826, 0.84, - 0.877, - 0.803, - 0.774, - 0.803, - 0.855, - 0.908, - 0.911, - 0.932, - 0.955, + 0.822, + 0.821, + 1.421, + 0.834, + 0.85, + 0.832, + 0.833, + 0.841, + 0.857, + 0.864, + 0.869, + 0.873, + 0.87, + 0.878, + 0.9, + 0.886, + 0.881, + 0.913, + 0.927, + 0.917, + 0.906, + 0.906, + 0.915, + 0.944, + 0.946, + 0.941, + 0.951, + 0.949, + 0.941, + 0.971, + 0.957, + 0.996, + 0.975, + 1, + 0.986, 0.985, - 0.984, - 0.999, - 1.068, - 1.085, - 1.355, - 1.07, - 1.08, - 1.387, - 1.09, - 1.093, + 0.988, + 0.99, + 1.015, + 0.998, + 1.004, + 1.004, + 1.03, + 1.011, + 1.008, + 1.008, + 1.015, + 1.02, + 1.038, + 1.02, + 1.018, + 1.025, + 1.038, + 1.03, + 3.33, + 1.024, + 1.065, + 1.028, 1.035, - 1.044, - 1.012, - 0.995, - 0.965, - 0.958, - 0.913, - 0.88, - 0.836, - 0.812, - 0.775, + 1.05, + 1.472, + 1.032, + 1.029, + 1.055, + 1.029, + 1.51, + 1.031, + 1.032, + 1.023, + 1.025, + 1.029, + 3.309, + 1.025, + 1.076, + 1.013, + 1.018, + 1.018, + 1.032, + 1.036, + 1.002, + 1, + 1.003, + 1.02, + 0.999, + 0.994, + 0.993, + 0.989, + 0.99, + 0.98, + 0.981, + 0.975, + 0.988, + 0.99, + 0.961, + 0.955, + 0.968, + 0.946, + 0.947, + 0.973, + 0.936, + 0.948, + 0.914, + 1.037, + 0.926, + 0.894, + 0.912, + 0.891, + 0.881, + 0.907, + 0.894, + 0.879, + 0.874, 0.869, - 0.831, - 0.812, - 0.676, - 0.787, - 0.356, - 0.733, - 0.814, + 0.871, + 0.869, + 0.903, + 0.857, + 0.856, + 0.845, + 0.874, 0.852, - 0.887, - 0.812, - 0.785, - 0.836, - 0.877, + 0.828, + 1.411, + 0.83, + 0.831, + 0.837, + 0.855, + 0.844, + 0.851, + 0.885, + 0.871, + 0.868, + 0.879, + 0.882, + 0.88, + 0.881, + 0.882, + 0.89, + 0.899, + 0.901, + 0.904, + 0.911, + 0.917, + 0.925, + 0.922, 0.936, - 0.944, + 0.964, + 0.964, + 0.957, + 0.96, + 0.954, + 0.976, + 0.984, 0.971, - 0.985, + 0.98, + 0.984, + 1.004, + 0.984, + 0.992, + 1.011, + 1.002, + 1.033, + 1.004, + 1.017, + 1, + 1.008, + 1.037, + 1.019, + 1.015, + 1.024, + 1.019, + 1.02, + 1.032, + 1.046, + 3.016, + 1.035, + 1.043, + 1.024, + 1.022, + 1.029, + 1.397, + 1.05, 1.03, 1.028, - 1.039, - 1.097, - 1.102, - 1.369, - 1.08, - 1.073, - 1.37, + 1.036, + 1.475, + 1.04, + 1.022, + 1.018, 1.063, - 1.071, - 1, - 1.008, - 0.97, + 1.032, + 3.335, + 1.031, + 1.043, + 1.029, + 1.036, + 1.039, + 1.016, + 1.032, + 1.009, + 1.018, + 0.987, + 0.984, + 1.003, + 0.986, + 0.985, + 0.971, + 0.982, + 0.984, + 0.965, + 0.977, + 0.963, + 0.957, + 0.961, + 1.242, + 0.961, + 0.968, + 0.961, + 0.961, + 0.975, + 0.973, + 0.965, + 0.976, + 0.986, + 0.972, + 0.953, + 0.948, 0.947, + 0.95, + 0.939, + 0.94, 0.934, - 0.928, - 0.881, - 0.867, + 0.944, + 0.917, + 0.918, + 0.908, + 0.898, + 0.878, + 0.866, + 0.877, 0.861, - 0.891, - 0.93, - 1.075, - 1.01, - 0.994, - 0.857, - 0.941, - 0.543, - 0.862, - 0.974, - 1.041, - 1.092, - 1.073, - 1.058, - 1.079, - 1.12, - 1.157, - 1.149, - 1.169, - 1.192, - 1.215, - 1.221, - 1.221, - 1.267, - 1.292, - 1.522, - 1.277, - 1.288, - 1.547, - 1.308, - 1.296, - 1.244, - 1.259, - 1.22, - 1.224, - 1.207, - 1.213, - 1.176, - 1.139, + 0.843, + 1.46, + 0.838, + 0.858, + 0.846, + 0.852, + 0.866, + 0.878, + 0.892, + 0.902, + 0.913, + 0.917, + 0.926, + 0.948, + 0.943, + 0.947, + 0.976, + 0.992, + 0.988, + 0.985, + 0.988, 1.103, - 1.082, + 1.026, + 1.022, + 1.021, + 1.03, + 1.038, + 1.044, 1.061, + 1.053, + 1.084, + 1.068, 1.096, - 1.034, - 0.977, - 0.839, + 1.083, + 1.09, + 1.096, + 1.094, + 1.122, + 1.105, + 1.113, + 1.113, + 1.135, + 1.127, + 1.125, + 1.13, + 1.128, + 1.131, + 1.158, + 1.148, + 1.141, + 1.145, + 1.15, + 1.151, + 3.273, + 1.151, + 1.191, + 1.156, + 1.156, + 1.174, + 1.59, + 1.157, + 1.156, + 1.176, + 1.162, + 1.496, + 1.153, + 1.16, + 1.158, + 1.151, + 1.153, + 3.053, + 1.156, + 1.195, + 1.143, + 1.142, + 1.148, + 1.156, + 1.161, + 1.134, + 1.123, + 1.12, + 1.14, + 1.116, + 1.114, + 1.112, + 1.107, + 1.104, + 1.095, + 1.09, + 1.09, + 1.094, + 1.095, + 1.072, + 1.065, + 1.071, + 1.053, + 1.041, + 1.059, + 1.027, + 1.04, + 1.011, + 1.011, + 1.017, + 0.985, + 0.999, + 0.975, + 0.962, + 0.979, + 0.966, + 0.95, + 0.936, + 0.926, + 0.92, + 0.917, + 0.945, + 0.893, 0.884, - 0.657, - 1.219, - 1.42, - 1.559, - 1.648, - 1.626, - 1.569, - 1.765, - 1.495, - 1.434, - 1.288, - 1.091, - 0.964, - 0.808, - 0.767, - 0.941, - 1.092, - 1.109, - 1.075, - 1.066 + 0.866, + 0.892, + 0.867, + 0.84, + 1.365, + 0.831, + 0.841, + 0.877, + 0.93, + 0.954, + 0.994, + 1.052, + 1.053, + 1.064, + 1.1, + 1.108, + 1.122, + 1.143, + 1.163, + 1.173, + 1.185, + 1.18, + 1.184, + 1.186, + 1.175, + 1.184, + 1.158, + 1.14, + 1.159, + 1.152, + 1.127, + 1.123, + 1.1, + 1.555, + 1.088, + 1.066, + 1.058, + 3.25, + 1.073, + 1.043, + 1.042, + 1.045, + 0.996, + 1.012, + 0.966, + 0.974, + 0.951, + 3.285, + 0.968, + 0.952, + 0.966, + 1, + 1.002, + 1.013, + 1.499, + 1.033, + 1.044, + 1.021, + 1.033, + 1.01, + 1.011, + 1.008, + 1.016, + 1.036, + 1.117 ], "reasons": [] } diff --git a/gallery/loop-studio/sheet.png b/gallery/loop-studio/sheet.png index 12a60cf..1abef45 100644 Binary files a/gallery/loop-studio/sheet.png and b/gallery/loop-studio/sheet.png differ diff --git a/gallery/loop-studio/showcase.gif b/gallery/loop-studio/showcase.gif index 8203325..f5e2ed2 100644 Binary files a/gallery/loop-studio/showcase.gif and b/gallery/loop-studio/showcase.gif differ diff --git a/gallery/loop-studio/showcase.json b/gallery/loop-studio/showcase.json index 8706363..668fca3 100644 --- a/gallery/loop-studio/showcase.json +++ b/gallery/loop-studio/showcase.json @@ -1,10 +1,10 @@ { "title": "Loop Studio Showcase", "says": "Loop Studio turns a one-line request into a checked, seamless loop.", - "seconds": 10, - "fps": 16, - "width": 800, - "height": 320, + "seconds": 8, + "fps": 60, + "width": 640, + "height": 288, "palette": "studio-dark", "scene": "flow", "stage": [ @@ -15,27 +15,27 @@ ], "steps": [ { - "from": 8.75, - "to": 1.25, - "caption": "a request arrives: \"deep sea, square\"", + "from": 7, + "to": 1, + "caption": "request arrives: \"deep sea, square\"", "source": "docs/contract.md:3" }, { - "from": 1.25, - "to": 3.75, - "caption": "sketch is drawn from the phase", + "from": 1, + "to": 3, + "caption": "sketch draws from phase", "source": "docs/contract.md:14" }, { - "from": 3.75, - "to": 6.25, - "caption": "seam and legibility are measured", + "from": 3, + "to": 5, + "caption": "seam and contrast measured", "source": "docs/tool.md:14" }, { - "from": 6.25, - "to": 8.75, - "caption": "the verified loop drops out", + "from": 5, + "to": 7, + "caption": "verified 60fps loop drops out", "source": "docs/tool.md:24" } ] diff --git a/gallery/loop-studio/showcase.webp b/gallery/loop-studio/showcase.webp new file mode 100644 index 0000000..864fe8f Binary files /dev/null and b/gallery/loop-studio/showcase.webp differ diff --git a/gallery/loop-studio/sketch.js b/gallery/loop-studio/sketch.js index ddf886e..b620fac 100644 --- a/gallery/loop-studio/sketch.js +++ b/gallery/loop-studio/sketch.js @@ -1,25 +1,25 @@ -// Scene Pack: flow — Fixed stage boxes with continuous rail handover +// Scene Pack: flow — Visual 4-Stage Studio Pipeline with Live Mini-Canvas, Seam Chart & Rail Handover export const meta = { mode: "showcase", scene: "flow", - seconds: 10, - fps: 16, - width: 800, - height: 320, + seconds: 8, + fps: 60, + width: 640, + height: 288, seed: 11, palette: "studio-dark" }; export const showcase = { says: "Loop Studio turns a one-line request into a checked, seamless loop.", - seconds: 10, + seconds: 8, scene: "flow", stage: ["request", "sketch", "check", "loop.gif"], steps: [ - { from: 8.75, to: 1.25, caption: "a request arrives: \"deep sea, square\"", source: "docs/contract.md:3" }, - { from: 1.25, to: 3.75, caption: "sketch is drawn from the phase", source: "docs/contract.md:14" }, - { from: 3.75, to: 6.25, caption: "seam and legibility are measured", source: "docs/tool.md:14" }, - { from: 6.25, to: 8.75, caption: "the verified loop drops out", source: "docs/tool.md:24" } + { from: 7.0, to: 1.0, caption: "request arrives: \"deep sea, square\"", source: "docs/contract.md:3" }, + { from: 1.0, to: 3.0, caption: "sketch draws from phase", source: "docs/contract.md:14" }, + { from: 3.0, to: 5.0, caption: "seam and contrast measured", source: "docs/tool.md:14" }, + { from: 5.0, to: 7.0, caption: "verified 60fps loop drops out", source: "docs/tool.md:24" } ] }; @@ -27,33 +27,31 @@ function ease(x) { return x <= 0 ? 0 : x >= 1 ? 1 : x * x * (3 - 2 * x); } -// Smooth continuous item travel + slow drift through each node so motion never freezes function placeItem(age, xs, W) { - const left = -0.06 * W; - const right = 1.06 * W; - const pad = 12; + const left = -0.05 * W; + const right = 1.05 * W; let x = left; let alpha = 1; - if (age < 2.5) { - x = left + (xs[0] - left) * ease(age / 2.5); - } else if (age < 5.0) { - const u = (age - 2.5) / 2.5; - x = xs[0] + (xs[1] - xs[0]) * (0.15 * u + 0.85 * ease(u)); - } else if (age < 7.5) { - const u = (age - 5.0) / 2.5; - x = xs[1] + (xs[2] - xs[1]) * (0.15 * u + 0.85 * ease(u)); - } else if (age < 10.0) { - const u = (age - 7.5) / 2.5; - x = xs[2] + (xs[3] - xs[2]) * (0.15 * u + 0.85 * ease(u)); + if (age < 2.0) { + x = left + (xs[0] - left) * ease(age / 2.0); + } else if (age < 4.0) { + const u = (age - 2.0) / 2.0; + x = xs[0] + (xs[1] - xs[0]) * (0.18 * u + 0.82 * ease(u)); + } else if (age < 6.0) { + const u = (age - 4.0) / 2.0; + x = xs[1] + (xs[2] - xs[1]) * (0.18 * u + 0.82 * ease(u)); + } else if (age < 8.0) { + const u = (age - 6.0) / 2.0; + x = xs[2] + (xs[3] - xs[2]) * (0.18 * u + 0.82 * ease(u)); } else { - const e = ease((age - 10.0) / 1.25); - x = xs[3] + (right - xs[3] + pad) * e; + const e = ease((age - 8.0) / 1.0); + x = xs[3] + (right - xs[3]) * e; alpha = 1 - e; } return { x, alpha, - checked: ease((age - 6.8) / 0.8) + checked: ease((age - 5.2) / 0.65) }; } @@ -67,102 +65,289 @@ export function render(ctx, phase, kit) { const SECONDS = S.seconds || meta.seconds; const t = phase * SECONDS; const TAU = Math.PI * 2; + const cyan = "#00E5B0"; + // 1. Depth Layer 1: Radial gradient ground + harmonic wave dot lattice ctx.globalAlpha = 1; - ctx.fillStyle = C.ground; + if (ctx.createRadialGradient) { + const bgGrad = ctx.createRadialGradient(W * 0.5, H * 0.42, 20, W * 0.5, H * 0.5, W * 0.65); + bgGrad.addColorStop(0, "#131930"); + bgGrad.addColorStop(1, C.ground); + ctx.fillStyle = bgGrad; + } else { + ctx.fillStyle = C.ground; + } ctx.fillRect(0, 0, W, H); - const count = labels.length; - const margin = W * 0.055; - const gap = W * 0.032; - const bw = Math.min(W * 0.195, (W - 2 * margin - (count - 1) * gap) / count); - const bh = Math.round(H * 0.17); - const totalW = count * bw + (count - 1) * gap; - const x0 = (W - totalW) / 2; - const by = Math.round(H * 0.29); - const railY = Math.round(H * 0.58); - const capY = Math.round(H * 0.84); - - const xs = labels.map((_, i) => x0 + i * (bw + gap) + bw / 2); - const items = [placeItem(t + 1.25, xs, W)]; - if (t >= 8.75) items.push(placeItem(t - 8.75, xs, W)); - - // Transport rail + subtle travelling carrier ticks (keeps frame-to-frame delta steady) + const gCols = 20; + const gRows = 9; + const cellW = W / gCols; + const cellH = H / gRows; + for (let r = 0; r < gRows; r++) { + for (let c = 0; c < gCols; c++) { + const gx = (c + 0.5) * cellW; + const gy = (r + 0.5) * cellH; + const dx = (gx - W * 0.5) / (W * 0.5); + const dy = (gy - H * 0.42) / (H * 0.5); + const dist = Math.sqrt(dx * dx + dy * dy); + const wave = 0.5 + 0.5 * Math.sin(TAU * (phase - dist * 1.2)); + ctx.globalAlpha = 0.08 + 0.16 * wave; + ctx.fillStyle = wave > 0.72 ? C.spark : C.line; + ctx.beginPath(); + ctx.arc(gx, gy, 1.2 + 1.4 * wave, 0, TAU); + ctx.fill(); + } + } + + // 2. Depth Layer 2: 4 Visual Studio Stage Cards + const count = 4; + const margin = W * 0.042; + const gap = W * 0.024; + const bw = (W - 2 * margin - (count - 1) * gap) / count; + const bh = Math.round(H * 0.48); + const by = Math.round(H * 0.30); + const railY = Math.round(H * 0.68); + const capY = Math.round(H * 0.87); + + const xs = [0, 1, 2, 3].map((i) => margin + i * (bw + gap) + bw / 2); + const items = [placeItem(t + 1.0, xs, W)]; + if (t >= 7.0) items.push(placeItem(t - 7.0, xs, W)); + + // Transport rail + glowing carrier stream ctx.globalAlpha = 1; ctx.strokeStyle = C.line; - ctx.lineWidth = 2; + ctx.lineWidth = 2.5; ctx.beginPath(); ctx.moveTo(0, railY); ctx.lineTo(W, railY); ctx.stroke(); - const tickCount = 16; - const tickSpacing = W / tickCount; - const tickShift = (phase * 4 * tickSpacing) % tickSpacing; - ctx.fillStyle = C.muted; - ctx.globalAlpha = 0.35; - for (let i = 0; i <= tickCount; i++) { - const tx = i * tickSpacing + tickShift; - ctx.fillRect(tx - 2, railY - 2, 4, 4); + const streamCount = 18; + const streamSpace = W / streamCount; + const streamShift = (phase * 3 * streamSpace) % streamSpace; + for (let i = 0; i <= streamCount; i++) { + const sx = i * streamSpace + streamShift; + ctx.globalAlpha = 0.45; + ctx.fillStyle = i % 2 === 0 ? C.spark : C.accent; + ctx.beginPath(); + ctx.arc(sx, railY, 2.2, 0, TAU); + ctx.fill(); } - // Stage boxes & vertical stems - ctx.font = "600 13px monospace"; - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; + const stepHeaders = ["01", "02", "03", "04"]; xs.forEach((cx, i) => { let near = 0; items.forEach((it) => { - near = Math.max(near, it.alpha * Math.max(0, 1 - Math.abs(it.x - cx) / (bw * 0.75))); + near = Math.max(near, it.alpha * Math.max(0, 1 - Math.abs(it.x - cx) / (bw * 0.78))); }); + const cardLeft = cx - bw / 2; + const cardTop = by - bh / 2; + const activeColor = i === 2 ? cyan : i === 3 ? C.spark : C.accent; + + // Vertical connector stem from card to rail ctx.globalAlpha = 1; - ctx.strokeStyle = near > 0.3 ? C.accent : C.line; - ctx.lineWidth = 2; + ctx.strokeStyle = near > 0.25 ? activeColor : C.line; + ctx.lineWidth = near > 0.25 ? 2.5 : 1.5; ctx.beginPath(); - ctx.moveTo(cx, by + bh / 2); + ctx.moveTo(cx, cardTop + bh); ctx.lineTo(cx, railY); ctx.stroke(); - kit.roundRect(ctx, cx - bw / 2, by - bh / 2, bw, bh, 8); - ctx.globalAlpha = 1; + // Node socket on rail + ctx.fillStyle = near > 0.25 ? activeColor : C.surface; + ctx.beginPath(); + ctx.arc(cx, railY, 4.5, 0, TAU); + ctx.fill(); + ctx.strokeStyle = activeColor; + ctx.lineWidth = 1.5; + ctx.stroke(); + + // Card surface + kit.roundRect(ctx, cardLeft, cardTop, bw, bh, 10); + ctx.globalAlpha = 0.96; ctx.fillStyle = C.surface; ctx.fill(); - if (near > 0.01) { - ctx.globalAlpha = 0.22 * near; - ctx.fillStyle = i >= 2 ? C.spark : C.accent; + // Subtle active header tint + if (near > 0.02) { + ctx.globalAlpha = 0.16 * near; + ctx.fillStyle = activeColor; ctx.fill(); } ctx.globalAlpha = 1; + ctx.strokeStyle = near > 0.15 ? activeColor : C.line; + ctx.lineWidth = near > 0.15 ? 2.2 : 1.4; + ctx.stroke(); + + // Card header bar divider + const headH = Math.round(bh * 0.24); ctx.strokeStyle = C.line; - ctx.lineWidth = 1.5; + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.moveTo(cardLeft + 1, cardTop + headH); + ctx.lineTo(cardLeft + bw - 1, cardTop + headH); ctx.stroke(); - if (near > 0.01) { - ctx.globalAlpha = near; - ctx.strokeStyle = i >= 2 ? C.spark : C.accent; + // Card header step badge + primary stage label + ctx.font = "700 10.5px monospace"; + ctx.fillStyle = activeColor; + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillText(stepHeaders[i], cardLeft + 10, cardTop + headH * 0.5); + + ctx.font = "700 11.5px monospace"; + ctx.fillStyle = C.body; + ctx.textAlign = "right"; + ctx.fillText(labels[i], cardLeft + bw - 10, cardTop + headH * 0.5); + + // Rich visual interior per stage card! + const innerY = cardTop + headH + (bh - headH) * 0.5; + + if (i === 0) { + // Card 1: Prompt lines + live rotating Phase Ring (0 -> 1) + const ringX = cardLeft + bw * 0.25; + const ringR = Math.min(bw, bh) * 0.155; + ctx.strokeStyle = C.line; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.arc(ringX, innerY, ringR, 0, TAU); + ctx.stroke(); + + const pAng = phase * TAU - Math.PI / 2; + ctx.strokeStyle = C.accent; + ctx.lineWidth = 2.5; + ctx.beginPath(); + ctx.arc(ringX, innerY, ringR, pAng - 1.8, pAng); + ctx.stroke(); + + ctx.fillStyle = C.spark; + ctx.beginPath(); + ctx.arc(ringX + Math.cos(pAng) * ringR, innerY + Math.sin(pAng) * ringR, 3.4, 0, TAU); + ctx.fill(); + + // Prompt spec labels on right half of Card 1 + const tx0 = cardLeft + bw * 0.45; + ctx.font = "500 9.5px monospace"; + ctx.fillStyle = C.muted; + ctx.textAlign = "left"; + ctx.fillText("8s · 60fps", tx0, innerY - 14); + ctx.fillStyle = C.body; + ctx.fillText("phase 0→1", tx0, innerY + 2); + ctx.fillStyle = cyan; + ctx.fillText("seed: 7", tx0, innerY + 18); + } else if (i === 1) { + // Card 2: Live Miniature Bioluminescent Particle-Orbit Sketch Viewport! + const vpW = bw - 20; + const vpH = bh - headH - 16; + const vpX = cardLeft + 10; + const vpY = cardTop + headH + 8; + kit.roundRect(ctx, vpX, vpY, vpW, vpH, 6); + ctx.fillStyle = "#060913"; + ctx.fill(); + + // 2 nested glowing orbits inside mini canvas + for (let ring = 1; ring <= 2; ring++) { + const rx = vpW * (0.18 * ring); + const ry = vpH * (0.21 * ring); + const dots = 6 + ring * 4; + const dir = ring === 1 ? 1 : -2; + for (let d = 0; d < dots; d++) { + const a = TAU * ((phase * dir + d / dots) % 1); + const px = cx + Math.cos(a) * rx; + const py = innerY + Math.sin(a) * ry; + ctx.globalAlpha = 0.45 + 0.55 * (0.5 + 0.5 * Math.sin(a)); + ctx.fillStyle = d % 3 === 0 ? cyan : d % 2 === 0 ? C.spark : C.accent; + ctx.beginPath(); + ctx.arc(px, py, d % 3 === 0 ? 3.2 : 2.2, 0, TAU); + ctx.fill(); + } + } + ctx.globalAlpha = 1; + ctx.fillStyle = cyan; + ctx.beginPath(); + ctx.arc(cx, innerY, 4.5 + 1.5 * Math.sin(TAU * phase * 2), 0, TAU); + ctx.fill(); + } else if (i === 2) { + // Card 3: Live Seam Check Bar Chart (1.02x PASS) + const bars = [1.0, 0.94, 1.05, 0.98, 1.02, 0.96, 1.04, 0.99, 1.03]; + const chartLeft = cardLeft + 14; + const chartBase = cardTop + bh - 14; + const barStep = (bw - 28) / bars.length; + const unitH = (bh - headH - 36) * 0.55; + + bars.forEach((v, bIdx) => { + const isLast = bIdx === bars.length - 1; + const wave = 1 + 0.08 * Math.sin(TAU * (phase * 2 - bIdx / bars.length)); + const hBar = v * unitH * wave; + ctx.globalAlpha = isLast ? 1 : 0.65; + ctx.fillStyle = isLast ? cyan : C.spark; + ctx.fillRect(chartLeft + bIdx * barStep, chartBase - hBar, Math.max(4, barStep - 4), hBar); + }); + + // Median 1.0x reference line + ctx.globalAlpha = 0.9; + ctx.strokeStyle = C.accent; + ctx.lineWidth = 1.2; + ctx.beginPath(); + ctx.moveTo(chartLeft, chartBase - unitH); + ctx.lineTo(cardLeft + bw - 14, chartBase - unitH); + ctx.stroke(); + + ctx.globalAlpha = 1; + ctx.font = "600 10px monospace"; + ctx.fillStyle = cyan; + ctx.textAlign = "left"; + ctx.fillText("1.02x PASS", chartLeft, cardTop + headH + 14); + } else if (i === 3) { + // Card 4: Verified Infinite Loop Lissajous Figure + Format Badges + const lissY = innerY - 8; + const rx = bw * 0.30; + const ry = (bh - headH) * 0.24; + ctx.strokeStyle = C.spark; ctx.lineWidth = 2.2; + ctx.beginPath(); + for (let s = 0; s <= 40; s++) { + const u = (s / 40) * TAU; + const lx = cx + Math.sin(u) * rx; + const ly = lissY + Math.sin(u * 2) * ry; + if (s === 0) ctx.moveTo(lx, ly); + else ctx.lineTo(lx, ly); + } ctx.stroke(); - } - ctx.globalAlpha = 1; - ctx.fillStyle = C.body; - ctx.fillText(labels[i], cx, by); + // Travelling spark along the infinity loop + const sparkU = phase * TAU; + const sx = cx + Math.sin(sparkU) * rx; + const sy = lissY + Math.sin(sparkU * 2) * ry; + ctx.fillStyle = cyan; + ctx.beginPath(); + ctx.arc(sx, sy, 4.5, 0, TAU); + ctx.fill(); + + ctx.font = "600 10px monospace"; + ctx.fillStyle = C.body; + ctx.textAlign = "center"; + ctx.fillText("GIF · MP4 · PNG", cx, cardTop + bh - 14); + } }); - // Moving payload orbs along rail + // 3. Depth Layer 3: Moving payload orbs along the transport rail items.forEach((it) => { - const r = Math.max(7, Math.round(H * 0.036)); - const pulse = 1 + 0.15 * Math.sin(TAU * phase * 2); - ctx.globalAlpha = it.alpha * 0.26; - ctx.fillStyle = it.checked > 0.5 ? C.spark : C.accent; + const r = Math.max(8, Math.round(H * 0.036)); + const pulse = 1 + 0.16 * Math.sin(TAU * phase * 2); + const col = it.checked > 0.5 ? cyan : C.accent; + + // Outer glow halo + ctx.globalAlpha = it.alpha * 0.28; + ctx.fillStyle = col; ctx.beginPath(); - ctx.arc(it.x, railY, r * 1.45 * pulse, 0, TAU); + ctx.arc(it.x, railY, r * 1.65 * pulse, 0, TAU); ctx.fill(); + // Inner orb ctx.globalAlpha = it.alpha; ctx.fillStyle = C.accent; ctx.beginPath(); @@ -171,32 +356,49 @@ export function render(ctx, phase, kit) { if (it.checked > 0) { ctx.globalAlpha = it.alpha * it.checked; - ctx.fillStyle = C.spark; + ctx.fillStyle = cyan; ctx.beginPath(); ctx.arc(it.x, railY, r, 0, TAU); ctx.fill(); ctx.strokeStyle = C.ground; - ctx.lineWidth = 2; + ctx.lineWidth = 2.2; ctx.beginPath(); ctx.moveTo(it.x - r * 0.42, railY); - ctx.lineTo(it.x - r * 0.1, railY + r * 0.35); - ctx.lineTo(it.x + r * 0.48, railY - r * 0.35); + ctx.lineTo(it.x - r * 0.08, railY + r * 0.36); + ctx.lineTo(it.x + r * 0.48, railY - r * 0.36); ctx.stroke(); } }); - // Caption bar at bottom (fixed pill + smooth text fade) - const pillW = Math.round(W * 0.62); - kit.roundRect(ctx, W / 2 - pillW / 2, capY - 16, pillW, 32, 6); - ctx.globalAlpha = 0.95; + // 4. Bottom Caption Pill + Step Progress Dots + const pillW = Math.round(W * 0.74); + const pillH = 34; + kit.roundRect(ctx, W / 2 - pillW / 2, capY - pillH / 2, pillW, pillH, 8); + ctx.globalAlpha = 0.96; ctx.fillStyle = C.surface; ctx.fill(); ctx.strokeStyle = C.line; - ctx.lineWidth = 1; + ctx.lineWidth = 1.5; ctx.stroke(); - ctx.font = "500 13px monospace"; + let activeStepIdx = 0; + steps.forEach((c, idx) => { + const len = ((c.to - c.from) % SECONDS + SECONDS) % SECONDS || SECONDS; + const u = ((t - c.from) % SECONDS + SECONDS) % SECONDS; + if (u < len) activeStepIdx = idx; + }); + + // Step indicator dots on left of pill + for (let d = 0; d < steps.length; d++) { + ctx.globalAlpha = 1; + ctx.fillStyle = d === activeStepIdx ? cyan : C.line; + ctx.beginPath(); + ctx.arc(W / 2 - pillW / 2 + 16 + d * 10, capY, d === activeStepIdx ? 3.5 : 2.5, 0, TAU); + ctx.fill(); + } + + ctx.font = "500 12px monospace"; ctx.textAlign = "center"; ctx.textBaseline = "middle"; @@ -204,10 +406,10 @@ export function render(ctx, phase, kit) { const len = ((c.to - c.from) % SECONDS + SECONDS) % SECONDS || SECONDS; const u = ((t - c.from) % SECONDS + SECONDS) % SECONDS; if (u >= len) return; - const fade = Math.max(0.2, Math.min(1, u / 0.35, (len - u) / 0.35)); + const fade = Math.max(0.25, Math.min(1, u / 0.35, (len - u) / 0.35)); ctx.globalAlpha = fade; ctx.fillStyle = C.body; - ctx.fillText(c.caption, W / 2, capY); + ctx.fillText(c.caption, W / 2 + 22, capY); }); ctx.globalAlpha = 1; diff --git a/gallery/loop-studio/storyboard.png b/gallery/loop-studio/storyboard.png index d3cd776..01d81af 100644 Binary files a/gallery/loop-studio/storyboard.png and b/gallery/loop-studio/storyboard.png differ diff --git a/gallery/manifest.json b/gallery/manifest.json index fe7bbbc..7f79cbb 100644 --- a/gallery/manifest.json +++ b/gallery/manifest.json @@ -1,83 +1,254 @@ { - "generatedAt": "2026-11-18T16:19:41.106Z", + "generatedAt": "2026-11-18T18:13:57.421Z", "items": [ { "id": "loop-studio", "title": "Loop Studio Showcase (Flow Pipeline)", "mode": "showcase", + "useCase": "README hero diagram explaining what a repo or workflow does end-to-end", + "fps": 60, "pass": true, - "seamScore": 1.066, + "seamScore": 1.116, "duplicateFrames": 0, - "flickerScore": 0.307, + "flickerScore": 0.582, "legiblePass": true, "sourcesPass": true, - "gifKB": 779.9, - "totalFrames": 160 + "gifKB": 10072.3, + "webpKB": 6098, + "totalFrames": 480 }, { "id": "cli-audit-session", "title": "Loop CLI Audit Showcase (Terminal)", "mode": "showcase", + "useCase": "CLI documentation showing commands, flags, and pass/fail audit output", + "fps": 16, "pass": true, - "seamScore": 0.998, + "seamScore": 0.989, "duplicateFrames": 0, - "flickerScore": 1.366, + "flickerScore": 0.89, "legiblePass": true, "sourcesPass": true, - "gifKB": 805, + "gifKB": 1371.6, "totalFrames": 160 }, + { + "id": "api-pipeline-code", + "title": "Phase Contract SDK Showcase (Code)", + "mode": "showcase", + "useCase": "SDK / library docs pairing live-stepping code with a synchronized state monitor", + "fps": 20, + "pass": true, + "seamScore": 1.006, + "duplicateFrames": 0, + "flickerScore": 0.08, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 2343.8, + "totalFrames": 200 + }, + { + "id": "mcp-mesh-topology", + "title": "Agent Orchestrator Mesh (Architecture)", + "mode": "showcase", + "useCase": "System architecture & multi-agent/MCP topology diagrams for engineering RFCs", + "fps": 20, + "pass": true, + "seamScore": 0.985, + "duplicateFrames": 0, + "flickerScore": 0.15, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 1463.6, + "totalFrames": 200 + }, { "id": "deep-sea-orbits", "title": "Abyssal Bioluminescence (Particle Orbit)", "mode": "ambient", + "useCase": "Calm ambient background for dark-mode apps, streams, and loading states", + "fps": 20, "pass": true, - "seamScore": 0.974, + "seamScore": 0.972, "duplicateFrames": 0, "flickerScore": 0.024, "legiblePass": true, "sourcesPass": true, - "gifKB": 1173.2, + "gifKB": 1247.8, "totalFrames": 80 }, { "id": "aurora-flow-field", "title": "Arctic Currents (Flow Field)", "mode": "ambient", + "useCase": "Organic generative header for landing pages, music visualizers, and project banners", + "fps": 20, "pass": true, - "seamScore": 1.013, + "seamScore": 1.037, "duplicateFrames": 0, - "flickerScore": 0.025, + "flickerScore": 0.028, "legiblePass": true, "sourcesPass": true, - "gifKB": 1674.1, + "gifKB": 3076.4, "totalFrames": 80 }, { "id": "nordic-isometric", "title": "Harmonic Architecture (Isometric Grid)", "mode": "ambient", + "useCase": "Infrastructure, cloud platform, and modular architecture hero tiles", + "fps": 20, "pass": true, - "seamScore": 0.946, + "seamScore": 0.927, "duplicateFrames": 0, - "flickerScore": 0.1, + "flickerScore": 0.169, "legiblePass": true, "sourcesPass": true, - "gifKB": 326.7, + "gifKB": 786.9, "totalFrames": 80 }, { "id": "cad-planetary", "title": "Epicyclic Telemetry (Blueprint CAD)", "mode": "ambient", + "useCase": "Robotics, hardware, CAD, and precision engineering repo badges", + "fps": 20, "pass": true, - "seamScore": 1.016, + "seamScore": 1.023, "duplicateFrames": 0, "flickerScore": 0.031, "legiblePass": true, "sourcesPass": true, - "gifKB": 762.6, + "gifKB": 1193.9, "totalFrames": 80 + }, + { + "id": "readme-hero-3d", + "title": "Nebula SDF Sculpture (3D Raymarch)", + "mode": "ambient", + "useCase": "Zero-dependency 3D product showcase & smooth shader sculpture for SaaS hero cards", + "fps": 30, + "pass": true, + "seamScore": 1.061, + "duplicateFrames": 0, + "flickerScore": 0.056, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 822.2, + "webpKB": 332.8, + "totalFrames": 90 + }, + { + "id": "retro-crt-loader", + "title": "Amber CRT Radar (Bayer Dither)", + "mode": "ambient", + "useCase": "Low-bandwidth terminal/game splash screen & zero-shimmer retro loading indicator", + "fps": 30, + "pass": true, + "seamScore": 1.005, + "duplicateFrames": 0, + "flickerScore": 0.114, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 339.2, + "webpKB": 2418.4, + "totalFrames": 90 + }, + { + "id": "kinetic-release-banner", + "title": "Editorial Kinetic Wave (60 fps Type)", + "mode": "ambient", + "useCase": "60 fps social release announcement card, talk title slide, and launch banner", + "fps": 60, + "pass": true, + "seamScore": 0.968, + "duplicateFrames": 0, + "flickerScore": 0.456, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 1408.1, + "webpKB": 1134.1, + "totalFrames": 240 + }, + { + "id": "sonar-bathymetry", + "title": "Abyssal Bathymetry (Topographic Isolines)", + "mode": "ambient", + "useCase": "Geospatial, weather, sonar, and telemetry elevation background loops", + "fps": 30, + "pass": true, + "seamScore": 0.951, + "duplicateFrames": 0, + "flickerScore": 0.051, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 440.8, + "webpKB": 1356.2, + "totalFrames": 90 + }, + { + "id": "git-pr-guardrails", + "title": "Protected Git Workflow (8s @ 60fps)", + "mode": "showcase", + "useCase": "GitHub workflow & CI/CD guardrails explainer showing branch protection, evals, and PR merges", + "fps": 60, + "pass": true, + "seamScore": 1.148, + "duplicateFrames": 0, + "flickerScore": 0.736, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 6539.7, + "webpKB": 3114.5, + "totalFrames": 480 + }, + { + "id": "json-to-gif-transform", + "title": "60fps Video Transformer (8s @ 60fps)", + "mode": "showcase", + "useCase": "Compiler, build pipeline, or media-processing explainer showing specs transforming into 60fps video", + "fps": 60, + "pass": true, + "seamScore": 1.005, + "duplicateFrames": 0, + "flickerScore": 0.103, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 5008.7, + "webpKB": 3798.9, + "totalFrames": 480 + }, + { + "id": "live-audio-spectrum", + "title": "120 BPM Harmonic Spectrum (6s @ 60fps)", + "mode": "ambient", + "useCase": "Music release loop, podcast player, and WebAudio/VST visualizer synced to 120 BPM (3 bars)", + "fps": 60, + "pass": true, + "seamScore": 1.05, + "duplicateFrames": 0, + "flickerScore": 0.261, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 1804, + "webpKB": 1688.8, + "totalFrames": 360 + }, + { + "id": "orbital-telemetry-watch", + "title": "Orbital Radar Telemetry (8s @ 60fps)", + "mode": "ambient", + "useCase": "Satellite tracker, aerospace HUD, and DevOps live observability dashboard splash", + "fps": 60, + "pass": true, + "seamScore": 1.037, + "duplicateFrames": 0, + "flickerScore": 0.045, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 5494.6, + "webpKB": 3257, + "totalFrames": 480 } ] } diff --git a/gallery/mcp-mesh-topology/audit.json b/gallery/mcp-mesh-topology/audit.json new file mode 100644 index 0000000..3e47cd8 --- /dev/null +++ b/gallery/mcp-mesh-topology/audit.json @@ -0,0 +1,15 @@ +{ + "id": "mcp-mesh-topology", + "title": "Agent Orchestrator Mesh (Architecture)", + "mode": "showcase", + "useCase": "System architecture & multi-agent/MCP topology diagrams for engineering RFCs", + "fps": 20, + "pass": true, + "seamScore": 0.985, + "duplicateFrames": 0, + "flickerScore": 0.15, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 1463.6, + "totalFrames": 200 +} diff --git a/gallery/mcp-mesh-topology/index.html b/gallery/mcp-mesh-topology/index.html new file mode 100644 index 0000000..354d54f --- /dev/null +++ b/gallery/mcp-mesh-topology/index.html @@ -0,0 +1,120 @@ + + + + + + Agent Orchestrator Mesh (Architecture) · Loop Studio + + + +
+
+

Agent Orchestrator Mesh (Architecture)

+ loading sketch.js... +
+
+
+ +
+
+ + + frame 000 / 120 · phase 0.00 + +
+
+
+ + + \ No newline at end of file diff --git a/gallery/mcp-mesh-topology/legible.json b/gallery/mcp-mesh-topology/legible.json new file mode 100644 index 0000000..d63688e --- /dev/null +++ b/gallery/mcp-mesh-topology/legible.json @@ -0,0 +1,71 @@ +{ + "pass": true, + "width": 800, + "height": 320, + "phoneWidth": 400, + "frame0ShowsAllStageLabels": true, + "stageLabelsChecked": 4, + "captions": [ + { + "step": 1, + "caption": "agent scaffolds sketch via loop CLI", + "words": 6, + "chars": 35, + "windowSeconds": 2.5, + "requiredSeconds": 2.3, + "passReadingTime": true, + "contrastRatio": 14.86, + "passContrast": true, + "minEdgeMarginPx": 37, + "phoneFontPx": 6.5, + "passMobileWidth": true, + "pass": true + }, + { + "step": 2, + "caption": "CLI renders storyboard & frame deltas", + "words": 6, + "chars": 37, + "windowSeconds": 2.5, + "requiredSeconds": 2.3, + "passReadingTime": true, + "contrastRatio": 14.86, + "passContrast": true, + "minEdgeMarginPx": 37, + "phoneFontPx": 6.5, + "passMobileWidth": true, + "pass": true + }, + { + "step": 3, + "caption": "cold-reader inspects storyboard.png", + "words": 3, + "chars": 35, + "windowSeconds": 2.5, + "requiredSeconds": 1.4, + "passReadingTime": true, + "contrastRatio": 14.86, + "passContrast": true, + "minEdgeMarginPx": 37, + "phoneFontPx": 6.5, + "passMobileWidth": true, + "pass": true + }, + { + "step": 4, + "caption": "verified loop.gif & audit return", + "words": 5, + "chars": 32, + "windowSeconds": 2.5, + "requiredSeconds": 2, + "passReadingTime": true, + "contrastRatio": 14.86, + "passContrast": true, + "minEdgeMarginPx": 37, + "phoneFontPx": 6.5, + "passMobileWidth": true, + "pass": true + } + ], + "reasons": [] +} diff --git a/gallery/mcp-mesh-topology/loop.gif b/gallery/mcp-mesh-topology/loop.gif new file mode 100644 index 0000000..1b29e6d Binary files /dev/null and b/gallery/mcp-mesh-topology/loop.gif differ diff --git a/gallery/mcp-mesh-topology/poster.png b/gallery/mcp-mesh-topology/poster.png new file mode 100644 index 0000000..8ae6ccb Binary files /dev/null and b/gallery/mcp-mesh-topology/poster.png differ diff --git a/gallery/mcp-mesh-topology/seam.json b/gallery/mcp-mesh-topology/seam.json new file mode 100644 index 0000000..5e050fa --- /dev/null +++ b/gallery/mcp-mesh-topology/seam.json @@ -0,0 +1,215 @@ +{ + "pass": true, + "totalFrames": 200, + "seamScore": 0.985, + "maxSeamScore": 1.5, + "duplicateFrames": 0, + "duplicatePairs": [], + "flickerScore": 0.15, + "maxFlickerScore": 2.5, + "medianStepDelta": 0.012173, + "seamStepDelta": 0.011987, + "normalizedSteps": [ + 0.911, + 0.923, + 0.96, + 0.997, + 0.996, + 0.993, + 0.988, + 0.986, + 0.986, + 0.989, + 0.993, + 0.994, + 0.991, + 0.99, + 0.991, + 0.991, + 0.977, + 0.934, + 1.073, + 1.096, + 1.058, + 1.075, + 1.086, + 1.054, + 1.266, + 1.026, + 1.081, + 1.162, + 1.164, + 1.15, + 1.157, + 1.162, + 1.015, + 1.021, + 1.029, + 1.033, + 1.021, + 0.962, + 0.934, + 0.973, + 0.897, + 0.916, + 0.94, + 0.993, + 1.003, + 1, + 0.981, + 0.928, + 0.909, + 0.949, + 0.923, + 0.932, + 0.955, + 1.01, + 1.023, + 1.02, + 1.015, + 1.012, + 1.012, + 1.014, + 1.017, + 1.018, + 1.017, + 1.018, + 1.019, + 1.017, + 0.97, + 0.941, + 1.095, + 1.101, + 1.042, + 1.067, + 1.068, + 1.002, + 1.211, + 0.993, + 1.048, + 1.132, + 1.134, + 1.121, + 1.128, + 1.133, + 0.983, + 0.989, + 0.995, + 0.999, + 0.983, + 0.93, + 0.906, + 0.935, + 0.907, + 0.923, + 0.95, + 1.01, + 1.028, + 1.025, + 1.016, + 0.968, + 0.928, + 0.985, + 0.911, + 0.923, + 0.96, + 0.997, + 0.996, + 0.993, + 0.988, + 0.986, + 0.986, + 0.989, + 0.993, + 0.994, + 0.991, + 0.99, + 0.991, + 0.991, + 0.977, + 0.934, + 1.08, + 1.102, + 1.065, + 1.081, + 1.092, + 1.056, + 1.345, + 1.026, + 1.072, + 1.142, + 1.143, + 1.129, + 1.135, + 1.139, + 1.015, + 1.021, + 1.029, + 1.033, + 1.021, + 0.962, + 0.934, + 0.973, + 0.897, + 0.916, + 0.94, + 0.993, + 1.003, + 1, + 0.981, + 0.928, + 0.909, + 0.949, + 0.923, + 0.932, + 0.955, + 1.01, + 1.023, + 1.02, + 1.015, + 1.012, + 1.012, + 1.014, + 1.017, + 1.018, + 1.017, + 1.018, + 1.019, + 1.017, + 0.97, + 0.941, + 1.07, + 1.079, + 1.019, + 1.044, + 1.046, + 0.993, + 1.325, + 0.993, + 1.046, + 1.126, + 1.128, + 1.115, + 1.122, + 1.126, + 0.983, + 0.989, + 0.995, + 0.999, + 0.983, + 0.93, + 0.906, + 0.935, + 0.907, + 0.923, + 0.95, + 1.01, + 1.028, + 1.025, + 1.016, + 0.968, + 0.928, + 0.985 + ], + "reasons": [] +} diff --git a/gallery/mcp-mesh-topology/sheet.png b/gallery/mcp-mesh-topology/sheet.png new file mode 100644 index 0000000..f9d2919 Binary files /dev/null and b/gallery/mcp-mesh-topology/sheet.png differ diff --git a/gallery/mcp-mesh-topology/showcase.gif b/gallery/mcp-mesh-topology/showcase.gif new file mode 100644 index 0000000..1b29e6d Binary files /dev/null and b/gallery/mcp-mesh-topology/showcase.gif differ diff --git a/gallery/mcp-mesh-topology/showcase.json b/gallery/mcp-mesh-topology/showcase.json new file mode 100644 index 0000000..827b7a8 --- /dev/null +++ b/gallery/mcp-mesh-topology/showcase.json @@ -0,0 +1,42 @@ +{ + "title": "Agent Orchestrator Mesh", + "says": "The Loop Studio orchestrator coordinates the CLI renderer, seam analyzer, and cold-read subagent.", + "seconds": 10, + "fps": 20, + "width": 800, + "height": 320, + "palette": "aurora", + "scene": "architecture", + "stage": [ + "Agent", + "loop CLI", + "Seam Audit", + "Cold Reader" + ], + "steps": [ + { + "from": 8.75, + "to": 1.25, + "caption": "agent scaffolds sketch via loop CLI", + "source": "AGENTS.md:9" + }, + { + "from": 1.25, + "to": 3.75, + "caption": "CLI renders storyboard & frame deltas", + "source": "skills/loop-render/SKILL.md:24" + }, + { + "from": 3.75, + "to": 6.25, + "caption": "cold-reader inspects storyboard.png", + "source": "agents/loop-cold-reader.md:10" + }, + { + "from": 6.25, + "to": 8.75, + "caption": "verified loop.gif & audit return", + "source": "skills/loop-audit/SKILL.md:9" + } + ] +} diff --git a/gallery/mcp-mesh-topology/sketch.js b/gallery/mcp-mesh-topology/sketch.js new file mode 100644 index 0000000..fd30d7b --- /dev/null +++ b/gallery/mcp-mesh-topology/sketch.js @@ -0,0 +1,109 @@ +// Scene Pack: architecture — Multi-tier topology with request/response packets +export const meta = { + mode: "showcase", + scene: "architecture", + seconds: 10, + fps: 20, + width: 800, + height: 320, + seed: 41, + palette: "aurora" +}; + +export const showcase = { + says: "The Loop Studio orchestrator coordinates the CLI renderer, seam analyzer, and cold-read subagent.", + seconds: 10, + scene: "architecture", + stage: ["Agent", "loop CLI", "Seam Audit", "Cold Reader"], + steps: [ + { from: 8.75, to: 1.25, caption: "agent scaffolds sketch via loop CLI", source: "AGENTS.md:9" }, + { from: 1.25, to: 3.75, caption: "CLI renders storyboard & frame deltas", source: "skills/loop-render/SKILL.md:24" }, + { from: 3.75, to: 6.25, caption: "cold-reader inspects storyboard.png", source: "agents/loop-cold-reader.md:10" }, + { from: 6.25, to: 8.75, caption: "verified loop.gif & audit return", source: "skills/loop-audit/SKILL.md:9" } + ] +}; + +export function render(ctx, phase, kit) { + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; + const C = kit.palettes[meta.palette] || kit.palettes["studio-dark"]; + const S = kit.showcase || showcase; + const labels = S.stage || showcase.stage; + const steps = S.steps || showcase.steps; + const SECONDS = S.seconds || meta.seconds; + const t = phase * SECONDS; + const TAU = Math.PI * 2; + + ctx.fillStyle = C.ground; + ctx.fillRect(0, 0, W, H); + + const nodes = [ + { x: Math.round(W * 0.18), y: Math.round(H * 0.38), w: Math.round(W * 0.17), h: Math.round(H * 0.17), label: labels[0] || "Agent", color: C.accent }, + { x: Math.round(W * 0.48), y: Math.round(H * 0.38), w: Math.round(W * 0.18), h: Math.round(H * 0.17), label: labels[1] || "loop CLI", color: C.body }, + { x: Math.round(W * 0.80), y: Math.round(H * 0.24), w: Math.round(W * 0.21), h: Math.round(H * 0.15), label: labels[2] || "Seam Audit", color: C.spark }, + { x: Math.round(W * 0.80), y: Math.round(H * 0.52), w: Math.round(W * 0.21), h: Math.round(H * 0.15), label: labels[3] || "Cold Reader", color: C.spark } + ]; + + const links = [ + [0, 1], + [1, 2], + [1, 3] + ]; + + links.forEach(([aIdx, bIdx], i) => { + const a = nodes[aIdx]; + const b = nodes[bIdx]; + ctx.strokeStyle = C.line; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(a.x + a.w / 2, a.y); + ctx.lineTo(b.x - b.w / 2, b.y); + ctx.stroke(); + + const u = (phase * 2 + i * 0.3) % 1; + const ping = u < 0.5 ? u * 2 : (1 - u) * 2; + const px = (a.x + a.w / 2) + ((b.x - b.w / 2) - (a.x + a.w / 2)) * ping; + const py = a.y + (b.y - a.y) * ping; + ctx.fillStyle = u < 0.5 ? C.accent : C.spark; + ctx.beginPath(); + ctx.arc(px, py, 5, 0, TAU); + ctx.fill(); + }); + + ctx.font = "600 13px monospace"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + nodes.forEach((n) => { + kit.roundRect(ctx, n.x - n.w / 2, n.y - n.h / 2, n.w, n.h, 8); + ctx.fillStyle = C.surface; + ctx.fill(); + ctx.strokeStyle = n.color; + ctx.lineWidth = 2; + ctx.stroke(); + + ctx.fillStyle = C.body; + ctx.fillText(n.label, n.x, n.y); + }); + + const capY = Math.round(H * 0.86); + const pillW = Math.round(W * 0.62); + kit.roundRect(ctx, W / 2 - pillW / 2, capY - 16, pillW, 32, 6); + ctx.globalAlpha = 0.95; + ctx.fillStyle = C.surface; + ctx.fill(); + ctx.strokeStyle = C.line; + ctx.lineWidth = 1; + ctx.stroke(); + + ctx.font = "500 13px monospace"; + steps.forEach((c) => { + const len = ((c.to - c.from) % SECONDS + SECONDS) % SECONDS || SECONDS; + const u = ((t - c.from) % SECONDS + SECONDS) % SECONDS; + if (u >= len) return; + const fade = Math.max(0.2, Math.min(1, u / 0.35, (len - u) / 0.35)); + ctx.globalAlpha = fade; + ctx.fillStyle = C.body; + ctx.fillText(c.caption, W / 2, capY); + }); + ctx.globalAlpha = 1; +} diff --git a/gallery/mcp-mesh-topology/sources.json b/gallery/mcp-mesh-topology/sources.json new file mode 100644 index 0000000..345f562 --- /dev/null +++ b/gallery/mcp-mesh-topology/sources.json @@ -0,0 +1,40 @@ +{ + "pass": true, + "repoRoot": "/Users/marcusk/.gemini/antigravity/scratch/loop-studio", + "checked": 4, + "citations": [ + { + "step": 1, + "source": "AGENTS.md:9", + "file": "AGENTS.md", + "line": 9, + "excerpt": "| Command | Purpose | Output |", + "valid": true + }, + { + "step": 2, + "source": "skills/loop-render/SKILL.md:24", + "file": "skills/loop-render/SKILL.md", + "line": 24, + "excerpt": "### 3. Showcase Storyboard (`loop story`)", + "valid": true + }, + { + "step": 3, + "source": "agents/loop-cold-reader.md:10", + "file": "agents/loop-cold-reader.md", + "line": 10, + "excerpt": "## Strict Isolation Rules", + "valid": true + }, + { + "step": 4, + "source": "skills/loop-audit/SKILL.md:9", + "file": "skills/loop-audit/SKILL.md", + "line": 9, + "excerpt": "", + "valid": true + } + ], + "reasons": [] +} diff --git a/gallery/mcp-mesh-topology/storyboard.png b/gallery/mcp-mesh-topology/storyboard.png new file mode 100644 index 0000000..f0fe104 Binary files /dev/null and b/gallery/mcp-mesh-topology/storyboard.png differ diff --git a/gallery/nordic-isometric/audit.json b/gallery/nordic-isometric/audit.json index c05aceb..79f975e 100644 --- a/gallery/nordic-isometric/audit.json +++ b/gallery/nordic-isometric/audit.json @@ -2,12 +2,14 @@ "id": "nordic-isometric", "title": "Harmonic Architecture (Isometric Grid)", "mode": "ambient", + "useCase": "Infrastructure, cloud platform, and modular architecture hero tiles", + "fps": 20, "pass": true, - "seamScore": 0.946, + "seamScore": 0.927, "duplicateFrames": 0, - "flickerScore": 0.1, + "flickerScore": 0.169, "legiblePass": true, "sourcesPass": true, - "gifKB": 326.7, + "gifKB": 786.9, "totalFrames": 80 } diff --git a/gallery/nordic-isometric/loop.gif b/gallery/nordic-isometric/loop.gif index 3d634ce..2823495 100644 Binary files a/gallery/nordic-isometric/loop.gif and b/gallery/nordic-isometric/loop.gif differ diff --git a/gallery/nordic-isometric/poster.png b/gallery/nordic-isometric/poster.png index f51498e..39cd807 100644 Binary files a/gallery/nordic-isometric/poster.png and b/gallery/nordic-isometric/poster.png differ diff --git a/gallery/nordic-isometric/seam.json b/gallery/nordic-isometric/seam.json index 1239877..e477267 100644 --- a/gallery/nordic-isometric/seam.json +++ b/gallery/nordic-isometric/seam.json @@ -1,95 +1,95 @@ { "pass": true, "totalFrames": 80, - "seamScore": 0.946, + "seamScore": 0.927, "maxSeamScore": 1.5, "duplicateFrames": 0, "duplicatePairs": [], - "flickerScore": 0.1, + "flickerScore": 0.169, "maxFlickerScore": 2.5, - "medianStepDelta": 0.09538, - "seamStepDelta": 0.090264, + "medianStepDelta": 0.06643, + "seamStepDelta": 0.061572, "normalizedSteps": [ - 0.92, - 0.908, - 0.902, - 1.002, - 0.911, - 0.941, - 0.931, - 0.921, - 0.932, - 0.959, - 0.977, - 0.935, + 0.898, + 0.886, + 0.891, + 1.06, + 0.905, + 0.919, 0.945, - 1, - 1.055, + 0.927, + 0.933, 0.948, - 0.964, + 0.981, + 0.921, + 0.93, + 1, + 1.13, 0.955, - 0.988, - 1.039, - 1.033, - 1.018, - 1.02, - 1.01, - 1.092, + 0.968, + 0.964, + 0.995, + 1.084, + 1.067, + 1.029, + 1.037, + 1.03, + 1.175, + 1.157, + 1.09, + 1.088, + 1.157, + 1.157, + 1.107, + 1.102, 1.089, - 1.036, - 1.051, - 1.081, - 1.097, - 1.068, - 1.071, - 1.054, - 1.076, - 1.071, - 1.134, - 1.078, - 1.145, - 1.118, + 1.094, + 1.09, + 1.197, + 1.086, + 1.169, 1.13, - 1.066, - 1.05, - 1.049, - 1.005, - 1.034, - 0.992, - 0.976, - 0.935, - 0.959, - 1.011, - 0.987, - 0.994, - 1.055, - 1.018, - 1.017, - 1, - 1.02, - 1.013, - 1.071, - 1.044, - 1.075, - 0.969, - 0.949, - 0.958, - 0.935, - 0.887, - 0.889, - 0.89, - 0.886, - 1.042, - 0.958, - 0.933, - 0.933, - 0.958, - 0.98, - 0.948, + 1.16, + 1.092, + 1.076, + 1.087, + 0.995, + 1.062, + 0.983, + 0.963, + 0.945, + 0.947, + 1.045, 0.958, - 0.999, + 0.983, + 1.083, + 1.001, + 1.024, + 1.028, + 1.034, + 1.021, + 1.101, + 1.036, + 1.132, 0.939, - 0.946 + 0.931, + 0.937, + 0.963, + 0.877, + 0.883, + 0.885, + 0.89, + 1.12, + 0.956, + 0.95, + 0.946, + 0.981, + 0.998, + 0.928, + 0.932, + 1.002, + 0.899, + 0.927 ], "reasons": [] } diff --git a/gallery/nordic-isometric/sheet.png b/gallery/nordic-isometric/sheet.png index 8e0c1b9..2b2d1b8 100644 Binary files a/gallery/nordic-isometric/sheet.png and b/gallery/nordic-isometric/sheet.png differ diff --git a/gallery/orbital-telemetry-watch/audit.json b/gallery/orbital-telemetry-watch/audit.json new file mode 100644 index 0000000..3c3f517 --- /dev/null +++ b/gallery/orbital-telemetry-watch/audit.json @@ -0,0 +1,16 @@ +{ + "id": "orbital-telemetry-watch", + "title": "Orbital Radar Telemetry (8s @ 60fps)", + "mode": "ambient", + "useCase": "Satellite tracker, aerospace HUD, and DevOps live observability dashboard splash", + "fps": 60, + "pass": true, + "seamScore": 1.037, + "duplicateFrames": 0, + "flickerScore": 0.045, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 5494.6, + "webpKB": 3257, + "totalFrames": 480 +} diff --git a/gallery/orbital-telemetry-watch/brief.json b/gallery/orbital-telemetry-watch/brief.json new file mode 100644 index 0000000..e766fe7 --- /dev/null +++ b/gallery/orbital-telemetry-watch/brief.json @@ -0,0 +1,12 @@ +{ + "title": "Orbital Radar Telemetry", + "prompt": "8-second 60fps blueprint radar HUD tracking 3 satellites on tilted elliptical orbits.", + "mode": "ambient", + "style": "blueprint-hud", + "palette": "blueprint", + "seconds": 8, + "fps": 60, + "width": 300, + "height": 300, + "seed": 204 +} diff --git a/gallery/orbital-telemetry-watch/index.html b/gallery/orbital-telemetry-watch/index.html new file mode 100644 index 0000000..f646c04 --- /dev/null +++ b/gallery/orbital-telemetry-watch/index.html @@ -0,0 +1,120 @@ + + + + + + Orbital Radar Telemetry (8s @ 60fps) · Loop Studio + + + +
+
+

Orbital Radar Telemetry (8s @ 60fps)

+ loading sketch.js... +
+
+
+ +
+
+ + + frame 000 / 120 · phase 0.00 + +
+
+
+ + + \ No newline at end of file diff --git a/gallery/orbital-telemetry-watch/legible.json b/gallery/orbital-telemetry-watch/legible.json new file mode 100644 index 0000000..bf71bb8 --- /dev/null +++ b/gallery/orbital-telemetry-watch/legible.json @@ -0,0 +1,20 @@ +{ + "pass": true, + "mode": "ambient", + "textElementsChecked": 2, + "captions": [ + { + "text": "ORBIT-HUD // 60FPS", + "contrastRatio": 14.93, + "minMarginPx": 12, + "passContrast": true + }, + { + "text": "T+0.0S", + "contrastRatio": 10.36, + "minMarginPx": 10, + "passContrast": true + } + ], + "reasons": [] +} diff --git a/gallery/orbital-telemetry-watch/loop.gif b/gallery/orbital-telemetry-watch/loop.gif new file mode 100644 index 0000000..5a4ee87 Binary files /dev/null and b/gallery/orbital-telemetry-watch/loop.gif differ diff --git a/gallery/orbital-telemetry-watch/loop.webp b/gallery/orbital-telemetry-watch/loop.webp new file mode 100644 index 0000000..85e9400 Binary files /dev/null and b/gallery/orbital-telemetry-watch/loop.webp differ diff --git a/gallery/orbital-telemetry-watch/poster.png b/gallery/orbital-telemetry-watch/poster.png new file mode 100644 index 0000000..a9d087b Binary files /dev/null and b/gallery/orbital-telemetry-watch/poster.png differ diff --git a/gallery/orbital-telemetry-watch/seam.json b/gallery/orbital-telemetry-watch/seam.json new file mode 100644 index 0000000..6a6817b --- /dev/null +++ b/gallery/orbital-telemetry-watch/seam.json @@ -0,0 +1,495 @@ +{ + "pass": true, + "totalFrames": 480, + "seamScore": 1.037, + "maxSeamScore": 1.5, + "duplicateFrames": 0, + "duplicatePairs": [], + "flickerScore": 0.045, + "maxFlickerScore": 2.5, + "medianStepDelta": 0.044209, + "seamStepDelta": 0.045863, + "normalizedSteps": [ + 1.028, + 1.047, + 1.084, + 1.055, + 1.052, + 1.044, + 1.036, + 1.017, + 0.993, + 1.067, + 0.983, + 0.994, + 1.011, + 1.014, + 1.036, + 1.016, + 1.012, + 1.011, + 1.009, + 1.006, + 1.002, + 1.031, + 0.996, + 0.986, + 0.981, + 0.973, + 1.003, + 0.962, + 0.954, + 0.944, + 0.942, + 0.943, + 0.948, + 0.933, + 0.923, + 0.906, + 0.9, + 0.93, + 0.971, + 0.921, + 0.92, + 0.919, + 0.916, + 0.909, + 0.949, + 0.911, + 0.899, + 0.89, + 0.862, + 0.872, + 0.889, + 0.917, + 0.901, + 0.907, + 0.91, + 0.911, + 0.917, + 0.969, + 0.918, + 0.916, + 0.924, + 0.933, + 0.979, + 0.944, + 0.95, + 0.952, + 0.961, + 0.97, + 0.976, + 1.002, + 0.988, + 0.992, + 0.998, + 1, + 1.031, + 1.021, + 1.022, + 1.026, + 1.027, + 1.029, + 1.063, + 1.037, + 1.044, + 1.047, + 1.047, + 1.052, + 1.051, + 1.084, + 1.051, + 1.047, + 1.043, + 1.039, + 1.038, + 1.045, + 1.035, + 1.039, + 1.056, + 1.065, + 1.065, + 1.104, + 1.067, + 1.067, + 1.066, + 1.071, + 1.108, + 1.07, + 1.065, + 1.063, + 1.063, + 1.06, + 1.07, + 1.054, + 1.05, + 1.046, + 1.041, + 1.037, + 1.034, + 1.064, + 1.019, + 1.015, + 1.008, + 1.01, + 1.008, + 1.016, + 0.969, + 0.974, + 0.976, + 0.973, + 0.971, + 0.987, + 0.963, + 0.962, + 0.96, + 0.956, + 0.976, + 0.96, + 0.957, + 0.958, + 0.957, + 0.958, + 0.993, + 0.962, + 0.962, + 0.962, + 0.964, + 0.951, + 0.933, + 0.963, + 0.976, + 0.986, + 0.988, + 1.001, + 1.004, + 1.015, + 1.01, + 1.015, + 1.019, + 1.021, + 1.02, + 1.068, + 1.031, + 1.038, + 1.043, + 1.047, + 1.085, + 1.052, + 1.049, + 1.05, + 1.055, + 1.057, + 1.075, + 1.068, + 1.072, + 1.082, + 1.087, + 1.092, + 1.132, + 1.105, + 1.108, + 1.108, + 1.106, + 1.113, + 1.116, + 1.147, + 1.114, + 1.108, + 1.11, + 1.11, + 1.104, + 1.124, + 1.101, + 1.096, + 1.09, + 1.089, + 1.103, + 1.086, + 1.077, + 1.069, + 1.057, + 1.048, + 1.085, + 1.059, + 1.055, + 1.045, + 1.034, + 1.019, + 1.037, + 0.995, + 0.982, + 0.957, + 0.94, + 0.926, + 0.917, + 0.926, + 0.923, + 0.914, + 0.893, + 0.875, + 0.863, + 0.902, + 0.847, + 0.85, + 0.849, + 0.837, + 0.883, + 0.838, + 0.826, + 0.827, + 0.822, + 0.819, + 0.837, + 0.818, + 0.82, + 0.821, + 0.823, + 0.825, + 0.886, + 0.833, + 0.83, + 0.829, + 0.826, + 0.829, + 0.828, + 0.872, + 0.831, + 0.831, + 0.827, + 0.832, + 0.864, + 0.845, + 0.838, + 0.842, + 0.851, + 0.85, + 0.877, + 0.874, + 0.88, + 0.894, + 0.904, + 0.91, + 0.917, + 0.962, + 0.935, + 0.94, + 0.95, + 0.96, + 0.993, + 0.968, + 0.975, + 0.979, + 0.99, + 1, + 1.006, + 1.005, + 0.993, + 0.984, + 1.012, + 1.021, + 1.065, + 1.032, + 1.038, + 1.049, + 1.075, + 1.064, + 1.093, + 1.071, + 1.067, + 1.071, + 1.073, + 1.075, + 1.076, + 1.09, + 1.08, + 1.083, + 1.082, + 1.08, + 1.125, + 1.084, + 1.083, + 1.076, + 1.077, + 1.082, + 1.08, + 1.106, + 1.069, + 1.058, + 1.05, + 1.043, + 1.059, + 1.032, + 1.028, + 1.024, + 1.023, + 1.019, + 1.033, + 1.006, + 1, + 0.994, + 0.986, + 0.983, + 0.979, + 1.005, + 0.967, + 0.964, + 0.963, + 0.96, + 0.994, + 0.957, + 0.958, + 0.949, + 0.952, + 0.952, + 0.956, + 0.966, + 0.954, + 0.953, + 0.954, + 0.901, + 0.957, + 0.959, + 0.955, + 0.952, + 0.95, + 0.948, + 0.987, + 0.946, + 0.948, + 0.948, + 0.948, + 0.953, + 0.954, + 0.967, + 0.958, + 0.961, + 0.966, + 0.972, + 1.002, + 0.982, + 0.987, + 0.979, + 0.98, + 0.988, + 1.01, + 1.047, + 1.019, + 1.028, + 1.028, + 1.031, + 1.055, + 1.036, + 1.039, + 1.043, + 1.045, + 1.05, + 1.07, + 1.053, + 1.051, + 1.051, + 1.055, + 1.054, + 1.055, + 1.087, + 1.052, + 1.05, + 1.049, + 1.03, + 1.068, + 1.052, + 1.037, + 1.045, + 1.049, + 1.057, + 1.06, + 1.069, + 1.061, + 1.057, + 1.055, + 1.052, + 1.087, + 1.048, + 1.045, + 1.044, + 1.041, + 1.035, + 1.067, + 1.029, + 1.02, + 1.011, + 1.007, + 1, + 0.992, + 0.998, + 0.978, + 0.968, + 0.961, + 0.956, + 1.006, + 0.943, + 0.935, + 0.927, + 0.92, + 0.922, + 0.919, + 0.955, + 0.908, + 0.863, + 0.804, + 0.835, + 0.908, + 0.899, + 0.902, + 0.899, + 0.898, + 0.898, + 0.922, + 0.907, + 0.889, + 0.868, + 0.876, + 0.88, + 0.883, + 0.919, + 0.886, + 0.888, + 0.895, + 0.903, + 0.941, + 0.911, + 0.917, + 0.921, + 0.928, + 0.943, + 0.95, + 0.966, + 0.948, + 0.96, + 0.966, + 0.972, + 1.023, + 0.969, + 1.002, + 1.01, + 1.015, + 1.022, + 1.063, + 1.031, + 1.031, + 1.036, + 1.039, + 1.046, + 1.047, + 1.062, + 1.05, + 1.051, + 1.052, + 1.05, + 1.094, + 1.043, + 1.036, + 1.037 + ], + "reasons": [] +} diff --git a/gallery/orbital-telemetry-watch/sheet.png b/gallery/orbital-telemetry-watch/sheet.png new file mode 100644 index 0000000..2947ff7 Binary files /dev/null and b/gallery/orbital-telemetry-watch/sheet.png differ diff --git a/gallery/orbital-telemetry-watch/sketch.js b/gallery/orbital-telemetry-watch/sketch.js new file mode 100644 index 0000000..734a93a --- /dev/null +++ b/gallery/orbital-telemetry-watch/sketch.js @@ -0,0 +1,116 @@ +// Custom 60fps Ambient Loop: orbital-telemetry-watch — 8s (480 frames) 60fps multi-stage orbital radar HUD +export const meta = { + mode: "ambient", + style: "blueprint-hud", + seconds: 8, + fps: 60, + width: 300, + height: 300, + seed: 204, + palette: "blueprint" +}; + +export function render(ctx, phase, kit) { + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; + const C = kit.palettes[meta.palette] || kit.palettes["blueprint"]; + const TAU = Math.PI * 2; + const cx = W / 2; + const cy = H / 2; + + ctx.fillStyle = C.ground; + ctx.fillRect(0, 0, W, H); + + // Drafting coordinate grid + const step = 25; + for (let x = step; x < W; x += step) { + ctx.strokeStyle = C.line; + ctx.lineWidth = x % 100 === 0 ? 1.2 : 0.6; + ctx.globalAlpha = x % 100 === 0 ? 0.5 : 0.25; + ctx.beginPath(); + ctx.moveTo(x, 0); + ctx.lineTo(x, H); + ctx.stroke(); + } + for (let y = step; y < H; y += step) { + ctx.strokeStyle = C.line; + ctx.lineWidth = y % 100 === 0 ? 1.2 : 0.6; + ctx.globalAlpha = y % 100 === 0 ? 0.5 : 0.25; + ctx.beginPath(); + ctx.moveTo(0, y); + ctx.lineTo(W, y); + ctx.stroke(); + } + + // Outer compass ring & rotating 60fps sweep arm (4 full rotations in 8s) + const outerR = W * 0.38; + ctx.globalAlpha = 0.85; + ctx.strokeStyle = C.muted; + ctx.lineWidth = 1.5; + ctx.beginPath(); + ctx.arc(cx, cy, outerR, 0, TAU); + ctx.stroke(); + + const sweepAng = phase * TAU * 4; + ctx.strokeStyle = C.accent; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(cx, cy); + ctx.lineTo(cx + Math.cos(sweepAng) * outerR, cy + Math.sin(sweepAng) * outerR); + ctx.stroke(); + + // 3 nested elliptical satellite tracks with glowing phase trails + const sats = []; + for (let i = 0; i < 3; i++) { + const rx = W * (0.16 + i * 0.085); + const ry = rx * 0.54; + const tilt = i * 0.95 + Math.sin(TAU * phase) * 0.15; + const speed = i === 1 ? -2 : i + 1; + const a = TAU * (phase * speed + i / 3); + const ox = Math.cos(a) * rx; + const oy = Math.sin(a) * ry; + const sx = cx + ox * Math.cos(tilt) - oy * Math.sin(tilt); + const sy = cy + ox * Math.sin(tilt) + oy * Math.cos(tilt); + sats.push({ x: sx, y: sy }); + + ctx.globalAlpha = 0.26; + ctx.strokeStyle = C.accent; + ctx.lineWidth = 1; + ctx.beginPath(); + for (let s = 0; s <= 40; s++) { + const u = (s / 40) * TAU; + const lx = cx + Math.cos(u) * rx * Math.cos(tilt) - Math.sin(u) * ry * Math.sin(tilt); + const ly = cy + Math.cos(u) * rx * Math.sin(tilt) + Math.sin(u) * ry * Math.cos(tilt); + if (s === 0) ctx.moveTo(lx, ly); + else ctx.lineTo(lx, ly); + } + ctx.stroke(); + + ctx.globalAlpha = 1; + ctx.fillStyle = i === 0 ? C.spark : C.body; + ctx.beginPath(); + ctx.arc(sx, sy, 4.5, 0, TAU); + ctx.fill(); + } + + // Telemetry constellation triangle connecting all 3 satellites + ctx.globalAlpha = 0.65; + ctx.strokeStyle = C.spark; + ctx.lineWidth = 1.4; + ctx.beginPath(); + ctx.moveTo(sats[0].x, sats[0].y); + ctx.lineTo(sats[1].x, sats[1].y); + ctx.lineTo(sats[2].x, sats[2].y); + ctx.closePath(); + ctx.stroke(); + + // HUD readouts + ctx.globalAlpha = 1; + ctx.font = "600 10.5px monospace"; + ctx.fillStyle = C.body; + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillText("ORBIT-HUD // 60FPS", 14, 18); + ctx.fillStyle = C.spark; + ctx.fillText("T+" + (phase * 8).toFixed(1) + "S", 14, H - 16); +} diff --git a/gallery/orbital-telemetry-watch/sources.json b/gallery/orbital-telemetry-watch/sources.json new file mode 100644 index 0000000..3fe0e95 --- /dev/null +++ b/gallery/orbital-telemetry-watch/sources.json @@ -0,0 +1,6 @@ +{ + "pass": true, + "checked": 0, + "citations": [], + "reasons": [] +} diff --git a/gallery/readme-hero-3d/audit.json b/gallery/readme-hero-3d/audit.json new file mode 100644 index 0000000..15700ba --- /dev/null +++ b/gallery/readme-hero-3d/audit.json @@ -0,0 +1,16 @@ +{ + "id": "readme-hero-3d", + "title": "Nebula SDF Sculpture (3D Raymarch)", + "mode": "ambient", + "useCase": "Zero-dependency 3D product showcase & smooth shader sculpture for SaaS hero cards", + "fps": 30, + "pass": true, + "seamScore": 1.061, + "duplicateFrames": 0, + "flickerScore": 0.056, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 822.2, + "webpKB": 332.8, + "totalFrames": 90 +} diff --git a/gallery/readme-hero-3d/brief.json b/gallery/readme-hero-3d/brief.json new file mode 100644 index 0000000..9a776ad --- /dev/null +++ b/gallery/readme-hero-3d/brief.json @@ -0,0 +1,12 @@ +{ + "title": "Nebula SDF Sculpture", + "prompt": "30 fps 3D raymarched smooth-union torus and orbiting spheres in neon nebula lighting.", + "mode": "ambient", + "style": "sdf-raymarch", + "palette": "nebula", + "seconds": 3, + "fps": 30, + "width": 280, + "height": 280, + "seed": 53 +} diff --git a/gallery/readme-hero-3d/index.html b/gallery/readme-hero-3d/index.html new file mode 100644 index 0000000..f8f7815 --- /dev/null +++ b/gallery/readme-hero-3d/index.html @@ -0,0 +1,120 @@ + + + + + + Nebula SDF Sculpture (3D Raymarch) · Loop Studio + + + +
+
+

Nebula SDF Sculpture (3D Raymarch)

+ loading sketch.js... +
+
+
+ +
+
+ + + frame 000 / 120 · phase 0.00 + +
+
+
+ + + \ No newline at end of file diff --git a/gallery/readme-hero-3d/legible.json b/gallery/readme-hero-3d/legible.json new file mode 100644 index 0000000..58322b2 --- /dev/null +++ b/gallery/readme-hero-3d/legible.json @@ -0,0 +1,7 @@ +{ + "pass": true, + "mode": "ambient", + "textElementsChecked": 0, + "captions": [], + "reasons": [] +} diff --git a/gallery/readme-hero-3d/loop.gif b/gallery/readme-hero-3d/loop.gif new file mode 100644 index 0000000..453b09d Binary files /dev/null and b/gallery/readme-hero-3d/loop.gif differ diff --git a/gallery/readme-hero-3d/loop.webp b/gallery/readme-hero-3d/loop.webp new file mode 100644 index 0000000..5ab05a8 Binary files /dev/null and b/gallery/readme-hero-3d/loop.webp differ diff --git a/gallery/readme-hero-3d/poster.png b/gallery/readme-hero-3d/poster.png new file mode 100644 index 0000000..01cf90a Binary files /dev/null and b/gallery/readme-hero-3d/poster.png differ diff --git a/gallery/readme-hero-3d/seam.json b/gallery/readme-hero-3d/seam.json new file mode 100644 index 0000000..f03d96b --- /dev/null +++ b/gallery/readme-hero-3d/seam.json @@ -0,0 +1,105 @@ +{ + "pass": true, + "totalFrames": 90, + "seamScore": 1.061, + "maxSeamScore": 1.5, + "duplicateFrames": 0, + "duplicatePairs": [], + "flickerScore": 0.056, + "maxFlickerScore": 2.5, + "medianStepDelta": 0.129204, + "seamStepDelta": 0.137061, + "normalizedSteps": [ + 1.107, + 1.121, + 1.09, + 1.075, + 1.066, + 1.015, + 0.995, + 0.951, + 0.927, + 0.893, + 0.902, + 0.898, + 0.928, + 0.941, + 0.966, + 0.97, + 1, + 1.037, + 1.048, + 1.034, + 1.034, + 1.024, + 1.037, + 1.029, + 1.037, + 1.047, + 1.055, + 1.047, + 0.992, + 0.981, + 0.941, + 0.933, + 0.919, + 0.915, + 0.938, + 0.94, + 0.973, + 0.964, + 0.964, + 0.953, + 0.987, + 0.976, + 1.002, + 1.029, + 1.051, + 1.037, + 1.072, + 1.081, + 1.093, + 1.083, + 1.045, + 1.037, + 0.953, + 0.903, + 0.924, + 0.993, + 1.064, + 1.077, + 1.029, + 1.014, + 0.994, + 0.998, + 1.01, + 1.022, + 1, + 1.056, + 1.097, + 1.074, + 1.074, + 1.115, + 1.097, + 1.065, + 1.056, + 1.087, + 1.062, + 1.008, + 0.98, + 0.978, + 0.963, + 0.971, + 0.984, + 0.963, + 0.934, + 0.946, + 0.922, + 0.929, + 0.944, + 0.964, + 0.957, + 1.061 + ], + "reasons": [] +} diff --git a/gallery/readme-hero-3d/sheet.png b/gallery/readme-hero-3d/sheet.png new file mode 100644 index 0000000..463b745 Binary files /dev/null and b/gallery/readme-hero-3d/sheet.png differ diff --git a/gallery/readme-hero-3d/sketch.js b/gallery/readme-hero-3d/sketch.js new file mode 100644 index 0000000..60684da --- /dev/null +++ b/gallery/readme-hero-3d/sketch.js @@ -0,0 +1,111 @@ +// Style Pack: sdf-raymarch — Software-safe 3D Signed Distance Field smooth union with specular & rim glow +export const meta = { + mode: "ambient", + style: "sdf-raymarch", + seconds: 3, + fps: 30, + width: 280, + height: 280, + seed: 53, + palette: "nebula" +}; + +function smin(a, b, k) { + const h = Math.max(k - Math.abs(a - b), 0) / k; + return Math.min(a, b) - h * h * k * 0.25; +} + +function sceneSDF(px, py, pz, phase) { + const TAU = Math.PI * 2; + const a1 = phase * TAU; + const c = Math.cos(a1); + const s = Math.sin(a1); + // Rotate torus across two axes + const rx = px * c - pz * s; + const rz = px * s + pz * c; + const ry = py * Math.cos(a1) - rz * Math.sin(a1); + const rz2 = py * Math.sin(a1) + rz * Math.cos(a1); + + const qx = Math.sqrt(rx * rx + rz2 * rz2) - 0.68; + const torus = Math.sqrt(qx * qx + ry * ry) - 0.22; + + // 3 orbiting satellite spheres smoothly blending into the torus + let d = torus; + for (let i = 0; i < 3; i++) { + const ang = a1 * 2 + (i * TAU) / 3; + const sx = Math.cos(ang) * 0.86; + const sy = Math.sin(ang) * 0.86; + const sz = Math.sin(a1 + i * 2.094) * 0.36; + const dx = px - sx; + const dy = py - sy; + const dz = pz - sz; + const sph = Math.sqrt(dx * dx + dy * dy + dz * dz) - 0.24; + d = smin(d, sph, 0.38); + } + return d; +} + +export function render(ctx, phase, kit) { + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; + const C = kit.palettes[meta.palette] || kit.palettes["nebula"]; + + if (ctx.createRadialGradient) { + const bg = ctx.createRadialGradient(W * 0.5, H * 0.5, 10, W * 0.5, H * 0.5, W * 0.65); + bg.addColorStop(0, C.surface); + bg.addColorStop(1, C.ground); + ctx.fillStyle = bg; + } else { + ctx.fillStyle = C.ground; + } + ctx.fillRect(0, 0, W, H); + + const cell = W >= 300 ? 3 : 2; + const eps = 0.02; + + for (let y = 0; y < H; y += cell) { + const uvY = -((y + cell * 0.5) / H - 0.5) * 2.25; + for (let x = 0; x < W; x += cell) { + const uvX = ((x + cell * 0.5) / W - 0.5) * 2.25; + const roZ = 2.75; + const len = Math.sqrt(uvX * uvX + uvY * uvY + 1.85 * 1.85); + const rdX = uvX / len; + const rdY = uvY / len; + const rdZ = -1.85 / len; + + let t = 0; + let hit = false; + for (let step = 0; step < 24; step++) { + const px = rdX * t; + const py = rdY * t; + const pz = roZ + rdZ * t; + const d = sceneSDF(px, py, pz, phase); + if (d < 0.018) { + hit = true; + break; + } + t += d; + if (t > 4.6) break; + } + + if (hit) { + const px = rdX * t; + const py = rdY * t; + const pz = roZ + rdZ * t; + const d0 = sceneSDF(px, py, pz, phase); + const nx = sceneSDF(px + eps, py, pz, phase) - d0; + const ny = sceneSDF(px, py + eps, pz, phase) - d0; + const nz = sceneSDF(px, py, pz + eps, phase) - d0; + const nLen = Math.sqrt(nx * nx + ny * ny + nz * nz) || 1; + const lDot = Math.max(0, (nx * 0.55 + ny * 0.62 + nz * 0.56) / nLen); + const rim = Math.pow(1 - Math.max(0, nz / nLen), 2.2); + const spec = Math.pow(lDot, 8); + + ctx.fillStyle = spec > 0.45 ? C.body : rim > 0.48 ? C.spark : lDot > 0.36 ? C.accent : C.surface; + ctx.globalAlpha = Math.min(1, 0.42 + lDot * 0.58 + rim * 0.32); + ctx.fillRect(x, y, cell, cell); + } + } + } + ctx.globalAlpha = 1; +} diff --git a/gallery/readme-hero-3d/sources.json b/gallery/readme-hero-3d/sources.json new file mode 100644 index 0000000..3fe0e95 --- /dev/null +++ b/gallery/readme-hero-3d/sources.json @@ -0,0 +1,6 @@ +{ + "pass": true, + "checked": 0, + "citations": [], + "reasons": [] +} diff --git a/gallery/retro-crt-loader/audit.json b/gallery/retro-crt-loader/audit.json new file mode 100644 index 0000000..cb54aef --- /dev/null +++ b/gallery/retro-crt-loader/audit.json @@ -0,0 +1,16 @@ +{ + "id": "retro-crt-loader", + "title": "Amber CRT Radar (Bayer Dither)", + "mode": "ambient", + "useCase": "Low-bandwidth terminal/game splash screen & zero-shimmer retro loading indicator", + "fps": 30, + "pass": true, + "seamScore": 1.005, + "duplicateFrames": 0, + "flickerScore": 0.114, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 339.2, + "webpKB": 2418.4, + "totalFrames": 90 +} diff --git a/gallery/retro-crt-loader/brief.json b/gallery/retro-crt-loader/brief.json new file mode 100644 index 0000000..6123d14 --- /dev/null +++ b/gallery/retro-crt-loader/brief.json @@ -0,0 +1,12 @@ +{ + "title": "Amber CRT Radar", + "prompt": "30 fps retro amber CRT sphere and radar sweep using ordered 4x4 Bayer dithering.", + "mode": "ambient", + "style": "dither-mono", + "palette": "amber-crt", + "seconds": 3, + "fps": 30, + "width": 280, + "height": 280, + "seed": 67 +} diff --git a/gallery/retro-crt-loader/index.html b/gallery/retro-crt-loader/index.html new file mode 100644 index 0000000..2b18fce --- /dev/null +++ b/gallery/retro-crt-loader/index.html @@ -0,0 +1,120 @@ + + + + + + Amber CRT Radar (Bayer Dither) · Loop Studio + + + +
+
+

Amber CRT Radar (Bayer Dither)

+ loading sketch.js... +
+
+
+ +
+
+ + + frame 000 / 120 · phase 0.00 + +
+
+
+ + + \ No newline at end of file diff --git a/gallery/retro-crt-loader/legible.json b/gallery/retro-crt-loader/legible.json new file mode 100644 index 0000000..d1ac4b0 --- /dev/null +++ b/gallery/retro-crt-loader/legible.json @@ -0,0 +1,20 @@ +{ + "pass": true, + "mode": "ambient", + "textElementsChecked": 2, + "captions": [ + { + "text": "BAYER-4X4 // SYNC", + "contrastRatio": 15.31, + "minMarginPx": 13, + "passContrast": true + }, + { + "text": "p:0.00", + "contrastRatio": 5.37, + "minMarginPx": 10, + "passContrast": true + } + ], + "reasons": [] +} diff --git a/gallery/retro-crt-loader/loop.gif b/gallery/retro-crt-loader/loop.gif new file mode 100644 index 0000000..8a9644f Binary files /dev/null and b/gallery/retro-crt-loader/loop.gif differ diff --git a/gallery/retro-crt-loader/loop.webp b/gallery/retro-crt-loader/loop.webp new file mode 100644 index 0000000..f905c19 Binary files /dev/null and b/gallery/retro-crt-loader/loop.webp differ diff --git a/gallery/retro-crt-loader/poster.png b/gallery/retro-crt-loader/poster.png new file mode 100644 index 0000000..7c982e2 Binary files /dev/null and b/gallery/retro-crt-loader/poster.png differ diff --git a/gallery/retro-crt-loader/seam.json b/gallery/retro-crt-loader/seam.json new file mode 100644 index 0000000..ec68cc6 --- /dev/null +++ b/gallery/retro-crt-loader/seam.json @@ -0,0 +1,105 @@ +{ + "pass": true, + "totalFrames": 90, + "seamScore": 1.005, + "maxSeamScore": 1.5, + "duplicateFrames": 0, + "duplicatePairs": [], + "flickerScore": 0.114, + "maxFlickerScore": 2.5, + "medianStepDelta": 0.056274, + "seamStepDelta": 0.056544, + "normalizedSteps": [ + 1.026, + 0.928, + 1.034, + 0.958, + 0.933, + 0.988, + 1.045, + 0.984, + 1.101, + 0.988, + 0.999, + 0.944, + 0.983, + 1.061, + 1.034, + 0.983, + 0.985, + 1.051, + 1.037, + 0.994, + 0.991, + 1.024, + 0.925, + 1.053, + 1.012, + 0.907, + 0.994, + 0.991, + 0.966, + 1.024, + 1.023, + 0.945, + 1.028, + 0.986, + 1.022, + 0.976, + 0.978, + 1.05, + 0.988, + 1.015, + 1.024, + 0.978, + 0.982, + 1.034, + 0.998, + 1.009, + 1, + 1.002, + 0.966, + 0.917, + 1.058, + 0.996, + 1.002, + 1.022, + 1.045, + 1.016, + 0.973, + 0.998, + 0.946, + 1.076, + 0.97, + 1.005, + 1.071, + 0.978, + 1.004, + 1.008, + 1.026, + 0.952, + 1.013, + 1.046, + 0.944, + 0.998, + 0.994, + 0.988, + 0.948, + 1.01, + 0.965, + 1.039, + 1.02, + 0.986, + 1.013, + 1.011, + 1.004, + 0.999, + 1.018, + 1.003, + 0.938, + 1.035, + 1.025, + 1.005 + ], + "reasons": [] +} diff --git a/gallery/retro-crt-loader/sheet.png b/gallery/retro-crt-loader/sheet.png new file mode 100644 index 0000000..3efdc1a Binary files /dev/null and b/gallery/retro-crt-loader/sheet.png differ diff --git a/gallery/retro-crt-loader/sketch.js b/gallery/retro-crt-loader/sketch.js new file mode 100644 index 0000000..98b0961 --- /dev/null +++ b/gallery/retro-crt-loader/sketch.js @@ -0,0 +1,70 @@ +// Style Pack: dither-mono — Ordered Bayer 4x4 dithering on a rotating sphere & CRT radar sweep +export const meta = { + mode: "ambient", + style: "dither-mono", + seconds: 3, + fps: 30, + width: 280, + height: 280, + seed: 67, + palette: "amber-crt" +}; + +export function render(ctx, phase, kit) { + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; + const C = kit.palettes[meta.palette] || kit.palettes["amber-crt"]; + const TAU = Math.PI * 2; + + ctx.fillStyle = C.ground; + ctx.fillRect(0, 0, W, H); + + const pixel = W >= 300 ? 4 : 3; + const cols = Math.floor(W / pixel); + const rows = Math.floor(H / pixel); + const lx = Math.cos(TAU * phase); + const ly = Math.sin(TAU * phase); + const lz = 0.65; + const lLen = Math.sqrt(lx * lx + ly * ly + lz * lz); + + for (let gy = 0; gy < rows; gy++) { + const ny = (gy / rows - 0.5) * 2.25; + for (let gx = 0; gx < cols; gx++) { + const nx = (gx / cols - 0.5) * 2.25; + const r2 = nx * nx + ny * ny; + + let lum = 0; + if (r2 < 0.64) { + const nz = Math.sqrt(Math.max(0, 0.64 - r2)); + const dot = Math.max(0, (nx * lx + ny * ly + nz * lz) / (0.8 * lLen)); + const ring = 0.5 + 0.5 * Math.sin(TAU * (phase * 2 - Math.sqrt(r2) * 2.4)); + lum = dot * 0.78 + ring * 0.28; + } else { + const dist = Math.sqrt(r2); + const angle = Math.atan2(ny, nx); + const sweep = 0.5 + 0.5 * Math.sin(angle * 3 - TAU * phase * 2); + const band = Math.max(0, 1 - Math.abs(dist - 0.94) * 6.5); + lum = band * sweep * 0.9; + } + + const threshold = kit.dither.bayer4(gx, gy); + if (lum > threshold + 0.34) { + ctx.fillStyle = C.spark; + ctx.fillRect(gx * pixel, gy * pixel, pixel - 1, pixel - 1); + } else if (lum > threshold) { + ctx.fillStyle = C.accent; + ctx.fillRect(gx * pixel, gy * pixel, pixel - 1, pixel - 1); + } + } + } + + // Subtle CRT corner telemetry stamp + ctx.font = "600 10px monospace"; + ctx.fillStyle = C.spark; + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillText("BAYER-4X4 // SYNC", 14, 18); + ctx.textAlign = "right"; + ctx.fillStyle = C.muted; + ctx.fillText("p:" + phase.toFixed(2), W - 14, H - 16); +} diff --git a/gallery/retro-crt-loader/sources.json b/gallery/retro-crt-loader/sources.json new file mode 100644 index 0000000..3fe0e95 --- /dev/null +++ b/gallery/retro-crt-loader/sources.json @@ -0,0 +1,6 @@ +{ + "pass": true, + "checked": 0, + "citations": [], + "reasons": [] +} diff --git a/gallery/sonar-bathymetry/audit.json b/gallery/sonar-bathymetry/audit.json new file mode 100644 index 0000000..5f4ac88 --- /dev/null +++ b/gallery/sonar-bathymetry/audit.json @@ -0,0 +1,16 @@ +{ + "id": "sonar-bathymetry", + "title": "Abyssal Bathymetry (Topographic Isolines)", + "mode": "ambient", + "useCase": "Geospatial, weather, sonar, and telemetry elevation background loops", + "fps": 30, + "pass": true, + "seamScore": 0.951, + "duplicateFrames": 0, + "flickerScore": 0.051, + "legiblePass": true, + "sourcesPass": true, + "gifKB": 440.8, + "webpKB": 1356.2, + "totalFrames": 90 +} diff --git a/gallery/sonar-bathymetry/brief.json b/gallery/sonar-bathymetry/brief.json new file mode 100644 index 0000000..d61e35e --- /dev/null +++ b/gallery/sonar-bathymetry/brief.json @@ -0,0 +1,12 @@ +{ + "title": "Abyssal Bathymetry", + "prompt": "30 fps animated bathymetric contour isolines over a cyclic scalar noise field.", + "mode": "ambient", + "style": "topographic-contour", + "palette": "abyss", + "seconds": 3, + "fps": 30, + "width": 280, + "height": 280, + "seed": 83 +} diff --git a/gallery/sonar-bathymetry/index.html b/gallery/sonar-bathymetry/index.html new file mode 100644 index 0000000..0ffc9bf --- /dev/null +++ b/gallery/sonar-bathymetry/index.html @@ -0,0 +1,120 @@ + + + + + + Abyssal Bathymetry (Topographic Isolines) · Loop Studio + + + +
+
+

Abyssal Bathymetry (Topographic Isolines)

+ loading sketch.js... +
+
+
+ +
+
+ + + frame 000 / 120 · phase 0.00 + +
+
+
+ + + \ No newline at end of file diff --git a/gallery/sonar-bathymetry/legible.json b/gallery/sonar-bathymetry/legible.json new file mode 100644 index 0000000..58322b2 --- /dev/null +++ b/gallery/sonar-bathymetry/legible.json @@ -0,0 +1,7 @@ +{ + "pass": true, + "mode": "ambient", + "textElementsChecked": 0, + "captions": [], + "reasons": [] +} diff --git a/gallery/sonar-bathymetry/loop.gif b/gallery/sonar-bathymetry/loop.gif new file mode 100644 index 0000000..192a496 Binary files /dev/null and b/gallery/sonar-bathymetry/loop.gif differ diff --git a/gallery/sonar-bathymetry/loop.webp b/gallery/sonar-bathymetry/loop.webp new file mode 100644 index 0000000..74d78d5 Binary files /dev/null and b/gallery/sonar-bathymetry/loop.webp differ diff --git a/gallery/sonar-bathymetry/poster.png b/gallery/sonar-bathymetry/poster.png new file mode 100644 index 0000000..53b0638 Binary files /dev/null and b/gallery/sonar-bathymetry/poster.png differ diff --git a/gallery/sonar-bathymetry/seam.json b/gallery/sonar-bathymetry/seam.json new file mode 100644 index 0000000..1431a79 --- /dev/null +++ b/gallery/sonar-bathymetry/seam.json @@ -0,0 +1,105 @@ +{ + "pass": true, + "totalFrames": 90, + "seamScore": 0.951, + "maxSeamScore": 1.5, + "duplicateFrames": 0, + "duplicatePairs": [], + "flickerScore": 0.051, + "maxFlickerScore": 2.5, + "medianStepDelta": 0.177524, + "seamStepDelta": 0.168777, + "normalizedSteps": [ + 0.944, + 0.944, + 0.935, + 0.982, + 1.002, + 1.012, + 1.032, + 1.067, + 1.086, + 1.099, + 1.101, + 1.083, + 1.077, + 1.06, + 1.057, + 1.062, + 1.045, + 1.06, + 1.052, + 1.009, + 0.999, + 0.938, + 0.909, + 0.882, + 0.867, + 0.901, + 0.88, + 0.9, + 0.884, + 0.91, + 0.902, + 0.907, + 0.913, + 0.964, + 0.977, + 1.004, + 1.004, + 1.01, + 1.001, + 1.024, + 1.061, + 1.051, + 1.023, + 0.969, + 0.962, + 0.976, + 1.011, + 1.016, + 1, + 1.009, + 0.974, + 0.942, + 0.963, + 0.964, + 0.95, + 0.965, + 0.957, + 0.942, + 0.944, + 0.928, + 0.954, + 0.973, + 0.982, + 0.968, + 0.957, + 0.959, + 0.913, + 0.939, + 0.927, + 0.958, + 0.964, + 1.045, + 1.089, + 1.08, + 1.122, + 1.118, + 1.078, + 1.107, + 1.104, + 1.103, + 1.073, + 1.09, + 1.071, + 1.046, + 1.037, + 1.079, + 1.02, + 1.013, + 0.973, + 0.951 + ], + "reasons": [] +} diff --git a/gallery/sonar-bathymetry/sheet.png b/gallery/sonar-bathymetry/sheet.png new file mode 100644 index 0000000..ee37b3c Binary files /dev/null and b/gallery/sonar-bathymetry/sheet.png differ diff --git a/gallery/sonar-bathymetry/sketch.js b/gallery/sonar-bathymetry/sketch.js new file mode 100644 index 0000000..da930e3 --- /dev/null +++ b/gallery/sonar-bathymetry/sketch.js @@ -0,0 +1,75 @@ +// Style Pack: topographic-contour — Cyclic elevation isolines with sonar sweep ticks +export const meta = { + mode: "ambient", + style: "topographic-contour", + seconds: 3, + fps: 30, + width: 280, + height: 280, + seed: 83, + palette: "abyss" +}; + +function field(nx, ny, cx, cy, kit, seed) { + const n1 = kit.noise2D(nx * 2.2 + cx, ny * 2.2 + cy, seed); + const n2 = 0.5 * kit.noise2D(nx * 4.4 - cy, ny * 4.4 + cx, seed + 13); + const r = Math.sqrt((nx - 0.5) * (nx - 0.5) + (ny - 0.5) * (ny - 0.5)); + return (n1 + n2) * 0.5 + (0.5 - r); +} + +export function render(ctx, phase, kit) { + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; + const C = kit.palettes[meta.palette] || kit.palettes["abyss"]; + const TAU = Math.PI * 2; + + ctx.fillStyle = C.ground; + ctx.fillRect(0, 0, W, H); + + const cx = Math.cos(TAU * phase) * 0.72; + const cy = Math.sin(TAU * phase) * 0.72; + const step = W >= 300 ? 4 : 3; + const cols = Math.floor(W / step); + const rows = Math.floor(H / step); + const bands = 9; + + const grid = new Int16Array(cols * rows); + for (let j = 0; j < rows; j++) { + for (let i = 0; i < cols; i++) { + const val = field(i / cols, j / rows, cx, cy, kit, meta.seed); + grid[j * cols + i] = Math.floor((val + 1) * bands); + } + } + + for (let j = 0; j < rows - 1; j++) { + for (let i = 0; i < cols - 1; i++) { + const b = grid[j * cols + i]; + const bR = grid[j * cols + i + 1]; + const bD = grid[(j + 1) * cols + i]; + if (b !== bR || b !== bD) { + const isMajor = ((b % 3) + 3) % 3 === 0; + ctx.fillStyle = isMajor ? C.spark : C.accent; + ctx.globalAlpha = isMajor ? 0.95 : 0.45; + ctx.fillRect(i * step, j * step, isMajor ? step : step - 1, isMajor ? step : step - 1); + } + } + } + + // Subtle rotating bathymetry target ring + const ringR = W * 0.38; + ctx.globalAlpha = 0.25; + ctx.strokeStyle = C.line; + ctx.lineWidth = 1.5; + ctx.beginPath(); + ctx.arc(W / 2, H / 2, ringR, 0, TAU); + ctx.stroke(); + + const ang = phase * TAU; + ctx.globalAlpha = 0.9; + ctx.fillStyle = C.spark; + ctx.beginPath(); + ctx.arc(W / 2 + Math.cos(ang) * ringR, H / 2 + Math.sin(ang) * ringR, 4, 0, TAU); + ctx.fill(); + + ctx.globalAlpha = 1; +} diff --git a/gallery/sonar-bathymetry/sources.json b/gallery/sonar-bathymetry/sources.json new file mode 100644 index 0000000..3fe0e95 --- /dev/null +++ b/gallery/sonar-bathymetry/sources.json @@ -0,0 +1,6 @@ +{ + "pass": true, + "checked": 0, + "citations": [], + "reasons": [] +} diff --git a/rules/AGENTS.md b/rules/AGENTS.md index eab4dc5..4d9df40 100644 --- a/rules/AGENTS.md +++ b/rules/AGENTS.md @@ -66,3 +66,7 @@ Never run a final `loop render` or hand deliverables to the user before running - `loop source-check ` -> verify every `"source"` in `showcase.json` resolves to an existing file and valid line range. - **Cold Read**: Invoke the `loop-cold-reader` subagent (or `loop-cold-read` skill) with *only* `storyboard.png` to confirm an unprimed reader can state what the project does in one sentence matching `showcase.json#says`. - **3-Round Revision Cap**: Repeat the inspect -> revise -> re-check cycle at most **3 rounds**. If any check still fails after Round 3, stop and report the exact failing metric and trade-off to the user. + +## 6. Concise Output + +- Keep user-facing updates and final replies brief (2–5 short lines): state the generated files, `seamScore`, and any key change or blocker. Never print long recaps, repeated status walls, or raw frame-delta arrays. diff --git a/skills/loop-render/SKILL.md b/skills/loop-render/SKILL.md index 7b85fc3..e9b06cf 100644 --- a/skills/loop-render/SKILL.md +++ b/skills/loop-render/SKILL.md @@ -59,15 +59,21 @@ node tool/bin/loop.js audit --repo ### 8. Final Render (`loop render`) Renders all $N$ frames (`0..N-1`) at full resolution and encodes: -- `loop.gif` (or `showcase.gif` in showcase mode) using adaptive 256-color quantization + LZW encoding (or FFmpeg two-pass `palettegen`/`paletteuse` when FFmpeg is installed) +- `loop.gif` (or `showcase.gif` in showcase mode) using adaptive 256-color quantization + LZW encoding (GIF89a frame delays use integer centiseconds, capping reliable browser playback at `50 fps` / `2 cs`) - `poster.png` (Frame `0` at full resolution) -- `loop.mp4` / `showcase.mp4` (`H.264 yuv420p` when FFmpeg is installed) +- `loop.mp4` / `showcase.mp4` (`H.264 yuv420p` at exact requested `fps` — `24`, `30`, `60`, or `120 fps` — via **FFmpeg** or native **macOS AVFoundation**) +- `loop.webp` / `showcase.webp` (24-bit Animated WebP with exact millisecond frame timing at `30–60+ fps` via `cwebp`+`webpmux` or FFmpeg) - `loop.webm` (`VP9` when FFmpeg is installed and `--formats webm` is requested) ```bash -node tool/bin/loop.js render --formats gif,png,mp4 +node tool/bin/loop.js render --fps 60 --formats mp4,webp,gif,png ``` +> [!TIP] +> **Choosing Frame Rates (`> 20 fps`)**: +> - For **GIFs**, use `20`, `25`, `30` (`3 cs` ≈ `33.3 fps`), or `50 fps` (`2 cs`, maximum reliable browser GIF speed). +> - For **true `30 / 60 / 120 fps` smooth video**, pass `--fps 60` with `--formats mp4,webp,png` (MP4 files are typically `4×–10×` smaller than GIFs with zero 256-color banding). + ### 9. Live Interactive Workbench (`loop serve`) Opens an interactive studio in the browser with a frame-exact phase scrubber, live seam-jump bar chart, mobile width toggle, and instant PNG/sheet export: ```bash diff --git a/skills/scenes/flow/template.js b/skills/scenes/flow/template.js index 145bc86..b620fac 100644 --- a/skills/scenes/flow/template.js +++ b/skills/scenes/flow/template.js @@ -1,25 +1,25 @@ -// Scene Pack: flow — Fixed stage boxes with continuous rail handover +// Scene Pack: flow — Visual 4-Stage Studio Pipeline with Live Mini-Canvas, Seam Chart & Rail Handover export const meta = { mode: "showcase", scene: "flow", - seconds: 10, - fps: 24, - width: 800, - height: 320, + seconds: 8, + fps: 60, + width: 640, + height: 288, seed: 11, palette: "studio-dark" }; export const showcase = { says: "Loop Studio turns a one-line request into a checked, seamless loop.", - seconds: 10, + seconds: 8, scene: "flow", stage: ["request", "sketch", "check", "loop.gif"], steps: [ - { from: 8.75, to: 1.25, caption: "a request arrives: \"deep sea, square\"", source: "docs/contract.md:3" }, - { from: 1.25, to: 3.75, caption: "sketch is drawn from the phase", source: "docs/contract.md:14" }, - { from: 3.75, to: 6.25, caption: "seam and legibility are measured", source: "docs/tool.md:14" }, - { from: 6.25, to: 8.75, caption: "the verified loop drops out", source: "docs/tool.md:24" } + { from: 7.0, to: 1.0, caption: "request arrives: \"deep sea, square\"", source: "docs/contract.md:3" }, + { from: 1.0, to: 3.0, caption: "sketch draws from phase", source: "docs/contract.md:14" }, + { from: 3.0, to: 5.0, caption: "seam and contrast measured", source: "docs/tool.md:14" }, + { from: 5.0, to: 7.0, caption: "verified 60fps loop drops out", source: "docs/tool.md:24" } ] }; @@ -27,33 +27,31 @@ function ease(x) { return x <= 0 ? 0 : x >= 1 ? 1 : x * x * (3 - 2 * x); } -// Smooth continuous item travel + slow drift through each node so motion never freezes function placeItem(age, xs, W) { - const left = -0.06 * W; - const right = 1.06 * W; - const pad = 12; + const left = -0.05 * W; + const right = 1.05 * W; let x = left; let alpha = 1; - if (age < 2.5) { - x = left + (xs[0] - left) * ease(age / 2.5); - } else if (age < 5.0) { - const u = (age - 2.5) / 2.5; - x = xs[0] + (xs[1] - xs[0]) * (0.15 * u + 0.85 * ease(u)); - } else if (age < 7.5) { - const u = (age - 5.0) / 2.5; - x = xs[1] + (xs[2] - xs[1]) * (0.15 * u + 0.85 * ease(u)); - } else if (age < 10.0) { - const u = (age - 7.5) / 2.5; - x = xs[2] + (xs[3] - xs[2]) * (0.15 * u + 0.85 * ease(u)); + if (age < 2.0) { + x = left + (xs[0] - left) * ease(age / 2.0); + } else if (age < 4.0) { + const u = (age - 2.0) / 2.0; + x = xs[0] + (xs[1] - xs[0]) * (0.18 * u + 0.82 * ease(u)); + } else if (age < 6.0) { + const u = (age - 4.0) / 2.0; + x = xs[1] + (xs[2] - xs[1]) * (0.18 * u + 0.82 * ease(u)); + } else if (age < 8.0) { + const u = (age - 6.0) / 2.0; + x = xs[2] + (xs[3] - xs[2]) * (0.18 * u + 0.82 * ease(u)); } else { - const e = ease((age - 10.0) / 1.25); - x = xs[3] + (right - xs[3] + pad) * e; + const e = ease((age - 8.0) / 1.0); + x = xs[3] + (right - xs[3]) * e; alpha = 1 - e; } return { x, alpha, - checked: ease((age - 6.8) / 0.8) + checked: ease((age - 5.2) / 0.65) }; } @@ -67,102 +65,289 @@ export function render(ctx, phase, kit) { const SECONDS = S.seconds || meta.seconds; const t = phase * SECONDS; const TAU = Math.PI * 2; + const cyan = "#00E5B0"; + // 1. Depth Layer 1: Radial gradient ground + harmonic wave dot lattice ctx.globalAlpha = 1; - ctx.fillStyle = C.ground; + if (ctx.createRadialGradient) { + const bgGrad = ctx.createRadialGradient(W * 0.5, H * 0.42, 20, W * 0.5, H * 0.5, W * 0.65); + bgGrad.addColorStop(0, "#131930"); + bgGrad.addColorStop(1, C.ground); + ctx.fillStyle = bgGrad; + } else { + ctx.fillStyle = C.ground; + } ctx.fillRect(0, 0, W, H); - const count = labels.length; - const margin = W * 0.055; - const gap = W * 0.032; - const bw = Math.min(W * 0.195, (W - 2 * margin - (count - 1) * gap) / count); - const bh = Math.round(H * 0.17); - const totalW = count * bw + (count - 1) * gap; - const x0 = (W - totalW) / 2; - const by = Math.round(H * 0.29); - const railY = Math.round(H * 0.58); - const capY = Math.round(H * 0.84); - - const xs = labels.map((_, i) => x0 + i * (bw + gap) + bw / 2); - const items = [placeItem(t + 1.25, xs, W)]; - if (t >= 8.75) items.push(placeItem(t - 8.75, xs, W)); - - // Transport rail + subtle travelling carrier ticks (keeps frame-to-frame delta steady) + const gCols = 20; + const gRows = 9; + const cellW = W / gCols; + const cellH = H / gRows; + for (let r = 0; r < gRows; r++) { + for (let c = 0; c < gCols; c++) { + const gx = (c + 0.5) * cellW; + const gy = (r + 0.5) * cellH; + const dx = (gx - W * 0.5) / (W * 0.5); + const dy = (gy - H * 0.42) / (H * 0.5); + const dist = Math.sqrt(dx * dx + dy * dy); + const wave = 0.5 + 0.5 * Math.sin(TAU * (phase - dist * 1.2)); + ctx.globalAlpha = 0.08 + 0.16 * wave; + ctx.fillStyle = wave > 0.72 ? C.spark : C.line; + ctx.beginPath(); + ctx.arc(gx, gy, 1.2 + 1.4 * wave, 0, TAU); + ctx.fill(); + } + } + + // 2. Depth Layer 2: 4 Visual Studio Stage Cards + const count = 4; + const margin = W * 0.042; + const gap = W * 0.024; + const bw = (W - 2 * margin - (count - 1) * gap) / count; + const bh = Math.round(H * 0.48); + const by = Math.round(H * 0.30); + const railY = Math.round(H * 0.68); + const capY = Math.round(H * 0.87); + + const xs = [0, 1, 2, 3].map((i) => margin + i * (bw + gap) + bw / 2); + const items = [placeItem(t + 1.0, xs, W)]; + if (t >= 7.0) items.push(placeItem(t - 7.0, xs, W)); + + // Transport rail + glowing carrier stream ctx.globalAlpha = 1; ctx.strokeStyle = C.line; - ctx.lineWidth = 2; + ctx.lineWidth = 2.5; ctx.beginPath(); ctx.moveTo(0, railY); ctx.lineTo(W, railY); ctx.stroke(); - const tickCount = 16; - const tickSpacing = W / tickCount; - const tickShift = (phase * 4 * tickSpacing) % tickSpacing; - ctx.fillStyle = C.muted; - ctx.globalAlpha = 0.35; - for (let i = 0; i <= tickCount; i++) { - const tx = i * tickSpacing + tickShift; - ctx.fillRect(tx - 2, railY - 2, 4, 4); + const streamCount = 18; + const streamSpace = W / streamCount; + const streamShift = (phase * 3 * streamSpace) % streamSpace; + for (let i = 0; i <= streamCount; i++) { + const sx = i * streamSpace + streamShift; + ctx.globalAlpha = 0.45; + ctx.fillStyle = i % 2 === 0 ? C.spark : C.accent; + ctx.beginPath(); + ctx.arc(sx, railY, 2.2, 0, TAU); + ctx.fill(); } - // Stage boxes & vertical stems - ctx.font = "600 13px monospace"; - ctx.textAlign = "center"; - ctx.textBaseline = "middle"; + const stepHeaders = ["01", "02", "03", "04"]; xs.forEach((cx, i) => { let near = 0; items.forEach((it) => { - near = Math.max(near, it.alpha * Math.max(0, 1 - Math.abs(it.x - cx) / (bw * 0.75))); + near = Math.max(near, it.alpha * Math.max(0, 1 - Math.abs(it.x - cx) / (bw * 0.78))); }); + const cardLeft = cx - bw / 2; + const cardTop = by - bh / 2; + const activeColor = i === 2 ? cyan : i === 3 ? C.spark : C.accent; + + // Vertical connector stem from card to rail ctx.globalAlpha = 1; - ctx.strokeStyle = near > 0.3 ? C.accent : C.line; - ctx.lineWidth = 2; + ctx.strokeStyle = near > 0.25 ? activeColor : C.line; + ctx.lineWidth = near > 0.25 ? 2.5 : 1.5; ctx.beginPath(); - ctx.moveTo(cx, by + bh / 2); + ctx.moveTo(cx, cardTop + bh); ctx.lineTo(cx, railY); ctx.stroke(); - kit.roundRect(ctx, cx - bw / 2, by - bh / 2, bw, bh, 8); - ctx.globalAlpha = 1; + // Node socket on rail + ctx.fillStyle = near > 0.25 ? activeColor : C.surface; + ctx.beginPath(); + ctx.arc(cx, railY, 4.5, 0, TAU); + ctx.fill(); + ctx.strokeStyle = activeColor; + ctx.lineWidth = 1.5; + ctx.stroke(); + + // Card surface + kit.roundRect(ctx, cardLeft, cardTop, bw, bh, 10); + ctx.globalAlpha = 0.96; ctx.fillStyle = C.surface; ctx.fill(); - if (near > 0.01) { - ctx.globalAlpha = 0.22 * near; - ctx.fillStyle = i >= 2 ? C.spark : C.accent; + // Subtle active header tint + if (near > 0.02) { + ctx.globalAlpha = 0.16 * near; + ctx.fillStyle = activeColor; ctx.fill(); } ctx.globalAlpha = 1; + ctx.strokeStyle = near > 0.15 ? activeColor : C.line; + ctx.lineWidth = near > 0.15 ? 2.2 : 1.4; + ctx.stroke(); + + // Card header bar divider + const headH = Math.round(bh * 0.24); ctx.strokeStyle = C.line; - ctx.lineWidth = 1.5; + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.moveTo(cardLeft + 1, cardTop + headH); + ctx.lineTo(cardLeft + bw - 1, cardTop + headH); ctx.stroke(); - if (near > 0.01) { - ctx.globalAlpha = near; - ctx.strokeStyle = i >= 2 ? C.spark : C.accent; + // Card header step badge + primary stage label + ctx.font = "700 10.5px monospace"; + ctx.fillStyle = activeColor; + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillText(stepHeaders[i], cardLeft + 10, cardTop + headH * 0.5); + + ctx.font = "700 11.5px monospace"; + ctx.fillStyle = C.body; + ctx.textAlign = "right"; + ctx.fillText(labels[i], cardLeft + bw - 10, cardTop + headH * 0.5); + + // Rich visual interior per stage card! + const innerY = cardTop + headH + (bh - headH) * 0.5; + + if (i === 0) { + // Card 1: Prompt lines + live rotating Phase Ring (0 -> 1) + const ringX = cardLeft + bw * 0.25; + const ringR = Math.min(bw, bh) * 0.155; + ctx.strokeStyle = C.line; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.arc(ringX, innerY, ringR, 0, TAU); + ctx.stroke(); + + const pAng = phase * TAU - Math.PI / 2; + ctx.strokeStyle = C.accent; + ctx.lineWidth = 2.5; + ctx.beginPath(); + ctx.arc(ringX, innerY, ringR, pAng - 1.8, pAng); + ctx.stroke(); + + ctx.fillStyle = C.spark; + ctx.beginPath(); + ctx.arc(ringX + Math.cos(pAng) * ringR, innerY + Math.sin(pAng) * ringR, 3.4, 0, TAU); + ctx.fill(); + + // Prompt spec labels on right half of Card 1 + const tx0 = cardLeft + bw * 0.45; + ctx.font = "500 9.5px monospace"; + ctx.fillStyle = C.muted; + ctx.textAlign = "left"; + ctx.fillText("8s · 60fps", tx0, innerY - 14); + ctx.fillStyle = C.body; + ctx.fillText("phase 0→1", tx0, innerY + 2); + ctx.fillStyle = cyan; + ctx.fillText("seed: 7", tx0, innerY + 18); + } else if (i === 1) { + // Card 2: Live Miniature Bioluminescent Particle-Orbit Sketch Viewport! + const vpW = bw - 20; + const vpH = bh - headH - 16; + const vpX = cardLeft + 10; + const vpY = cardTop + headH + 8; + kit.roundRect(ctx, vpX, vpY, vpW, vpH, 6); + ctx.fillStyle = "#060913"; + ctx.fill(); + + // 2 nested glowing orbits inside mini canvas + for (let ring = 1; ring <= 2; ring++) { + const rx = vpW * (0.18 * ring); + const ry = vpH * (0.21 * ring); + const dots = 6 + ring * 4; + const dir = ring === 1 ? 1 : -2; + for (let d = 0; d < dots; d++) { + const a = TAU * ((phase * dir + d / dots) % 1); + const px = cx + Math.cos(a) * rx; + const py = innerY + Math.sin(a) * ry; + ctx.globalAlpha = 0.45 + 0.55 * (0.5 + 0.5 * Math.sin(a)); + ctx.fillStyle = d % 3 === 0 ? cyan : d % 2 === 0 ? C.spark : C.accent; + ctx.beginPath(); + ctx.arc(px, py, d % 3 === 0 ? 3.2 : 2.2, 0, TAU); + ctx.fill(); + } + } + ctx.globalAlpha = 1; + ctx.fillStyle = cyan; + ctx.beginPath(); + ctx.arc(cx, innerY, 4.5 + 1.5 * Math.sin(TAU * phase * 2), 0, TAU); + ctx.fill(); + } else if (i === 2) { + // Card 3: Live Seam Check Bar Chart (1.02x PASS) + const bars = [1.0, 0.94, 1.05, 0.98, 1.02, 0.96, 1.04, 0.99, 1.03]; + const chartLeft = cardLeft + 14; + const chartBase = cardTop + bh - 14; + const barStep = (bw - 28) / bars.length; + const unitH = (bh - headH - 36) * 0.55; + + bars.forEach((v, bIdx) => { + const isLast = bIdx === bars.length - 1; + const wave = 1 + 0.08 * Math.sin(TAU * (phase * 2 - bIdx / bars.length)); + const hBar = v * unitH * wave; + ctx.globalAlpha = isLast ? 1 : 0.65; + ctx.fillStyle = isLast ? cyan : C.spark; + ctx.fillRect(chartLeft + bIdx * barStep, chartBase - hBar, Math.max(4, barStep - 4), hBar); + }); + + // Median 1.0x reference line + ctx.globalAlpha = 0.9; + ctx.strokeStyle = C.accent; + ctx.lineWidth = 1.2; + ctx.beginPath(); + ctx.moveTo(chartLeft, chartBase - unitH); + ctx.lineTo(cardLeft + bw - 14, chartBase - unitH); + ctx.stroke(); + + ctx.globalAlpha = 1; + ctx.font = "600 10px monospace"; + ctx.fillStyle = cyan; + ctx.textAlign = "left"; + ctx.fillText("1.02x PASS", chartLeft, cardTop + headH + 14); + } else if (i === 3) { + // Card 4: Verified Infinite Loop Lissajous Figure + Format Badges + const lissY = innerY - 8; + const rx = bw * 0.30; + const ry = (bh - headH) * 0.24; + ctx.strokeStyle = C.spark; ctx.lineWidth = 2.2; + ctx.beginPath(); + for (let s = 0; s <= 40; s++) { + const u = (s / 40) * TAU; + const lx = cx + Math.sin(u) * rx; + const ly = lissY + Math.sin(u * 2) * ry; + if (s === 0) ctx.moveTo(lx, ly); + else ctx.lineTo(lx, ly); + } ctx.stroke(); - } - ctx.globalAlpha = 1; - ctx.fillStyle = C.body; - ctx.fillText(labels[i], cx, by); + // Travelling spark along the infinity loop + const sparkU = phase * TAU; + const sx = cx + Math.sin(sparkU) * rx; + const sy = lissY + Math.sin(sparkU * 2) * ry; + ctx.fillStyle = cyan; + ctx.beginPath(); + ctx.arc(sx, sy, 4.5, 0, TAU); + ctx.fill(); + + ctx.font = "600 10px monospace"; + ctx.fillStyle = C.body; + ctx.textAlign = "center"; + ctx.fillText("GIF · MP4 · PNG", cx, cardTop + bh - 14); + } }); - // Moving payload orbs along rail + // 3. Depth Layer 3: Moving payload orbs along the transport rail items.forEach((it) => { - const r = Math.max(7, Math.round(H * 0.036)); - const pulse = 1 + 0.15 * Math.sin(TAU * phase * 2); - ctx.globalAlpha = it.alpha * 0.26; - ctx.fillStyle = it.checked > 0.5 ? C.spark : C.accent; + const r = Math.max(8, Math.round(H * 0.036)); + const pulse = 1 + 0.16 * Math.sin(TAU * phase * 2); + const col = it.checked > 0.5 ? cyan : C.accent; + + // Outer glow halo + ctx.globalAlpha = it.alpha * 0.28; + ctx.fillStyle = col; ctx.beginPath(); - ctx.arc(it.x, railY, r * 1.45 * pulse, 0, TAU); + ctx.arc(it.x, railY, r * 1.65 * pulse, 0, TAU); ctx.fill(); + // Inner orb ctx.globalAlpha = it.alpha; ctx.fillStyle = C.accent; ctx.beginPath(); @@ -171,32 +356,49 @@ export function render(ctx, phase, kit) { if (it.checked > 0) { ctx.globalAlpha = it.alpha * it.checked; - ctx.fillStyle = C.spark; + ctx.fillStyle = cyan; ctx.beginPath(); ctx.arc(it.x, railY, r, 0, TAU); ctx.fill(); ctx.strokeStyle = C.ground; - ctx.lineWidth = 2; + ctx.lineWidth = 2.2; ctx.beginPath(); ctx.moveTo(it.x - r * 0.42, railY); - ctx.lineTo(it.x - r * 0.1, railY + r * 0.35); - ctx.lineTo(it.x + r * 0.48, railY - r * 0.35); + ctx.lineTo(it.x - r * 0.08, railY + r * 0.36); + ctx.lineTo(it.x + r * 0.48, railY - r * 0.36); ctx.stroke(); } }); - // Caption bar at bottom (fixed pill + smooth text fade) - const pillW = Math.round(W * 0.62); - kit.roundRect(ctx, W / 2 - pillW / 2, capY - 16, pillW, 32, 6); - ctx.globalAlpha = 0.95; + // 4. Bottom Caption Pill + Step Progress Dots + const pillW = Math.round(W * 0.74); + const pillH = 34; + kit.roundRect(ctx, W / 2 - pillW / 2, capY - pillH / 2, pillW, pillH, 8); + ctx.globalAlpha = 0.96; ctx.fillStyle = C.surface; ctx.fill(); ctx.strokeStyle = C.line; - ctx.lineWidth = 1; + ctx.lineWidth = 1.5; ctx.stroke(); - ctx.font = "500 13px monospace"; + let activeStepIdx = 0; + steps.forEach((c, idx) => { + const len = ((c.to - c.from) % SECONDS + SECONDS) % SECONDS || SECONDS; + const u = ((t - c.from) % SECONDS + SECONDS) % SECONDS; + if (u < len) activeStepIdx = idx; + }); + + // Step indicator dots on left of pill + for (let d = 0; d < steps.length; d++) { + ctx.globalAlpha = 1; + ctx.fillStyle = d === activeStepIdx ? cyan : C.line; + ctx.beginPath(); + ctx.arc(W / 2 - pillW / 2 + 16 + d * 10, capY, d === activeStepIdx ? 3.5 : 2.5, 0, TAU); + ctx.fill(); + } + + ctx.font = "500 12px monospace"; ctx.textAlign = "center"; ctx.textBaseline = "middle"; @@ -204,10 +406,10 @@ export function render(ctx, phase, kit) { const len = ((c.to - c.from) % SECONDS + SECONDS) % SECONDS || SECONDS; const u = ((t - c.from) % SECONDS + SECONDS) % SECONDS; if (u >= len) return; - const fade = Math.max(0.2, Math.min(1, u / 0.35, (len - u) / 0.35)); + const fade = Math.max(0.25, Math.min(1, u / 0.35, (len - u) / 0.35)); ctx.globalAlpha = fade; ctx.fillStyle = C.body; - ctx.fillText(c.caption, W / 2, capY); + ctx.fillText(c.caption, W / 2 + 22, capY); }); ctx.globalAlpha = 1; diff --git a/skills/styles/dither-mono/template.js b/skills/styles/dither-mono/template.js index 0779dfd..f13d1dd 100644 --- a/skills/styles/dither-mono/template.js +++ b/skills/styles/dither-mono/template.js @@ -1,25 +1,25 @@ -// Style Pack: dither-mono — Ordered Bayer 4x4 dithering on a rotating torus & sphere +// Style Pack: dither-mono — Ordered Bayer 4x4 dithering on a rotating sphere & CRT radar sweep export const meta = { mode: "ambient", style: "dither-mono", seconds: 4, - fps: 24, - width: 360, - height: 360, + fps: 30, + width: 320, + height: 320, seed: 67, - palette: "phosphor" + palette: "amber-crt" }; export function render(ctx, phase, kit) { - const W = meta.width; - const H = meta.height; - const C = kit.palettes[meta.palette] || kit.palettes["phosphor"]; + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; + const C = kit.palettes[meta.palette] || kit.palettes["amber-crt"]; const TAU = Math.PI * 2; ctx.fillStyle = C.ground; ctx.fillRect(0, 0, W, H); - const pixel = 4; + const pixel = W >= 300 ? 4 : 3; const cols = Math.floor(W / pixel); const rows = Math.floor(H / pixel); const lx = Math.cos(TAU * phase); @@ -28,29 +28,27 @@ export function render(ctx, phase, kit) { const lLen = Math.sqrt(lx * lx + ly * ly + lz * lz); for (let gy = 0; gy < rows; gy++) { - const ny = (gy / rows - 0.5) * 2.2; + const ny = (gy / rows - 0.5) * 2.25; for (let gx = 0; gx < cols; gx++) { - const nx = (gx / cols - 0.5) * 2.2; + const nx = (gx / cols - 0.5) * 2.25; const r2 = nx * nx + ny * ny; let lum = 0; - if (r2 < 0.72) { - // Central lit sphere + latitude wave bands - const nz = Math.sqrt(Math.max(0, 0.72 - r2)); - const dot = Math.max(0, (nx * lx + ny * ly + nz * lz) / (0.85 * lLen)); - const ring = 0.5 + 0.5 * Math.sin(TAU * (phase * 2 - Math.sqrt(r2) * 2.2)); - lum = dot * 0.78 + ring * 0.25; + if (r2 < 0.64) { + const nz = Math.sqrt(Math.max(0, 0.64 - r2)); + const dot = Math.max(0, (nx * lx + ny * ly + nz * lz) / (0.8 * lLen)); + const ring = 0.5 + 0.5 * Math.sin(TAU * (phase * 2 - Math.sqrt(r2) * 2.4)); + lum = dot * 0.78 + ring * 0.28; } else { - // Outer orbital radar rings const dist = Math.sqrt(r2); const angle = Math.atan2(ny, nx); const sweep = 0.5 + 0.5 * Math.sin(angle * 3 - TAU * phase * 2); - const band = Math.max(0, 1 - Math.abs(dist - 0.96) * 7.5); - lum = band * sweep * 0.85; + const band = Math.max(0, 1 - Math.abs(dist - 0.94) * 6.5); + lum = band * sweep * 0.9; } const threshold = kit.dither.bayer4(gx, gy); - if (lum > threshold + 0.35) { + if (lum > threshold + 0.34) { ctx.fillStyle = C.spark; ctx.fillRect(gx * pixel, gy * pixel, pixel - 1, pixel - 1); } else if (lum > threshold) { @@ -59,4 +57,14 @@ export function render(ctx, phase, kit) { } } } + + // Subtle CRT corner telemetry stamp + ctx.font = "600 10px monospace"; + ctx.fillStyle = C.spark; + ctx.textAlign = "left"; + ctx.textBaseline = "middle"; + ctx.fillText("BAYER-4X4 // SYNC", 14, 18); + ctx.textAlign = "right"; + ctx.fillStyle = C.muted; + ctx.fillText("p:" + phase.toFixed(2), W - 14, H - 16); } diff --git a/skills/styles/kinetic-type/template.js b/skills/styles/kinetic-type/template.js index ee13a10..9943f2d 100644 --- a/skills/styles/kinetic-type/template.js +++ b/skills/styles/kinetic-type/template.js @@ -1,19 +1,19 @@ -// Style Pack: kinetic-type — Harmonic wave typography poster +// Style Pack: kinetic-type — Silky 60fps harmonic wave typography poster export const meta = { mode: "ambient", style: "kinetic-type", - seconds: 4, - fps: 24, - width: 400, - height: 400, + seconds: 2, + fps: 60, + width: 320, + height: 320, seed: 61, palette: "editorial", word: "PHASE 0→1" }; export function render(ctx, phase, kit) { - const W = meta.width; - const H = meta.height; + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; const C = kit.palettes[meta.palette] || kit.palettes["editorial"]; const TAU = Math.PI * 2; const word = meta.word || "LOOP STUDIO"; @@ -22,7 +22,7 @@ export function render(ctx, phase, kit) { ctx.fillRect(0, 0, W, H); const rows = 9; - const rowH = (H - 56) / rows; + const rowH = (H - 44) / rows; ctx.textAlign = "center"; ctx.textBaseline = "middle"; @@ -30,22 +30,22 @@ export function render(ctx, phase, kit) { const isCenter = r === Math.floor(rows / 2); const dist = Math.abs(r - Math.floor(rows / 2)); const wave = Math.sin(TAU * (phase - r / rows)); - const x = W / 2 + wave * (isCenter ? 14 : 46); - const y = 28 + (r + 0.5) * rowH; + const x = W / 2 + wave * (isCenter ? 10 : 38); + const y = 22 + (r + 0.5) * rowH; - // Background band pill - const pillW = W * (0.68 + 0.16 * (0.5 + 0.5 * Math.cos(TAU * (phase + r / rows)))); - kit.roundRect(ctx, x - pillW / 2, y - rowH * 0.38, pillW, rowH * 0.76, 6); - ctx.globalAlpha = isCenter ? 0.95 : 0.25 + 0.45 * (1 - dist / rows); - ctx.fillStyle = isCenter ? C.accent : C.surface; + const pillW = W * (0.68 + 0.14 * (0.5 + 0.5 * Math.cos(TAU * (phase + r / rows)))); + kit.roundRect(ctx, x - pillW / 2, y - rowH * 0.37, pillW, rowH * 0.74, 6); + ctx.globalAlpha = isCenter ? 0.98 : 0.3 + 0.45 * (1 - dist / rows); + ctx.fillStyle = isCenter ? C.spark : C.surface; ctx.fill(); - ctx.strokeStyle = isCenter ? C.spark : C.line; + ctx.strokeStyle = isCenter ? C.accent : C.line; ctx.lineWidth = isCenter ? 2 : 1; ctx.stroke(); - ctx.font = (isCenter ? "700 18px" : "600 15px") + " monospace"; - ctx.globalAlpha = isCenter ? 1 : 0.45 + 0.5 * (0.5 + 0.5 * wave); - ctx.fillStyle = isCenter ? C.body : r % 2 === 0 ? C.spark : C.body; + const fontPx = Math.max(10, Math.round(W * (isCenter ? 0.044 : 0.036))); + ctx.font = (isCenter ? "700 " : "600 ") + fontPx + "px monospace"; + ctx.globalAlpha = isCenter ? 1 : 0.5 + 0.5 * (0.5 + 0.5 * wave); + ctx.fillStyle = isCenter ? C.ground : r % 2 === 0 ? C.accent : C.body; ctx.fillText(word, x, y); } diff --git a/skills/styles/sdf-raymarch/template.js b/skills/styles/sdf-raymarch/template.js index 2d28ef0..e891ecd 100644 --- a/skills/styles/sdf-raymarch/template.js +++ b/skills/styles/sdf-raymarch/template.js @@ -1,11 +1,11 @@ -// Style Pack: sdf-raymarch — Software-safe 3D Signed Distance Field smooth union +// Style Pack: sdf-raymarch — Software-safe 3D Signed Distance Field smooth union with specular & rim glow export const meta = { mode: "ambient", style: "sdf-raymarch", seconds: 4, - fps: 24, - width: 360, - height: 360, + fps: 30, + width: 320, + height: 320, seed: 53, palette: "nebula" }; @@ -20,65 +20,72 @@ function sceneSDF(px, py, pz, phase) { const a1 = phase * TAU; const c = Math.cos(a1); const s = Math.sin(a1); - // Rotate point for torus + // Rotate torus across two axes const rx = px * c - pz * s; const rz = px * s + pz * c; const ry = py * Math.cos(a1) - rz * Math.sin(a1); const rz2 = py * Math.sin(a1) + rz * Math.cos(a1); - const qx = Math.sqrt(rx * rx + rz2 * rz2) - 0.72; - const torus = Math.sqrt(qx * qx + ry * ry) - 0.24; + const qx = Math.sqrt(rx * rx + rz2 * rz2) - 0.68; + const torus = Math.sqrt(qx * qx + ry * ry) - 0.22; - // 3 orbiting spheres + // 3 orbiting satellite spheres smoothly blending into the torus let d = torus; for (let i = 0; i < 3; i++) { const ang = a1 * 2 + (i * TAU) / 3; - const sx = Math.cos(ang) * 0.88; - const sy = Math.sin(ang) * 0.88; - const sz = Math.sin(a1 + i * 2.1) * 0.35; + const sx = Math.cos(ang) * 0.86; + const sy = Math.sin(ang) * 0.86; + const sz = Math.sin(a1 + i * 2.094) * 0.36; const dx = px - sx; const dy = py - sy; const dz = pz - sz; - const sph = Math.sqrt(dx * dx + dy * dy + dz * dz) - 0.26; - d = smin(d, sph, 0.35); + const sph = Math.sqrt(dx * dx + dy * dy + dz * dz) - 0.24; + d = smin(d, sph, 0.38); } return d; } export function render(ctx, phase, kit) { - const W = meta.width; - const H = meta.height; + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; const C = kit.palettes[meta.palette] || kit.palettes["nebula"]; - ctx.fillStyle = C.ground; + if (ctx.createRadialGradient) { + const bg = ctx.createRadialGradient(W * 0.5, H * 0.5, 10, W * 0.5, H * 0.5, W * 0.65); + bg.addColorStop(0, C.surface); + bg.addColorStop(1, C.ground); + ctx.fillStyle = bg; + } else { + ctx.fillStyle = C.ground; + } ctx.fillRect(0, 0, W, H); - const cell = 5; + const cell = W >= 300 ? 3 : 2; const eps = 0.02; for (let y = 0; y < H; y += cell) { - const uvY = -((y + cell * 0.5) / H - 0.5) * 2.2; + const uvY = -((y + cell * 0.5) / H - 0.5) * 2.25; for (let x = 0; x < W; x += cell) { - const uvX = ((x + cell * 0.5) / W - 0.5) * 2.2; - const roZ = 2.8; - const len = Math.sqrt(uvX * uvX + uvY * uvY + 1.8 * 1.8); + const uvX = ((x + cell * 0.5) / W - 0.5) * 2.25; + const roZ = 2.75; + const len = Math.sqrt(uvX * uvX + uvY * uvY + 1.85 * 1.85); const rdX = uvX / len; const rdY = uvY / len; - const rdZ = -1.8 / len; + const rdZ = -1.85 / len; let t = 0; let hit = false; - for (let step = 0; step < 22; step++) { + for (let step = 0; step < 24; step++) { const px = rdX * t; const py = rdY * t; const pz = roZ + rdZ * t; const d = sceneSDF(px, py, pz, phase); - if (d < 0.02) { + if (d < 0.018) { hit = true; break; } t += d; - if (t > 4.8) break; + if (t > 4.6) break; } if (hit) { @@ -90,11 +97,12 @@ export function render(ctx, phase, kit) { const ny = sceneSDF(px, py + eps, pz, phase) - d0; const nz = sceneSDF(px, py, pz + eps, phase) - d0; const nLen = Math.sqrt(nx * nx + ny * ny + nz * nz) || 1; - const lDot = Math.max(0, (nx * 0.57 + ny * 0.57 + nz * 0.57) / nLen); - const rim = Math.pow(1 - Math.max(0, nz / nLen), 2); + const lDot = Math.max(0, (nx * 0.55 + ny * 0.62 + nz * 0.56) / nLen); + const rim = Math.pow(1 - Math.max(0, nz / nLen), 2.2); + const spec = Math.pow(lDot, 8); - ctx.fillStyle = rim > 0.55 ? C.spark : lDot > 0.48 ? C.accent : C.surface; - ctx.globalAlpha = Math.min(1, 0.35 + lDot * 0.65 + rim * 0.35); + ctx.fillStyle = spec > 0.45 ? C.body : rim > 0.48 ? C.spark : lDot > 0.36 ? C.accent : C.surface; + ctx.globalAlpha = Math.min(1, 0.42 + lDot * 0.58 + rim * 0.32); ctx.fillRect(x, y, cell, cell); } } diff --git a/skills/styles/topographic-contour/template.js b/skills/styles/topographic-contour/template.js index bd6f376..4cfd398 100644 --- a/skills/styles/topographic-contour/template.js +++ b/skills/styles/topographic-contour/template.js @@ -1,11 +1,11 @@ -// Style Pack: topographic-contour — Cyclic elevation isolines +// Style Pack: topographic-contour — Cyclic elevation isolines with sonar sweep ticks export const meta = { mode: "ambient", style: "topographic-contour", seconds: 4, - fps: 24, - width: 360, - height: 360, + fps: 30, + width: 320, + height: 320, seed: 83, palette: "abyss" }; @@ -18,8 +18,8 @@ function field(nx, ny, cx, cy, kit, seed) { } export function render(ctx, phase, kit) { - const W = meta.width; - const H = meta.height; + const W = ctx.width || meta.width; + const H = ctx.height || meta.height; const C = kit.palettes[meta.palette] || kit.palettes["abyss"]; const TAU = Math.PI * 2; @@ -28,7 +28,7 @@ export function render(ctx, phase, kit) { const cx = Math.cos(TAU * phase) * 0.72; const cy = Math.sin(TAU * phase) * 0.72; - const step = 4; + const step = W >= 300 ? 4 : 3; const cols = Math.floor(W / step); const rows = Math.floor(H / step); const bands = 9; @@ -49,10 +49,27 @@ export function render(ctx, phase, kit) { if (b !== bR || b !== bD) { const isMajor = ((b % 3) + 3) % 3 === 0; ctx.fillStyle = isMajor ? C.spark : C.accent; - ctx.globalAlpha = isMajor ? 0.95 : 0.48; + ctx.globalAlpha = isMajor ? 0.95 : 0.45; ctx.fillRect(i * step, j * step, isMajor ? step : step - 1, isMajor ? step : step - 1); } } } + + // Subtle rotating bathymetry target ring + const ringR = W * 0.38; + ctx.globalAlpha = 0.25; + ctx.strokeStyle = C.line; + ctx.lineWidth = 1.5; + ctx.beginPath(); + ctx.arc(W / 2, H / 2, ringR, 0, TAU); + ctx.stroke(); + + const ang = phase * TAU; + ctx.globalAlpha = 0.9; + ctx.fillStyle = C.spark; + ctx.beginPath(); + ctx.arc(W / 2 + Math.cos(ang) * ringR, H / 2 + Math.sin(ang) * ringR, 4, 0, TAU); + ctx.fill(); + ctx.globalAlpha = 1; } diff --git a/tool/bin/loop.js b/tool/bin/loop.js index fb3fd2e..9ff240d 100755 --- a/tool/bin/loop.js +++ b/tool/bin/loop.js @@ -5,7 +5,14 @@ import fs from "node:fs"; import path from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; -import { encodePNG, encodeGIF, detectFFmpeg } from "../lib/encoders.js"; +import { + encodePNG, + encodeGIF, + encodeMP4, + encodeWebM, + encodeAnimatedWebP, + detectCapabilities +} from "../lib/encoders.js"; import { analyzeSeam, analyzeLegibility, analyzeSources } from "../lib/analyzers.js"; import { renderAllFrames, renderContactSheet, renderStoryboard } from "../lib/compositor.js"; import { generatePreviewHtml, serveLoop } from "../lib/server.js"; @@ -44,7 +51,7 @@ function readJsonIfExists(filePath) { } } -async function loadSketchProject(targetDir) { +async function loadSketchProject(targetDir, flags = {}) { const absDir = path.resolve(targetDir); const sketchPath = path.join(absDir, "sketch.js"); if (!fs.existsSync(sketchPath)) { @@ -54,10 +61,30 @@ async function loadSketchProject(targetDir) { const sketchModule = await import(pathToFileURL(sketchPath).href + cacheBust); const briefJson = readJsonIfExists(path.join(absDir, "brief.json")); const showcaseJson = readJsonIfExists(path.join(absDir, "showcase.json")) || sketchModule.showcase || null; + + const showcaseOverrides = showcaseJson + ? { + ...(showcaseJson.seconds ? { seconds: showcaseJson.seconds } : {}), + ...(showcaseJson.fps ? { fps: showcaseJson.fps } : {}), + ...(showcaseJson.width ? { width: showcaseJson.width } : {}), + ...(showcaseJson.height ? { height: showcaseJson.height } : {}), + ...(showcaseJson.palette ? { palette: showcaseJson.palette } : {}) + } + : {}; + + const flagOverrides = { + ...(flags.fps ? { fps: Number(flags.fps) } : {}), + ...(flags.seconds ? { seconds: Number(flags.seconds) } : {}), + ...(flags.width ? { width: Number(flags.width) } : {}), + ...(flags.height ? { height: Number(flags.height) } : {}), + ...(flags.palette ? { palette: flags.palette } : {}) + }; + const meta = { ...(sketchModule.meta || {}), ...(briefJson || {}), - ...(showcaseJson ? { seconds: showcaseJson.seconds || sketchModule.meta?.seconds || 10 } : {}) + ...showcaseOverrides, + ...flagOverrides }; return { absDir, sketchPath, sketchModule, briefJson, showcaseJson, meta }; } @@ -95,18 +122,18 @@ function cmdNew(targetDir, flags) { const showcaseData = { title: path.basename(absDir), says: "Loop Studio turns a one-line request into a checked, seamless loop.", - seconds: 10, - fps: 24, - width: 800, - height: 320, + seconds: Number(flags.seconds || 8), + fps: Number(flags.fps || 60), + width: Number(flags.width || 640), + height: Number(flags.height || 288), palette, scene, stage: ["request", "sketch", "check", "loop.gif"], steps: [ - { from: 8.5, to: 1.5, caption: "a request arrives: \"deep sea, slow, square\"", source: "README.md:12" }, - { from: 1.5, to: 5.0, caption: "a sketch is written, driven by the phase", source: "rules/AGENTS.md:8" }, - { from: 5.0, to: 7.0, caption: "the seam and legibility are measured", source: "skills/loop-render/SKILL.md:30" }, - { from: 7.0, to: 8.5, caption: "the verified loop drops out", source: "skills/loop-render/SKILL.md:54" } + { from: 7.0, to: 1.0, caption: "request arrives: \"deep sea, square\"", source: "docs/contract.md:3" }, + { from: 1.0, to: 3.0, caption: "sketch draws from phase", source: "docs/contract.md:14" }, + { from: 3.0, to: 5.0, caption: "seam and contrast measured", source: "docs/tool.md:14" }, + { from: 5.0, to: 7.0, caption: "verified 60fps loop drops out", source: "docs/tool.md:24" } ] }; const scPath = path.join(absDir, "showcase.json"); @@ -121,7 +148,7 @@ function cmdNew(targetDir, flags) { style, palette, seconds: Number(flags.seconds || 4), - fps: Number(flags.fps || 24), + fps: Number(flags.fps || 30), width: Number(flags.width || 400), height: Number(flags.height || 400), seed: Number(flags.seed || 42) @@ -137,7 +164,7 @@ function cmdNew(targetDir, flags) { } async function cmdSheet(targetDir, flags) { - const { absDir, sketchModule, showcaseJson, meta } = await loadSketchProject(targetDir); + const { absDir, sketchModule, showcaseJson, meta } = await loadSketchProject(targetDir, flags); const every = flags.every ? Number(flags.every) : undefined; const cols = flags.cols ? Number(flags.cols) : 4; const sheetCanvas = renderContactSheet(sketchModule, { ...meta, showcase: showcaseJson, every, cols }); @@ -147,8 +174,8 @@ async function cmdSheet(targetDir, flags) { console.log(JSON.stringify({ status: "ok", file: outPath, width: sheetCanvas.width, height: sheetCanvas.height, bytes: pngBuf.length }, null, 2)); } -async function cmdStory(targetDir) { - const { absDir, sketchModule, showcaseJson, meta } = await loadSketchProject(targetDir); +async function cmdStory(targetDir, flags) { + const { absDir, sketchModule, showcaseJson, meta } = await loadSketchProject(targetDir, flags); const boardCanvas = renderStoryboard(sketchModule, showcaseJson, meta); const pngBuf = encodePNG(boardCanvas.data, boardCanvas.width, boardCanvas.height); const outPath = path.join(absDir, "storyboard.png"); @@ -156,9 +183,8 @@ async function cmdStory(targetDir) { console.log(JSON.stringify({ status: "ok", file: outPath, width: boardCanvas.width, height: boardCanvas.height, bytes: pngBuf.length }, null, 2)); } -async function cmdSeam(targetDir) { - const { absDir, sketchModule, showcaseJson, meta } = await loadSketchProject(targetDir); - // Render at evaluation resolution for fast & exact seam measurement +async function cmdSeam(targetDir, flags) { + const { absDir, sketchModule, showcaseJson, meta } = await loadSketchProject(targetDir, flags); const scale = meta.width > 400 ? 0.5 : 1; const evalW = Math.max(120, Math.round((meta.width || 400) * scale)); const evalH = Math.max(80, Math.round((meta.height || 400) * scale)); @@ -171,12 +197,13 @@ async function cmdSeam(targetDir) { const report = analyzeSeam(frames, evalW, evalH); const outPath = path.join(absDir, "seam.json"); fs.writeFileSync(outPath, JSON.stringify(report, null, 2) + "\n", "utf8"); - console.log(JSON.stringify({ file: outPath, ...report }, null, 2)); + const { normalizedSteps: _omit, ...summary } = report; + console.log(JSON.stringify({ file: outPath, ...summary }, null, 2)); if (!report.pass) process.exitCode = 1; } -async function cmdLegible(targetDir) { - const { absDir, sketchModule, showcaseJson, meta } = await loadSketchProject(targetDir); +async function cmdLegible(targetDir, flags) { + const { absDir, sketchModule, showcaseJson, meta } = await loadSketchProject(targetDir, flags); const report = analyzeLegibility(sketchModule, showcaseJson, meta); const outPath = path.join(absDir, "legible.json"); fs.writeFileSync(outPath, JSON.stringify(report, null, 2) + "\n", "utf8"); @@ -185,7 +212,7 @@ async function cmdLegible(targetDir) { } async function cmdSourceCheck(targetDir, flags) { - const { absDir, showcaseJson } = await loadSketchProject(targetDir); + const { absDir, showcaseJson } = await loadSketchProject(targetDir, flags); const repoRoot = flags.repo ? path.resolve(flags.repo) : REPO_ROOT; const report = analyzeSources(showcaseJson, repoRoot); const outPath = path.join(absDir, "sources.json"); @@ -195,7 +222,7 @@ async function cmdSourceCheck(targetDir, flags) { } async function cmdAudit(targetDir, flags) { - const { absDir, sketchModule, showcaseJson, meta } = await loadSketchProject(targetDir); + const { absDir, sketchModule, showcaseJson, meta } = await loadSketchProject(targetDir, flags); const repoRoot = flags.repo ? path.resolve(flags.repo) : REPO_ROOT; const scale = meta.width > 400 ? 0.5 : 1; @@ -238,30 +265,126 @@ async function cmdAudit(targetDir, flags) { if (!pass) process.exitCode = 1; } -async function cmdRender(targetDir) { - const { absDir, sketchModule, showcaseJson, meta } = await loadSketchProject(targetDir); +function resolveFormats(flags, caps, briefJson) { + if (flags.formats) { + const raw = String(flags.formats) + .split(",") + .map((s) => s.trim().toLowerCase()) + .filter(Boolean); + if (raw.includes("all")) { + const list = ["png", "gif"]; + if (caps.macosAVFoundation || caps.ffmpeg) list.push("mp4"); + if (caps.animatedWebP) list.push("webp"); + if (caps.ffmpeg) list.push("webm"); + return list; + } + return raw; + } + if (Array.isArray(briefJson?.formats) && briefJson.formats.length > 0) { + return briefJson.formats.map((s) => String(s).toLowerCase()); + } + const defaults = ["png", "gif"]; + if (caps.macosAVFoundation || caps.ffmpeg) defaults.push("mp4"); + return defaults; +} + +async function cmdRender(targetDir, flags) { + const { absDir, sketchModule, briefJson, showcaseJson, meta } = await loadSketchProject(targetDir, flags); + const caps = detectCapabilities(); + const formats = resolveFormats(flags, caps, briefJson); + const { frames, width, height, fps, totalFrames } = renderAllFrames(sketchModule, { ...meta, showcase: showcaseJson }); - // 1. Poster PNG (Frame 0) - const posterBuf = encodePNG(frames[0], width, height); - const posterPath = path.join(absDir, "poster.png"); - fs.writeFileSync(posterPath, posterBuf); - - // 2. Animated GIF89a - const gifBuf = encodeGIF(frames, width, height, fps); const isShowcase = meta.mode === "showcase" || Boolean(showcaseJson); - const primaryGifName = isShowcase ? "showcase.gif" : "loop.gif"; - const gifPath = path.join(absDir, primaryGifName); - fs.writeFileSync(gifPath, gifBuf); - if (isShowcase) { - // Also write loop.gif alias for uniform tooling - fs.writeFileSync(path.join(absDir, "loop.gif"), gifBuf); + const stem = isShowcase ? "showcase" : "loop"; + const files = {}; + const notes = []; + + if (formats.includes("png") || formats.includes("poster")) { + const posterBuf = encodePNG(frames[0], width, height); + const posterPath = path.join(absDir, "poster.png"); + fs.writeFileSync(posterPath, posterBuf); + files.poster = { path: posterPath, bytes: posterBuf.length, kb: Number((posterBuf.length / 1024).toFixed(1)) }; + } + + if (formats.includes("gif")) { + const gifBuf = encodeGIF(frames, width, height, fps); + const gifPath = path.join(absDir, `${stem}.gif`); + fs.writeFileSync(gifPath, gifBuf); + if (isShowcase) { + fs.writeFileSync(path.join(absDir, "loop.gif"), gifBuf); + } + const delayCs = Math.max(2, Math.round(100 / fps)); + const effectiveGifFps = Number((100 / delayCs).toFixed(1)); + if (fps > 50) { + notes.push(`GIF89a frame delay caps at 2cs (${effectiveGifFps}fps); use MP4 or WebP for true ${fps}fps playback.`); + } + files.gif = { + path: gifPath, + bytes: gifBuf.length, + kb: Number((gifBuf.length / 1024).toFixed(1)), + effectiveFps: effectiveGifFps + }; + } + + if (formats.includes("mp4")) { + if (caps.macosAVFoundation || caps.ffmpeg) { + const mp4Path = path.join(absDir, `${stem}.mp4`); + try { + const res = encodeMP4(frames, width, height, fps, mp4Path); + files.mp4 = { + path: res.path, + backend: res.backend, + fps, + bytes: res.bytes, + kb: Number((res.bytes / 1024).toFixed(1)) + }; + } catch (err) { + if (flags.formats) { + throw err; + } + notes.push(`Skipped default MP4: ${err.message.split("\n")[0]}`); + } + } else { + notes.push("Skipped MP4: install ffmpeg or run on macOS with Swift AVFoundation."); + } + } + + if (formats.includes("webp")) { + if (caps.animatedWebP) { + const webpPath = path.join(absDir, `${stem}.webp`); + const res = encodeAnimatedWebP(frames, width, height, fps, webpPath); + files.webp = { + path: res.path, + backend: res.backend, + fps, + bytes: res.bytes, + kb: Number((res.bytes / 1024).toFixed(1)) + }; + } else { + notes.push("Skipped WebP: requires cwebp + webpmux or ffmpeg."); + } + } + + if (formats.includes("webm")) { + if (caps.ffmpeg) { + const webmPath = path.join(absDir, `${stem}.webm`); + const res = encodeWebM(frames, width, height, fps, webmPath); + files.webm = { + path: res.path, + backend: res.backend, + fps, + bytes: res.bytes, + kb: Number((res.bytes / 1024).toFixed(1)) + }; + } else { + notes.push("Skipped WebM: install ffmpeg (`brew install ffmpeg`) for VP9 WebM encoding."); + } } - // 3. Measure seam on full render const seam = analyzeSeam(frames, width, height); fs.writeFileSync(path.join(absDir, "seam.json"), JSON.stringify(seam, null, 2) + "\n", "utf8"); @@ -276,10 +399,8 @@ async function cmdRender(targetDir) { totalFrames, seamScore: seam.seamScore, duplicateFrames: seam.duplicateFrames, - files: { - gif: { path: gifPath, bytes: gifBuf.length, kb: Number((gifBuf.length / 1024).toFixed(1)) }, - poster: { path: posterPath, bytes: posterBuf.length, kb: Number((posterBuf.length / 1024).toFixed(1)) } - } + files, + ...(notes.length ? { notes } : {}) }, null, 2 @@ -288,7 +409,7 @@ async function cmdRender(targetDir) { } function cmdDoctor() { - const hasFFmpeg = detectFFmpeg(); + const caps = detectCapabilities(); const chromePaths = [ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "/usr/bin/google-chrome", @@ -305,7 +426,9 @@ function cmdDoctor() { softCanvas2D: true, pureJsGif89a: true, pureJsPng: true, - ffmpeg: hasFFmpeg, + macosAVFoundation: caps.macosAVFoundation, + animatedWebP: caps.animatedWebP, + ffmpeg: caps.ffmpeg, headlessChrome: Boolean(chromeFound), chromePath: chromeFound } @@ -320,14 +443,14 @@ function printHelp() { console.log(`Loop Studio CLI (loop) — Deterministic Seamless Animation & Showcase Engine Usage: - loop new [--mode showcase|ambient] [--scene ] [--style ] [--palette ] + loop new [--mode showcase|ambient] [--scene ] [--style ] [--palette ] [--fps ] loop sheet [--every ] [--cols ] loop story loop seam loop legible loop source-check [--repo ] loop audit [--repo ] - loop render + loop render [--fps ] [--formats gif,mp4,webp,webm,png|all] [--width ] [--height ] loop serve [--port 4173] loop doctor `); @@ -344,13 +467,13 @@ async function main() { await cmdSheet(dir, flags); break; case "story": - await cmdStory(dir); + await cmdStory(dir, flags); break; case "seam": - await cmdSeam(dir); + await cmdSeam(dir, flags); break; case "legible": - await cmdLegible(dir); + await cmdLegible(dir, flags); break; case "source-check": await cmdSourceCheck(dir, flags); @@ -359,7 +482,7 @@ async function main() { await cmdAudit(dir, flags); break; case "render": - await cmdRender(dir); + await cmdRender(dir, flags); break; case "serve": serveLoop(dir, Number(flags.port || 4173), path.join(REPO_ROOT, "tool/lib/loop-kit.js")); diff --git a/tool/lib/encoders.js b/tool/lib/encoders.js index 4744732..4e40921 100644 --- a/tool/lib/encoders.js +++ b/tool/lib/encoders.js @@ -1,9 +1,17 @@ -// Loop Studio — Pure-JS PNG & GIF89a Encoders + Optional FFmpeg Driver -// Zero external npm dependencies required; uses Node's built-in node:zlib. +// Loop Studio — Pure-JS PNG & GIF89a Encoders + Native MP4 (AVFoundation/FFmpeg), WebM & Animated WebP +// Zero external npm dependencies required. +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; import zlib from "node:zlib"; +import { fileURLToPath } from "node:url"; import { spawnSync } from "node:child_process"; +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const SWIFT_MP4_SCRIPT = path.resolve(__dirname, "../scripts/encode-mp4.swift"); + const CRC_TABLE = new Uint32Array(256); for (let n = 0; n < 256; n++) { let c = n; @@ -31,7 +39,7 @@ function pngChunk(type, data) { return Buffer.concat([len, typeBuf, data, crcBuf]); } -export function encodePNG(rgba, width, height) { +export function encodePNG(rgba, width, height, compressionLevel = 6) { const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]); const ihdr = Buffer.alloc(13); ihdr.writeUInt32BE(width, 0); @@ -53,7 +61,7 @@ export function encodePNG(rgba, width, height) { } } - const compressed = zlib.deflateSync(raw, { level: 6 }); + const compressed = zlib.deflateSync(raw, { level: compressionLevel }); return Buffer.concat([ signature, pngChunk("IHDR", ihdr), @@ -73,7 +81,6 @@ function buildGlobalPalette(frames, width, height) { const data = frames[f]; for (let p = 0; p < totalPixels; p += pixStep) { const idx = p * 4; - // Quantize to 6-6-6 bits (18-bit key) to preserve exact UI/palette colors and smooth steps const r = data[idx] & 0xfc; const g = data[idx + 1] & 0xfc; const b = data[idx + 2] & 0xfc; @@ -89,7 +96,6 @@ function buildGlobalPalette(frames, width, height) { const r = (key >> 16) & 0xff; const g = (key >> 8) & 0xff; const b = key & 0xff; - // Avoid adding near-duplicate colors if we have plenty of candidates let tooClose = false; if (sorted.length > 256 && palette.length > 16) { for (let i = 0; i < palette.length; i++) { @@ -106,7 +112,6 @@ function buildGlobalPalette(frames, width, height) { if (!tooClose) palette.push([r, g, b]); } - // Fill any remaining slots if needed for (const [key] of sorted) { if (palette.length >= 256) break; const r = (key >> 16) & 0xff; @@ -153,8 +158,8 @@ function mapFrameToIndices(rgba, totalPixels, palette, cache) { // LZW encoder for GIF89a 8-bit indices function lzwEncode(indices) { const minCodeSize = 8; - const clearCode = 1 << minCodeSize; // 256 - const eoiCode = clearCode + 1; // 257 + const clearCode = 1 << minCodeSize; + const eoiCode = clearCode + 1; const outBytes = []; let bitBuf = 0; @@ -170,9 +175,8 @@ function lzwEncode(indices) { } } - let codeSize = minCodeSize + 1; // 9 - let nextCode = eoiCode + 1; // 258 - // Flat hash table / Map from (prefix << 8) | suffix -> code + let codeSize = minCodeSize + 1; + let nextCode = eoiCode + 1; let table = new Map(); emitCode(clearCode, codeSize); @@ -208,7 +212,6 @@ function lzwEncode(indices) { outBytes.push(bitBuf & 0xff); } - // Pack into GIF sub-blocks of max 255 bytes const chunks = [Buffer.from([minCodeSize])]; let offset = 0; while (offset < outBytes.length) { @@ -221,7 +224,7 @@ function lzwEncode(indices) { chunks.push(block); offset += size; } - chunks.push(Buffer.from([0x00])); // Block terminator + chunks.push(Buffer.from([0x00])); return Buffer.concat(chunks); } @@ -229,15 +232,16 @@ export function encodeGIF(frames, width, height, fps = 24) { const palette = buildGlobalPalette(frames, width, height); const cache = new Map(); const totalPixels = width * height; + // GIF89a stores frame delay in centiseconds; 2cs (50fps) is the fastest reliable browser speed const delayCs = Math.max(2, Math.round(100 / fps)); const header = Buffer.alloc(13); header.write("GIF89a", 0, "ascii"); header.writeUInt16LE(width, 6); header.writeUInt16LE(height, 8); - header[10] = 0xf7; // Global Color Table flag (1), color res (7), sort (0), size 2^(7+1)=256 - header[11] = 0; // bg color index - header[12] = 0; // pixel aspect ratio + header[10] = 0xf7; + header[11] = 0; + header[12] = 0; const gct = Buffer.alloc(256 * 3); for (let i = 0; i < 256; i++) { @@ -246,7 +250,6 @@ export function encodeGIF(frames, width, height, fps = 24) { gct[i * 3 + 2] = palette[i][2]; } - // Netscape 2.0 infinite loop extension const netscape = Buffer.from([ 0x21, 0xff, 0x0b, 0x4e, 0x45, 0x54, 0x53, 0x43, 0x41, 0x50, 0x45, 0x32, 0x2e, 0x30, @@ -257,32 +260,225 @@ export function encodeGIF(frames, width, height, fps = 24) { for (let f = 0; f < frames.length; f++) { const gce = Buffer.alloc(8); - gce[0] = 0x21; // Extension Introducer - gce[1] = 0xf9; // Graphic Control Label - gce[2] = 0x04; // Byte size - gce[3] = 0x04; // Disposal method 1 (Do not dispose / overwrite) + gce[0] = 0x21; + gce[1] = 0xf9; + gce[2] = 0x04; + gce[3] = 0x04; gce.writeUInt16LE(delayCs, 4); gce[6] = 0x00; gce[7] = 0x00; const imgDesc = Buffer.alloc(10); - imgDesc[0] = 0x2c; // Image Separator + imgDesc[0] = 0x2c; imgDesc.writeUInt16LE(0, 1); imgDesc.writeUInt16LE(0, 3); imgDesc.writeUInt16LE(width, 5); imgDesc.writeUInt16LE(height, 7); - imgDesc[9] = 0x00; // Use Global Color Table + imgDesc[9] = 0x00; const indices = mapFrameToIndices(frames[f], totalPixels, palette, cache); const lzw = lzwEncode(indices); parts.push(gce, imgDesc, lzw); } - parts.push(Buffer.from([0x3b])); // GIF Trailer + parts.push(Buffer.from([0x3b])); return Buffer.concat(parts); } +function findBinary(name, extraPaths = []) { + const direct = spawnSync("which", [name], { encoding: "utf8" }); + if (direct.status === 0 && direct.stdout.trim()) { + return direct.stdout.trim().split("\n")[0]; + } + for (const p of extraPaths) { + if (fs.existsSync(p)) return p; + } + return null; +} + export function detectFFmpeg() { - const res = spawnSync("ffmpeg", ["-version"], { encoding: "utf8" }); - return res.status === 0; + return Boolean(findBinary("ffmpeg", ["/opt/homebrew/bin/ffmpeg", "/usr/local/bin/ffmpeg"])); +} + +export function detectCapabilities() { + const ffmpegPath = findBinary("ffmpeg", ["/opt/homebrew/bin/ffmpeg", "/usr/local/bin/ffmpeg"]); + const swiftPath = process.platform === "darwin" ? findBinary("swift", ["/usr/bin/swift"]) : null; + const cwebpPath = findBinary("cwebp", ["/opt/homebrew/bin/cwebp", "/usr/local/bin/cwebp"]); + const webpmuxPath = findBinary("webpmux", ["/opt/homebrew/bin/webpmux", "/usr/local/bin/webpmux"]); + + return { + ffmpeg: Boolean(ffmpegPath), + ffmpegPath, + macosAVFoundation: Boolean(swiftPath && fs.existsSync(SWIFT_MP4_SCRIPT)), + swiftPath, + animatedWebP: Boolean((cwebpPath && webpmuxPath) || ffmpegPath), + cwebpPath, + webpmuxPath + }; +} + +export function encodeMP4(frames, width, height, fps = 30, outPath) { + const caps = detectCapabilities(); + const absOut = path.resolve(outPath); + + if (caps.ffmpegPath) { + const tmpRaw = path.join(os.tmpdir(), `loop-studio-${process.pid}-${Date.now()}.rgba`); + try { + const fd = fs.openSync(tmpRaw, "w"); + for (const frame of frames) fs.writeSync(fd, frame); + fs.closeSync(fd); + + const res = spawnSync( + caps.ffmpegPath, + [ + "-y", + "-f", "rawvideo", + "-pix_fmt", "rgba", + "-s", `${width}x${height}`, + "-r", String(fps), + "-i", tmpRaw, + "-vf", "pad=ceil(iw/2)*2:ceil(ih/2)*2", + "-c:v", "libx264", + "-pix_fmt", "yuv420p", + "-movflags", "+faststart", + "-crf", "17", + absOut + ], + { encoding: "utf8" } + ); + if (res.status !== 0) { + throw new Error(`ffmpeg MP4 encoding failed: ${res.stderr}`); + } + return { backend: "ffmpeg", path: absOut, bytes: fs.statSync(absOut).size }; + } finally { + if (fs.existsSync(tmpRaw)) fs.unlinkSync(tmpRaw); + } + } + + if (caps.macosAVFoundation) { + const tmpRaw = path.join(os.tmpdir(), `loop-studio-${process.pid}-${Date.now()}.rgba`); + try { + const fd = fs.openSync(tmpRaw, "w"); + for (const frame of frames) fs.writeSync(fd, frame); + fs.closeSync(fd); + + const res = spawnSync( + caps.swiftPath, + [SWIFT_MP4_SCRIPT, tmpRaw, String(width), String(height), String(fps), String(frames.length), absOut], + { encoding: "utf8" } + ); + if (res.status !== 0) { + throw new Error(`macOS AVFoundation MP4 encoding failed: ${res.stderr || res.stdout}`); + } + return { backend: "macos-avfoundation", path: absOut, bytes: fs.statSync(absOut).size }; + } finally { + if (fs.existsSync(tmpRaw)) fs.unlinkSync(tmpRaw); + } + } + + throw new Error("No MP4 encoder found (install ffmpeg or run on macOS with Swift AVFoundation)."); +} + +export function encodeWebM(frames, width, height, fps = 30, outPath) { + const caps = detectCapabilities(); + if (!caps.ffmpegPath) { + throw new Error("WebM encoding requires ffmpeg (install via `brew install ffmpeg`)."); + } + const absOut = path.resolve(outPath); + const tmpRaw = path.join(os.tmpdir(), `loop-studio-webm-${process.pid}-${Date.now()}.rgba`); + try { + const fd = fs.openSync(tmpRaw, "w"); + for (const frame of frames) fs.writeSync(fd, frame); + fs.closeSync(fd); + + const res = spawnSync( + caps.ffmpegPath, + [ + "-y", + "-f", "rawvideo", + "-pix_fmt", "rgba", + "-s", `${width}x${height}`, + "-r", String(fps), + "-i", tmpRaw, + "-c:v", "libvpx-vp9", + "-pix_fmt", "yuv420p", + "-b:v", "0", + "-crf", "24", + absOut + ], + { encoding: "utf8" } + ); + if (res.status !== 0) { + throw new Error(`ffmpeg WebM encoding failed: ${res.stderr}`); + } + return { backend: "ffmpeg", path: absOut, bytes: fs.statSync(absOut).size }; + } finally { + if (fs.existsSync(tmpRaw)) fs.unlinkSync(tmpRaw); + } +} + +export function encodeAnimatedWebP(frames, width, height, fps = 30, outPath) { + const caps = detectCapabilities(); + const absOut = path.resolve(outPath); + const durationMs = Math.max(8, Math.round(1000 / fps)); + + if (caps.cwebpPath && caps.webpmuxPath) { + const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "loop-studio-webp-")); + const quality = frames.length > 200 ? "80" : "88"; + try { + const muxArgs = []; + for (let i = 0; i < frames.length; i++) { + const pngPath = path.join(tmpDir, `f_${i}.png`); + const webpPath = path.join(tmpDir, `f_${i}.webp`); + fs.writeFileSync(pngPath, encodePNG(frames[i], width, height, 1)); + const cw = spawnSync(caps.cwebpPath, ["-quiet", "-q", quality, pngPath, "-o", webpPath], { encoding: "utf8" }); + if (cw.status !== 0) { + throw new Error(`cwebp failed on frame ${i}: ${cw.stderr}`); + } + muxArgs.push("-frame", webpPath, `+${durationMs}+0+0+1-b`); + } + muxArgs.push("-loop", "0", "-o", absOut); + + const mux = spawnSync(caps.webpmuxPath, muxArgs, { encoding: "utf8" }); + if (mux.status !== 0) { + throw new Error(`webpmux failed: ${mux.stderr}`); + } + return { backend: "cwebp+webpmux", path: absOut, bytes: fs.statSync(absOut).size }; + } finally { + fs.rmSync(tmpDir, { recursive: true, force: true }); + } + } + + if (caps.ffmpegPath) { + const tmpRaw = path.join(os.tmpdir(), `loop-studio-webp-${process.pid}-${Date.now()}.rgba`); + try { + const fd = fs.openSync(tmpRaw, "w"); + for (const frame of frames) fs.writeSync(fd, frame); + fs.closeSync(fd); + const res = spawnSync( + caps.ffmpegPath, + [ + "-y", + "-f", "rawvideo", + "-pix_fmt", "rgba", + "-s", `${width}x${height}`, + "-r", String(fps), + "-i", tmpRaw, + "-vcodec", "libwebp", + "-loop", "0", + "-q:v", "85", + absOut + ], + { encoding: "utf8" } + ); + if (res.status !== 0) { + throw new Error(`ffmpeg WebP encoding failed: ${res.stderr}`); + } + return { backend: "ffmpeg", path: absOut, bytes: fs.statSync(absOut).size }; + } finally { + if (fs.existsSync(tmpRaw)) fs.unlinkSync(tmpRaw); + } + } + + throw new Error("No Animated WebP encoder found (requires cwebp+webpmux or ffmpeg)."); } diff --git a/tool/lib/soft-canvas.js b/tool/lib/soft-canvas.js index 59bb78c..355f5ca 100644 --- a/tool/lib/soft-canvas.js +++ b/tool/lib/soft-canvas.js @@ -1,112 +1,234 @@ -// Loop Studio — Pure-JS Deterministic 2D Software Canvas Engine -// Provides zero-dependency 2D Canvas rendering for Node.js, CI, and sandboxed environments, -// plus telemetry hooks for `loop legible` contrast and bounding-box verification. +// Loop Studio — Pure-JS Deterministic 2D Software Canvas Engine (v2) +// Features: +// - Sub-pixel anti-aliased Vector SDF Font Engine (smooth curves & diagonals, cached glyph atlas) +// - Linear & Radial Gradient support (createLinearGradient, createRadialGradient) +// - Anti-aliased discs, rings, thick capsule strokes, and scanline polygon fills +// - Pre-blend background contrast & bounding-box telemetry for `loop legible` import { color as colorUtil } from "./loop-kit.js"; -// Compact 5x7 bitmap font for printable ASCII (each char is 7 rows of 5-bit integers, MSB on left) -const GLYPHS = { - " ": [0, 0, 0, 0, 0, 0, 0], - "!": [4, 4, 4, 4, 4, 0, 4], - "\"": [10, 10, 4, 0, 0, 0, 0], - "#": [10, 31, 10, 10, 31, 10, 0], - "$": [4, 15, 20, 14, 5, 30, 4], - "%": [25, 26, 4, 8, 19, 0, 0], - "&": [12, 18, 20, 8, 21, 18, 13], - "'": [4, 4, 0, 0, 0, 0, 0], - "(": [2, 4, 8, 8, 8, 4, 2], - ")": [8, 4, 2, 2, 2, 4, 8], - "*": [0, 4, 21, 14, 21, 4, 0], - "+": [0, 4, 4, 31, 4, 4, 0], - ",": [0, 0, 0, 0, 4, 4, 8], - "-": [0, 0, 0, 31, 0, 0, 0], - ".": [0, 0, 0, 0, 0, 12, 12], - "/": [1, 2, 4, 4, 8, 16, 0], - "0": [14, 17, 19, 21, 25, 17, 14], - "1": [4, 12, 4, 4, 4, 4, 14], - "2": [14, 17, 1, 6, 8, 16, 31], - "3": [31, 2, 4, 6, 1, 17, 14], - "4": [2, 6, 10, 18, 31, 2, 2], - "5": [31, 16, 30, 1, 1, 17, 14], - "6": [6, 8, 16, 30, 17, 17, 14], - "7": [31, 1, 2, 4, 8, 8, 8], - "8": [14, 17, 17, 14, 17, 17, 14], - "9": [14, 17, 17, 15, 1, 2, 12], - ":": [0, 12, 12, 0, 12, 12, 0], - ";": [0, 12, 12, 0, 12, 4, 8], - "<": [2, 4, 8, 16, 8, 4, 2], - "=": [0, 0, 31, 0, 31, 0, 0], - ">": [8, 4, 2, 1, 2, 4, 8], - "?": [14, 17, 1, 6, 4, 0, 4], - "@": [14, 17, 23, 21, 23, 16, 14], - "A": [14, 17, 17, 31, 17, 17, 17], - "B": [30, 17, 17, 30, 17, 17, 30], - "C": [14, 17, 16, 16, 16, 17, 14], - "D": [28, 18, 17, 17, 17, 18, 28], - "E": [31, 16, 16, 30, 16, 16, 31], - "F": [31, 16, 16, 30, 16, 16, 16], - "G": [14, 17, 16, 23, 17, 17, 15], - "H": [17, 17, 17, 31, 17, 17, 17], - "I": [14, 4, 4, 4, 4, 4, 14], - "J": [7, 2, 2, 2, 2, 18, 12], - "K": [17, 18, 20, 24, 20, 18, 17], - "L": [16, 16, 16, 16, 16, 16, 31], - "M": [17, 27, 21, 21, 17, 17, 17], - "N": [17, 25, 21, 19, 17, 17, 17], - "O": [14, 17, 17, 17, 17, 17, 14], - "P": [30, 17, 17, 30, 16, 16, 16], - "Q": [14, 17, 17, 17, 21, 18, 13], - "R": [30, 17, 17, 30, 20, 18, 17], - "S": [15, 16, 16, 14, 1, 1, 30], - "T": [31, 4, 4, 4, 4, 4, 4], - "U": [17, 17, 17, 17, 17, 17, 14], - "V": [17, 17, 17, 17, 17, 10, 4], - "W": [17, 17, 17, 21, 21, 27, 17], - "X": [17, 17, 10, 4, 10, 17, 17], - "Y": [17, 17, 10, 4, 4, 4, 4], - "Z": [31, 1, 2, 4, 8, 16, 31], - "[": [14, 8, 8, 8, 8, 8, 14], - "\\": [16, 8, 4, 4, 2, 1, 0], - "]": [14, 2, 2, 2, 2, 2, 14], - "^": [4, 10, 17, 0, 0, 0, 0], - "_": [0, 0, 0, 0, 0, 0, 31], - "`": [8, 4, 0, 0, 0, 0, 0], - "a": [0, 0, 14, 1, 15, 17, 15], - "b": [16, 16, 22, 25, 17, 17, 30], - "c": [0, 0, 14, 16, 16, 17, 14], - "d": [1, 1, 13, 19, 17, 17, 15], - "e": [0, 0, 14, 17, 31, 16, 14], - "f": [6, 9, 8, 28, 8, 8, 8], - "g": [0, 15, 17, 17, 15, 1, 14], - "h": [16, 16, 22, 25, 17, 17, 17], - "i": [4, 0, 12, 4, 4, 4, 14], - "j": [2, 0, 6, 2, 2, 18, 12], - "k": [16, 16, 18, 20, 24, 20, 18], - "l": [12, 4, 4, 4, 4, 4, 14], - "m": [0, 0, 26, 21, 21, 17, 17], - "n": [0, 0, 22, 25, 17, 17, 17], - "o": [0, 0, 14, 17, 17, 17, 14], - "p": [0, 0, 30, 17, 30, 16, 16], - "q": [0, 0, 15, 17, 15, 1, 1], - "r": [0, 0, 22, 25, 16, 16, 16], - "s": [0, 0, 15, 16, 14, 1, 30], - "t": [8, 8, 28, 8, 8, 9, 6], - "u": [0, 0, 17, 17, 17, 19, 13], - "v": [0, 0, 17, 17, 17, 10, 4], - "w": [0, 0, 17, 17, 21, 21, 10], - "x": [0, 0, 17, 10, 4, 10, 17], - "y": [0, 0, 17, 17, 15, 1, 14], - "z": [0, 0, 31, 2, 4, 8, 31], - "{": [2, 4, 4, 8, 4, 4, 2], - "|": [4, 4, 4, 4, 4, 4, 4], - "}": [8, 4, 4, 2, 4, 4, 8], - "~": [0, 0, 8, 21, 2, 0, 0], - "→": [0, 4, 2, 31, 2, 4, 0], - "·": [0, 0, 0, 6, 6, 0, 0], - "—": [0, 0, 0, 31, 0, 0, 0], - "×": [0, 17, 10, 4, 10, 17, 0] +// Vector stroke definitions on a [0..8, 0..12] grid (baseline at y=10, cap-height y=1, x-height y=4, descender y=12) +// Commands: ["L", x0, y0, x1, y1] or ["A", cx, cy, rx, ry, startDeg, endDeg] or ["P", x0, y0, x1, y1, ...] +const VECTOR_GLYPHS = { + " ": [], + "!": [["L", 4, 1, 4, 7.5], ["A", 4, 10, 0.4, 0.4, 0, 360]], + "\"": [["L", 2.8, 1, 2.8, 3.8], ["L", 5.2, 1, 5.2, 3.8]], + "#": [["L", 2.8, 1.5, 2.2, 10], ["L", 5.8, 1.5, 5.2, 10], ["L", 1.2, 4.2, 6.8, 4.2], ["L", 1.0, 7.2, 6.6, 7.2]], + "$": [["A", 4, 3.8, 2.3, 1.8, 110, 350], ["L", 2.2, 4.5, 5.8, 6.8], ["A", 4, 8.0, 2.3, 1.8, -70, 170], ["L", 4, 0.6, 4, 11]], + "%": [["A", 2.3, 2.8, 1.3, 1.3, 0, 360], ["L", 6.4, 1.2, 1.6, 10], ["A", 5.7, 8.5, 1.3, 1.3, 0, 360]], + "&": [["A", 3.8, 3.0, 1.7, 1.6, 0, 360], ["A", 3.6, 7.6, 2.3, 2.2, 40, 320], ["L", 2.2, 4.2, 6.8, 10]], + "'": [["L", 4, 1, 3.6, 3.8]], + "(": [["A", 5.5, 5.6, 2.8, 5.2, 115, 245]], + ")": [["A", 2.5, 5.6, 2.8, 5.2, -65, 65]], + "*": [["L", 4, 2.2, 4, 7.8], ["L", 1.5, 3.6, 6.5, 6.4], ["L", 6.5, 3.6, 1.5, 6.4]], + "+": [["L", 4, 2.8, 4, 8.8], ["L", 1.2, 5.8, 6.8, 5.8]], + ",": [["L", 4.2, 9.2, 3.2, 11.6]], + "-": [["L", 1.5, 5.8, 6.5, 5.8]], + ".": [["A", 4, 9.6, 0.5, 0.5, 0, 360]], + "/": [["L", 6.2, 1, 1.8, 10.4]], + "0": [["A", 4, 5.5, 2.6, 4.4, 0, 360], ["L", 2.2, 8.4, 5.8, 2.6]], + "1": [["L", 2.2, 2.8, 4.2, 1.1], ["L", 4.2, 1.1, 4.2, 10], ["L", 2.0, 10, 6.4, 10]], + "2": [["A", 4, 3.3, 2.3, 2.1, 195, 405], ["L", 6.0, 4.7, 1.5, 10], ["L", 1.5, 10, 6.6, 10]], + "3": [["A", 3.9, 3.2, 2.2, 2.0, 200, 450], ["A", 4.0, 7.6, 2.4, 2.3, -90, 160]], + "4": [["L", 5.2, 1.1, 1.3, 7.2], ["L", 1.3, 7.2, 6.8, 7.2], ["L", 5.2, 1.1, 5.2, 10]], + "5": [["L", 6.2, 1.2, 2.0, 1.2], ["L", 2.0, 1.2, 1.8, 5.2], ["A", 4.0, 7.3, 2.5, 2.6, -135, 155]], + "6": [["A", 4.2, 5.5, 2.6, 4.3, 140, 260], ["A", 4.0, 7.4, 2.4, 2.5, 0, 360]], + "7": [["L", 1.4, 1.2, 6.6, 1.2], ["L", 6.6, 1.2, 2.8, 10]], + "8": [["A", 4, 3.2, 2.1, 2.0, 0, 360], ["A", 4, 7.6, 2.4, 2.3, 0, 360]], + "9": [["A", 4.0, 3.6, 2.4, 2.4, 0, 360], ["A", 3.8, 5.5, 2.6, 4.3, -40, 80]], + ":": [["A", 4, 4.4, 0.5, 0.5, 0, 360], ["A", 4, 9.4, 0.5, 0.5, 0, 360]], + ";": [["A", 4, 4.4, 0.5, 0.5, 0, 360], ["L", 4.2, 9.0, 3.2, 11.4]], + "<": [["L", 6.2, 2.4, 1.8, 5.8], ["L", 1.8, 5.8, 6.2, 9.2]], + "=": [["L", 1.4, 4.3, 6.6, 4.3], ["L", 1.4, 7.3, 6.6, 7.3]], + ">": [["L", 1.8, 2.4, 6.2, 5.8], ["L", 6.2, 5.8, 1.8, 9.2]], + "?": [["A", 4, 3.3, 2.3, 2.1, 195, 425], ["L", 4, 5.3, 4, 7.4], ["A", 4, 9.8, 0.45, 0.45, 0, 360]], + "@": [["A", 4, 5.6, 3.1, 3.8, 35, 330], ["A", 4, 5.8, 1.4, 1.6, 0, 360], ["L", 5.4, 4.2, 5.4, 7.3]], + "A": [["L", 1.2, 10, 4.0, 1.1], ["L", 4.0, 1.1, 6.8, 10], ["L", 2.1, 7.0, 5.9, 7.0]], + "B": [["L", 1.6, 1.2, 1.6, 10], ["L", 1.6, 1.2, 4.4, 1.2], ["L", 1.6, 5.4, 4.5, 5.4], ["L", 1.6, 10, 4.5, 10], ["A", 4.4, 3.3, 1.9, 2.1, -90, 90], ["A", 4.5, 7.7, 2.1, 2.3, -90, 90]], + "C": [["A", 4.2, 5.6, 2.7, 4.4, 42, 318]], + "D": [["L", 1.6, 1.2, 1.6, 10], ["L", 1.6, 1.2, 3.8, 1.2], ["L", 1.6, 10, 3.8, 10], ["A", 3.8, 5.6, 2.8, 4.4, -90, 90]], + "E": [["L", 1.6, 1.2, 1.6, 10], ["L", 1.6, 1.2, 6.4, 1.2], ["L", 1.6, 5.5, 5.6, 5.5], ["L", 1.6, 10, 6.4, 10]], + "F": [["L", 1.6, 1.2, 1.6, 10], ["L", 1.6, 1.2, 6.4, 1.2], ["L", 1.6, 5.5, 5.6, 5.5]], + "G": [["A", 4.2, 5.6, 2.7, 4.4, 35, 330], ["L", 4.2, 6.0, 6.8, 6.0], ["L", 6.8, 6.0, 6.8, 9.6]], + "H": [["L", 1.6, 1.2, 1.6, 10], ["L", 6.4, 1.2, 6.4, 10], ["L", 1.6, 5.5, 6.4, 5.5]], + "I": [["L", 2.2, 1.2, 5.8, 1.2], ["L", 4.0, 1.2, 4.0, 10], ["L", 2.2, 10, 5.8, 10]], + "J": [["L", 2.4, 1.2, 6.2, 1.2], ["L", 5.2, 1.2, 5.2, 7.6], ["A", 3.4, 7.6, 1.8, 2.3, 0, 170]], + "K": [["L", 1.6, 1.2, 1.6, 10], ["L", 6.4, 1.2, 1.6, 6.0], ["L", 3.2, 4.5, 6.5, 10]], + "L": [["L", 1.8, 1.2, 1.8, 10], ["L", 1.8, 10, 6.4, 10]], + "M": [["L", 1.3, 10, 1.3, 1.2], ["L", 1.3, 1.2, 4.0, 6.4], ["L", 4.0, 6.4, 6.7, 1.2], ["L", 6.7, 1.2, 6.7, 10]], + "N": [["L", 1.5, 10, 1.5, 1.2], ["L", 1.5, 1.2, 6.5, 10], ["L", 6.5, 10, 6.5, 1.2]], + "O": [["A", 4, 5.6, 2.7, 4.4, 0, 360]], + "P": [["L", 1.6, 1.2, 1.6, 10], ["L", 1.6, 1.2, 4.4, 1.2], ["L", 1.6, 5.8, 4.4, 5.8], ["A", 4.4, 3.5, 2.1, 2.3, -90, 90]], + "Q": [["A", 4, 5.4, 2.7, 4.2, 0, 360], ["L", 4.4, 7.2, 6.8, 10.4]], + "R": [["L", 1.6, 1.2, 1.6, 10], ["L", 1.6, 1.2, 4.4, 1.2], ["L", 1.6, 5.6, 4.4, 5.6], ["A", 4.4, 3.4, 2.1, 2.2, -90, 90], ["L", 4.2, 5.6, 6.5, 10]], + "S": [["A", 4.1, 3.3, 2.3, 2.0, 145, 350], ["L", 2.1, 4.2, 5.9, 6.8], ["A", 3.9, 7.8, 2.4, 2.1, -35, 165]], + "T": [["L", 1.2, 1.2, 6.8, 1.2], ["L", 4.0, 1.2, 4.0, 10]], + "U": [["L", 1.6, 1.2, 1.6, 7.2], ["L", 6.4, 1.2, 6.4, 7.2], ["A", 4.0, 7.2, 2.4, 2.8, 0, 180]], + "V": [["L", 1.3, 1.2, 4.0, 10], ["L", 4.0, 10, 6.7, 1.2]], + "W": [["L", 1.0, 1.2, 2.4, 10], ["L", 2.4, 10, 4.0, 4.8], ["L", 4.0, 4.8, 5.6, 10], ["L", 5.6, 10, 7.0, 1.2]], + "X": [["L", 1.4, 1.2, 6.6, 10], ["L", 6.6, 1.2, 1.4, 10]], + "Y": [["L", 1.4, 1.2, 4.0, 5.6], ["L", 6.6, 1.2, 4.0, 5.6], ["L", 4.0, 5.6, 4.0, 10]], + "Z": [["L", 1.4, 1.2, 6.6, 1.2], ["L", 6.6, 1.2, 1.4, 10], ["L", 1.4, 10, 6.6, 10]], + "[": [["L", 5.2, 1, 2.6, 1], ["L", 2.6, 1, 2.6, 10.6], ["L", 2.6, 10.6, 5.2, 10.6]], + "\\": [["L", 1.8, 1, 6.2, 10.4]], + "]": [["L", 2.8, 1, 5.4, 1], ["L", 5.4, 1, 5.4, 10.6], ["L", 5.4, 10.6, 2.8, 10.6]], + "^": [["L", 1.8, 4.2, 4.0, 1.2], ["L", 4.0, 1.2, 6.2, 4.2]], + "_": [["L", 1.0, 10.8, 7.0, 10.8]], + "`": [["L", 3.2, 1.0, 4.6, 3.2]], + "a": [["A", 3.8, 7.2, 2.2, 2.7, 50, 310], ["L", 6.0, 4.2, 6.0, 10], ["A", 3.9, 5.2, 2.0, 1.4, 200, 350]], + "b": [["L", 1.7, 1.0, 1.7, 10], ["A", 4.0, 7.0, 2.3, 2.9, -115, 115]], + "c": [["A", 4.3, 7.0, 2.4, 2.9, 45, 315]], + "d": [["L", 6.3, 1.0, 6.3, 10], ["A", 4.0, 7.0, 2.3, 2.9, 65, 295]], + "e": [["L", 1.6, 6.8, 6.4, 6.8], ["A", 4.0, 7.0, 2.4, 2.9, 35, 360]], + "f": [["A", 4.8, 2.6, 1.5, 1.5, 180, 330], ["L", 3.3, 2.6, 3.3, 10], ["L", 1.8, 4.6, 5.4, 4.6]], + "g": [["A", 4.0, 6.8, 2.2, 2.6, 0, 360], ["L", 6.2, 4.2, 6.2, 10.2], ["A", 3.9, 10.2, 2.3, 1.8, 0, 165]], + "h": [["L", 1.7, 1.0, 1.7, 10], ["A", 4.0, 6.0, 2.2, 2.0, 180, 360], ["L", 6.2, 6.0, 6.2, 10]], + "i": [["A", 4.0, 1.8, 0.5, 0.5, 0, 360], ["L", 2.6, 4.2, 4.2, 4.2], ["L", 4.2, 4.2, 4.2, 10], ["L", 2.4, 10, 5.8, 10]], + "j": [["A", 4.8, 1.8, 0.5, 0.5, 0, 360], ["L", 4.8, 4.2, 4.8, 10.2], ["A", 3.2, 10.2, 1.6, 1.6, 0, 165]], + "k": [["L", 1.8, 1.0, 1.8, 10], ["L", 6.0, 4.2, 1.8, 7.2], ["L", 3.4, 6.0, 6.2, 10]], + "l": [["L", 2.6, 1.0, 4.2, 1.0], ["L", 4.2, 1.0, 4.2, 10], ["L", 2.4, 10, 5.8, 10]], + "m": [["L", 1.2, 4.2, 1.2, 10], ["A", 2.6, 5.6, 1.4, 1.5, 180, 360], ["L", 4.0, 5.6, 4.0, 10], ["A", 5.4, 5.6, 1.4, 1.5, 180, 360], ["L", 6.8, 5.6, 6.8, 10]], + "n": [["L", 1.7, 4.2, 1.7, 10], ["A", 4.0, 6.0, 2.2, 1.9, 180, 360], ["L", 6.2, 6.0, 6.2, 10]], + "o": [["A", 4.0, 7.0, 2.4, 2.9, 0, 360]], + "p": [["L", 1.7, 4.2, 1.7, 11.8], ["A", 4.0, 7.0, 2.3, 2.9, -115, 115]], + "q": [["L", 6.3, 4.2, 6.3, 11.8], ["A", 4.0, 7.0, 2.3, 2.9, 65, 295]], + "r": [["L", 2.2, 4.2, 2.2, 10], ["A", 4.4, 5.8, 2.1, 1.7, 180, 330]], + "s": [["A", 4.0, 5.5, 2.0, 1.4, 140, 345], ["L", 2.2, 6.2, 5.8, 7.6], ["A", 4.0, 8.5, 2.1, 1.4, -35, 165]], + "t": [["L", 3.6, 1.8, 3.6, 8.6], ["L", 1.8, 4.2, 5.8, 4.2], ["A", 4.8, 8.6, 1.2, 1.3, 90, 180]], + "u": [["L", 1.7, 4.2, 1.7, 8.0], ["A", 4.0, 8.0, 2.2, 1.9, 0, 180], ["L", 6.2, 4.2, 6.2, 10]], + "v": [["L", 1.5, 4.2, 4.0, 10], ["L", 4.0, 10, 6.5, 4.2]], + "w": [["L", 1.0, 4.2, 2.4, 10], ["L", 2.4, 10, 4.0, 6.0], ["L", 4.0, 6.0, 5.6, 10], ["L", 5.6, 10, 7.0, 4.2]], + "x": [["L", 1.6, 4.2, 6.4, 10], ["L", 6.4, 4.2, 1.6, 10]], + "y": [["L", 1.6, 4.2, 4.0, 9.6], ["L", 6.4, 4.2, 2.4, 11.8]], + "z": [["L", 1.6, 4.2, 6.4, 4.2], ["L", 6.4, 4.2, 1.6, 10], ["L", 1.6, 10, 6.4, 10]], + "{": [["L", 5.0, 1, 3.6, 1.6], ["L", 3.6, 1.6, 3.6, 4.8], ["L", 3.6, 4.8, 2.2, 5.8], ["L", 2.2, 5.8, 3.6, 6.8], ["L", 3.6, 6.8, 3.6, 10], ["L", 3.6, 10, 5.0, 10.6]], + "|": [["L", 4.0, 0.8, 4.0, 10.8]], + "}": [["L", 3.0, 1, 4.4, 1.6], ["L", 4.4, 1.6, 4.4, 4.8], ["L", 4.4, 4.8, 5.8, 5.8], ["L", 5.8, 5.8, 4.4, 6.8], ["L", 4.4, 6.8, 4.4, 10], ["L", 4.4, 10, 3.0, 10.6]], + "~": [["A", 2.6, 5.8, 1.4, 1.2, 180, 360], ["A", 5.4, 5.8, 1.4, 1.2, 0, 180]], + "→": [["L", 1.0, 5.8, 6.6, 5.8], ["L", 4.4, 3.4, 6.8, 5.8], ["L", 4.4, 8.2, 6.8, 5.8]], + "·": [["A", 4.0, 5.8, 0.7, 0.7, 0, 360]], + "—": [["L", 0.8, 5.8, 7.2, 5.8]], + "×": [["L", 1.8, 3.6, 6.2, 8.0], ["L", 6.2, 3.6, 1.8, 8.0]], + "✓": [["L", 1.4, 6.2, 3.3, 8.8], ["L", 3.3, 8.8, 6.8, 2.4]], + "π": [["L", 1.4, 4.2, 6.6, 4.2], ["L", 2.8, 4.2, 2.4, 10], ["L", 5.2, 4.2, 5.4, 10]] }; +const GLYPH_ATLAS_CACHE = new Map(); + +function distToSegment(px, py, x0, y0, x1, y1) { + const dx = x1 - x0; + const dy = y1 - y0; + const len2 = dx * dx + dy * dy; + if (len2 < 1e-6) return Math.hypot(px - x0, py - y0); + const t = Math.max(0, Math.min(1, ((px - x0) * dx + (py - y0) * dy) / len2)); + return Math.hypot(px - (x0 + t * dx), py - (y0 + t * dy)); +} + +function getGlyphBitmap(ch, pxSize, bold) { + const key = `${ch}|${pxSize}|${bold ? 1 : 0}`; + let cached = GLYPH_ATLAS_CACHE.get(key); + if (cached) return cached; + + const ops = VECTOR_GLYPHS[ch] || VECTOR_GLYPHS[ch.toUpperCase()] || VECTOR_GLYPHS["?"]; + const scale = pxSize / 11.5; + const w = Math.max(4, Math.ceil(8.0 * scale)); + const h = Math.max(6, Math.ceil(12.5 * scale)); + const alpha = new Uint8Array(w * h); + + if (ops.length === 0) { + cached = { w, h, alpha }; + GLYPH_ATLAS_CACHE.set(key, cached); + return cached; + } + + // Convert arcs into fine polyline segments in pixel coordinates + const segs = []; + for (const op of ops) { + if (op[0] === "L") { + segs.push([op[1] * scale, op[2] * scale, op[3] * scale, op[4] * scale]); + } else if (op[0] === "A") { + const [, cx, cy, rx, ry, sDeg, eDeg] = op; + const steps = 14; + for (let i = 0; i < steps; i++) { + const a0 = ((sDeg + ((eDeg - sDeg) * i) / steps) * Math.PI) / 180; + const a1 = ((sDeg + ((eDeg - sDeg) * (i + 1)) / steps) * Math.PI) / 180; + segs.push([ + (cx + Math.cos(a0) * rx) * scale, + (cy + Math.sin(a0) * ry) * scale, + (cx + Math.cos(a1) * rx) * scale, + (cy + Math.sin(a1) * ry) * scale + ]); + } + } + } + + const strokeRadius = Math.max(0.58, (bold ? 0.88 : 0.70) * scale); + const feather = 0.72; + + for (let py = 0; py < h; py++) { + const cy = py + 0.5; + for (let px = 0; px < w; px++) { + const cx = px + 0.5; + let minDist = Infinity; + for (let s = 0; s < segs.length; s++) { + const seg = segs[s]; + const d = distToSegment(cx, cy, seg[0], seg[1], seg[2], seg[3]); + if (d < minDist) minDist = d; + } + const cov = Math.max(0, Math.min(1, (strokeRadius + feather * 0.5 - minDist) / feather)); + if (cov > 0) { + alpha[py * w + px] = Math.round(cov * 255); + } + } + } + + cached = { w, h, alpha }; + GLYPH_ATLAS_CACHE.set(key, cached); + return cached; +} + +class SoftGradient { + constructor(type, coords) { + this.type = type; + this.coords = coords; + this.stops = []; + } + addColorStop(offset, color) { + this.stops.push({ offset: Math.max(0, Math.min(1, offset)), rgba: colorUtil.parseHex(color) }); + this.stops.sort((a, b) => a.offset - b.offset); + } + sample(px, py) { + if (this.stops.length === 0) return [0, 0, 0, 255]; + if (this.stops.length === 1) return this.stops[0].rgba; + let t = 0; + if (this.type === "linear") { + const [x0, y0, x1, y1] = this.coords; + const dx = x1 - x0; + const dy = y1 - y0; + const len2 = dx * dx + dy * dy || 1; + t = Math.max(0, Math.min(1, ((px - x0) * dx + (py - y0) * dy) / len2)); + } else { + const [x0, y0, r0, x1, y1, r1] = this.coords; + const d = Math.hypot(px - x1, py - y1); + t = Math.max(0, Math.min(1, (d - r0) / Math.max(1, r1 - r0))); + } + for (let i = 0; i < this.stops.length - 1; i++) { + const s0 = this.stops[i]; + const s1 = this.stops[i + 1]; + if (t >= s0.offset && t <= s1.offset) { + const u = (t - s0.offset) / Math.max(1e-5, s1.offset - s0.offset); + return [ + Math.round(s0.rgba[0] + (s1.rgba[0] - s0.rgba[0]) * u), + Math.round(s0.rgba[1] + (s1.rgba[1] - s0.rgba[1]) * u), + Math.round(s0.rgba[2] + (s1.rgba[2] - s0.rgba[2]) * u), + 255 + ]; + } + } + return this.stops[this.stops.length - 1].rgba; + } +} + export class SoftCanvas2D { constructor(width, height) { this.width = Math.max(1, Math.round(width)); @@ -139,6 +261,21 @@ export class SoftCanvas2D { return this; } + createLinearGradient(x0, y0, x1, y1) { + return new SoftGradient("linear", [this._mapX(x0), this._mapY(y0), this._mapX(x1), this._mapY(y1)]); + } + + createRadialGradient(x0, y0, r0, x1, y1, r1) { + return new SoftGradient("radial", [ + this._mapX(x0), + this._mapY(y0), + r0 * this._sx, + this._mapX(x1), + this._mapY(y1), + r1 * this._sx + ]); + } + save() { this._stack.push({ fillStyle: this.fillStyle, @@ -196,7 +333,12 @@ export class SoftCanvas2D { return y * this._sy + this._ty; } - _parseColor(style) { + _parseColor(style, px = 0, py = 0) { + if (style instanceof SoftGradient) { + const rgba = style.sample(px, py); + const a = Math.max(0, Math.min(1, this.globalAlpha)); + return [rgba[0], rgba[1], rgba[2], Math.round(rgba[3] * a)]; + } const rgba = colorUtil.parseHex(style); const a = Math.max(0, Math.min(1, this.globalAlpha)); return [rgba[0], rgba[1], rgba[2], Math.round(rgba[3] * a)]; @@ -236,14 +378,16 @@ export class SoftCanvas2D { } fillRect(x, y, w, h) { - const [r, g, b, a] = this._parseColor(this.fillStyle); - if (a <= 0) return; + const isGrad = this.fillStyle instanceof SoftGradient; + const base = isGrad ? null : this._parseColor(this.fillStyle); + if (!isGrad && base[3] <= 0) return; const x0 = Math.max(0, Math.round(this._mapX(x))); const y0 = Math.max(0, Math.round(this._mapY(y))); const x1 = Math.min(this.width, Math.round(this._mapX(x + w))); const y1 = Math.min(this.height, Math.round(this._mapY(y + h))); for (let py = y0; py < y1; py++) { for (let px = x0; px < x1; px++) { + const [r, g, b, a] = isGrad ? this._parseColor(this.fillStyle, px, py) : base; this._blendPixel(px, py, r, g, b, a); } } @@ -286,7 +430,7 @@ export class SoftCanvas2D { let delta = endAngle - startAngle; if (!ccw && delta < 0) delta += Math.PI * 2; - const steps = Math.max(12, Math.min(64, Math.ceil(Math.abs(delta) * mr * 0.45))); + const steps = Math.max(16, Math.min(72, Math.ceil(Math.abs(delta) * mr * 0.55))); for (let i = 0; i <= steps; i++) { const a = startAngle + (delta * i) / steps; const px = mcx + Math.cos(a) * mr; @@ -310,7 +454,6 @@ export class SoftCanvas2D { this._path.push({ type: "L", x: mx1, y: my1 }); return; } - // Smooth corner approximation with 4 segments const x0 = last.x; const y0 = last.y; const dx0 = x0 - mx1; @@ -324,8 +467,8 @@ export class SoftCanvas2D { const sy = my1 + (dy0 / len0) * t; const ex = mx1 + (dx2 / len2) * t; const ey = my1 + (dy2 / len2) * t; - for (let i = 1; i <= 4; i++) { - const u = i / 4; + for (let i = 1; i <= 6; i++) { + const u = i / 6; const iu = 1 - u; const qx = iu * iu * sx + 2 * iu * u * mx1 + u * u * ex; const qy = iu * iu * sy + 2 * iu * u * my1 + u * u * ey; @@ -344,7 +487,7 @@ export class SoftCanvas2D { const y2 = this._mapY(cp2y); const x3 = this._mapX(x); const y3 = this._mapY(y); - const steps = 16; + const steps = 20; for (let i = 1; i <= steps; i++) { const u = i / steps; const iu = 1 - u; @@ -363,7 +506,7 @@ export class SoftCanvas2D { const y1 = this._mapY(cpy); const x2 = this._mapX(x); const y2 = this._mapY(y); - const steps = 12; + const steps = 14; for (let i = 1; i <= steps; i++) { const u = i / steps; const iu = 1 - u; @@ -380,10 +523,10 @@ export class SoftCanvas2D { } fill() { - const [r, g, b, a] = this._parseColor(this.fillStyle); - if (a <= 0) return; + const isGrad = this.fillStyle instanceof SoftGradient; + const base = isGrad ? null : this._parseColor(this.fillStyle); + if (!isGrad && base[3] <= 0) return; - // Fast anti-aliased disc rasterizer for full circles if (this._circleFastPath) { const { cx, cy, r: rad } = this._circleFastPath; const x0 = Math.max(0, Math.floor(cx - rad - 1)); @@ -395,8 +538,9 @@ export class SoftCanvas2D { for (let px = x0; px <= x1; px++) { const dx = px - cx; const d = Math.sqrt(dx * dx + dy * dy); - if (d <= rad + 0.5) { - const cov = Math.max(0, Math.min(1, rad + 0.5 - d)); + if (d <= rad + 0.65) { + const cov = Math.max(0, Math.min(1, rad + 0.65 - d)); + const [r, g, b, a] = isGrad ? this._parseColor(this.fillStyle, px, py) : base; this._blendPixel(px, py, r, g, b, Math.round(a * cov)); } } @@ -429,9 +573,10 @@ export class SoftCanvas2D { } nodes.sort((u, v) => u - v); for (let k = 0; k < nodes.length - 1; k += 2) { - const x0 = Math.max(0, Math.round(nodes[k])); - const x1 = Math.min(this.width - 1, Math.round(nodes[k + 1])); + const x0 = Math.max(0, Math.floor(nodes[k])); + const x1 = Math.min(this.width - 1, Math.ceil(nodes[k + 1])); for (let x = x0; x <= x1; x++) { + const [r, g, b, a] = isGrad ? this._parseColor(this.fillStyle, x, y) : base; this._blendPixel(x, y, r, g, b, a); } } @@ -441,40 +586,53 @@ export class SoftCanvas2D { stroke() { const [r, g, b, a] = this._parseColor(this.strokeStyle); if (a <= 0 || this._path.length < 2) return; - const hw = Math.max(0.5, (this.lineWidth * this._sx) / 2); + const hw = Math.max(0.55, (this.lineWidth * this._sx) / 2); + + // Anti-aliased circle ring fast path + if (this._circleFastPath) { + const { cx, cy, r: rad } = this._circleFastPath; + const pad = Math.ceil(hw + 1.5); + const x0 = Math.max(0, Math.floor(cx - rad - pad)); + const x1 = Math.min(this.width - 1, Math.ceil(cx + rad + pad)); + const y0 = Math.max(0, Math.floor(cy - rad - pad)); + const y1 = Math.min(this.height - 1, Math.ceil(cy + rad + pad)); + for (let py = y0; py <= y1; py++) { + const dy = py - cy; + for (let px = x0; px <= x1; px++) { + const dx = px - cx; + const dist = Math.abs(Math.sqrt(dx * dx + dy * dy) - rad); + if (dist <= hw + 0.7) { + const cov = Math.max(0, Math.min(1, hw + 0.7 - dist)); + this._blendPixel(px, py, r, g, b, Math.round(a * cov)); + } + } + } + return; + } for (let i = 1; i < this._path.length; i++) { const p0 = this._path[i - 1]; const p1 = this._path[i]; if (p1.type === "M") continue; - this._drawSegment(p0.x, p0.y, p1.x, p1.y, hw, r, g, b, a); + this._drawAntiAliasedSegment(p0.x, p0.y, p1.x, p1.y, hw, r, g, b, a); } } - _drawSegment(x0, y0, x1, y1, hw, r, g, b, a) { - const dx = x1 - x0; - const dy = y1 - y0; - const len = Math.sqrt(dx * dx + dy * dy); - if (len < 0.001) return; - - const steps = Math.ceil(len * 1.5); - const rad = Math.max(0.5, hw); - const ir = Math.ceil(rad); - for (let s = 0; s <= steps; s++) { - const u = s / steps; - const cx = x0 + dx * u; - const cy = y0 + dy * u; - const ix0 = Math.round(cx); - const iy0 = Math.round(cy); - if (rad <= 0.85) { - this._blendPixel(ix0, iy0, r, g, b, a); - } else { - for (let oy = -ir; oy <= ir; oy++) { - for (let ox = -ir; ox <= ir; ox++) { - if (ox * ox + oy * oy <= rad * rad + 0.35) { - this._blendPixel(ix0 + ox, iy0 + oy, r, g, b, a); - } - } + _drawAntiAliasedSegment(x0, y0, x1, y1, hw, r, g, b, a) { + const pad = Math.ceil(hw + 1.2); + const minX = Math.max(0, Math.floor(Math.min(x0, x1) - pad)); + const maxX = Math.min(this.width - 1, Math.ceil(Math.max(x0, x1) + pad)); + const minY = Math.max(0, Math.floor(Math.min(y0, y1) - pad)); + const maxY = Math.min(this.height - 1, Math.ceil(Math.max(y0, y1) + pad)); + + for (let py = minY; py <= maxY; py++) { + const cy = py + 0.5; + for (let px = minX; px <= maxX; px++) { + const cx = px + 0.5; + const d = distToSegment(cx, cy, x0, y0, x1, y1); + if (d <= hw + 0.65) { + const cov = Math.max(0, Math.min(1, hw + 0.65 - d)); + this._blendPixel(px, py, r, g, b, Math.round(a * cov)); } } } @@ -484,11 +642,9 @@ export class SoftCanvas2D { const m = String(this.font || "13px monospace").match(/(\d+(?:\.\d+)?)px/); const px = m ? parseFloat(m[1]) : 13; const bold = /bold|[6789]00/i.test(String(this.font)); - const effPx = px * this._sx; - const scale = effPx >= 12.5 ? Math.max(2, Math.round(effPx / 7.5)) : 1; - const charW = 5 * scale + Math.max(1, scale - 1); - const charH = 7 * scale; - return { px, bold, scale, charW, charH }; + const effPx = Math.max(9, Math.round(px * this._sx)); + const sample = getGlyphBitmap("M", effPx, bold); + return { px, effPx, bold, charW: sample.w, charH: sample.h }; } measureText(text) { @@ -503,7 +659,7 @@ export class SoftCanvas2D { const [r, g, b, a] = this._parseColor(this.fillStyle); if (a <= 0) return; - const { px, scale, charW, charH } = this._parseFont(); + const { px, effPx, bold, charW, charH } = this._parseFont(); const totalW = str.length * charW; let startX = this._mapX(x); let startY = this._mapY(y); @@ -511,9 +667,9 @@ export class SoftCanvas2D { if (this.textAlign === "center") startX -= totalW / 2; else if (this.textAlign === "right" || this.textAlign === "end") startX -= totalW; - if (this.textBaseline === "middle") startY -= charH / 2; - else if (this.textBaseline === "bottom") startY -= charH; - else if (this.textBaseline === "alphabetic") startY -= charH * 0.8; + if (this.textBaseline === "middle") startY -= charH * 0.46; + else if (this.textBaseline === "bottom") startY -= charH * 0.9; + else if (this.textBaseline === "alphabetic") startY -= charH * 0.78; startX = Math.round(startX); startY = Math.round(startY); @@ -538,18 +694,13 @@ export class SoftCanvas2D { for (let c = 0; c < str.length; c++) { const ch = str[c]; - const rows = GLYPHS[ch] || GLYPHS[ch.toUpperCase()] || GLYPHS["?"]; + const bmp = getGlyphBitmap(ch, effPx, bold); const cx0 = startX + c * charW; - for (let ry = 0; ry < 7; ry++) { - const rowBits = rows[ry]; - if (!rowBits) continue; - for (let rx = 0; rx < 5; rx++) { - if ((rowBits >> (4 - rx)) & 1) { - for (let sy = 0; sy < scale; sy++) { - for (let sx = 0; sx < scale; sx++) { - this._blendPixel(cx0 + rx * scale + sx, startY + ry * scale + sy, r, g, b, a); - } - } + for (let gy = 0; gy < bmp.h; gy++) { + for (let gx = 0; gx < bmp.w; gx++) { + const ga = bmp.alpha[gy * bmp.w + gx]; + if (ga > 0) { + this._blendPixel(cx0 + gx, startY + gy, r, g, b, (a * ga) >> 8); } } } diff --git a/tool/scripts/build-gallery.js b/tool/scripts/build-gallery.js index 7bb9910..badfe91 100644 --- a/tool/scripts/build-gallery.js +++ b/tool/scripts/build-gallery.js @@ -1,11 +1,11 @@ // Loop Studio — Gallery Builder -// Builds and renders all 6 official gallery fixtures (2 showcase loops + 4 ambient loops) -// along with their contact sheets, storyboards, audit reports, posters, and animated GIFs. +// Builds and renders all 12 official gallery fixtures (4 showcase loops + 8 ambient loops) +// along with their contact sheets, storyboards, audit reports, posters, GIFs, and high-FPS WebPs. import fs from "node:fs"; import path from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; -import { encodePNG, encodeGIF } from "../lib/encoders.js"; +import { encodePNG, encodeGIF, encodeAnimatedWebP, detectCapabilities } from "../lib/encoders.js"; import { analyzeSeam, analyzeLegibility, analyzeSources } from "../lib/analyzers.js"; import { renderAllFrames, renderContactSheet, renderStoryboard } from "../lib/compositor.js"; import { generatePreviewHtml } from "../lib/server.js"; @@ -15,28 +15,30 @@ const __dirname = path.dirname(__filename); const REPO_ROOT = path.resolve(__dirname, "../.."); const GALLERY_ITEMS = [ + // === Showcase Loops === { id: "loop-studio", title: "Loop Studio Showcase (Flow Pipeline)", mode: "showcase", scene: "flow", palette: "studio-dark", - prompt: "Make me a 10 second video that loops smoothly about this repo and what it does.", + useCase: "README hero diagram explaining what a repo or workflow does end-to-end", + prompt: "Make me an 8 second 60fps video that loops smoothly about this repo and what it does.", showcase: { title: "Loop Studio Showcase", says: "Loop Studio turns a one-line request into a checked, seamless loop.", - seconds: 10, - fps: 16, - width: 800, - height: 320, + seconds: 8, + fps: 60, + width: 640, + height: 288, palette: "studio-dark", scene: "flow", stage: ["request", "sketch", "check", "loop.gif"], steps: [ - { from: 8.75, to: 1.25, caption: "a request arrives: \"deep sea, square\"", source: "docs/contract.md:3" }, - { from: 1.25, to: 3.75, caption: "sketch is drawn from the phase", source: "docs/contract.md:14" }, - { from: 3.75, to: 6.25, caption: "seam and legibility are measured", source: "docs/tool.md:14" }, - { from: 6.25, to: 8.75, caption: "the verified loop drops out", source: "docs/tool.md:24" } + { from: 7.0, to: 1.0, caption: "request arrives: \"deep sea, square\"", source: "docs/contract.md:3" }, + { from: 1.0, to: 3.0, caption: "sketch draws from phase", source: "docs/contract.md:14" }, + { from: 3.0, to: 5.0, caption: "seam and contrast measured", source: "docs/tool.md:14" }, + { from: 5.0, to: 7.0, caption: "verified 60fps loop drops out", source: "docs/tool.md:24" } ] } }, @@ -46,6 +48,7 @@ const GALLERY_ITEMS = [ mode: "showcase", scene: "terminal", palette: "phosphor", + useCase: "CLI documentation showing commands, flags, and pass/fail audit output", prompt: "Animate how the loop CLI audits a sketch for seam continuity and WCAG legibility.", showcase: { title: "Loop CLI Audit Session", @@ -65,12 +68,72 @@ const GALLERY_ITEMS = [ ] } }, + { + id: "api-pipeline-code", + title: "Phase Contract SDK Showcase (Code)", + mode: "showcase", + scene: "code", + palette: "studio-dark", + useCase: "SDK / library docs pairing live-stepping code with a synchronized state monitor", + prompt: "Show how the render(ctx, phase) SDK contract executes line-by-line.", + showcase: { + title: "Phase Contract SDK Showcase", + says: "Every Loop Studio sketch exports meta and a pure render(ctx, phase) function.", + seconds: 10, + fps: 20, + width: 800, + height: 320, + palette: "studio-dark", + scene: "code", + stage: [ + "export const meta = { seconds: 4 };", + "export function render(ctx, phase) {", + " const a = phase * Math.PI * 2;", + " drawOrbit(ctx, a); // seam 1.00" + ], + steps: [ + { from: 8.75, to: 1.25, caption: "declare duration and fps in meta", source: "rules/AGENTS.md:8" }, + { from: 1.25, to: 3.75, caption: "pass normalized phase to render()", source: "rules/AGENTS.md:17" }, + { from: 3.75, to: 6.25, caption: "convert phase to integer cycles", source: "skills/loop-math/SKILL.md:22" }, + { from: 6.25, to: 8.75, caption: "last frame meets frame 0 cleanly", source: "skills/loop-render/SKILL.md:30" } + ] + } + }, + { + id: "mcp-mesh-topology", + title: "Agent Orchestrator Mesh (Architecture)", + mode: "showcase", + scene: "architecture", + palette: "aurora", + useCase: "System architecture & multi-agent/MCP topology diagrams for engineering RFCs", + prompt: "Animate how the Loop Studio agent coordinates the CLI, seam auditor, and cold-reader subagent.", + showcase: { + title: "Agent Orchestrator Mesh", + says: "The Loop Studio orchestrator coordinates the CLI renderer, seam analyzer, and cold-read subagent.", + seconds: 10, + fps: 20, + width: 800, + height: 320, + palette: "aurora", + scene: "architecture", + stage: ["Agent", "loop CLI", "Seam Audit", "Cold Reader"], + steps: [ + { from: 8.75, to: 1.25, caption: "agent scaffolds sketch via loop CLI", source: "AGENTS.md:9" }, + { from: 1.25, to: 3.75, caption: "CLI renders storyboard & frame deltas", source: "skills/loop-render/SKILL.md:24" }, + { from: 3.75, to: 6.25, caption: "cold-reader inspects storyboard.png", source: "agents/loop-cold-reader.md:10" }, + { from: 6.25, to: 8.75, caption: "verified loop.gif & audit return", source: "skills/loop-audit/SKILL.md:9" } + ] + } + }, + + // === Ambient Loops === { id: "deep-sea-orbits", title: "Abyssal Bioluminescence (Particle Orbit)", mode: "ambient", style: "particle-orbit", palette: "abyss", + useCase: "Calm ambient background for dark-mode apps, streams, and loading states", prompt: "Make a 4-second square loop. Deep sea, slow, bioluminescent.", brief: { title: "Abyssal Bioluminescence", @@ -91,6 +154,7 @@ const GALLERY_ITEMS = [ mode: "ambient", style: "flow-field", palette: "aurora", + useCase: "Organic generative header for landing pages, music visualizers, and project banners", prompt: "Drifting aurora currents, organic silk streamlines, 4-second loop.", brief: { title: "Arctic Currents", @@ -111,6 +175,7 @@ const GALLERY_ITEMS = [ mode: "ambient", style: "isometric-grid", palette: "nordic", + useCase: "Infrastructure, cloud platform, and modular architecture hero tiles", prompt: "Clean architectural blocks on an isometric grid rising and falling in waves.", brief: { title: "Harmonic Architecture", @@ -131,6 +196,7 @@ const GALLERY_ITEMS = [ mode: "ambient", style: "blueprint-cad", palette: "blueprint", + useCase: "Robotics, hardware, CAD, and precision engineering repo badges", prompt: "Precision engineering blueprint with planetary gear linkages rotating at 1x and -2x harmonic speeds.", brief: { title: "Epicyclic Telemetry", @@ -144,28 +210,215 @@ const GALLERY_ITEMS = [ height: 320, seed: 79 } + }, + { + id: "readme-hero-3d", + title: "Nebula SDF Sculpture (3D Raymarch)", + mode: "ambient", + style: "sdf-raymarch", + palette: "nebula", + useCase: "Zero-dependency 3D product showcase & smooth shader sculpture for SaaS hero cards", + prompt: "30 fps 3D raymarched smooth-union torus and orbiting spheres in neon nebula lighting.", + brief: { + title: "Nebula SDF Sculpture", + prompt: "30 fps 3D raymarched smooth-union torus and orbiting spheres in neon nebula lighting.", + mode: "ambient", + style: "sdf-raymarch", + palette: "nebula", + seconds: 3, + fps: 30, + width: 280, + height: 280, + seed: 53 + } + }, + { + id: "retro-crt-loader", + title: "Amber CRT Radar (Bayer Dither)", + mode: "ambient", + style: "dither-mono", + palette: "amber-crt", + useCase: "Low-bandwidth terminal/game splash screen & zero-shimmer retro loading indicator", + prompt: "30 fps retro amber CRT sphere and radar sweep using ordered 4x4 Bayer dithering.", + brief: { + title: "Amber CRT Radar", + prompt: "30 fps retro amber CRT sphere and radar sweep using ordered 4x4 Bayer dithering.", + mode: "ambient", + style: "dither-mono", + palette: "amber-crt", + seconds: 3, + fps: 30, + width: 280, + height: 280, + seed: 67 + } + }, + { + id: "kinetic-release-banner", + title: "Editorial Kinetic Wave (60 fps Type)", + mode: "ambient", + style: "kinetic-type", + palette: "editorial", + useCase: "60 fps social release announcement card, talk title slide, and launch banner", + prompt: "Silky 60 fps 4-second editorial kinetic typography wave repeating PHASE 0→1.", + brief: { + title: "Editorial Kinetic Wave", + prompt: "Silky 60 fps 4-second editorial kinetic typography wave repeating PHASE 0→1.", + mode: "ambient", + style: "kinetic-type", + palette: "editorial", + seconds: 4, + fps: 60, + width: 280, + height: 280, + seed: 61 + } + }, + { + id: "sonar-bathymetry", + title: "Abyssal Bathymetry (Topographic Isolines)", + mode: "ambient", + style: "topographic-contour", + palette: "abyss", + useCase: "Geospatial, weather, sonar, and telemetry elevation background loops", + prompt: "30 fps animated bathymetric contour isolines over a cyclic scalar noise field.", + brief: { + title: "Abyssal Bathymetry", + prompt: "30 fps animated bathymetric contour isolines over a cyclic scalar noise field.", + mode: "ambient", + style: "topographic-contour", + palette: "abyss", + seconds: 3, + fps: 30, + width: 280, + height: 280, + seed: 83 + } + }, + + // === Longer 60 fps Multi-Act Storytelling & Audio/Telemetry Loops === + { + id: "git-pr-guardrails", + title: "Protected Git Workflow (8s @ 60fps)", + mode: "showcase", + scene: "flow", + palette: "studio-dark", + customSketch: true, + useCase: "GitHub workflow & CI/CD guardrails explainer showing branch protection, evals, and PR merges", + prompt: "8-second 60fps showcase animating feat/* -> PR + CI evals -> protected dev & main.", + showcase: { + title: "Protected Git Workflow (60fps)", + says: "Branch guardrails block direct pushes and require passing CI evals before merging into dev and main.", + seconds: 8, + fps: 60, + width: 640, + height: 270, + palette: "studio-dark", + scene: "flow", + stage: ["feat/*", "PR + CI", "dev", "main"], + steps: [ + { from: 7.0, to: 1.0, caption: "branch feat/* forks from dev", source: ".github/workflows/ci.yml:5" }, + { from: 1.0, to: 3.0, caption: "CI runs 34 eval checks", source: ".github/workflows/ci.yml:19" }, + { from: 3.0, to: 5.0, caption: "CODEOWNERS approves the PR", source: ".github/CODEOWNERS:2" }, + { from: 5.0, to: 7.0, caption: "merged into dev & main", source: ".github/workflows/ci.yml:4" } + ] + } + }, + { + id: "json-to-gif-transform", + title: "60fps Video Transformer (8s @ 60fps)", + mode: "showcase", + scene: "transform", + palette: "abyss", + customSketch: true, + useCase: "Compiler, build pipeline, or media-processing explainer showing specs transforming into 60fps video", + prompt: "8-second 60fps transform showcase turning brief.json into 480 audited frames and MP4/WebP.", + showcase: { + title: "60fps Video Transformer", + says: "The Loop Studio transformer converts brief.json into 480 audited 60fps video frames.", + seconds: 8, + fps: 60, + width: 640, + height: 270, + palette: "abyss", + scene: "transform", + stage: ["brief.json", "60 FPS", "MP4 + WebP"], + steps: [ + { from: 7.0, to: 1.0, caption: "brief.json sets 60fps target", source: "skills/loop-brief/SKILL.md:31" }, + { from: 1.0, to: 3.0, caption: "renders 480 phase-exact frames", source: "rules/AGENTS.md:8" }, + { from: 3.0, to: 5.0, caption: "verifies seam score & contrast", source: "skills/loop-audit/SKILL.md:14" }, + { from: 5.0, to: 7.0, caption: "encodes 60fps MP4 & WebP", source: "skills/loop-render/SKILL.md:62" } + ] + } + }, + { + id: "live-audio-spectrum", + title: "120 BPM Harmonic Spectrum (6s @ 60fps)", + mode: "ambient", + style: "kinetic-audio", + palette: "ember", + customSketch: true, + useCase: "Music release loop, podcast player, and WebAudio/VST visualizer synced to 120 BPM (3 bars)", + prompt: "6-second 60fps 120 BPM harmonic spectrum visualizer with macro phrase swell and oscilloscope wave.", + brief: { + title: "120 BPM Harmonic Spectrum", + prompt: "6-second 60fps 120 BPM harmonic spectrum visualizer with macro phrase swell and oscilloscope wave.", + mode: "ambient", + style: "kinetic-audio", + palette: "ember", + seconds: 6, + fps: 60, + width: 340, + height: 240, + bpm: 120, + seed: 120 + } + }, + { + id: "orbital-telemetry-watch", + title: "Orbital Radar Telemetry (8s @ 60fps)", + mode: "ambient", + style: "blueprint-hud", + palette: "blueprint", + customSketch: true, + useCase: "Satellite tracker, aerospace HUD, and DevOps live observability dashboard splash", + prompt: "8-second 60fps blueprint radar HUD tracking 3 satellites on tilted elliptical orbits.", + brief: { + title: "Orbital Radar Telemetry", + prompt: "8-second 60fps blueprint radar HUD tracking 3 satellites on tilted elliptical orbits.", + mode: "ambient", + style: "blueprint-hud", + palette: "blueprint", + seconds: 8, + fps: 60, + width: 300, + height: 300, + seed: 204 + } } ]; -async function buildItem(item) { +async function buildItem(item, caps) { const dir = path.join(REPO_ROOT, "gallery", item.id); fs.mkdirSync(dir, { recursive: true }); - const templatePath = - item.mode === "showcase" - ? path.join(REPO_ROOT, "skills", "scenes", item.scene, "template.js") - : path.join(REPO_ROOT, "skills", "styles", item.style, "template.js"); - - let sketchCode = fs.readFileSync(templatePath, "utf8"); + const sketchPath = path.join(dir, "sketch.js"); const spec = item.mode === "showcase" ? item.showcase : item.brief; - sketchCode = sketchCode - .replace(/fps:\s*\d+/, `fps: ${spec.fps}`) - .replace(/width:\s*\d+/, `width: ${spec.width}`) - .replace(/height:\s*\d+/, `height: ${spec.height}`) - .replace(/palette:\s*"[^"]+"/, `palette: "${item.palette}"`); + if (!item.customSketch) { + const templatePath = + item.mode === "showcase" + ? path.join(REPO_ROOT, "skills", "scenes", item.scene, "template.js") + : path.join(REPO_ROOT, "skills", "styles", item.style, "template.js"); - const sketchPath = path.join(dir, "sketch.js"); - fs.writeFileSync(sketchPath, sketchCode, "utf8"); + let sketchCode = fs.readFileSync(templatePath, "utf8"); + sketchCode = sketchCode + .replace(/seconds:\s*\d+/, `seconds: ${spec.seconds}`) + .replace(/fps:\s*\d+/, `fps: ${spec.fps}`) + .replace(/width:\s*\d+/, `width: ${spec.width}`) + .replace(/height:\s*\d+/, `height: ${spec.height}`) + .replace(/palette:\s*"[^"]+"/, `palette: "${item.palette}"`); + fs.writeFileSync(sketchPath, sketchCode, "utf8"); + } if (item.mode === "showcase") { fs.writeFileSync(path.join(dir, "showcase.json"), JSON.stringify(item.showcase, null, 2) + "\n", "utf8"); @@ -188,13 +441,23 @@ async function buildItem(item) { fs.writeFileSync(path.join(dir, "poster.png"), posterBuf); const gifBuf = encodeGIF(frames, width, height, fps); - const gifName = item.mode === "showcase" ? "showcase.gif" : "loop.gif"; - fs.writeFileSync(path.join(dir, gifName), gifBuf); + const stem = item.mode === "showcase" ? "showcase" : "loop"; + fs.writeFileSync(path.join(dir, `${stem}.gif`), gifBuf); if (item.mode === "showcase") { fs.writeFileSync(path.join(dir, "loop.gif"), gifBuf); } - // 3. Contact sheet or storyboard + // 3. High-FPS Animated WebP when cwebp+webpmux are available (skipped gracefully on minimal CI) + let webpKB = null; + const webpPath = path.join(dir, `${stem}.webp`); + if (caps.cwebpPath && caps.webpmuxPath && fps >= 25) { + const wRes = encodeAnimatedWebP(frames, width, height, fps, webpPath); + webpKB = Number((wRes.bytes / 1024).toFixed(1)); + } else if (fs.existsSync(webpPath)) { + webpKB = Number((fs.statSync(webpPath).size / 1024).toFixed(1)); + } + + // 4. Contact sheet or storyboard const sheetCanvas = renderContactSheet(sketchModule, { ...meta, showcase: item.showcase, cols: 4 }); fs.writeFileSync(path.join(dir, "sheet.png"), encodePNG(sheetCanvas.data, sheetCanvas.width, sheetCanvas.height)); @@ -203,7 +466,7 @@ async function buildItem(item) { fs.writeFileSync(path.join(dir, "storyboard.png"), encodePNG(boardCanvas.data, boardCanvas.width, boardCanvas.height)); } - // 4. Seam, Legibility, Sources, Audit + // 5. Seam, Legibility, Sources, Audit const seam = analyzeSeam(frames, width, height); fs.writeFileSync(path.join(dir, "seam.json"), JSON.stringify(seam, null, 2) + "\n", "utf8"); @@ -217,6 +480,8 @@ async function buildItem(item) { id: item.id, title: item.title, mode: item.mode, + useCase: item.useCase, + fps, pass: seam.pass && legible.pass && sources.pass, seamScore: seam.seamScore, duplicateFrames: seam.duplicateFrames, @@ -224,6 +489,7 @@ async function buildItem(item) { legiblePass: legible.pass, sourcesPass: sources.pass, gifKB: Number((gifBuf.length / 1024).toFixed(1)), + ...(webpKB !== null ? { webpKB } : {}), totalFrames }; fs.writeFileSync(path.join(dir, "audit.json"), JSON.stringify(audit, null, 2) + "\n", "utf8"); @@ -231,11 +497,14 @@ async function buildItem(item) { } async function main() { + const caps = detectCapabilities(); const results = []; for (const item of GALLERY_ITEMS) { - const res = await buildItem(item); + const res = await buildItem(item, caps); results.push(res); - console.log(`[Gallery] ${res.id}: pass=${res.pass} seam=${res.seamScore} dup=${res.duplicateFrames} gif=${res.gifKB}KB`); + console.log( + `[Gallery] ${res.id} (${res.fps}fps): pass=${res.pass} seam=${res.seamScore} dup=${res.duplicateFrames} gif=${res.gifKB}KB${res.webpKB ? ` webp=${res.webpKB}KB` : ""}` + ); } fs.writeFileSync( path.join(REPO_ROOT, "gallery", "manifest.json"), diff --git a/tool/scripts/encode-mp4.swift b/tool/scripts/encode-mp4.swift new file mode 100644 index 0000000..f9587ff --- /dev/null +++ b/tool/scripts/encode-mp4.swift @@ -0,0 +1,146 @@ +import Foundation +import AVFoundation +import CoreVideo +import CoreMedia + +let args = CommandLine.arguments +guard args.count >= 7, + let width = Int(args[2]), + let height = Int(args[3]), + let fps = Int(args[4]), + let totalFrames = Int(args[5]) else { + fputs("Usage: encode-mp4.swift \n", stderr) + exit(1) +} + +let rawPath = args[1] +let outPath = args[6] +let encW = width % 2 == 0 ? width : width + 1 +let encH = height % 2 == 0 ? height : height + 1 +let safeFps = max(1, fps) + +let outURL = URL(fileURLWithPath: outPath) +try? FileManager.default.removeItem(at: outURL) + +guard let fileHandle = FileHandle(forReadingAtPath: rawPath) else { + fputs("Cannot open raw RGBA file: \(rawPath)\n", stderr) + exit(1) +} +defer { try? fileHandle.close() } + +do { + let writer = try AVAssetWriter(outputURL: outURL, fileType: .mp4) + let bitRate = max(1_800_000, min(16_000_000, encW * encH * safeFps / 3)) + let videoSettings: [String: Any] = [ + AVVideoCodecKey: AVVideoCodecType.h264, + AVVideoWidthKey: encW, + AVVideoHeightKey: encH, + AVVideoCompressionPropertiesKey: [ + AVVideoAverageBitRateKey: bitRate, + AVVideoProfileLevelKey: AVVideoProfileLevelH264HighAutoLevel, + AVVideoMaxKeyFrameIntervalKey: safeFps + ] + ] + + let input = AVAssetWriterInput(mediaType: .video, outputSettings: videoSettings) + input.expectsMediaDataInRealTime = false + + let sourceAttrs: [String: Any] = [ + kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_32BGRA, + kCVPixelBufferWidthKey as String: encW, + kCVPixelBufferHeightKey as String: encH + ] + let adaptor = AVAssetWriterInputPixelBufferAdaptor( + assetWriterInput: input, + sourcePixelBufferAttributes: sourceAttrs + ) + + guard writer.canAdd(input) else { + fputs("Cannot add AVAssetWriterInput\n", stderr) + exit(1) + } + writer.add(input) + + guard writer.startWriting() else { + fputs("startWriting failed: \(writer.error?.localizedDescription ?? "unknown")\n", stderr) + exit(1) + } + writer.startSession(atSourceTime: .zero) + + let frameByteCount = width * height * 4 + let srcRowBytes = width * 4 + + for f in 0.. BGRA + dst[di] = src[si + 2] + dst[di + 1] = src[si + 1] + dst[di + 2] = src[si] + dst[di + 3] = src[si + 3] + } + } + } + } + CVPixelBufferUnlockBaseAddress(pixelBuffer, []) + + let pts = CMTime(value: Int64(f), timescale: Int32(safeFps)) + if !adaptor.append(pixelBuffer, withPresentationTime: pts) { + fputs("Failed to append frame \(f): \(writer.error?.localizedDescription ?? "unknown")\n", stderr) + exit(1) + } + } + + input.markAsFinished() + let sem = DispatchSemaphore(value: 0) + writer.finishWriting { + sem.signal() + } + sem.wait() + + if writer.status != .completed { + fputs("AVAssetWriter finished with status \(writer.status.rawValue): \(writer.error?.localizedDescription ?? "unknown")\n", stderr) + exit(1) + } +} catch { + fputs("MP4 encoding error: \(error)\n", stderr) + exit(1) +} diff --git a/tool/test/run-evals.js b/tool/test/run-evals.js index f4b693c..367bc9c 100644 --- a/tool/test/run-evals.js +++ b/tool/test/run-evals.js @@ -6,10 +6,12 @@ // each fail the exact check designed to catch them. import fs from "node:fs"; +import os from "node:os"; import path from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; import { analyzeSeam, analyzeLegibility, analyzeSources } from "../lib/analyzers.js"; import { renderAllFrames } from "../lib/compositor.js"; +import { detectCapabilities, encodeAnimatedWebP } from "../lib/encoders.js"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -179,10 +181,43 @@ function testGalleryArtifacts() { } } +async function testHighFpsRendering() { + console.log("\n=== 4. High-FPS (60 fps) Video Pipeline ==="); + const p = path.join(REPO_ROOT, "skills", "styles", "particle-orbit", "template.js"); + const mod = await import(pathToFileURL(p).href); + const { frames, width, height, fps, totalFrames } = renderAllFrames(mod, { + width: 160, + height: 160, + seconds: 1, + fps: 60 + }); + const seam = analyzeSeam(frames, width, height); + assert( + fps === 60 && totalFrames === 60 && frames.length === 60 && seam.pass, + `60fps render produces 60 exact frames with passing seam (seamScore=${seam.seamScore}, dup=${seam.duplicateFrames})` + ); + + const caps = detectCapabilities(); + if (caps.cwebpPath && caps.webpmuxPath) { + const tmpWebp = path.join(os.tmpdir(), `loop-eval-60fps-${process.pid}.webp`); + try { + const res = encodeAnimatedWebP(frames.slice(0, 12), width, height, 60, tmpWebp); + const header = fs.readFileSync(tmpWebp).subarray(0, 12).toString("ascii"); + assert( + res.bytes > 0 && header.startsWith("RIFF") && header.endsWith("WEBP"), + `60fps Animated WebP encodes cleanly (${res.bytes} bytes via ${res.backend})` + ); + } finally { + if (fs.existsSync(tmpWebp)) fs.unlinkSync(tmpWebp); + } + } +} + async function main() { await testTemplates(); testNegativeGates(); testGalleryArtifacts(); + await testHighFpsRendering(); console.log(`\n========================================`); console.log(`Loop Studio Evals: ${passed} passed, ${failed} failed`);