Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Marketing: ten text templates drawn live in your brand

Adarsh655a6e46a75e
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index b50966db..fc9fb97f 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -386,7 +386,7 @@ Each studio keeps its data and pure planner in `src/lib/`, its server module in
| **Mixed Media** (`/mixed-media`) | `catalog/mixed-media.ts`: 33 presets with settings, frames = floor(s × fps), open render (one job, on `oss-mixed-media` until round 5 part 1), cloud Fast plan (trim → restyle → original sound), preview plan. Round 4 part 2: the cloud Per frame plan (`planMixedFrames`, the cloud default until round 5 part 1): cut → `extract-frames` (every Nth frame of the clip, `frameSampling`; up to 500 a call) → one Nano Banana 2 or Seedream 5.0 Flash edit per frame (`frameEditParams`: a fixed seed on Nano Banana 2, while Seedream 5.0 Flash takes none; `planMixedFrames` gives each frame the one styled before it as a second picture, in lanes of 12 that start from the approved preview) → `images-to-video` in clips of up to 200 frames → `join-clips` at up to 2048 px (`frameJoinSize`; 4K frames are then drawn at 2K, `frameResolution`) → the cut's own sound; the limits are `FRAME_LIMITS`. Since round 5 part 1 (O9) the default on both engines is Fuobe Mixed Media (`MIXED_ORIGINAL`, `MIXED_FRAME_MODELS`: the Original first, then Nano Banana 2 and Seedream 5.0 Flash in the cloud), drawn frame by frame with no lanes (`originalFrameRequest`, `originalFrameParams`, `originalFrameSize`); `MIXED_MODES` adds Smooth on both engines (`planMixedSmooth`), and Fast stays cloud only (see Fuobe Originals) | `mixed-media.ts`: estimate (adds `mode`, `perFrameUsd`, the sampled `fps`, `providers`, `modelId`), render, preview; `cloudMode` takes `mode` or reads it from the model (a model of the other mode is a 422); since round 5 part 1 `mode: "smooth"`, `source.width` / `height` for the frame size, the look LoRAs a run can reach (civitai key, LoRA folder) with notes, and Smooth's 17-frame / 5 fps refusal before anything is paid for; `retryMixed` redoes only failed or canceled steps and what follows them (`createPipeline` `existing`, `unfilledRequest`) and cancels the old waiting ones; `framesProgress` names the frame that failed; no table (History is the feed: features `mixed-media`, `mixed-media-step`, `mixed-media-frame-step`, `mixed-media-preview`) | `/api/mixed-media[/preview \| /estimate \| /retry \| /progress?id=]` | `components/mixed-media/*` (the Restyle switch, Per frame or Fast, since round 5 part 1 also Smooth, and the price per frame) |
| **Image studios** (Color signature, Moodboards, Photodump, Fashion Factory, Character Sheet) | `catalog/palettes.ts` (`applySignature`, `SignatureRecord` in `request.signature`; since round 4 part 3 a Soul model locks the palette by default on the open engine, and curated moodboards are Fuobe Soul looks: see Fuobe Originals), `catalog/packs.ts` (photo-run planners with `PlanCaps`; since round 4 part 5 `PlanCaps` is only `has(id, engine)`, the packs and templates come from `studio-packs.generated.ts`, and `castSheetModel` makes Character Sheet's Soul Cast sheet on Fuobe Soul's cloud half in Cinema's casting look (Nano Banana Pro when that half is switched off; the Soul Cast sheet graph on the GPU); since round 4 part 4 Photodump and Fashion run a character with a Soul ID on Fuobe Soul with its trained LoRA on both engines, `PHOTODUMP_SOUL` and `soulIdOf`, else Nano Banana Pro, Seedream 5.0 Pro or Qwen-Image-Edit from the photos; since round 5 part 1 the cloud's default without a Soul ID is hosted Qwen-Image-Edit 2511, `PHOTO_EDIT`, and Fashion Factory's outfit is Fuobe Try-On with its photoset on Qwen edit, `FASHION_MODELS`, `fashionModel`, Nano Banana Pro and FASHN staying as cloud choices; Character Sheet's "From a description" draws on Fuobe Soul in the casting look). Since round 4 part 4 a moodboard trained as a style LoRA is a Fuobe look (`OWN_LOOK`, `own-style`: its LoRA, no look words) on Fuobe Soul and the Z-Image family on either engine (`palettes.ts`) | `palettes.ts` (seeded 50 palettes, lock chains; the lock keeps a Soul look's `presetStrength` and the `engine`), `moodboards.ts` (status derived from the cover job, Recraft style id, style LoRA; since round 4 part 4 `moodboardTrainingTargets` and `trainMoodboard`: a style element from up to 80 of the board's images, trained on the GPU or with fal's Z-Image style trainer), `photodump.ts` (runs as one `createPipeline` batch; `retryPhoto`, since round 4 part 5 through `currentRequest`, its chained step too; the character sheets, `sheetRequest`, which since round 5 part 1 draw the casting look on Fuobe Soul, or on the Soul Cast sheet graph with that look's words and LoRAs) | `/api/palettes[/id \| /lock]`, `/api/moodboards[/id[/retry \| /train]]` (since round 4 part 4 `GET …/train` lists the style targets with price, blocker and demo flag, and `POST` takes an optional `target`), `/api/photodump[/packs[/id] \| /character \| /fashion \| /retry]` (since round 5 part 1 `/fashion` takes an optional `modelId` for the photoset) | `components/{palettes,moodboards,photodump,fashion}/*`; k-means in `palettes/extract.worker.ts`; the chips load through `useSignature` in the composer; the curated sets are built in (`CURATED_SETS` in `moodboards/logic.ts`, drawn covers, nothing fetched from Higgsfield) and a curated card opens `/image?model=fuobe-soul&moodboard=curated:<id>`; since round 4 part 5 the empty Image studio's "Make your own Soul look" cards (`moodboards/soul-preset-cards.tsx`) show for Fuobe Soul and Soul HD, where they showed for Soul 2.0 |
| **AI Influencer builder** (`/influencer`; round 4 part 2) | `src/lib/influencer.ts`: the tiers (Average, Bold, Extreme, and six creature types with species and body colour), what each tier shows, pick rules and the two clashes (`togglePick`, `conflictFor`, `setTier`), seeded Shuffle with the researched weights and per-category locks (`shuffleInfluencer`), the prompt compiler (`compileSheetPrompt`, `compileCastPrompt`, `compileDressPrompt`), `faceOfRun` and `planInfluencer` per engine; the option data is generated (`catalog/influencer-options.generated.ts`) | `influencer.ts`: prices with Photodump's helpers (`planCaps`, `previewRun`, `runEngine`) and makes one job or a two-step `createPipeline`. Cloud: one sheet on Nano Banana Pro (16:9, 2K; the default until round 5 part 1) or Seedream 5.0 Pro, with the photo and clothing as references. Open: the Soul Cast sheet (`oss-zimage-soul-cast`); with a face, a reference or clothing, Qwen-Image-Edit 2511 (`oss-qwen-edit`) then takes the sheet as image 1, the photo and clothing after it (3 images at most), and the sheet becomes a helper step (`influencer-step`). No Higgsfield route. `retryPhoto` (`photodump.ts`) runs both steps again when the sheet failed, and re-chains a pass that never launched. Since round 5 part 1 (O10) the cloud default is Fuobe Soul: a 16:9 1080p sheet in the Realistic look (`INFLUENCER_LOOK`, `v1-realistic`), then hosted Qwen-Image-Edit 2511 adds the face, reference or clothing with no size sent, so the sheet keeps its shape; Nano Banana Pro and Seedream 5.0 Pro stay as choices and are the fallback, with a note, when Fuobe Soul or hosted Qwen edit is switched off. On the GPU the Soul Cast sheet carries that look's words and LoRAs | `POST /api/influencer` (`?preview=1` prices it; since round 5 part 1 also `POST /api/influencer/estimate`, the same price at the path the evaluation harness uses); retries through `POST /api/photodump/retry` | `components/influencer/*` (`influencer-builder.tsx`, `option-panel.tsx`); Save as character reuses `SaveCharacter` from `fashion/character-sheet.tsx` and reads the face from the run itself (`faceOfRun`); linked from Character Sheet, and from the AI Influencer app through `StudioConfig.related` |
-| **Marketing** (Marketing Studio, Click to Ad, Ads Studio, Ad Multiplier) | `catalog/marketing.ts`: 84 templates, 11 formats, 9 hooks, 14 settings, 10 ad styles, angles, word budgets, `formatModels` (since round 4 part 5 without Marketing Studio Image; since round 5 part 1 Fuobe Marketing Image first for every image format on both engines and the only one on the GPU, `MARKETING_IMAGE_MODEL`, with `wordsOnTop` saying when the browser sets the words), Ads Studio's picture models (`AD_VISUAL_MODELS`, `adVisualModel`, round 5 part 1), `UGC_MODELS`, `OPEN_SOUND_JOIN`; since round 4 part 5 the Ad Multiplier's `MULTIPLIER_MODELS` (cloud: Kling O3 edit by default, Happy Horse video edit and Gemini Omni Flash), `MULTIPLIER_WINDOW` (Kling O3 and Happy Horse recreate at most 15 s) and `mentionsFor` binding `@ImageN` for Happy Horse as for Kling; since round 4 part 2 the Click to Ad logo end card (`END_CARD`, `END_CARD_MODELS`, `endCardSteps`: cloud [`overlay-image`: the logo on the brand colour →] `ken-burns` → a silent track (`merge-audio-video`) → `join-clips` after the ad; open `oss-append-endcard`, or `oss-still-to-clip` + `oss-join-sound1` for an ad ComfyUI didn't encode) | `brand.ts` (website scrape, research job, `kitForSite`), `marketing.ts` (`planMarketing`, `planClickToAd`, `planMultiplier` with `referenceFacts` → RunPlan → `createPipeline`; since round 4 part 5 it cuts a longer selection to the edit model's window with a note, prices the edit by the clip's length and keeps the reference's sound (`KEEP_SOUND`: Kling's `keep_audio`, Happy Horse's `audio_setting` "origin"); since round 4 part 4 the Ad Multiplier's open recreation runs `fuobe-genjutsu-motion` pinned to the open engine; `marketing_runs` keeps the input for Run again and the browser composite; `withEndCard` turns the ad's last step into a helper and adds the card, with `adEncoder`, `cardBackground` and `silentWav`; since round 5 part 1 `onPlanEngine` pins every dual-engine step to the studio's engine in the estimate and the launch, `runsFor` makes a batch with words on top N one-picture runs, and a GPU Standalone shot of one photo is flagged `productShot`), `ads.ts` (batches, creatives, concepts, chat, proposals; since round 4 part 5 every ad is copy plus one visual composited in the browser: `BatchBody` has no `route` or `ratio`, the estimate no `route`, and an ad Higgsfield drew whole is `baked`, shown as it is and remade the Fuobe way on Retry; since round 5 part 1 `BatchBody` takes an optional `modelId` for the picture, and Retry reuses the batch's) | `/api/brands/**` (since round 4 part 5 `POST /api/brands/[id]/chat/confirm` takes `{messageId, engine}`), `/api/products/**`, `/api/marketing/**` (Click to Ad and its estimate take `endCard`; since round 5 part 1 `POST /api/marketing/runs/[id]/compose` serves cloud Fuobe Marketing Image runs too), `/api/ads/**` | `components/{marketing,ads,brand}/*` (since round 5 part 1 Ads Studio's cloud-only "Pictures by" select in `ads/new-ads.tsx`); ad layout math (`ads/layout.ts`) → canvas render with Google fonts (`ads/render.ts`) → stored zip (`ads/zip.ts`); @mention helpers (`ads/mention.ts`); the 9:16 end card drawn in the browser (`marketing/end-card.ts`) and uploaded once per look; the animated end card (Kinetic Motion: five styles in `src/lib/motion/scenes/end-card/`, drawn and encoded in the browser by `src/components/motion/`, `marketing/end-card-motion.tsx`) sent as `endCard.clip`, which replaces the still and its push-in (cloud: its silent track, then `join-clips`; open: one `oss-join-sound1` with the ad first) |
+| **Marketing** (Marketing Studio, Click to Ad, Ads Studio, Ad Multiplier) | `catalog/marketing.ts`: 88 templates (10 drawn by Kinetic Motion), 11 formats, 9 hooks, 14 settings, 10 ad styles, angles, word budgets, `formatModels` (since round 4 part 5 without Marketing Studio Image; since round 5 part 1 Fuobe Marketing Image first for every image format on both engines and the only one on the GPU, `MARKETING_IMAGE_MODEL`, with `wordsOnTop` saying when the browser sets the words), Ads Studio's picture models (`AD_VISUAL_MODELS`, `adVisualModel`, round 5 part 1), `UGC_MODELS`, `OPEN_SOUND_JOIN`; since round 4 part 5 the Ad Multiplier's `MULTIPLIER_MODELS` (cloud: Kling O3 edit by default, Happy Horse video edit and Gemini Omni Flash), `MULTIPLIER_WINDOW` (Kling O3 and Happy Horse recreate at most 15 s) and `mentionsFor` binding `@ImageN` for Happy Horse as for Kling; since round 4 part 2 the Click to Ad logo end card (`END_CARD`, `END_CARD_MODELS`, `endCardSteps`: cloud [`overlay-image`: the logo on the brand colour →] `ken-burns` → a silent track (`merge-audio-video`) → `join-clips` after the ad; open `oss-append-endcard`, or `oss-still-to-clip` + `oss-join-sound1` for an ad ComfyUI didn't encode) | `brand.ts` (website scrape, research job, `kitForSite`), `marketing.ts` (`planMarketing`, `planClickToAd`, `planMultiplier` with `referenceFacts` → RunPlan → `createPipeline`; since round 4 part 5 it cuts a longer selection to the edit model's window with a note, prices the edit by the clip's length and keeps the reference's sound (`KEEP_SOUND`: Kling's `keep_audio`, Happy Horse's `audio_setting` "origin"); since round 4 part 4 the Ad Multiplier's open recreation runs `fuobe-genjutsu-motion` pinned to the open engine; `marketing_runs` keeps the input for Run again and the browser composite; `withEndCard` turns the ad's last step into a helper and adds the card, with `adEncoder`, `cardBackground` and `silentWav`; since round 5 part 1 `onPlanEngine` pins every dual-engine step to the studio's engine in the estimate and the launch, `runsFor` makes a batch with words on top N one-picture runs, and a GPU Standalone shot of one photo is flagged `productShot`), `ads.ts` (batches, creatives, concepts, chat, proposals; since round 4 part 5 every ad is copy plus one visual composited in the browser: `BatchBody` has no `route` or `ratio`, the estimate no `route`, and an ad Higgsfield drew whole is `baked`, shown as it is and remade the Fuobe way on Retry; since round 5 part 1 `BatchBody` takes an optional `modelId` for the picture, and Retry reuses the batch's) | `/api/brands/**` (since round 4 part 5 `POST /api/brands/[id]/chat/confirm` takes `{messageId, engine}`), `/api/products/**`, `/api/marketing/**` (Click to Ad and its estimate take `endCard`; since round 5 part 1 `POST /api/marketing/runs/[id]/compose` serves cloud Fuobe Marketing Image runs too), `/api/ads/**` | `components/{marketing,ads,brand}/*` (since round 5 part 1 Ads Studio's cloud-only "Pictures by" select in `ads/new-ads.tsx`); ad layout math (`ads/layout.ts`) → canvas render with Google fonts (`ads/render.ts`) → stored zip (`ads/zip.ts`); @mention helpers (`ads/mention.ts`); the 9:16 end card drawn in the browser (`marketing/end-card.ts`) and uploaded once per look; the animated end card (Kinetic Motion: five styles in `src/lib/motion/scenes/end-card/`, drawn and encoded in the browser by `src/components/motion/`, `marketing/end-card-motion.tsx`) sent as `endCard.clip`, which replaces the still and its push-in (cloud: its silent track, then `join-clips`; open: one `oss-join-sound1` with the ad first) |
| **Faceless Studio / Explainer** (`/faceless`, `/explainer`) | `catalog/faceless.ts`: genres, 22 styles (12 for Faceless), block planning, `buildEpisodeGraph` (steps keyed still / clip / join / narration / music / mix / words / captions), `planRerun`, `planRetry`, `estimateGraph`, `spokenTimes`, `sceneTiming`, `musicLength`, `styleRefLimit`. Round 4: Frame by frame is a Ken Burns move per scene, not a video model (`ENGINE_MODELS.kenBurns`: the cloud's `ken-burns` zooms only, the open `oss-ken-burns` pans and zooms and splits scenes over 10 s; the moves come from the scene's words, `sceneMoves` in `src/lib/av/ken-burns.ts`), joined with `framesJoin` (`oss-join-encoded` on the open engine); `musicPlan` adds a `music-loop` step when the film outlasts the music (open `oss-audio-loop` crossfades up to 600 s, the cloud's `join-audio` repeats whole plays); `staleSteps` / `bedFits` redo kept steps whose model, operation, clip length or music bed no longer fits; the open `upscale` is `oss-upscale-video-esrgan`. Since round 4 part 2 a channel's `settings.brief` (`BriefLook`, from Content Factory) adds look, camera and music words to the prompts, sets the scene length and the captions' words and position | `faceless.ts`: channels (avatar job), episodes, scripts written in the background by the llm provider (`askLlm`), `launch()` (stage one: stills, narration, word timings) and `advance()` (scenes cut to the spoken times, then clips, joins, music, mix, subtitles), `settle()`, `ensureFacelessRunner()` (2 s sweep, started at boot); a Motion change that reads as the scene's current camera move answers 422 (`sameCameraMove`); `readDocument()` for PDF and Word sources | `/api/faceless/**`, `/api/explainer[/link \| /document]` | `components/{faceless,explainer}/*` |
| **Content Factory** (`/content-factory`, `/content-factory/[id]`; round 4 part 2) | `catalog/content-factory.ts`: the style brief (`StyleBrief`: format, hook, pacing, shots, look, animation, voice, music, captions, topics; `parseBrief` reads an LLM's answer, `offlineBrief` makes one from the clip's shape, length and speech rate), 8 preset styles, 4 animation styles, lengths 30 s to 5 min, up to 10 episodes, the link guard (`referenceLink`: TikTok, Instagram, a direct clip or a web page; YouTube asks for an upload; `pageMedia` finds a page's og:video or `<video>`), episode titles (`parseSeries`, `offlineSeries`), prices (`seriesPrice`, `briefCostUsd`) and the Generate in Claude message (`claudePlan`, `claudeMessage`, `mcpCommand`) | `content-factory.ts`: a series is a `content_series` row whose episodes are ordinary Faceless episodes in a channel of its own (`createChannel` with the brief in its settings, then `createEpisode` per title; nothing is forked). Reading a reference: cloud = `extract-frames` (about a frame a second, JPEG) and Scribe v2 as generations, then `llmText` writes the brief from up to 20 frames (`fitFrames` keeps them within 15 MB) and the transcript; open = one `oss-reference-brief` job (Gemma 4 E4B, the first 30 s). A link is fetched through `fetchRemote`. The brief is written in this process when the series is next read (`seriesView`), and Generate / Next episode hold a one-process claim, so repeated clicks make one series | `/api/content-factory/series[/id[/generate \| /episodes \| /read]]`, `/api/content-factory/{estimate,claude}`; `POST /api/faceless/episodes` takes 30–300 s on a channel whose settings carry a brief | `components/content-factory/*` (`home.tsx`, `series-view.tsx`, `parts.tsx`, `hooks.ts`); the series page is a record page with a real 404 (`series` in `record-pages.ts` / `records.ts`) |
| **Image to 3D** (`/image-to-3d`; round 4 part 3: five modes and Rig & animate) | `lib/av/model3d.ts`: the modes (From an image, From several images, From text, Pick an object, Splat: `MODEL3D_MODES`), the models per mode and engine, the default first (`MODELS_3D`; From an image opens on Pixal3D, `oss-pixal3d` on `image-to-3d-pixal3d`, with TRELLIS.2 as the fallback; Pick an object has no open model, rigging is Meshy on fal only), the sides of a multi-view model (`VIEW_SIDES`: the front is needed; left and right are the object's own), `model3dBlocker`, `model3dRequest` (the sides go in `params.extra.views`), `viewerGlb` (the web GLB when there is one), `stillPromptFor3d`, what a card shows (`model3dView`, `splatFormatOf`, `stillOf`: the still a text-to-3D model was built from), `CLOUD_NOTICES` ("Built with DINOv3" for TripoSplat and TRELLIS.2 on fal too), 30 curated Meshy animations in 6 groups (`ANIMATION_PRESETS`; the dialog starts on Casual walk, and any id up to 696 can be typed) and `rigRequest` | ordinary generations; the open text route is `createStillTo3d` (see Pipelines); the extra formats and previews are stored (`persistArtifacts`). `src/server/model3d-finish.ts` finishes the first GLB of an open image-to-3D job in two steps, each a child process: `finishModel` before the job succeeds (`scripts/model3d/finish-glb.mjs` with glTF Transform, meshoptimizer and sharp: a roughness floor by material read from the metallic channel, the pivot at the bottom centre, meshopt geometry and WebP textures at 2048, in `meta.web`; the raw GLB stays the download), then `startTurntable` after it (`scripts/model3d/render-turntable.mjs`: `<model-viewer>` in headless Chromium on SwiftShader, CPU only, 96 frames at 24 fps on a studio backdrop, encoded by ffmpeg, plus a poster), one at a time at below-normal priority; `meta.finish.turntable` is queued, rendering (with progress), done, skipped (no Chromium or ffmpeg: the page records one in the browser) or failed, and a restart picks up the queued ones. A failure keeps what was made | `POST /api/generations` (and `?preview=1` for the price line before a run); `?mode=` and `?model=` pick the mode and model (⌘K opens every 3D model and Meshy Rigging here) | `app/(studio)/image-to-3d/page.tsx` (an async server component: each open model's licence line, read from the manifest in a `"use cache"` function), `components/model3d/*`: `model3d-studio.tsx` (the mode radio group, the side slots, the price), `model-card.tsx` (cards play the turntable and never load a GLB; a splat shows its orbit video or cut-out and a .spz / .ply download, since Fuobe doesn't draw splats; a rigged model plays its animation), `model-viewer.ts` (the viewer's setup: the same-origin meshopt decoder `public/vendor/meshopt_decoder.js`), `turntable.ts` and `webm.ts` (the browser's own turntable when the server can't: 96 frames at 24 fps through WebCodecs), `rig-dialog.tsx`, `hooks.ts`. The Library viewer (`ModelViewer` in `result-media.tsx`) never loads model-viewer for a splat |
@@ -406,6 +406,8 @@ Each studio keeps its data and pure planner in `src/lib/`, its server module in
Motion graphics drawn by code, in the brand's own fonts and colours, with the words exactly as typed. A **scene** is a pure function of a **recipe** (JSON: scene, seed, size, fps, length, the typed fields, the brand, the person's own files, control values, export settings) and an absolute time: `scene.plan(input)` lays the text out once (`layout.ts`: balanced lines, never cut, never re-cased, never split mid-word; a field that doesn't fit is reported as `overflow` and blocks the render) and builds a timeline of cues (`tween.ts`, on the named curves in `ease.ts`: Bézier, closed-form springs), and `plan.evaluate(t)` gives a display list (`display.ts`: groups with transforms, clips, masks and blends; rects, ellipses, paths with stroke trim, text runs, images) in design units (1080 on the short side, `sizes.ts`). Randomness is a hash of the seed and a key (`random.ts`); there is no clock, DOM or `Math.random` in `src/lib/motion`, so any frame can be seeked in any order (`tests/motion-scenes.test.ts`). `camera2d.ts` is a 2.5D camera with parallax by depth. The browser half: `draw.ts` (`drawDisplayList`, the only code that draws a list, and SVG logo outlines read with the browser's SVG engine), `fonts.ts` (an export waits for the brand font or stops), `player.tsx` (the live preview: absolute time on animation frames, pauses off screen or in a hidden tab, rest frame for reduced motion, a smaller backing store on slow devices), `render.ts` (`renderClip`: frame i at i / fps, motion blur from shutter samples never across a cut, as many per frame as its fastest edge needs (`listTravel` in `display.ts`: one for a frame that barely moves, up to 48), WebCodecs H.264 MP4 from the canvas itself, else VP8 WebM, else the recorder) and `save.ts` (`saveMotionResult`: `POST /api/uploads`, then `POST /api/generations/local` with model `local-motion`, op `motion` and the recipe in `params.extra.motion`; nothing is downloaded from the page). Phase 1 ships the end card's five styles (`scenes/end-card/`: Draw-on, Rise, Iris, Split, Glint), whose rest frame is the still card's own layout (`planEndCard` and `renderEndCard` use the same `endCardRest` and drawer). The rest layout sizes type from the frame's short side, keeps a tall card's bottom fifth clear, and sets the words and pill in the kit colour that reads best on the brand colour (`cardColours`). Each style opens a few frames into its motion (`lead`), is readable by about 0.9 s of a 2.5 s card (`settled`), then a slow push-in (`CAMERA_FROM`, the `drift` curve) comes home on the last frame (`rest`, the poster); `signature` is the frame the style chooser shows. A saved clip carries its poster in `output.meta.poster`. Click to Ad joins the rendered card after the ad: in the cloud with its silent track and `merge-videos`, on the open engine with `oss-join-sound1`, which re-encodes the ad at 25 fps (the still card's `oss-append-endcard` copies the ad's picture instead); the open path has not yet been run end to end on a GPU.
+**Marketing templates drawn by code.** Ten Marketing Studio templates are Kinetic Motion scenes instead of model prompts (`render: "code"` in `catalog/marketing.ts`, with their `scene`, typed `fields` and `easy` choices): Kinetic Headline, Line-Art Reveal, Logo Sting, Feature Cards, Dashboard Zoom, Retro Starburst, and the new Offer Badge, Big Number, Five-Star Quote and Logo End Card (the five end-card styles as its Style choice). The scenes are in `src/lib/motion/scenes/marketing/` (`kit.ts`: the light, dark and brand-colour looks from the kit with every word at 4.5:1 or more, the safe area, the pace, the tabular rolling counter, `*stars*` that mark a highlighted word and are never drawn); `outline.ts` traces a cut-out picture's edge from its transparency (marching squares, then Ramer–Douglas–Peucker) for Line-Art Reveal, and a photo without one gets a traced frame. `template.ts` turns what the template's panel holds (words, choices, size, length 5–15 s, brand, picture) into the recipe; `showcase.ts` holds the fictional brands each template opens with. The panel (`components/marketing/kinetic-template.tsx` with `components/motion/{fields,easy-chips,brand-row,made-strip}.tsx`) replaces the composer for these templates: anyone can type and play, Save renders in the tab and records the clip as `feature: "marketing-kinetic"` through `save.ts` (the same upload rule as any file; a guest gets the sign-up card and an account with neither its own GPU nor a key the Connect card before anything renders), and "Made with this template" lists the saved clips, which open in the result viewer. Their covers are rendered by the engine itself: `scripts/kinetic/render-covers.mjs` plays each showcase on the development-only page `/dev/kinetic-covers` and writes cover masters (`meta.json` `rest`: `"end"`, or the seconds of the moment the words are all set), then `pnpm eval:covers --templates` versions them into `public/previews/templates/marketing/`.
+
## ComfyUI workflow library (`workflows/comfyui/`, `scripts/comfy/`)
`manifest.json` lists 158 workflows, 153 of them `validated: true` (the five H3 graphs of round 4 parts 4 and 5 are `validated: false`, below), each with its **bindings** (canonical key → node id + input), outputs (with `stem` and `role`), defaults, limits, required model files with download URLs and sizes, custom node packs, VRAM, licence, notes, `autoDownloads`, and since round 3 `expand` (`captions` or `timeline`: the provider rewrites the graph per request) and `worker: "isolated"`. Round 4 adds `expand: "videos"` / `"audios"` (joins, one loader per clip), model files marked `optional` (FILM beside RIFE; the Workflows page leaves them out of the missing count), and output roles `scene`, `depth`, `mask`, `cutout`, `matte`, `preview`, `frames`, `frame`, `lines`, `splat` and `brief` (the graphs with `frame`, `lines` and `brief` got their models in round 4 part 2, for Layers' OCR and Content Factory, and the `splat` graph in round 4 part 3, for Image to 3D; round 4 part 5 adds `master`, Character Swap Studio's lossless take, and round 5 part 2 `report`, a node's own account of the run, with the stems `music` and `effects`). The pipeline in `scripts/comfy/` exports the official templates through the real ComfyUI frontend (`app.graphToPrompt()`), applies documented transforms (`library.spec.mjs`, `lib/graph.mjs`), builds hand-written API graphs from `hand-built/*.json`, and validates every graph with `POST /prompt` against a live ComfyUI using zero-byte placeholder models.
diff --git a/docs/public-signup.md b/docs/public-signup.md
index 3eefea7b..241278e0 100644
--- a/docs/public-signup.md
+++ b/docs/public-signup.md
@@ -31,7 +31,10 @@ Every change a guest sends (generate, upload, save a setting, create a project
studio shows a "Create a free account to run this" card with **Sign up** and **Log in**. Where
signing up wouldn't help, a guest gets an account's answer instead: 403 `assist-owner` for Assist,
and 403 `own-gpu-tool` for a tool an account's own GPU or key doesn't run (Shorts, Katana,
-Marketing…). The pages of those tools say so up front and turn off their upload and Generate. Price
+Marketing…). The pages of those tools say so up front and turn off their upload and Generate.
+What is drawn in the browser itself is open to try: Click to Ad's animated end card and Marketing
+Studio's code-drawn templates (Kinetic Motion) take a guest's words and play live (a code-drawn
+template shows no "isn't available" note, as nothing is generated); their Save opens the sign-up card before anything renders. Price
checks (the estimate routes, and `?preview=1` on the run routes that support it) stay open, so the
studios can show prices. A guest may send 120 price checks a minute (per visitor behind a trusted
reverse proxy; see below), and so may each account. A price check reads only the header of a file
diff --git a/public/previews/kinetic/heel.webp b/public/previews/kinetic/heel.webp
new file mode 100644
index 00000000..f7a473bf
Binary files /dev/null and b/public/previews/kinetic/heel.webp differ
diff --git a/public/previews/kinetic/marks/ardent.svg b/public/previews/kinetic/marks/ardent.svg
new file mode 100644
index 00000000..b5daed92
--- /dev/null
+++ b/public/previews/kinetic/marks/ardent.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="1741" height="213" viewBox="0 0 1740.5 212.72"><g fill="#111111"><g transform="translate(7 7)"><path fill-rule="evenodd" d="M33.78 198.72V65.58A65.58 65.58 0 0 1 164.94 65.58V198.72ZM42.72 189.78H156V65.58A56.64 56.64 0 0 0 42.72 65.58Z"/><path fill-rule="evenodd" d="M99.36 91.41L116.05 115.26L99.36 139.1L82.67 115.26Z"/></g><g transform="translate(249.4 22.46)"><path d="M127.6 30.8L127.6 30.8L127.6 33.8Q122.5 34.0 120 34.9Q117.4 35.9 116.6 38.5Q115.8 41.2 115.8 46.7L115.8 46.7L115.8 121.1Q115.8 126.5 116.6 129.2Q117.4 131.9 120 132.8Q122.5 133.7 127.6 134L127.6 134L127.6 137Q123.9 136.7 118.3 136.6Q112.8 136.6 107.1 136.6L107.1 136.6Q100.8 136.6 95.3 136.6Q89.7 136.7 86.4 137L86.4 137L86.4 134Q91.5 133.7 94.1 132.8Q96.8 131.9 97.6 129.2Q98.5 126.5 98.5 121.1L98.5 121.1L98.5 39.0L99.3 39.4L62.4 137.6L60 137.6L21.3 40.4L21.3 117.2Q21.3 123.5 22.2 127.0Q23.1 130.6 26.1 132.1Q29.1 133.6 35.3 134L35.3 134L35.3 137Q32.4 136.7 28.0 136.6Q23.6 136.6 19.6 136.6L19.6 136.6Q15.9 136.6 12.2 136.6Q8.4 136.7 6 137L6 137L6 134Q10.9 133.6 13.5 132.1Q16.1 130.7 16.9 127.3Q17.8 123.8 17.8 117.8L17.8 117.8L17.8 46.7Q17.8 41.2 16.9 38.5Q16.1 35.9 13.5 34.9Q10.9 34.0 6 33.8L6 33.8L6 30.8Q8.4 31.0 12.2 31.1Q15.9 31.3 19.6 31.3L19.6 31.3Q24 31.3 28.4 31.1Q32.9 31.0 36 30.8L36 30.8L69.1 116L66.3 118.0L98.8 31.3Q100.8 31.3 102.9 31.3Q105 31.3 107.1 31.3L107.1 31.3Q112.8 31.3 118.3 31.1Q123.9 31.0 127.6 30.8ZM206.2 30.2L206.2 30.2L242.8 124.4Q244.9 129.9 247.7 131.9Q250.4 133.8 252.8 134L252.8 134L252.8 137Q249.3 136.7 244.4 136.6Q239.5 136.6 234.6 136.6L234.6 136.6Q228.3 136.6 222.8 136.6Q217.4 136.7 214.2 137L214.2 137L214.2 134Q221.8 133.7 223.8 131.4Q225.8 129.1 222.8 121.4L222.8 121.4L195.8 48.5L198.3 45.8L173.3 110.9Q170.7 117.7 170.1 122.2Q169.6 126.7 170.9 129.2Q172.2 131.8 175.3 132.8Q178.4 133.8 183.1 134L183.1 134L183.1 137Q178.6 136.7 174.0 136.6Q169.4 136.6 165.4 136.6L165.4 136.6Q161.8 136.6 159.0 136.6Q156.3 136.7 154 137L154 137L154 134Q157.2 133.3 160.3 130.3Q163.4 127.3 166.3 120.0L166.3 120.0L201.1 30.2Q202.3 30.2 203.7 30.2Q205 30.2 206.2 30.2ZM178.8 93.8L221.9 93.8L221.9 96.8L177.3 96.8L178.8 93.8ZM320.6 30.8L320.6 30.8L320.6 33.8Q315.7 34.0 313.1 34.9Q310.6 35.9 309.7 38.5Q308.8 41.2 308.8 46.7L308.8 46.7L308.8 121.1Q308.8 126.5 309.7 129.2Q310.6 131.9 313.1 132.8Q315.7 133.7 320.6 134L320.6 134L320.6 137Q317 136.7 311.5 136.6Q306.1 136.6 300.4 136.6L300.4 136.6Q294.1 136.6 288.6 136.6Q283.1 136.7 279.7 137L279.7 137L279.7 134Q284.8 133.7 287.3 132.8Q289.9 131.9 290.7 129.2Q291.5 126.5 291.5 121.1L291.5 121.1L291.5 46.7Q291.5 41.2 290.7 38.5Q289.9 35.9 287.2 34.9Q284.6 34.0 279.7 33.8L279.7 33.8L279.7 30.8Q283.1 31.0 288.6 31.1Q294.1 31.3 300.4 31.3L300.4 31.3Q306.1 31.3 311.5 31.1Q317 31.0 320.6 30.8ZM388.2 29L388.2 29Q396.1 29 400.3 30.8Q404.6 32.6 407.7 34.7L407.7 34.7Q409.5 35.8 410.6 36.3Q411.8 36.8 412.8 36.8L412.8 36.8Q414.3 36.8 415.0 35.2Q415.6 33.5 416.1 30.2L416.1 30.2L419.5 30.2Q419.4 32.9 419.2 36.6Q418.9 40.3 418.9 46.3Q418.8 52.3 418.8 62L418.8 62L415.3 62Q414.9 54.7 412.1 47.8Q409.3 40.9 404.0 36.5Q398.7 32.2 390.4 32.2L390.4 32.2Q382.8 32.2 377.8 36.7Q372.8 41.3 372.8 48.8L372.8 48.8Q372.8 55.4 376.1 59.8Q379.3 64.3 385.1 68.1Q390.9 71.9 398.3 76.6L398.3 76.6Q405.8 81.3 411.8 86.1Q417.8 90.8 421.2 96.5Q424.6 102.2 424.6 110.3L424.6 110.3Q424.6 120.0 420.1 126.4Q415.5 132.8 407.8 135.9Q400.2 139.1 391.1 139.1L391.1 139.1Q382.6 139.1 377.7 137.3Q372.8 135.5 369.3 133.6L369.3 133.6Q366 131.4 364.2 131.4L364.2 131.4Q362.7 131.4 362.0 133.1Q361.3 134.8 360.9 138.1L360.9 138.1L357.4 138.1Q357.8 134.8 357.8 130.3Q357.9 125.9 358.0 118.7Q358.1 111.5 358.1 100.6L358.1 100.6L361.5 100.6Q362.1 109.8 364.9 118.0Q367.6 126.0 373.4 130.9Q379.2 135.8 388.8 135.8L388.8 135.8Q393.9 135.8 398.3 133.8Q402.6 131.9 405.3 127.7Q408 123.5 408 116.9L408 116.9Q408 110.8 405.1 106.1Q402.1 101.5 397.0 97.5Q391.8 93.5 384.9 89.3L384.9 89.3Q377.8 84.8 371.7 80.3Q365.6 75.8 361.9 69.8Q358.2 63.8 358.2 55.5L358.2 55.5Q358.2 46.4 362.5 40.5Q366.8 34.7 373.6 31.9Q380.4 29 388.2 29ZM510.7 28.7L510.7 28.7Q525.4 28.7 536.6 35.2Q547.8 41.6 553.9 53.7Q560.0 65.8 560.0 83L560.0 83Q560.0 99.8 553.8 112.4Q547.5 125 536.2 132.1Q525.0 139.1 510.6 139.1L510.6 139.1Q495.7 139.1 484.6 132.7Q473.5 126.2 467.3 114.0Q461.2 101.9 461.2 84.8L461.2 84.8Q461.2 68 467.6 55.4Q473.9 42.8 485.1 35.8Q496.1 28.7 510.7 28.7ZM510.1 31.4L510.1 31.4Q500.8 31.4 493.9 38.2Q487 44.9 483.3 56.8Q479.5 68.6 479.5 84.2L479.5 84.2Q479.5 100.1 483.7 111.9Q487.9 123.7 495.1 130.0Q502.3 136.4 511.1 136.4L511.1 136.4Q520.5 136.4 527.3 129.7Q534.1 122.9 537.9 111.0Q541.8 99.1 541.8 83.6L541.8 83.6Q541.8 67.5 537.5 55.9Q533.2 44.2 526.1 37.8Q519.0 31.4 510.1 31.4ZM691.1 30.8L691.1 30.8L691.1 33.8Q686 34.1 683.4 35.6Q680.9 37.1 680.1 40.5Q679.3 43.9 679.3 50L679.3 50L679.3 137.6Q678.0 137.6 676.9 137.6Q675.6 137.6 674.3 137.6L674.3 137.6L610.7 45.2L610.7 117.2Q610.7 123.5 611.6 127.0Q612.5 130.6 615.5 132.1Q618.5 133.6 624.6 134L624.6 134L624.6 137Q621.8 136.7 617.4 136.6Q612.9 136.6 609.0 136.6L609.0 136.6Q605.3 136.6 601.5 136.6Q597.8 136.7 595.4 137L595.4 137L595.4 134Q600.4 133.6 602.9 132.1Q605.4 130.7 606.4 127.3Q607.3 123.8 607.3 117.8L607.3 117.8L607.3 46.7Q607.3 41.2 606.4 38.5Q605.4 35.9 602.9 34.9Q600.4 34.0 595.4 33.8L595.4 33.8L595.4 30.8Q597.8 31.0 601.5 31.1Q605.3 31.3 609.0 31.3L609.0 31.3Q612.4 31.3 615.5 31.1Q618.6 31.0 621.0 30.8L621.0 30.8L675.8 109.1L675.8 50.6Q675.8 44.2 674.8 40.7Q673.9 37.3 670.9 35.7Q667.9 34.1 661.9 33.8L661.9 33.8L661.9 30.8Q664.5 31.0 669.0 31.1Q673.5 31.3 677.4 31.3L677.4 31.3Q681.2 31.3 684.9 31.1Q688.7 31.0 691.1 30.8Z M827.4 30.2L827.4 30.2L864.0 124.4Q866.1 129.9 868.8 131.9Q871.6 133.8 874.0 134L874.0 134L874.0 137Q870.4 136.7 865.5 136.6Q860.7 136.6 855.7 136.6L855.7 136.6Q849.4 136.6 844.0 136.6Q838.6 136.7 835.3 137L835.3 137L835.3 134Q843.0 133.7 845.0 131.4Q847.0 129.1 844.0 121.4L844.0 121.4L817.0 48.5L819.4 45.8L794.5 110.9Q791.8 117.7 791.3 122.2Q790.8 126.7 792.0 129.2Q793.3 131.8 796.5 132.8Q799.6 133.8 804.3 134L804.3 134L804.3 137Q799.8 136.7 795.2 136.6Q790.6 136.6 786.6 136.6L786.6 136.6Q783.0 136.6 780.2 136.6Q777.4 136.7 775.2 137L775.2 137L775.2 134Q778.3 133.3 781.5 130.3Q784.6 127.3 787.5 120.0L787.5 120.0L822.3 30.2Q823.5 30.2 824.8 30.2Q826.2 30.2 827.4 30.2ZM799.9 93.8L843.1 93.8L843.1 96.8L798.4 96.8L799.9 93.8ZM900.8 33.8L900.8 30.8Q904.3 31.0 909.7 31.1Q915.2 31.3 920.6 31.3L920.6 31.3Q927.8 31.3 934.3 31.1Q940.9 31.0 943.6 31.0L943.6 31.0Q956.3 31.0 964.8 34.3Q973.3 37.5 977.4 43.5Q981.5 49.4 981.5 57.0L981.5 57.0Q981.5 61.7 979.6 66.9Q977.8 72.0 973.1 76.5Q968.5 80.9 960.5 83.8Q952.6 86.6 940.3 86.6L940.3 86.6L925.9 86.6L925.9 83.6L938.8 83.6Q948.8 83.6 954.1 80.2Q959.5 76.8 961.3 71.2Q963.2 65.6 963.2 58.7L963.2 58.7Q963.2 46.9 958.1 40.3Q953 33.8 940.4 33.8L940.4 33.8Q934.0 33.8 931.9 36.4Q929.9 38.9 929.9 46.7L929.9 46.7L929.9 121.1Q929.9 126.5 930.8 129.2Q931.7 131.9 934.3 132.8Q936.8 133.7 941.8 134L941.8 134L941.8 137Q938.2 136.7 932.7 136.6Q927.2 136.6 921.5 136.6L921.5 136.6Q915.2 136.6 909.7 136.6Q904.3 136.7 900.8 137L900.8 137L900.8 134Q905.9 133.7 908.5 132.8Q911 131.9 911.8 129.2Q912.7 126.5 912.7 121.1L912.7 121.1L912.7 46.7Q912.7 41.2 911.8 38.5Q911 35.9 908.4 34.9Q905.8 34.0 900.8 33.8L900.8 33.8ZM926.5 86.6L926.2 84.1Q933.8 84.3 938.5 84.7Q943.1 85.1 946.3 85.4Q949.4 85.7 952.1 86.2L952.1 86.2Q963.4 87.7 968.5 92.2Q973.7 96.7 975.7 106.0L975.7 106.0L979.4 121.3Q980.8 127.7 982.3 130.4Q983.9 133.1 987.1 133.1L987.1 133.1Q989.5 132.9 991.0 131.7Q992.6 130.4 994.4 128.2L994.4 128.2L996.5 129.8Q993.1 134.4 989.3 136.8Q985.6 139.1 979.3 139.1L979.3 139.1Q972.8 139.1 968.2 135.7Q963.7 132.3 961.7 122.9L961.7 122.9L958.7 107.9Q957.4 101.5 955.7 96.7Q954.1 92 951.1 89.3Q948.2 86.6 942.7 86.6L942.7 86.6L926.5 86.6ZM1065 30.8L1065 30.8Q1092.8 30.8 1106.3 44.2Q1119.8 57.7 1119.8 82.7L1119.8 82.7Q1119.8 99.1 1113.2 111.3Q1106.6 123.5 1094.0 130.3Q1081.5 137 1063.7 137L1063.7 137Q1061.4 137 1057.6 136.8Q1053.8 136.7 1049.7 136.6Q1045.7 136.6 1042.4 136.6L1042.4 136.6Q1036.7 136.6 1031.2 136.6Q1025.7 136.7 1022.3 137L1022.3 137L1022.3 134Q1027.4 133.7 1029.9 132.8Q1032.5 131.9 1033.3 129.2Q1034.1 126.5 1034.1 121.1L1034.1 121.1L1034.1 46.7Q1034.1 41.2 1033.3 38.5Q1032.5 35.9 1029.8 34.9Q1027.2 34.0 1022.3 33.8L1022.3 33.8L1022.3 30.8Q1025.7 31.0 1031.2 31.2Q1036.7 31.4 1042.1 31.3L1042.1 31.3Q1047.5 31.1 1054.1 31.0Q1060.8 30.8 1065 30.8ZM1062.5 33.5L1062.5 33.5Q1055.6 33.5 1053.5 36.0Q1051.4 38.6 1051.4 46.4L1051.4 46.4L1051.4 121.4Q1051.4 129.2 1053.5 131.8Q1055.7 134.3 1062.6 134.3L1062.6 134.3Q1077.8 134.3 1086.2 128.4Q1094.6 122.5 1098 111.0Q1101.5 99.7 1101.5 83.3L1101.5 83.3Q1101.5 66.5 1097.7 55.5Q1094.0 44.5 1085.5 39.0Q1077 33.5 1062.5 33.5ZM1232.1 30.8L1232.1 30.8Q1231.5 36.5 1231.2 41.8Q1231.0 47.2 1231.0 50L1231.0 50Q1231.0 52.9 1231.2 55.4Q1231.3 58.0 1231.5 59.6L1231.5 59.6L1228.0 59.6Q1227.0 50 1224.8 44.5Q1222.6 38.9 1218.3 36.6Q1214.1 34.3 1206.4 34.3L1206.4 34.3L1196.1 34.3Q1191.3 34.3 1188.8 35.1Q1186.3 35.9 1185.4 38.4Q1184.5 40.9 1184.5 46.1L1184.5 46.1L1184.5 121.7Q1184.5 126.8 1185.4 129.3Q1186.3 131.9 1188.8 132.7Q1191.3 133.6 1196.1 133.6L1196.1 133.6L1205.8 133.6Q1214.4 133.6 1219.4 130.8Q1224.4 128.2 1227.0 122Q1229.7 115.8 1231.0 105.2L1231.0 105.2L1234.5 105.2Q1234.0 109.5 1234.0 116.6L1234.0 116.6Q1234.0 119.6 1234.2 125.3Q1234.5 131 1235.1 137L1235.1 137Q1227.4 136.7 1217.8 136.6Q1208.2 136.6 1200.7 136.6L1200.7 136.6Q1197.3 136.6 1191.9 136.6Q1186.5 136.6 1180.2 136.6Q1174.0 136.7 1167.6 136.8Q1161.3 136.8 1155.4 137L1155.4 137L1155.4 134Q1160.5 133.7 1163.1 132.8Q1165.6 131.9 1166.4 129.2Q1167.3 126.5 1167.3 121.1L1167.3 121.1L1167.3 46.7Q1167.3 41.2 1166.4 38.5Q1165.6 35.9 1163.0 34.9Q1160.4 34.0 1155.4 33.8L1155.4 33.8L1155.4 30.8Q1161.3 31.0 1167.6 31.0Q1174.0 31.1 1180.2 31.2Q1186.5 31.3 1191.9 31.3Q1197.3 31.3 1200.7 31.3L1200.7 31.3Q1207.6 31.3 1216.4 31.2Q1225.2 31.1 1232.1 30.8ZM1180.0 82.1L1207.2 82.1Q1207.2 82.1 1207.2 83.6Q1207.2 85.1 1207.2 85.1L1207.2 85.1L1180.0 85.1Q1180.0 85.1 1180.0 83.6Q1180.0 82.1 1180.0 82.1L1180.0 82.1ZM1208.1 62.3L1211.5 62.3Q1210.9 70.9 1211.0 75.3Q1211.1 79.8 1211.1 83.6L1211.1 83.6Q1211.1 87.3 1211.2 91.8Q1211.4 96.3 1212.0 104.9L1212.0 104.9L1208.5 104.9Q1207.8 100.0 1206.6 95.4Q1205.4 90.8 1202.3 88.0Q1199.2 85.1 1192.8 85.1L1192.8 85.1L1192.8 82.1Q1197.6 82.1 1200.3 80.2Q1203.1 78.2 1204.6 75.1Q1206.1 71.9 1206.8 68.5Q1207.5 65.2 1208.1 62.3L1208.1 62.3ZM1365.8 30.8L1365.8 30.8L1365.8 33.8Q1360.7 34.1 1358.2 35.6Q1355.6 37.1 1354.8 40.5Q1354.0 43.9 1354.0 50L1354.0 50L1354.0 137.6Q1352.8 137.6 1351.6 137.6Q1350.4 137.6 1349.0 137.6L1349.0 137.6L1285.4 45.2L1285.4 117.2Q1285.4 123.5 1286.3 127.0Q1287.2 130.6 1290.2 132.1Q1293.2 133.6 1299.4 134L1299.4 134L1299.4 137Q1296.5 136.7 1292.1 136.6Q1287.7 136.6 1283.8 136.6L1283.8 136.6Q1280.0 136.6 1276.3 136.6Q1272.5 136.7 1270.1 137L1270.1 137L1270.1 134Q1275.1 133.6 1277.6 132.1Q1280.2 130.7 1281.1 127.3Q1282.0 123.8 1282.0 117.8L1282.0 117.8L1282.0 46.7Q1282.0 41.2 1281.1 38.5Q1280.2 35.9 1277.6 34.9Q1275.1 34.0 1270.1 33.8L1270.1 33.8L1270.1 30.8Q1272.5 31.0 1276.3 31.1Q1280.0 31.3 1283.8 31.3L1283.8 31.3Q1287.1 31.3 1290.2 31.1Q1293.4 31.0 1295.8 30.8L1295.8 30.8L1350.5 109.1L1350.5 50.6Q1350.5 44.2 1349.5 40.7Q1348.6 37.3 1345.6 35.7Q1342.6 34.1 1336.6 33.8L1336.6 33.8L1336.6 30.8Q1339.3 31.0 1343.8 31.1Q1348.3 31.3 1352.2 31.3L1352.2 31.3Q1355.9 31.3 1359.7 31.1Q1363.4 31.0 1365.8 30.8ZM1484.1 30.8L1484.1 30.8Q1483.5 37.1 1483.3 43.0Q1483.1 49.0 1483.1 52.1L1483.1 52.1Q1483.1 55.5 1483.2 58.7Q1483.4 61.9 1483.5 64.1L1483.5 64.1L1480.1 64.1Q1478.6 52.9 1476.1 46.4Q1473.6 40.0 1469.0 37.1Q1464.3 34.3 1455.6 34.3L1455.6 34.3L1449.2 34.3L1449.2 119.8Q1449.2 125.8 1450.3 128.8Q1451.4 131.8 1454.8 132.7Q1458.2 133.7 1464.6 134L1464.6 134L1464.6 137Q1460.4 136.7 1453.8 136.6Q1447.2 136.6 1440.3 136.6L1440.3 136.6Q1433.1 136.6 1426.7 136.6Q1420.4 136.7 1416.5 137L1416.5 137L1416.5 134Q1422.9 133.7 1426.2 132.7Q1429.5 131.8 1430.7 128.8Q1431.9 125.8 1431.9 119.8L1431.9 119.8L1431.9 34.3L1425.3 34.3Q1416.9 34.3 1412.1 37.1Q1407.3 40.0 1404.9 46.4Q1402.5 52.9 1401.0 64.1L1401.0 64.1L1397.6 64.1Q1397.9 61.9 1397.9 58.7Q1398.0 55.5 1398.0 52.1L1398.0 52.1Q1398.0 49.0 1397.8 43.0Q1397.6 37.1 1397.0 30.8L1397.0 30.8Q1403.4 31.0 1411.1 31.1Q1418.7 31.3 1426.5 31.3Q1434.3 31.3 1440.6 31.3L1440.6 31.3Q1446.9 31.3 1454.6 31.3Q1462.2 31.3 1470.0 31.1Q1477.8 31.0 1484.1 30.8Z "/></g></g></svg>
diff --git a/public/previews/kinetic/marks/aurele.svg b/public/previews/kinetic/marks/aurele.svg
new file mode 100644
index 00000000..fd32adea
--- /dev/null
+++ b/public/previews/kinetic/marks/aurele.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="1314" height="285" viewBox="0 0 1314.15 285.11"><g fill="#cfae6e"><g transform="translate(10 15.5)"><path fill-rule="evenodd" d="M127.05 0L254.1 127.05L127.05 254.1L0 127.05ZM127.05 10.1L10.1 127.05L127.05 244L244 127.05Z"/><path fill-rule="evenodd" d="M76.23 178.28L122.6 71.55H131.5L177.87 178.28H165.16L127.69 99.51L88.94 178.28Z"/><path fill-rule="evenodd" d="M103.16 139.86H150.94A2.54 2.54 0 0 1 153.48 142.4V144.3A2.54 2.54 0 0 1 150.94 146.84H103.16A2.54 2.54 0 0 1 100.62 144.3V142.4A2.54 2.54 0 0 1 103.16 139.86Z"/></g><g transform="translate(336.55 4.5)"><path d="M100.6 120.6L37.6 120.6L40.3 115.3L99.1 115.3L100.6 120.6ZM149.3 169.5L149.3 169.5Q150.2 169.5 150.2 170.7Q150.2 172 149.3 172L149.3 172Q143.0 172 136.4 171.6Q129.8 171.2 123.7 171.2L123.7 171.2Q116.8 171.2 111.6 171.6Q106.5 172 100.2 172L100.2 172Q99.3 172 99.3 170.7Q99.3 169.5 100.2 169.5L100.2 169.5Q109.6 169.5 111.5 166.1Q113.4 162.8 108.4 152.9L108.4 152.9L64.5 63.6L73.1 49.6L31.5 143.2Q26.0 156.0 31.2 162.8Q36.3 169.5 48.7 169.5L48.7 169.5Q49.8 169.5 49.8 170.7Q49.8 172 48.7 172L48.7 172Q42.4 172 37.2 171.6Q31.9 171.2 23.9 171.2L23.9 171.2Q16.0 171.2 11.2 171.6Q6.5 172-0.4 172L-0.4 172Q-1.3 172-1.3 170.7Q-1.3 169.5-0.4 169.5L-0.4 169.5Q5.3 169.5 9.3 167.2Q13.4 164.9 17.4 158.7Q21.4 152.5 26.3 141.3L26.3 141.3L71.4 39.5Q71.8 38.9 73.3 38.9Q74.8 38.9 75.0 39.5L75.0 39.5L126.4 143.2Q131.3 153.3 135.0 159.1Q138.8 164.9 142.2 167.2Q145.5 169.5 149.3 169.5ZM301.9 125.4L301.9 66.4Q301.9 55.5 296.9 49.4Q292 43.3 282.8 43.3L282.8 43.3Q282.3 43.3 282.3 42.0Q282.3 40.8 282.8 40.8L282.8 40.8Q288.0 40.8 293.4 41.1Q298.7 41.4 305.0 41.4L305.0 41.4Q310.5 41.4 315.8 41.1Q321.2 40.8 325.6 40.8L325.6 40.8Q326.0 40.8 326.0 42.0Q326.0 43.3 325.6 43.3L325.6 43.3Q317.2 43.3 312.8 49.4Q308.4 55.5 308.4 66.4L308.4 66.4L308.4 125.2Q308.4 140.5 302.0 151.6Q295.6 162.8 284.0 168.8Q272.5 174.9 256.9 174.9L256.9 174.9Q241.6 174.9 229.6 169.0Q217.7 163.0 211.0 151.8Q204.4 140.7 204.4 125.4L204.4 125.4L204.4 57.8Q204.4 51.7 203.3 48.6Q202.1 45.6 198.7 44.4Q195.2 43.3 188.5 43.3L188.5 43.3Q187.8 43.3 187.8 42.0Q187.8 40.8 188.5 40.8L188.5 40.8Q193.7 40.8 200.3 41.1Q207.0 41.4 214.3 41.4L214.3 41.4Q222.1 41.4 228.6 41.1Q235.1 40.8 240.3 40.8L240.3 40.8Q241.0 40.8 241.0 42.0Q241.0 43.3 240.3 43.3L240.3 43.3Q233.4 43.3 230.1 44.5Q226.7 45.8 225.5 48.9Q224.4 52.1 224.4 58.2L224.4 58.2L224.4 118.0Q224.4 143.7 235.0 155.6Q245.6 167.6 263.9 167.6L263.9 167.6Q281.7 167.6 291.8 156.6Q301.9 145.5 301.9 125.4L301.9 125.4ZM482.1 172L482.1 172Q479 172 471.6 164.0Q464.3 156.0 453.9 141.0Q443.5 126.0 430.7 105.2L430.7 105.2L447.5 100.2Q464.5 125.6 476.6 140.8Q488.7 156.0 498.0 162.8Q507.4 169.5 516.0 169.5L516.0 169.5Q516.4 169.5 516.4 170.7Q516.4 172 516.0 172L516.0 172Q502.7 172 494.4 172Q486.1 172 482.1 172ZM434.5 40.1L434.5 40.1Q452.8 40.1 462.7 47.4Q472.7 54.6 472.7 67.2L472.7 67.2Q472.7 79.2 465.9 88.6Q459.1 98.1 448.2 103.3Q437.4 108.6 425.0 108.6L425.0 108.6Q422.5 108.6 419.6 108.5Q416.6 108.4 414.3 108.2L414.3 108.2L414.3 155.0Q414.3 161.1 415.4 164.2Q416.4 167.4 419.9 168.4Q423.4 169.5 430.1 169.5L430.1 169.5Q430.7 169.5 430.7 170.7Q430.7 172 430.1 172L430.1 172Q424.8 172 418.3 171.8Q411.8 171.6 404.0 171.6L404.0 171.6Q396.7 171.6 390.0 171.8Q383.2 172 378.0 172L378.0 172Q377.4 172 377.4 170.7Q377.4 169.5 378.0 169.5L378.0 169.5Q384.9 169.5 388.3 168.4Q391.6 167.4 392.9 164.2Q394.2 161.1 394.2 155.0L394.2 155.0L394.2 57.8Q394.2 51.7 393.0 48.6Q391.9 45.6 388.5 44.4Q385.1 43.3 378.2 43.3L378.2 43.3Q377.8 43.3 377.8 42.0Q377.8 40.8 378.2 40.8L378.2 40.8Q383.4 40.8 390.1 41.1Q396.7 41.4 404.0 41.4L404.0 41.4Q410.8 41.4 419.2 40.8Q427.6 40.1 434.5 40.1ZM451.9 74.6L451.9 74.6Q451.9 62.4 449.1 55.8Q446.2 49.2 441.2 46.6Q436.2 44.1 429.4 44.1L429.4 44.1Q421.3 44.1 417.8 47.2Q414.3 50.2 414.3 58.2L414.3 58.2L414.3 102.5Q417.3 102.9 420.6 103.1Q424.0 103.3 426.5 103.3L426.5 103.3Q440.6 103.3 446.2 96.3Q451.9 89.3 451.9 74.6ZM653.8 172L653.8 172L562.7 172Q562.1 172 562.1 170.7Q562.1 169.5 562.7 169.5L562.7 169.5Q569.6 169.5 573.0 168.4Q576.3 167.4 577.5 164.2Q578.6 161.1 578.6 155.0L578.6 155.0L578.6 57.8Q578.6 51.7 577.5 48.6Q576.3 45.6 573.0 44.4Q569.6 43.3 562.7 43.3L562.7 43.3Q562.1 43.3 562.1 42.0Q562.1 40.8 562.7 40.8L562.7 40.8L650.0 40.8Q652.1 40.8 652.1 42.6L652.1 42.6L652.6 69.9Q652.6 70.4 651.5 70.5Q650.5 70.6 650.0 69.9L650.0 69.9Q647.7 58.0 640.4 52.1Q633.0 46.2 621.1 46.2L621.1 46.2L612.5 46.2Q607.2 46.2 604.2 47.4Q601.1 48.5 599.9 51.1Q598.6 53.8 598.6 58.2L598.6 58.2L598.6 154.2Q598.6 158.6 599.7 161.4Q600.9 164.2 603.4 165.4Q605.9 166.5 610.6 166.5L610.6 166.5L620.9 166.5Q635.1 166.5 644.0 159.7Q652.8 152.9 656.5 139.4L656.5 139.4Q656.8 138.8 657.9 139.0Q659.1 139.2 659.1 139.7L659.1 139.7Q658.2 145.5 657.6 153.7Q657.0 161.9 657.0 168.8L657.0 168.8Q657.0 172 653.8 172ZM642.1 124.5L642.1 124.5Q642.1 115.7 636.2 111.1Q630.3 106.5 618.5 106.5L618.5 106.5L589.1 106.5L589.1 101.0L618.8 101.0Q630.5 101.0 636.2 97.0Q641.9 93.0 641.9 85.5L641.9 85.5Q641.9 84.9 643.0 84.9Q644.2 84.9 644.2 85.5L644.2 85.5Q644.2 92.2 644.1 96.0Q644.0 99.8 644.0 103.8L644.0 103.8Q644.0 108.8 644.3 113.7Q644.6 118.7 644.6 124.5L644.6 124.5Q644.6 125.0 643.3 125.0Q642.1 125.0 642.1 124.5ZM637.0 29.4L637.0 29.4Q626.3 24.6 615.3 20.6Q604.3 16.6 590.2 13.2L590.2 13.2Q588.5 12.8 590.7 11.6Q592.9 10.3 596.9 8.7Q600.9 7.2 604.5 6.3Q608.0 5.5 608.9 6.1L608.9 6.1Q615.8 11.1 622.7 16.6Q629.7 22.1 637.9 27.3L637.9 27.3Q638.7 27.5 638.3 28.7Q637.9 29.8 637.0 29.4ZM751.4 58.0L751.4 58.0L751.4 154.2Q751.4 159.4 752.4 162.1Q753.5 164.9 756.4 165.7Q759.3 166.5 765.0 166.5L765.0 166.5L777.6 166.5Q792.5 166.5 802.8 158.1Q813.1 149.7 816.5 135.9L816.5 135.9Q816.7 135.3 817.7 135.5Q818.8 135.7 818.8 136.3L818.8 136.3Q818.1 142.8 817.5 151.9Q816.9 161.1 816.9 168.8L816.9 168.8Q816.9 172 813.7 172L813.7 172L715.5 172Q715.0 172 715.0 170.7Q715.0 169.5 715.5 169.5L715.5 169.5Q722.2 169.5 725.6 168.4Q729.1 167.4 730.3 164.2Q731.4 161.1 731.4 155.0L731.4 155.0L731.4 57.8Q731.4 51.7 730.3 48.6Q729.1 45.6 725.6 44.4Q722.2 43.3 715.5 43.3L715.5 43.3Q715.0 43.3 715.0 42.0Q715.0 40.8 715.5 40.8L715.5 40.8Q720.5 40.8 727.2 41.1Q733.9 41.4 741.3 41.4L741.3 41.4Q749.1 41.4 755.7 41.1Q762.3 40.8 767.3 40.8L767.3 40.8Q768.0 40.8 768.0 42.0Q768.0 43.3 767.3 43.3L767.3 43.3Q760.6 43.3 757.1 44.4Q753.7 45.6 752.5 48.7Q751.4 51.9 751.4 58.0ZM962.3 172L962.3 172L871.2 172Q870.5 172 870.5 170.7Q870.5 169.5 871.2 169.5L871.2 169.5Q878.1 169.5 881.5 168.4Q884.8 167.4 886.0 164.2Q887.1 161.1 887.1 155.0L887.1 155.0L887.1 57.8Q887.1 51.7 886.0 48.6Q884.8 45.6 881.5 44.4Q878.1 43.3 871.2 43.3L871.2 43.3Q870.5 43.3 870.5 42.0Q870.5 40.8 871.2 40.8L871.2 40.8L958.5 40.8Q960.6 40.8 960.6 42.6L960.6 42.6L961.0 69.9Q961.0 70.4 960.0 70.5Q958.9 70.6 958.5 69.9L958.5 69.9Q956.2 58.0 948.9 52.1Q941.5 46.2 929.5 46.2L929.5 46.2L920.9 46.2Q915.7 46.2 912.6 47.4Q909.6 48.5 908.3 51.1Q907.1 53.8 907.1 58.2L907.1 58.2L907.1 154.2Q907.1 158.6 908.2 161.4Q909.4 164.2 911.9 165.4Q914.4 166.5 919.0 166.5L919.0 166.5L929.3 166.5Q943.6 166.5 952.4 159.7Q961.3 152.9 965.0 139.4L965.0 139.4Q965.2 138.8 966.4 139.0Q967.6 139.2 967.6 139.7L967.6 139.7Q966.7 145.5 966.1 153.7Q965.5 161.9 965.5 168.8L965.5 168.8Q965.5 172 962.3 172ZM950.5 124.5L950.5 124.5Q950.5 115.7 944.7 111.1Q938.8 106.5 927.0 106.5L927.0 106.5L897.6 106.5L897.6 101.0L927.2 101.0Q939.0 101.0 944.7 97.0Q950.3 93.0 950.3 85.5L950.3 85.5Q950.3 84.9 951.5 84.9Q952.6 84.9 952.6 85.5L952.6 85.5Q952.6 92.2 952.5 96.0Q952.4 99.8 952.4 103.8L952.4 103.8Q952.4 108.8 952.7 113.7Q953.1 118.7 953.1 124.5L953.1 124.5Q953.1 125.0 951.8 125.0Q950.5 125.0 950.5 124.5Z "/></g><g transform="translate(332.85 222.31)"><path d="M12.8 17.3L12.8 46.6Q12.8 48.5 13.3 49.5Q13.8 50.5 15.3 50.8Q16.8 51.2 19.9 51.2L19.9 51.2Q20.1 51.2 20.1 51.6Q20.1 52 19.9 52L19.9 52Q17.9 52 15.5 51.9Q13.1 51.9 10.2 51.9L10.2 51.9Q8.1 51.9 6.1 51.9Q4.1 52 2.5 52L2.5 52Q2.4 52 2.4 51.6Q2.4 51.2 2.5 51.2L2.5 51.2Q4.7 51.2 5.9 50.9Q7.0 50.6 7.3 49.6Q7.7 48.7 7.7 46.8L7.7 46.8L7.7 17.2Q7.7 15.3 7.3 14.4Q7.0 13.5 5.9 13.1Q4.7 12.8 2.5 12.8L2.5 12.8Q2.4 12.8 2.4 12.4Q2.4 12 2.5 12L2.5 12Q4.1 12 6.1 12.1Q8.1 12.2 10.2 12.2L10.2 12.2Q11.8 12.2 14.2 12Q16.6 11.8 19.1 11.8L19.1 11.8Q22.8 11.8 25.8 12.9Q28.7 14.0 30.5 16.3Q32.3 18.6 32.4 22.3L32.4 22.3Q32.4 25.6 31.2 28.1Q30.0 30.5 27.9 32.1Q25.8 33.7 23.3 34.5Q20.7 35.2 18.3 35.2L18.3 35.2Q17.5 35.2 16.7 35.2Q15.9 35.1 15.2 34.9L15.2 34.9Q15.0 34.8 15.1 34.4Q15.2 34.0 15.4 34.1L15.4 34.1Q15.9 34.2 16.5 34.3Q17.2 34.3 17.6 34.3L17.6 34.3Q20.0 34.3 22.1 33.2Q24.1 32.0 25.4 29.6Q26.7 27.2 26.7 23.6L26.7 23.6Q26.7 20.2 25.5 17.8Q24.3 15.5 22.2 14.2Q20.1 12.9 17.3 12.9L17.3 12.9Q15.6 12.9 14.6 13.2Q13.6 13.4 13.2 14.4Q12.8 15.3 12.8 17.3L12.8 17.3ZM98.4 35.3L79.8 35.3L80.5 33.9L98.0 33.9L98.4 35.3ZM112.9 51.2L112.9 51.2Q113.2 51.2 113.2 51.6Q113.2 52 112.9 52L112.9 52Q111.0 52 109.1 51.9Q107.1 51.7 105.2 51.7L105.2 51.7Q103.2 51.7 101.7 51.9Q100.2 52 98.3 52L98.3 52Q98.1 52 98.1 51.6Q98.1 51.2 98.3 51.2L98.3 51.2Q101.5 51.2 102.2 50.2Q102.9 49.2 101.5 46.3L101.5 46.3L87.7 17.7L89.8 14.6L77.3 43.6Q75.6 47.5 77.1 49.3Q78.6 51.2 82.6 51.2L82.6 51.2Q82.9 51.2 82.9 51.6Q82.9 52 82.6 52L82.6 52Q80.7 52 79.1 51.9Q77.5 51.7 75.0 51.7L75.0 51.7Q72.7 51.7 71.2 51.9Q69.8 52 67.7 52L67.7 52Q67.5 52 67.5 51.6Q67.5 51.2 67.7 51.2L67.7 51.2Q69.5 51.2 70.8 50.6Q72.0 49.9 73.2 48.1Q74.4 46.3 75.8 43.0L75.8 43.0L89.4 11.6Q89.5 11.4 89.9 11.3Q90.3 11.3 90.3 11.6L90.3 11.6L105.7 43.2Q107.2 46.4 108.4 48.1Q109.5 49.9 110.6 50.6Q111.6 51.2 112.9 51.2ZM183.9 52L183.9 52Q182.9 52 180.6 49.5Q178.2 47.1 175.0 42.5Q171.7 37.9 167.6 31.6L167.6 31.6L171.9 30.2Q177.3 38.0 181.0 42.6Q184.8 47.2 187.6 49.2Q190.5 51.2 193.2 51.2L193.2 51.2Q193.3 51.2 193.3 51.6Q193.3 52 193.2 52L193.2 52Q189.6 52 187.3 52Q185.0 52 183.9 52ZM168.6 11.8L168.6 11.8Q174.0 11.8 176.8 14.1Q179.6 16.4 179.6 20.1L179.6 20.1Q179.6 23.7 177.6 26.5Q175.6 29.3 172.3 30.9Q169.0 32.5 165.2 32.5L165.2 32.5Q164.4 32.5 163.6 32.5Q162.8 32.5 162.0 32.4L162.0 32.4L162.0 46.8Q162.0 48.7 162.4 49.6Q162.8 50.6 163.9 50.9Q165.0 51.2 167.2 51.2L167.2 51.2Q167.4 51.2 167.4 51.6Q167.4 52 167.2 52L167.2 52Q165.6 52 163.7 51.9Q161.8 51.9 159.5 51.9L159.5 51.9Q157.3 51.9 155.3 51.9Q153.3 52 151.7 52L151.7 52Q151.6 52 151.6 51.6Q151.6 51.2 151.7 51.2L151.7 51.2Q153.9 51.2 155.0 50.9Q156.2 50.6 156.6 49.6Q157.0 48.7 157.0 46.8L157.0 46.8L157.0 17.2Q157.0 15.3 156.6 14.4Q156.2 13.5 155.1 13.1Q154.0 12.8 151.8 12.8L151.8 12.8Q151.7 12.8 151.7 12.4Q151.7 12 151.8 12L151.8 12Q153.4 12 155.4 12.1Q157.3 12.2 159.5 12.2L159.5 12.2Q161.5 12.2 164.1 12Q166.7 11.8 168.6 11.8ZM174.4 22.2L174.4 22.2Q174.4 18.6 173.4 16.6Q172.5 14.6 170.7 13.7Q169.0 12.9 166.6 12.9L166.6 12.9Q164.2 12.9 163.1 13.8Q162.0 14.6 162.0 17.3L162.0 17.3L162.0 30.8Q162.9 30.9 164.0 30.9Q165.1 31.0 165.8 31.0L165.8 31.0Q170.6 31.0 172.5 28.8Q174.4 26.7 174.4 22.2ZM241.9 17.3L241.9 46.8Q241.9 48.7 242.2 49.6Q242.6 50.6 243.7 50.9Q244.8 51.2 247.1 51.2L247.1 51.2Q247.2 51.2 247.2 51.6Q247.2 52 247.1 52L247.1 52Q245.5 52 243.5 51.9Q241.6 51.9 239.3 51.9L239.3 51.9Q237.0 51.9 235.0 51.9Q233.1 52 231.5 52L231.5 52Q231.3 52 231.3 51.6Q231.3 51.2 231.5 51.2L231.5 51.2Q233.7 51.2 234.8 50.9Q236.0 50.6 236.4 49.6Q236.8 48.7 236.8 46.8L236.8 46.8L236.8 17.2Q236.8 15.3 236.4 14.4Q236.0 13.5 234.8 13.1Q233.7 12.8 231.5 12.8L231.5 12.8Q231.3 12.8 231.3 12.4Q231.3 12 231.5 12L231.5 12Q233.1 12 235.0 12.1Q237.0 12.2 239.3 12.2L239.3 12.2Q241.6 12.2 243.6 12.1Q245.5 12 247.1 12L247.1 12Q247.2 12 247.2 12.4Q247.2 12.8 247.1 12.8L247.1 12.8Q244.8 12.8 243.7 13.2Q242.7 13.5 242.3 14.5Q241.9 15.5 241.9 17.3L241.9 17.3ZM295.9 19.2L295.9 19.2Q295.9 21.7 297.2 23.6Q298.4 25.4 300.5 26.9Q302.5 28.3 304.8 29.7L304.8 29.7Q307.2 31.1 309.4 32.7Q311.6 34.3 313.1 36.5Q314.5 38.6 314.5 41.7L314.5 41.7Q314.5 44.8 312.9 47.3Q311.2 49.8 308.3 51.3Q305.3 52.8 301.1 52.8L301.1 52.8Q299.5 52.8 297.8 52.5Q296.1 52.2 294.5 51.7Q293.0 51.2 291.7 50.4L291.7 50.4Q291.5 50.2 291.3 50.0Q291.1 49.7 291.1 49.2L291.1 49.2L290.5 40.0Q290.4 39.7 290.8 39.7Q291.1 39.6 291.2 39.9L291.2 39.9Q291.8 41.9 292.7 43.9Q293.7 46.0 295.0 47.7Q296.4 49.4 298.3 50.5Q300.2 51.6 302.7 51.6L302.7 51.6Q304.4 51.6 306.0 50.9Q307.6 50.3 308.7 48.8Q309.7 47.3 309.7 44.6L309.7 44.6Q309.7 41.5 308.4 39.4Q307.0 37.3 304.9 35.7Q302.8 34.2 300.4 32.8L300.4 32.8Q298.2 31.4 296.1 29.9Q294.0 28.3 292.7 26.3Q291.5 24.3 291.5 21.4L291.5 21.4Q291.5 18.0 293.3 15.7Q295.1 13.5 298.0 12.4Q300.8 11.3 303.8 11.3L303.8 11.3Q305.8 11.3 307.8 11.7Q309.9 12.1 311.6 12.8L311.6 12.8Q312.1 13.0 312.3 13.3Q312.5 13.6 312.5 13.9L312.5 13.9L312.8 21.9Q312.8 22.1 312.5 22.2Q312.2 22.2 312.1 22.0L312.1 22.0Q311.9 20.9 311.2 19.3Q310.6 17.6 309.5 16.1Q308.4 14.5 306.7 13.4Q305.0 12.4 302.6 12.4L302.6 12.4Q300.4 12.4 298.9 13.3Q297.4 14.2 296.6 15.7Q295.9 17.2 295.9 19.2Z "/></g></g></svg>
diff --git a/public/previews/kinetic/marks/ledgerly.svg b/public/previews/kinetic/marks/ledgerly.svg
new file mode 100644
index 00000000..0b420ed5
--- /dev/null
+++ b/public/previews/kinetic/marks/ledgerly.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="1088" height="211" viewBox="0 0 1088.2 211"><g fill="#111111"><g transform="translate(11 20.45)"><path fill-rule="evenodd" d="M14.46 20.41H155.64A14.46 14.46 0 0 1 170.1 34.87V34.87A14.46 14.46 0 0 1 155.64 49.33H14.46A14.46 14.46 0 0 1 0 34.87V34.87A14.46 14.46 0 0 1 14.46 20.41Z"/><path fill-rule="evenodd" d="M14.46 70.59H108.01A14.46 14.46 0 0 1 122.47 85.05V85.05A14.46 14.46 0 0 1 108.01 99.51H14.46A14.46 14.46 0 0 1 0 85.05V85.05A14.46 14.46 0 0 1 14.46 70.59Z"/><path fill-rule="evenodd" d="M14.46 120.77H63.79A14.46 14.46 0 0 1 78.25 135.23V135.23A14.46 14.46 0 0 1 63.79 149.69H14.46A14.46 14.46 0 0 1 0 135.23V135.23A14.46 14.46 0 0 1 14.46 120.77Z"/><path fill-rule="evenodd" d="M128.36 135.23A17.93 17.93 0 1 1 164.21 135.23A17.93 17.93 0 1 1 128.36 135.23Z"/></g><g transform="translate(242.2 -20)"><path d="M108.8 178L14.5 178L14.5 31L39.9 31L39.9 155.1L108.8 155.1L108.8 178ZM170.6 180.9L170.6 180.9Q155.1 180.9 143.2 174.3Q131.3 167.7 124.7 155.6Q118.1 143.6 118.1 127.4L118.1 127.4L118.1 124.9Q118.1 108.5 124.6 96.5Q131.1 84.5 142.9 77.9Q154.7 71.3 170.0 71.3L170.0 71.3Q185.1 71.3 196.4 77.9Q207.8 84.5 214.1 96.5Q220.4 108.5 220.4 124.5L220.4 124.5L220.4 133.1L142.5 133.1Q142.9 145.2 151.1 152.6Q159.3 159.9 171.2 159.9L171.2 159.9Q183 159.9 188.7 154.8Q194.3 149.7 197.3 143.1L197.3 143.1L217.2 153.4Q214.3 159.1 208.7 165.5Q203.2 171.9 193.9 176.4Q184.7 180.9 170.6 180.9ZM142.7 114.8L142.7 114.8L195.8 114.8Q195.0 104.5 187.9 98.4Q180.9 92.3 169.8 92.3L169.8 92.3Q158.2 92.3 151.3 98.4Q144.4 104.5 142.7 114.8ZM281.6 180.9L281.6 180.9Q269.0 180.9 258.1 174.7Q247.1 168.6 240.6 156.6Q234.1 144.6 234.1 127.8L234.1 127.8L234.1 124.5Q234.1 107.7 240.6 95.7Q247.1 83.7 258.0 77.5Q268.8 71.3 281.6 71.3L281.6 71.3Q291.2 71.3 298.0 73.6Q304.7 75.9 308.8 79.5Q312.9 83.1 315.2 87.3L315.2 87.3L318.8 87.3L318.8 31L342.7 31L342.7 178L319.2 178L319.2 164.3L315.6 164.3Q311.8 170.7 304.0 175.8Q296.3 180.9 281.6 180.9ZM288.7 159.9L288.7 159.9Q301.7 159.9 310.3 151.4Q319.0 142.9 319.0 127.2L319.0 127.2L319.0 125.1Q319.0 109.1 310.5 100.7Q301.9 92.3 288.7 92.3L288.7 92.3Q275.7 92.3 267.0 100.7Q258.3 109.1 258.3 125.1L258.3 125.1L258.3 127.2Q258.3 142.9 267.0 151.4Q275.7 159.9 288.7 159.9ZM362.3 126.6L362.3 126.6L362.3 123.4Q362.3 107.0 368.8 95.4Q375.3 83.7 386.3 77.5Q397.2 71.3 410.2 71.3L410.2 71.3Q424.9 71.3 432.6 76.6Q440.2 81.8 443.8 87.9L443.8 87.9L447.4 87.9L447.4 74.3L470.9 74.3L470.9 197.7Q470.9 208.0 465 214.0Q459.1 220 449.0 220L449.0 220L379.3 220L379.3 199L440.8 199Q446.9 199 446.9 192.7L446.9 192.7L446.9 162.7L443.4 162.7Q441.1 166.2 437.1 169.9Q433.1 173.6 426.6 176.1Q420.1 178.6 410.2 178.6L410.2 178.6Q397.2 178.6 386.3 172.4Q375.3 166.2 368.8 154.6Q362.3 142.9 362.3 126.6ZM416.9 157.4L416.9 157.4Q429.9 157.4 438.5 149.1Q447.1 140.8 447.1 125.9L447.1 125.9L447.1 123.8Q447.1 108.7 438.6 100.5Q430.1 92.3 416.9 92.3L416.9 92.3Q403.9 92.3 395.2 100.5Q386.5 108.7 386.5 123.8L386.5 123.8L386.5 125.9Q386.5 140.8 395.2 149.1Q403.9 157.4 416.9 157.4ZM543 180.9L543 180.9Q527.5 180.9 515.6 174.3Q503.7 167.7 497.1 155.6Q490.5 143.6 490.5 127.4L490.5 127.4L490.5 124.9Q490.5 108.5 497.0 96.5Q503.5 84.5 515.3 77.9Q527.0 71.3 542.4 71.3L542.4 71.3Q557.5 71.3 568.8 77.9Q580.2 84.5 586.5 96.5Q592.8 108.5 592.8 124.5L592.8 124.5L592.8 133.1L514.9 133.1Q515.3 145.2 523.5 152.6Q531.7 159.9 543.6 159.9L543.6 159.9Q555.4 159.9 561.1 154.8Q566.7 149.7 569.7 143.1L569.7 143.1L589.6 153.4Q586.7 159.1 581.1 165.5Q575.5 171.9 566.3 176.4Q557.1 180.9 543 180.9ZM515.1 114.8L515.1 114.8L568.2 114.8Q567.4 104.5 560.3 98.4Q553.3 92.3 542.2 92.3L542.2 92.3Q530.6 92.3 523.7 98.4Q516.8 104.5 515.1 114.8ZM635.7 178L611.6 178L611.6 74.3L635.3 74.3L635.3 86.2L638.9 86.2Q641.2 79.7 646.6 76.8Q652.1 73.8 659.6 73.8L659.6 73.8L672.2 73.8L672.2 95.3L659.2 95.3Q648.7 95.3 642.2 100.8Q635.7 106.4 635.7 117.9L635.7 117.9L635.7 178ZM711.8 178L687.7 178L687.7 31L711.8 31L711.8 178ZM813.1 220L748.0 220L748.0 199L805.4 199Q811.2 199 811.2 192.7L811.2 192.7L811.2 163.7L807.7 163.7Q806.0 167.5 802.2 171.2Q798.4 174.8 792.1 177.3Q785.8 179.7 776.2 179.7L776.2 179.7Q764.2 179.7 755.0 174.3Q745.7 169.0 740.7 159.2Q735.6 149.4 735.6 136.4L735.6 136.4L735.6 74.3L759.6 74.3L759.6 134.5Q759.6 147.1 765.8 153.2Q772.0 159.3 783.3 159.3L783.3 159.3Q796.1 159.3 803.6 150.9Q811.0 142.5 811.0 126.8L811.0 126.8L811.0 74.3L835.0 74.3L835.0 197.7Q835.0 208.0 829.1 214.0Q823.2 220 813.1 220L813.1 220Z "/></g></g></svg>
diff --git a/public/previews/kinetic/marks/lumen.svg b/public/previews/kinetic/marks/lumen.svg
new file mode 100644
index 00000000..cd00a129
--- /dev/null
+++ b/public/previews/kinetic/marks/lumen.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="1312" height="161" viewBox="0 0 1311.98 160.8"><g fill="#111111"><g transform="translate(9 9)"><path fill-rule="evenodd" d="M0 71.4A71.4 71.4 0 1 1 142.8 71.4A71.4 71.4 0 1 1 0 71.4ZM18.56 71.4A52.84 52.84 0 1 0 124.24 71.4A52.84 52.84 0 1 0 18.56 71.4Z"/><path fill-rule="evenodd" d="M67.12 57.12A18.56 18.56 0 1 1 104.24 57.12A18.56 18.56 0 1 1 67.12 57.12Z"/></g><g transform="translate(197.98 -20)"><path d="M103.6 169L13.8 169L13.8 29L38 29L38 147.2L103.6 147.2L103.6 169ZM156.8 170.6L156.8 170.6Q145.4 170.6 136.6 165.5Q127.8 160.4 123 151.1Q118.2 141.8 118.2 129.4L118.2 129.4L118.2 70.2L141 70.2L141 127.6Q141 139.6 146.9 145.4Q152.8 151.2 163.6 151.2L163.6 151.2Q175.8 151.2 182.9 143.2Q190 135.2 190 120.2L190 120.2L190 70.2L212.8 70.2L212.8 169L190.4 169L190.4 155.2L187 155.2Q184.4 160.6 177.5 165.6Q170.6 170.6 156.8 170.6ZM261 169L238 169L238 70.2L260.6 70.2L260.6 81.2L264 81.2Q266.6 76.2 272.7 72.3Q278.8 68.4 289 68.4L289 68.4Q299.8 68.4 306.4 72.8Q313 77.2 316.4 84L316.4 84L319.6 84Q323 77.2 329.4 72.8Q335.8 68.4 347.6 68.4L347.6 68.4Q356.8 68.4 364.3 72.4Q371.8 76.4 376.3 84.2Q380.8 92 380.8 103.6L380.8 103.6L380.8 169L357.8 169L357.8 105.2Q357.8 96.6 353.2 92.1Q348.6 87.6 340.4 87.6L340.4 87.6Q331.4 87.6 326.1 93.5Q320.8 99.4 320.8 110.4L320.8 110.4L320.8 169L298 169L298 105.2Q298 96.6 293.4 92.1Q288.8 87.6 280.6 87.6L280.6 87.6Q271.4 87.6 266.2 93.5Q261 99.4 261 110.4L261 110.4L261 169ZM450.2 171.8L450.2 171.8Q435.4 171.8 424.1 165.5Q412.8 159.2 406.5 147.7Q400.2 136.2 400.2 120.8L400.2 120.8L400.2 118.4Q400.2 102.8 406.4 91.4Q412.6 80 423.8 73.7Q435 67.4 449.6 67.4L449.6 67.4Q464 67.4 474.8 73.7Q485.6 80 491.6 91.4Q497.6 102.8 497.6 118L497.6 118L497.6 126.2L423.4 126.2Q423.8 137.8 431.6 144.8Q439.4 151.8 450.8 151.8L450.8 151.8Q462 151.8 467.4 146.9Q472.8 142 475.6 135.8L475.6 135.8L494.6 145.6Q491.8 151 486.5 157.1Q481.2 163.2 472.4 167.5Q463.6 171.8 450.2 171.8ZM423.6 108.8L423.6 108.8L474.2 108.8Q473.4 99 466.7 93.2Q460 87.4 449.4 87.4L449.4 87.4Q438.4 87.4 431.8 93.2Q425.2 99 423.6 108.8ZM540.2 169L517.2 169L517.2 70.2L539.8 70.2L539.8 84L543.2 84Q545.8 78.4 552.6 73.4Q559.4 68.4 573.2 68.4L573.2 68.4Q584.6 68.4 593.4 73.6Q602.2 78.8 607.1 88Q612 97.2 612 109.8L612 109.8L612 169L589 169L589 111.6Q589 99.6 583.1 93.7Q577.2 87.8 566.4 87.8L566.4 87.8Q554.2 87.8 547.2 95.9Q540.2 104 540.2 119L540.2 119L540.2 169Z M772.4 169L682.6 169L682.6 29L706.8 29L706.8 147.2L772.4 147.2L772.4 169ZM818.6 171.8L818.6 171.8Q808.2 171.8 799.8 168.1Q791.4 164.4 786.5 157.4Q781.6 150.4 781.6 140.2L781.6 140.2Q781.6 130.2 786.5 123.4Q791.4 116.6 800 113.1Q808.6 109.6 819.6 109.6L819.6 109.6L848.2 109.6L848.2 103.6Q848.2 95.8 843.4 90.9Q838.6 86 828.4 86L828.4 86Q818.4 86 813.3 90.7Q808.2 95.4 806.6 102.8L806.6 102.8L785.4 95.8Q787.8 88 793.1 81.6Q798.4 75.2 807.2 71.3Q816 67.4 828.8 67.4L828.8 67.4Q848.2 67.4 859.3 77.1Q870.4 86.8 870.4 105.2L870.4 105.2L870.4 144Q870.4 150 876 150L876 150L884.4 150L884.4 169L868.2 169Q861 169 856.4 165.4Q851.8 161.8 851.8 155.6L851.8 155.6L851.8 155.2L848.4 155.2Q847.2 158 844.2 162Q841.2 166 835.1 168.9Q829 171.8 818.6 171.8ZM822.4 153L822.4 153Q833.8 153 841 146.5Q848.2 140 848.2 129L848.2 129L848.2 127L821 127Q813.6 127 809 130.2Q804.4 133.4 804.4 139.6L804.4 139.6Q804.4 145.6 809.2 149.3Q814 153 822.4 153ZM957.8 171.8L957.8 171.8Q943.8 171.8 936.3 166.9Q928.8 162 925.4 156L925.4 156L922 156L922 169L899.4 169L899.4 29L922.4 29L922.4 82.6L925.8 82.6Q928 78.6 931.9 75.2Q935.8 71.8 942.1 69.6Q948.4 67.4 957.8 67.4L957.8 67.4Q970 67.4 980.2 73.3Q990.4 79.2 996.6 90.6Q1002.8 102 1002.8 118L1002.8 118L1002.8 121.2Q1002.8 137.2 996.6 148.6Q990.4 160 980.1 165.9Q969.8 171.8 957.8 171.8ZM951 151.8L951 151.8Q963.4 151.8 971.6 143.7Q979.8 135.6 979.8 120.6L979.8 120.6L979.8 118.6Q979.8 103.4 971.7 95.4Q963.6 87.4 951 87.4L951 87.4Q938.6 87.4 930.3 95.4Q922 103.4 922 118.6L922 118.6L922 120.6Q922 135.6 930.3 143.7Q938.6 151.8 951 151.8ZM1064 171.8L1064 171.8Q1044.8 171.8 1032.4 163.4Q1020.0 155 1017.4 138.8L1017.4 138.8L1038.6 133.4Q1040 141 1043.6 145.4Q1047.2 149.8 1052.5 151.6Q1057.8 153.4 1064 153.4L1064 153.4Q1073.4 153.4 1078.1 150Q1082.8 146.6 1082.8 141.4L1082.8 141.4Q1082.8 136 1078.3 133.4Q1073.8 130.8 1064.6 129L1064.6 129L1058.4 128Q1048.2 126 1039.8 122.5Q1031.4 119 1026.3 112.9Q1021.2 106.8 1021.2 97.4L1021.2 97.4Q1021.2 83 1031.9 75.2Q1042.6 67.4 1060 67.4L1060 67.4Q1076.6 67.4 1087.4 74.8Q1098.2 82.2 1101.4 94.6L1101.4 94.6L1080.2 101Q1078.6 92.6 1073.2 89.1Q1067.8 85.6 1060 85.6L1060 85.6Q1052 85.6 1047.7 88.4Q1043.4 91.2 1043.4 96.4L1043.4 96.4Q1043.4 101.6 1047.8 104.2Q1052.2 106.8 1059.6 108L1059.6 108L1065.8 109.2Q1076.8 111.2 1085.7 114.4Q1094.6 117.6 1099.8 123.6Q1105 129.6 1105 139.8L1105 139.8Q1105 155.2 1093.9 163.5Q1082.8 171.8 1064 171.8Z "/></g></g></svg>
diff --git a/public/previews/kinetic/marks/sora.svg b/public/previews/kinetic/marks/sora.svg
new file mode 100644
index 00000000..fa44a2b2
--- /dev/null
+++ b/public/previews/kinetic/marks/sora.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="1150" height="185" viewBox="0 0 1150.14 185.2"><g fill="#111111"><g transform="translate(9 9)"><path fill-rule="evenodd" d="M23.41 100.32A60.19 60.19 0 0 1 143.79 100.32Z"/><path fill-rule="evenodd" d="M5.02 108.35H162.18A5.02 5.02 0 0 1 167.2 113.36V113.36A5.02 5.02 0 0 1 162.18 118.38H5.02A5.02 5.02 0 0 1 0 113.36V113.36A5.02 5.02 0 0 1 5.02 108.35Z"/><path fill-rule="evenodd" d="M35.11 126.4H132.09A5.02 5.02 0 0 1 137.1 131.42V131.42A5.02 5.02 0 0 1 132.09 136.44H35.11A5.02 5.02 0 0 1 30.1 131.42V131.42A5.02 5.02 0 0 1 35.11 126.4Z"/><path fill-rule="evenodd" d="M61.86 144.46H105.34A5.02 5.02 0 0 1 110.35 149.48V149.48A5.02 5.02 0 0 1 105.34 154.49H61.86A5.02 5.02 0 0 1 56.85 149.48V149.48A5.02 5.02 0 0 1 61.86 144.46Z"/></g><g transform="translate(230.64 -6.7)"><path d="M66.1 175.1L66.1 175.1Q57.9 175.1 52 173.2Q46.1 171.2 42.4 169.3Q38.6 167.4 36.8 167.4L36.8 167.4Q34.8 167.4 33.5 168.6Q32.2 169.8 31.1 171.3Q29.9 172.9 28.6 174.1Q27.3 175.3 25.4 175.3L25.4 175.3Q23.3 175.3 22.0 174.1Q20.6 172.8 20.1 169.9L20.1 169.9L13.2 137.3Q12.8 135.1 13.8 133.5Q14.7 131.9 16.9 131.2L16.9 131.2Q19.3 130.4 21.1 131.3Q22.9 132.2 24.2 134.8L24.2 134.8Q29.9 146 36.4 152.6Q42.8 159.2 49.8 162Q56.8 164.8 64.1 164.8L64.1 164.8Q74.3 164.8 80.2 159.5Q86.1 154.2 86.1 145.3L86.1 145.3Q86.2 139.5 83.5 134.8Q80.8 130.2 73.3 125.8Q65.8 121.4 51.1 116.6L51.1 116.6Q35.9 111.7 26.8 105.3Q17.6 98.8 13.5 90.2Q9.4 81.6 9.4 70.2L9.4 70.2Q9.4 58.1 15.2 48.9Q20.9 39.7 31.4 34.5Q41.8 29.4 55.8 29.4L55.8 29.4Q64.8 29.4 70.7 31.3Q76.6 33.1 80.4 35Q84.2 36.9 86.7 36.9L86.7 36.9Q88.9 36.9 90.1 34.9Q91.3 33 92.7 31.0Q94.1 29.1 96.9 29.1L96.9 29.1Q99.1 29.1 100.6 30.5Q102 31.9 103.1 35.7L103.1 35.7L112.5 68.5Q113.3 71.1 112.4 73.1Q111.4 75.2 109.1 75.9L109.1 75.9Q106.8 76.7 105.0 75.8Q103.1 74.8 101.9 72.5L101.9 72.5Q95.7 60.1 88.7 52.9Q81.6 45.8 74.1 42.7Q66.6 39.6 58.9 39.6L58.9 39.6Q48.7 39.6 42.7 45.4Q36.6 51.3 36.6 60.7L36.6 60.7Q36.6 66.4 39.3 71.3Q41.9 76.2 49.3 80.8Q56.7 85.5 70.7 90.7L70.7 90.7Q86.2 96.2 95.4 102.6Q104.5 109 108.5 117.0Q112.4 125.1 112.4 135.5L112.4 135.5Q112.4 146.4 106.9 155.4Q101.4 164.4 91.1 169.8Q80.8 175.1 66.1 175.1ZM179.7 75L179.7 75Q195.2 75 206.9 81.3Q218.6 87.6 225.2 98.8Q231.7 110.1 231.7 125L231.7 125Q231.7 139.1 224.9 150.3Q218.2 161.5 206.3 168Q194.4 174.5 178.7 174.5L178.7 174.5Q163.3 174.5 151.7 168.1Q140 161.7 133.4 150.4Q126.8 139.2 126.8 124.5L126.8 124.5Q126.8 110.2 133.6 99.0Q140.3 87.9 152.2 81.4Q164.1 75 179.7 75ZM186.8 164L186.8 164Q193.6 163 197.8 157.8Q201.9 152.5 203.1 143.3Q204.2 134.1 201.8 121.2L201.8 121.2Q199.5 108.3 195.1 100.0Q190.7 91.6 184.7 87.9Q178.7 84.2 171.7 85.4L171.7 85.4Q164.8 86.5 160.7 91.8Q156.5 97 155.4 106.1Q154.4 115.3 156.7 128.3L156.7 128.3Q159 141.1 163.4 149.4Q167.8 157.8 173.8 161.5Q179.8 165.2 186.8 164ZM283.9 118.5L280.4 119Q280.4 104.5 284.5 94.7Q288.6 84.9 295.3 79.9Q302 75 309.7 75L309.7 75Q319.2 75 324.4 80.4Q329.6 85.8 329.6 95.9L329.6 95.9Q329.6 104.9 325.9 109.3Q322.2 113.7 316.3 113.7L316.3 113.7Q310.3 113.7 307.2 110.5Q304.1 107.3 304.1 101.6L304.1 101.6L304.1 98Q304 94.8 302.6 93.3Q301.2 91.7 298 91.7L298 91.7Q294.5 91.7 291.3 94.6Q288 97.5 286.0 103.4Q283.9 109.3 283.9 118.5L283.9 118.5ZM282.3 81.9L282.3 81.9L283.9 104.6L283.9 155.9Q283.9 158.8 285.1 160.2Q286.2 161.5 289.2 162L289.2 162L297.8 163.3Q300.1 163.7 301.3 164.8Q302.4 165.9 302.4 167.8L302.4 167.8Q302.4 169.8 301.0 170.9Q299.5 172 296.8 172L296.8 172L250.1 172Q247.3 172 246 170.9Q244.7 169.8 244.7 167.9L244.7 167.9Q244.7 166.4 245.6 165.3Q246.5 164.3 248.4 163.6L248.4 163.6L252.3 162.6Q254.1 162 255.0 160.6Q255.8 159.1 255.8 156L255.8 156L255.8 98.9Q255.8 96.3 255.1 95.2Q254.3 94.1 252.6 93.8L252.6 93.8L247.3 93.4Q245.5 93 244.7 92.1Q243.9 91.2 243.9 89.8L243.9 89.8Q243.9 88.1 244.9 87.1Q245.9 86.1 248.5 85.1L248.5 85.1L266.7 78.5Q271.6 76.6 273.9 76.0Q276.2 75.5 277.5 75.5L277.5 75.5Q279.7 75.5 280.8 76.9Q281.9 78.4 282.3 81.9ZM399 159.3L399 159.3L399 157.2L397.1 156.8L397.1 97.1Q397.1 90.1 393.6 86.3Q390 82.4 383.5 82.4L383.5 82.4Q377.6 82.4 374.4 84.9Q371.2 87.4 371.2 91.1L371.2 91.1L371.2 99.9Q371.2 105.9 367.2 109.2Q363.2 112.4 355.9 112.4L355.9 112.4Q349.7 112.4 346.5 109.4Q343.3 106.5 343.3 101.4L343.3 101.4Q343.3 95.1 348.5 89.0Q353.7 83 363.8 79.0Q373.9 75.1 388.7 75.1L388.7 75.1Q407.1 75.1 416.1 82.5Q425 90 425 102.7L425 102.7L425 154.7Q425 157.5 426.1 158.9Q427.3 160.3 429.4 160.3L429.4 160.3Q431.6 160.3 432.7 159.3Q433.8 158.2 434.6 157.1L434.6 157.1Q435.1 156.4 435.7 155.9Q436.3 155.5 437.2 155.5L437.2 155.5Q438.4 155.5 439 156.4Q439.6 157.3 439.6 158.8L439.6 158.8Q439.6 162.2 437.3 165.8Q434.9 169.4 430.3 171.9Q425.6 174.5 418.6 174.5L418.6 174.5Q409.7 174.5 404.4 170.4Q399 166.4 399 159.3ZM339.1 151.1L339.1 151.1Q339.1 138.6 350.3 130.9Q361.4 123.2 381.4 123.2L381.4 123.2Q387.9 123.2 393.1 124.3Q398.4 125.4 402.2 127.3L402.2 127.3L400 133.7Q396.6 132.1 393.1 131.2Q389.5 130.3 385.4 130.3L385.4 130.3Q377.1 130.3 372.4 134.6Q367.8 138.8 367.8 146.3L367.8 146.3Q367.8 153.8 371.8 157.8Q375.7 161.8 382 161.8L382 161.8Q387.4 161.8 392.4 159.3Q397.3 156.9 400.7 152.5L400.7 152.5L402.9 158.2Q397.4 166 388.1 170.3Q378.9 174.5 368.5 174.5L368.5 174.5Q355.4 174.5 347.3 168Q339.1 161.5 339.1 151.1Z M548.2 175.1L548.2 175.1Q540 175.1 534.1 173.2Q528.2 171.2 524.5 169.3Q520.7 167.4 518.9 167.4L518.9 167.4Q516.9 167.4 515.6 168.6Q514.3 169.8 513.1 171.3Q512 172.9 510.7 174.1Q509.4 175.3 507.5 175.3L507.5 175.3Q505.4 175.3 504.1 174.1Q502.7 172.8 502.2 169.9L502.2 169.9L495.3 137.3Q494.9 135.1 495.9 133.5Q496.8 131.9 499 131.2L499 131.2Q501.4 130.4 503.2 131.3Q505 132.2 506.3 134.8L506.3 134.8Q512 146 518.5 152.6Q524.9 159.2 531.9 162Q538.9 164.8 546.2 164.8L546.2 164.8Q556.4 164.8 562.3 159.5Q568.2 154.2 568.2 145.3L568.2 145.3Q568.3 139.5 565.6 134.8Q562.9 130.2 555.4 125.8Q547.9 121.4 533.2 116.6L533.2 116.6Q518 111.7 508.9 105.3Q499.7 98.8 495.6 90.2Q491.5 81.6 491.5 70.2L491.5 70.2Q491.5 58.1 497.3 48.9Q503 39.7 513.5 34.5Q523.9 29.4 537.9 29.4L537.9 29.4Q546.9 29.4 552.8 31.3Q558.7 33.1 562.5 35Q566.3 36.9 568.8 36.9L568.8 36.9Q571 36.9 572.2 34.9Q573.4 33 574.8 31.0Q576.2 29.1 579 29.1L579 29.1Q581.2 29.1 582.7 30.5Q584.1 31.9 585.2 35.7L585.2 35.7L594.6 68.5Q595.4 71.1 594.5 73.1Q593.5 75.2 591.2 75.9L591.2 75.9Q588.9 76.7 587.1 75.8Q585.2 74.8 584 72.5L584 72.5Q577.8 60.1 570.8 52.9Q563.7 45.8 556.2 42.7Q548.7 39.6 541 39.6L541 39.6Q530.8 39.6 524.8 45.4Q518.7 51.3 518.7 60.7L518.7 60.7Q518.7 66.4 521.4 71.3Q524 76.2 531.4 80.8Q538.8 85.5 552.8 90.7L552.8 90.7Q568.3 96.2 577.5 102.6Q586.6 109 590.6 117.0Q594.5 125.1 594.5 135.5L594.5 135.5Q594.5 146.4 589 155.4Q583.5 164.4 573.2 169.8Q562.9 175.1 548.2 175.1ZM653.7 172L614.8 172Q611.9 172 610.8 170.9Q609.7 169.8 609.7 167.9L609.7 167.9Q609.7 166.4 610.6 165.3Q611.4 164.3 613.4 163.6L613.4 163.6L617.3 162.6Q619.1 161.9 620.0 160.5Q620.8 159.1 620.8 156L620.8 156L620.8 46.5Q620.8 44 620.1 42.9Q619.3 41.8 617.6 41.5L617.6 41.5L612.3 41.1Q610.5 40.6 609.7 39.7Q608.9 38.8 608.9 37.4L608.9 37.4Q608.9 35.8 609.9 34.8Q610.8 33.8 613.5 32.8L613.5 32.8L632.1 26Q635.9 24.6 638.2 23.9Q640.5 23.3 642.6 23.3L642.6 23.3Q645.7 23.3 647.3 25.0Q648.9 26.8 648.9 29.7L648.9 29.7L648.9 156Q648.9 159.1 649.8 160.5Q650.7 161.9 652.5 162.6L652.5 162.6L656.1 163.6Q659.3 164.9 659.3 167.6L659.3 167.6Q659.3 172 653.7 172L653.7 172ZM643.6 137.1L640.5 128.6L681.5 95.2Q685.0 92.4 684.7 89.9Q684.3 87.5 680.4 86.3L680.4 86.3L676.9 85.4Q675.0 84.8 674.3 83.9Q673.6 83 673.6 81.5L673.6 81.5Q673.6 79.5 675.0 78.4Q676.4 77.3 678.9 77.3L678.9 77.3L713.9 77.3Q716.3 77.3 717.8 78.4Q719.2 79.5 719.2 81.3L719.2 81.3Q719.2 83.2 718.0 84.4Q716.8 85.6 713.0 86.5L713.0 86.5Q707.9 87.6 704.0 89.8Q700.0 92 694.0 96.8L694.0 96.8L643.6 137.1ZM656.4 121.2L675.2 104.7L710.8 156.1Q713.2 159.4 715.0 160.8Q716.8 162.1 720.1 163.2L720.1 163.2Q722.2 164.2 723.3 165.4Q724.3 166.6 724.3 168.1L724.3 168.1Q724.3 169.9 722.9 170.9Q721.4 172 719.0 172L719.0 172L678.2 172Q676.0 172 674.7 170.9Q673.4 169.8 673.4 167.9L673.4 167.9Q673.4 166.6 674.1 165.7Q674.8 164.8 676.4 164.2L676.4 164.2L679.6 163.3Q682.4 162.5 682.6 160.8Q682.8 159.2 680.0 155.3L680.0 155.3L656.4 121.2ZM770.2 81.8L770.2 81.8L770.2 156Q770.2 159.1 771.1 160.6Q771.9 162 773.7 162.6L773.7 162.6L777.5 163.6Q779.4 164.2 780.3 165.3Q781.2 166.3 781.2 167.9L781.2 167.9Q781.2 169.8 779.9 170.9Q778.6 172 775.7 172L775.7 172L736.3 172Q733.5 172 732.2 170.9Q730.9 169.8 730.9 167.9L730.9 167.9Q730.9 166.4 731.8 165.3Q732.7 164.3 734.6 163.6L734.6 163.6L738.5 162.6Q740.3 161.9 741.2 160.5Q742.0 159.1 742.0 156L742.0 156L742.0 98.7Q742.0 96.1 741.3 95Q740.5 93.9 738.8 93.6L738.8 93.6L733.5 93.2Q731.7 92.8 730.9 91.9Q730.1 91 730.1 89.6L730.1 89.6Q730.1 87.9 731.1 86.9Q732.0 85.9 734.7 84.9L734.7 84.9L753.3 78.1Q757.2 76.7 759.6 76.1Q761.9 75.5 763.5 75.5L763.5 75.5Q766.9 75.5 768.6 77.3Q770.2 79 770.2 81.8ZM753.9 60.2L753.9 60.2Q745.9 60.2 741.1 56.0Q736.2 51.9 736.2 45.2L736.2 45.2Q736.2 38.5 741.1 34.4Q745.9 30.4 753.9 30.4L753.9 30.4Q762.0 30.4 766.9 34.4Q771.7 38.5 771.7 45.2L771.7 45.2Q771.7 51.9 766.9 56.0Q762.0 60.2 753.9 60.2ZM831.5 81.8L831.5 81.8L831.5 156Q831.5 159.1 832.4 160.5Q833.3 161.9 835.1 162.6L835.1 162.6L838.7 163.6Q841.9 164.9 841.9 167.6L841.9 167.6Q841.9 172 836.3 172L836.3 172L797.7 172Q794.9 172 793.6 170.9Q792.3 169.8 792.3 167.9L792.3 167.9Q792.3 166.4 793.2 165.3Q794.0 164.3 795.9 163.6L795.9 163.6L799.9 162.6Q801.7 161.9 802.6 160.5Q803.4 159.1 803.4 156L803.4 156L803.4 98.7Q803.4 96.1 802.7 95Q801.9 93.9 800.2 93.6L800.2 93.6L794.9 93.2Q793.1 92.8 792.3 91.9Q791.5 91 791.5 89.6L791.5 89.6Q791.5 87.9 792.5 86.9Q793.4 85.9 796.1 84.9L796.1 84.9L814.7 78.1Q818.5 76.7 820.8 76.1Q823.1 75.5 825.2 75.5L825.2 75.5Q828.3 75.5 829.9 77.3Q831.5 79 831.5 81.8ZM832.5 100.6L828.5 104.1L823.9 99.4L827.8 95.9Q840.4 84.6 849.4 79.8Q858.4 75 866.5 75L866.5 75Q878.8 75 885.6 83.3Q892.4 91.5 893.9 105.2L893.9 105.2L899.5 155.7Q899.8 159 900.6 160.5Q901.4 162 903.3 162.6L903.3 162.6L906.8 163.6Q908.7 164.3 909.6 165.3Q910.5 166.4 910.5 167.9L910.5 167.9Q910.5 169.8 909.2 170.9Q907.9 172 905.0 172L905.0 172L866.0 172Q860.5 172 860.5 167.6L860.5 167.6Q860.5 164.9 863.6 163.6L863.6 163.6L867.4 162.6Q869.3 161.9 870.4 160.4Q871.4 158.9 871.0 155.7L871.0 155.7L865.8 109.3Q864.8 100.6 861.4 96.2Q857.9 91.8 851.2 91.8L851.2 91.8Q847.0 91.8 842.4 94Q837.7 96.2 832.5 100.6L832.5 100.6Z "/></g></g></svg>
diff --git a/public/previews/kinetic/marks/vesper.svg b/public/previews/kinetic/marks/vesper.svg
new file mode 100644
index 00000000..1a791d94
--- /dev/null
+++ b/public/previews/kinetic/marks/vesper.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="1138" height="170" viewBox="0 0 1137.77 170.33"><g fill="#111111"><g transform="translate(8 8)"><path fill-rule="evenodd" d="M0 77.17A74.08 74.08 0 1 1 148.16 77.17A74.08 74.08 0 1 1 0 77.17ZM44.45 62.35A60.74 60.74 0 1 0 165.94 62.35A60.74 60.74 0 1 0 44.45 62.35Z"/><path fill-rule="evenodd" d="M123.46 24.69L128.87 40.9L145.07 46.3L128.87 51.7L123.46 67.91L118.06 51.7L101.86 46.3L118.06 40.9Z"/></g><g transform="translate(222.57 -12.18)"><path d="M92.8 35.4L92.8 35.4Q92.8 33.3 94.2 32.1Q95.7 31 98.6 31L98.6 31L128.8 31Q131.9 31 133.3 32.1Q134.7 33.3 134.7 35.3L134.7 35.3Q134.7 36.8 133.8 37.8Q132.8 38.8 130.6 39.7L130.6 39.7L127.1 41.0Q124.1 42.3 122.1 44.9Q120.2 47.4 118.3 53.1L118.3 53.1L87.0 145.3Q85.9 148.6 85.4 150.7Q84.9 152.8 84.9 155.0L84.9 155.0L84.9 159.3Q84.9 161.5 83.6 162.8Q82.3 164 80.2 164L80.2 164L56.8 164Q54.6 164 53.4 162.8Q52.2 161.5 52.2 159.2L52.2 159.2L52.2 154.8Q52.2 153.3 51.6 151.5Q51.1 149.7 50.4 147.3L50.4 147.3L15.6 47.6Q14.6 44.7 13.4 43.3Q12.3 42.0 10.2 41.2L10.2 41.2L6.5 39.9Q2.9 38.5 2.9 35.4L2.9 35.4Q2.9 33.3 4.3 32.1Q5.8 31 8.7 31L8.7 31L54.1 31Q57.2 31 58.6 32.1Q60.0 33.3 60.0 35.4L60.0 35.4Q60.0 37.1 59.0 38.1Q58.0 39.1 55.9 39.7L55.9 39.7L49.7 41.1Q47.2 41.9 46.6 43.7Q46.1 45.5 47.5 49.4L47.5 49.4L81.3 147.8L72.4 154.6L107.3 52.3Q108.8 47.7 107.8 45.2Q106.8 42.6 102.3 41.0L102.3 41.0L96.9 39.7Q94.9 39.0 93.9 38.0Q92.8 37.1 92.8 35.4ZM205.1 101.9L205.1 92.5L235.2 92.5Q241.1 92.5 243.5 90.2Q245.9 87.9 247.2 81.3L247.2 81.3Q247.7 79.0 248.9 77.8Q250.1 76.7 251.9 76.6L251.9 76.6Q255.5 76.4 256.6 80.7L256.6 80.7L263.9 108.9Q264.5 111.4 263.8 112.8Q263.2 114.3 261.2 115.0L261.2 115.0Q259.3 115.5 257.7 115.0Q256.0 114.4 254.9 112.6L254.9 112.6Q252.3 108.2 250.1 105.9Q247.8 103.6 245.1 102.7Q242.3 101.9 238.0 101.9L238.0 101.9L205.1 101.9ZM172.5 35.4L172.5 35.4Q172.5 33.3 173.9 32.1Q175.3 31 178.3 31L178.3 31L250.5 31Q253.9 31 256.1 30.1Q258.4 29.1 260.3 28.2Q262.3 27.2 264.8 27.2L264.8 27.2Q267.7 27.2 269.2 28.8Q270.6 30.4 271.8 34.1L271.8 34.1L279.4 60.8Q280.0 63.2 279.3 64.8Q278.5 66.4 276.4 67.1L276.4 67.1Q274.0 67.9 272.1 67.0Q270.2 66.2 269.0 63.8L269.0 63.8Q265.4 56.4 262.3 51.8Q259.2 47.2 256.1 44.7Q253.0 42.3 249.3 41.4Q245.6 40.5 240.8 40.5L240.8 40.5L216.1 40.5L216.1 145.1Q216.1 149.8 218.8 152.2Q221.4 154.5 226.8 154.5L226.8 154.5L243.6 154.5Q250.0 154.5 254.8 152.4Q259.5 150.2 263.8 144.2Q268.2 138.2 273.4 126.3L273.4 126.3Q274.3 124.1 275.9 123.3Q277.6 122.6 279.7 122.9L279.7 122.9Q282.0 123.2 283.0 125.0Q284.0 126.7 283.4 129.2L283.4 129.2L275.2 160.5Q274.2 164.1 272.6 165.8Q271.0 167.5 267.9 167.5L267.9 167.5Q265.7 167.5 263.7 166.6Q261.8 165.7 259.5 164.9Q257.2 164 253.9 164L253.9 164L178.3 164Q175.3 164 173.9 162.8Q172.5 161.6 172.5 159.6L172.5 159.6Q172.5 156.0 176.5 154.8L176.5 154.8L181.9 153.6Q184.3 152.9 185.5 151.6Q186.6 150.2 186.6 148.1L186.6 148.1L186.6 46.9Q186.6 44.8 185.5 43.4Q184.3 42.1 181.9 41.5L181.9 41.5L176.5 40.2Q172.5 39.0 172.5 35.4ZM376.9 166.9L376.9 166.9Q369.1 166.9 363.5 165.1Q357.9 163.2 354.3 161.4Q350.8 159.6 349.1 159.6L349.1 159.6Q347.2 159.6 345.9 160.8Q344.7 161.9 343.6 163.4Q342.5 164.9 341.3 166.0Q340.0 167.1 338.2 167.1L338.2 167.1Q336.2 167.1 335.0 165.9Q333.7 164.8 333.2 162.0L333.2 162.0L326.6 131.0Q326.3 128.9 327.2 127.4Q328.1 125.9 330.2 125.2L330.2 125.2Q332.4 124.5 334.2 125.3Q335.9 126.2 337.1 128.7L337.1 128.7Q342.5 139.3 348.6 145.6Q354.8 151.8 361.4 154.5Q368.1 157.2 375 157.2L375 157.2Q384.7 157.2 390.3 152.1Q395.9 147.1 395.9 138.6L395.9 138.6Q396.0 133.1 393.4 128.7Q390.9 124.3 383.7 120.1Q376.6 115.9 362.7 111.4L362.7 111.4Q348.2 106.7 339.5 100.6Q330.8 94.5 326.9 86.3Q323.0 78.1 323.0 67.3L323.0 67.3Q323.0 55.8 328.5 47.1Q334.0 38.3 343.9 33.4Q353.8 28.5 367.1 28.5L367.1 28.5Q375.7 28.5 381.3 30.3Q386.9 32.0 390.5 33.8Q394.1 35.7 396.5 35.7L396.5 35.7Q398.6 35.7 399.7 33.8Q400.8 31.9 402.2 30.1Q403.5 28.2 406.2 28.2L406.2 28.2Q408.3 28.2 409.6 29.6Q411.0 30.9 412.1 34.5L412.1 34.5L421.0 65.7Q421.7 68.1 420.8 70.1Q419.9 72.0 417.8 72.7L417.8 72.7Q415.6 73.5 413.8 72.6Q412.1 71.7 410.9 69.5L410.9 69.5Q405.0 57.7 398.3 50.9Q391.6 44.1 384.5 41.2Q377.4 38.2 370.1 38.2L370.1 38.2Q360.4 38.2 354.6 43.8Q348.9 49.3 348.9 58.3L348.9 58.3Q348.9 63.7 351.4 68.3Q353.9 73.0 360.9 77.4Q368.0 81.8 381.3 86.8L381.3 86.8Q396.0 92.0 404.7 98.1Q413.4 104.2 417.1 111.8Q420.9 119.4 420.9 129.3L420.9 129.3Q420.9 139.7 415.7 148.2Q410.4 156.8 400.7 161.9Q390.9 166.9 376.9 166.9ZM582.8 79.5L582.8 79.5Q582.8 91.8 576.5 100.8Q570.2 109.8 558.7 114.8Q547.1 119.7 531.4 119.7L531.4 119.7Q521.0 119.7 512.3 117.5Q503.7 115.4 497.2 111.4L497.2 111.4L498.6 102.9Q502.0 105.3 506.0 106.9Q510.0 108.4 514.4 109.2Q518.9 110.0 523.7 110.0L523.7 110.0Q532.5 110.0 539.3 106.4Q546.2 102.8 550.1 95.8Q554.0 88.8 554.0 78.7L554.0 78.7Q554.0 67.0 549.3 58.5Q544.7 49.9 536.4 45.2Q528.0 40.4 516.7 40.4L516.7 40.4L509.2 40.4L509.2 148.1Q509.2 150.2 510.3 151.7Q511.5 153.2 514.0 153.6L514.0 153.6L522.2 154.7Q524.6 155.2 525.6 156.3Q526.7 157.4 526.7 159.6L526.7 159.6Q526.7 161.6 525.3 162.8Q523.9 164 521.0 164L521.0 164L471.4 164Q468.5 164 467.0 162.8Q465.6 161.6 465.6 159.6L465.6 159.6Q465.6 156.0 469.6 154.8L469.6 154.8L475.1 153.6Q477.4 152.9 478.6 151.6Q479.8 150.2 479.8 148.1L479.8 148.1L479.8 46.9Q479.8 44.8 478.6 43.4Q477.4 42.1 475.1 41.5L475.1 41.5L469.6 40.2Q465.6 39.0 465.6 35.4L465.6 35.4Q465.6 33.3 467.0 32.1Q468.5 31 471.4 31L471.4 31L517.5 31Q538.2 31 552.8 37.2Q567.4 43.4 575.1 54.4Q582.8 65.4 582.8 79.5ZM656.8 101.9L656.8 92.5L686.9 92.5Q692.8 92.5 695.2 90.2Q697.7 87.9 698.9 81.3L698.9 81.3Q699.5 79.0 700.6 77.8Q701.8 76.7 703.6 76.6L703.6 76.6Q707.3 76.4 708.3 80.7L708.3 80.7L715.6 108.9Q716.2 111.4 715.6 112.8Q714.9 114.3 713.0 115.0L713.0 115.0Q711.1 115.5 709.4 115.0Q707.7 114.4 706.6 112.6L706.6 112.6Q704.0 108.2 701.8 105.9Q699.6 103.6 696.8 102.7Q694.0 101.9 689.8 101.9L689.8 101.9L656.8 101.9ZM624.2 35.4L624.2 35.4Q624.2 33.3 625.6 32.1Q627.1 31 630.0 31L630.0 31L702.2 31Q705.6 31 707.9 30.1Q710.1 29.1 712.0 28.2Q714.0 27.2 716.6 27.2L716.6 27.2Q719.4 27.2 720.9 28.8Q722.4 30.4 723.5 34.1L723.5 34.1L731.1 60.8Q731.8 63.2 731 64.8Q730.2 66.4 728.2 67.1L728.2 67.1Q725.8 67.9 723.9 67.0Q722.0 66.2 720.7 63.8L720.7 63.8Q717.1 56.4 714.0 51.8Q711.0 47.2 707.8 44.7Q704.7 42.3 701.0 41.4Q697.4 40.5 692.5 40.5L692.5 40.5L667.8 40.5L667.8 145.1Q667.8 149.8 670.5 152.2Q673.1 154.5 678.6 154.5L678.6 154.5L695.3 154.5Q701.7 154.5 706.5 152.4Q711.2 150.2 715.6 144.2Q719.9 138.2 725.1 126.3L725.1 126.3Q726.1 124.1 727.7 123.3Q729.3 122.6 731.4 122.9L731.4 122.9Q733.8 123.2 734.8 125.0Q735.8 126.7 735.1 129.2L735.1 129.2L726.9 160.5Q726.0 164.1 724.4 165.8Q722.7 167.5 719.6 167.5L719.6 167.5Q717.4 167.5 715.5 166.6Q713.5 165.7 711.2 164.9Q709.0 164 705.6 164L705.6 164L630.0 164Q627.1 164 625.6 162.8Q624.2 161.6 624.2 159.6L624.2 159.6Q624.2 156.0 628.2 154.8L628.2 154.8L633.6 153.6Q636 152.9 637.2 151.6Q638.4 150.2 638.4 148.1L638.4 148.1L638.4 46.9Q638.4 44.8 637.2 43.4Q636 42.1 633.6 41.5L633.6 41.5L628.2 40.2Q624.2 39.0 624.2 35.4ZM894.9 76.7L894.9 76.7Q894.9 85.8 890.9 93.2Q886.8 100.6 879.3 105.6Q871.8 110.6 861.4 112.5L861.4 112.5Q857.6 113.2 854.3 113.9Q851.1 114.7 847.7 115.3Q844.4 115.8 840.3 115.8L840.3 115.8Q834.4 115.8 829.1 115.0Q823.7 114.2 819.2 112.7Q814.8 111.1 811.4 108.9L811.4 108.9L812.0 100.3Q814.7 102.3 818.3 103.6Q822.0 105.0 826.3 105.7Q830.6 106.3 835.4 106.3L835.4 106.3Q849.2 106.3 856.9 98.9Q864.6 91.5 864.6 77.1L864.6 77.1Q864.6 66.2 860.0 57.8Q855.4 49.4 847.1 44.6Q838.8 39.8 827.6 39.8L827.6 39.8L819.2 39.8L819.2 148.1Q819.2 150.2 820.3 151.6Q821.3 152.9 823.4 153.6L823.4 153.6L830.0 154.8Q832.2 155.6 833.1 156.7Q834.0 157.8 834.0 159.6L834.0 159.6Q834.0 164 828.3 164L828.3 164L781.4 164Q778.5 164 777.1 162.8Q775.7 161.6 775.7 159.6L775.7 159.6Q775.7 156.0 779.7 154.8L779.7 154.8L785.1 153.6Q787.4 152.9 788.6 151.6Q789.9 150.2 789.9 148.1L789.9 148.1L789.9 46.9Q789.9 44.8 788.6 43.4Q787.4 42.1 785.1 41.5L785.1 41.5L779.7 40.2Q775.7 39.0 775.7 35.4L775.7 35.4Q775.7 33.3 777.1 32.1Q778.5 31 781.4 31L781.4 31L828.6 31Q850.0 31 864.8 36.8Q879.6 42.7 887.2 53.0Q894.9 63.3 894.9 76.7ZM862.0 149.4L840.1 111.9L868.9 108.6L893.5 148.0Q895.3 150.8 897.2 152.3Q899.0 153.8 902.2 154.8L902.2 154.8Q905.1 155.6 906.2 156.7Q907.2 157.8 907.2 159.6L907.2 159.6Q907.2 161.6 905.7 162.8Q904.3 164 901.3 164L901.3 164L860.8 164Q855.2 164 855.2 159.6L855.2 159.6Q855.2 158.4 855.9 157.5Q856.6 156.7 858.0 156.0L858.0 156.0L860.7 155.3Q862.8 154.4 863.1 153.1Q863.4 151.7 862.0 149.4L862.0 149.4Z "/></g></g></svg>
diff --git a/public/previews/kinetic/perfume.webp b/public/previews/kinetic/perfume.webp
new file mode 100644
index 00000000..71982f63
Binary files /dev/null and b/public/previews/kinetic/perfume.webp differ
diff --git a/public/previews/templates/marketing/m2-line-reveal.jpg b/public/previews/templates/marketing/m2-line-reveal.jpg
new file mode 100644
index 00000000..2d8e484a
Binary files /dev/null and b/public/previews/templates/marketing/m2-line-reveal.jpg differ
diff --git a/public/previews/templates/marketing/m2-line-reveal.mp4 b/public/previews/templates/marketing/m2-line-reveal.mp4
new file mode 100644
index 00000000..89e29e0e
Binary files /dev/null and b/public/previews/templates/marketing/m2-line-reveal.mp4 differ
diff --git a/public/previews/templates/marketing/m2-offer-badge.jpg b/public/previews/templates/marketing/m2-offer-badge.jpg
new file mode 100644
index 00000000..a6b52937
Binary files /dev/null and b/public/previews/templates/marketing/m2-offer-badge.jpg differ
diff --git a/public/previews/templates/marketing/m2-offer-badge.mp4 b/public/previews/templates/marketing/m2-offer-badge.mp4
new file mode 100644
index 00000000..1dbca4c9
Binary files /dev/null and b/public/previews/templates/marketing/m2-offer-badge.mp4 differ
diff --git a/public/previews/templates/marketing/m2-retro-starburst.jpg b/public/previews/templates/marketing/m2-retro-starburst.jpg
index dec9765e..90bbd0ef 100644
Binary files a/public/previews/templates/marketing/m2-retro-starburst.jpg and b/public/previews/templates/marketing/m2-retro-starburst.jpg differ
diff --git a/public/previews/templates/marketing/m2-retro-starburst.mp4 b/public/previews/templates/marketing/m2-retro-starburst.mp4
new file mode 100644
index 00000000..94368e3c
Binary files /dev/null and b/public/previews/templates/marketing/m2-retro-starburst.mp4 differ
diff --git a/public/previews/templates/marketing/ms-big-number.jpg b/public/previews/templates/marketing/ms-big-number.jpg
new file mode 100644
index 00000000..de44ef09
Binary files /dev/null and b/public/previews/templates/marketing/ms-big-number.jpg differ
diff --git a/public/previews/templates/marketing/ms-big-number.mp4 b/public/previews/templates/marketing/ms-big-number.mp4
new file mode 100644
index 00000000..67d1eca4
Binary files /dev/null and b/public/previews/templates/marketing/ms-big-number.mp4 differ
diff --git a/public/previews/templates/marketing/ms-dashboard-zoom.jpg b/public/previews/templates/marketing/ms-dashboard-zoom.jpg
new file mode 100644
index 00000000..c1b0ab50
Binary files /dev/null and b/public/previews/templates/marketing/ms-dashboard-zoom.jpg differ
diff --git a/public/previews/templates/marketing/ms-dashboard-zoom.mp4 b/public/previews/templates/marketing/ms-dashboard-zoom.mp4
new file mode 100644
index 00000000..681044c2
Binary files /dev/null and b/public/previews/templates/marketing/ms-dashboard-zoom.mp4 differ
diff --git a/public/previews/templates/marketing/ms-end-card.jpg b/public/previews/templates/marketing/ms-end-card.jpg
new file mode 100644
index 00000000..3b7b39ce
Binary files /dev/null and b/public/previews/templates/marketing/ms-end-card.jpg differ
diff --git a/public/previews/templates/marketing/ms-end-card.mp4 b/public/previews/templates/marketing/ms-end-card.mp4
new file mode 100644
index 00000000..db4e3097
Binary files /dev/null and b/public/previews/templates/marketing/ms-end-card.mp4 differ
diff --git a/public/previews/templates/marketing/ms-feature-cards.jpg b/public/previews/templates/marketing/ms-feature-cards.jpg
new file mode 100644
index 00000000..26453350
Binary files /dev/null and b/public/previews/templates/marketing/ms-feature-cards.jpg differ
diff --git a/public/previews/templates/marketing/ms-feature-cards.mp4 b/public/previews/templates/marketing/ms-feature-cards.mp4
new file mode 100644
index 00000000..743f8b8d
Binary files /dev/null and b/public/previews/templates/marketing/ms-feature-cards.mp4 differ
diff --git a/public/previews/templates/marketing/ms-five-star-quote.jpg b/public/previews/templates/marketing/ms-five-star-quote.jpg
new file mode 100644
index 00000000..32be3027
Binary files /dev/null and b/public/previews/templates/marketing/ms-five-star-quote.jpg differ
diff --git a/public/previews/templates/marketing/ms-five-star-quote.mp4 b/public/previews/templates/marketing/ms-five-star-quote.mp4
new file mode 100644
index 00000000..67fb92db
Binary files /dev/null and b/public/previews/templates/marketing/ms-five-star-quote.mp4 differ
diff --git a/public/previews/templates/marketing/ms-kinetic-headline.jpg b/public/previews/templates/marketing/ms-kinetic-headline.jpg
new file mode 100644
index 00000000..bf13ba64
Binary files /dev/null and b/public/previews/templates/marketing/ms-kinetic-headline.jpg differ
diff --git a/public/previews/templates/marketing/ms-kinetic-headline.mp4 b/public/previews/templates/marketing/ms-kinetic-headline.mp4
new file mode 100644
index 00000000..78df08e0
Binary files /dev/null and b/public/previews/templates/marketing/ms-kinetic-headline.mp4 differ
diff --git a/public/previews/templates/marketing/ms-logo-sting.jpg b/public/previews/templates/marketing/ms-logo-sting.jpg
new file mode 100644
index 00000000..61115ddb
Binary files /dev/null and b/public/previews/templates/marketing/ms-logo-sting.jpg differ
diff --git a/public/previews/templates/marketing/ms-logo-sting.mp4 b/public/previews/templates/marketing/ms-logo-sting.mp4
new file mode 100644
index 00000000..8711397e
Binary files /dev/null and b/public/previews/templates/marketing/ms-logo-sting.mp4 differ
diff --git a/public/previews/templates/marketing/thumbs/m2-line-reveal.jpg b/public/previews/templates/marketing/thumbs/m2-line-reveal.jpg
new file mode 100644
index 00000000..9f5c6acf
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/m2-line-reveal.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/m2-offer-badge.jpg b/public/previews/templates/marketing/thumbs/m2-offer-badge.jpg
new file mode 100644
index 00000000..d842c7ae
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/m2-offer-badge.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/m2-retro-starburst.jpg b/public/previews/templates/marketing/thumbs/m2-retro-starburst.jpg
index 10b90db5..835f6bef 100644
Binary files a/public/previews/templates/marketing/thumbs/m2-retro-starburst.jpg and b/public/previews/templates/marketing/thumbs/m2-retro-starburst.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-big-number.jpg b/public/previews/templates/marketing/thumbs/ms-big-number.jpg
new file mode 100644
index 00000000..04a5c1ea
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/ms-big-number.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-dashboard-zoom.jpg b/public/previews/templates/marketing/thumbs/ms-dashboard-zoom.jpg
new file mode 100644
index 00000000..da5bc2dd
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/ms-dashboard-zoom.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-end-card.jpg b/public/previews/templates/marketing/thumbs/ms-end-card.jpg
new file mode 100644
index 00000000..2467a16c
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/ms-end-card.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-feature-cards.jpg b/public/previews/templates/marketing/thumbs/ms-feature-cards.jpg
new file mode 100644
index 00000000..df4cbf86
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/ms-feature-cards.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-five-star-quote.jpg b/public/previews/templates/marketing/thumbs/ms-five-star-quote.jpg
new file mode 100644
index 00000000..59f8baf8
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/ms-five-star-quote.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-kinetic-headline.jpg b/public/previews/templates/marketing/thumbs/ms-kinetic-headline.jpg
new file mode 100644
index 00000000..cfa25828
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/ms-kinetic-headline.jpg differ
diff --git a/public/previews/templates/marketing/thumbs/ms-logo-sting.jpg b/public/previews/templates/marketing/thumbs/ms-logo-sting.jpg
new file mode 100644
index 00000000..1d1a5867
Binary files /dev/null and b/public/previews/templates/marketing/thumbs/ms-logo-sting.jpg differ
diff --git a/scripts/eval/lib/covers.mjs b/scripts/eval/lib/covers.mjs
index 7d379aad..eb292643 100644
--- a/scripts/eval/lib/covers.mjs
+++ b/scripts/eval/lib/covers.mjs
@@ -330,7 +330,8 @@ export function dissolveBack(frames, fade) {
*
* With `rest: "end"` (a reveal that ends on its result), the clip keeps its own end (up to REST_CLIP_SECONDS) and
* is not crossfaded; its poster is its last frame, whose time comes back as `at`: a card shows that frame at rest
- * and starts the clip there, so nothing jumps.
+ * and starts the clip there, so nothing jumps. With `rest` a number of seconds the same holds for the frame at that
+ * time (a clip whose telling moment comes before its end, such as a headline that resolves to a logo).
*
* With `length: "full"` (an effect whose end matters), the clip keeps its whole length (up to REST_CLIP_SECONDS)
* instead of its first CLIP_SECONDS. Every frame shows clean: its loop dissolves from its last frame back to its first
@@ -338,30 +339,34 @@ export function dissolveBack(frames, fade) {
* @param {string} src
* @param {"image" | "video"} kind
* @param {string} destBase
- * @param {{ rest?: "start" | "end", length?: "full" }} [opts]
+ * @param {{ rest?: "start" | "end" | number, length?: "full" }} [opts]
* @returns {{ poster: string, video?: string, at?: number }}
*/
export function encode(src, kind, destBase, opts = {}) {
const fit = (px) => `scale='if(gt(iw,ih),min(${px},iw),-2)':'if(gt(iw,ih),-2,min(${px},ih))'`;
if (kind === "video") {
const atEnd = opts.rest === "end";
+ // A clip that rests on a moment of its own (seconds): kept whole, like a reveal, with that frame its poster.
+ const atTime = typeof opts.rest === "number" && opts.rest >= 0 ? opts.rest : null;
+ const whole = atEnd || atTime !== null;
// How much of the clip its loop keeps: the first CLIP_SECONDS, or all of it (up to REST_CLIP_SECONDS).
const full = opts.length === "full";
const keep = full ? REST_CLIP_SECONDS : CLIP_SECONDS;
// Decoded at CLIP_FPS: what it keeps, plus the frames the crossfade takes back from the start (a reveal or a full
// clip: all of it, as a full clip's dissolve is added after its end).
- const seconds = atEnd || full ? REST_CLIP_SECONDS : keep + LOOP_FADE / CLIP_FPS;
+ const seconds = whole || full ? REST_CLIP_SECONDS : keep + LOOP_FADE / CLIP_FPS;
const y4m = run(["-i", src, "-t", String(seconds), "-an", "-sn", "-dn", "-vf", `${fit(CLIP_PX)},fps=${CLIP_FPS},format=yuv420p`, "-f", "yuv4mpegpipe", "-"]);
const { header, frames, luma } = readY4m(y4m);
if (frames.length < 2) throw new Error(`${src} has no frames to make a clip of`);
const cut = frames.slice(0, keep * CLIP_FPS);
const fade = Math.min(LOOP_FADE, Math.floor(frames.length / 4));
- const looped = atEnd ? frames : loopsAlready(cut, luma) ? cut : full ? dissolveBack(cut, fade) : seamless(frames, fade);
+ const looped = whole ? frames : loopsAlready(cut, luma) ? cut : full ? dissolveBack(cut, fade) : seamless(frames, fade);
const stream = (list) => Buffer.concat([Buffer.from(`${header}\n`, "latin1"), ...list.flatMap((fr) => [Buffer.from("FRAME\n"), fr])]);
run(["-f", "yuv4mpegpipe", "-i", "-", "-an", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "28", "-map_metadata", "-1", "-movflags", "+faststart", `${destBase}.mp4`], stream(looped));
- if (atEnd) {
- run(["-f", "yuv4mpegpipe", "-i", "-", "-frames:v", "1", "-vf", "format=yuvj420p", "-q:v", "4", `${destBase}.jpg`], stream([looped.at(-1)]));
- return { poster: `${destBase}.jpg`, video: `${destBase}.mp4`, at: Math.round(((looped.length - 1) / CLIP_FPS) * 1000) / 1000 };
+ if (whole) {
+ const i = atEnd ? looped.length - 1 : Math.min(looped.length - 1, Math.round(atTime * CLIP_FPS));
+ run(["-f", "yuv4mpegpipe", "-i", "-", "-frames:v", "1", "-vf", "format=yuvj420p", "-q:v", "4", `${destBase}.jpg`], stream([looped[i]]));
+ return { poster: `${destBase}.jpg`, video: `${destBase}.mp4`, at: Math.round((i / CLIP_FPS) * 1000) / 1000 };
}
run(["-i", `${destBase}.mp4`, "-frames:v", "1", "-vf", "format=yuvj420p", "-q:v", "4", `${destBase}.jpg`]);
return { poster: `${destBase}.jpg`, video: `${destBase}.mp4` };
diff --git a/scripts/eval/lib/template-covers.mjs b/scripts/eval/lib/template-covers.mjs
index 0f5e8d14..531a51bc 100644
--- a/scripts/eval/lib/template-covers.mjs
+++ b/scripts/eval/lib/template-covers.mjs
@@ -197,7 +197,8 @@ function readMaster(folder) {
* clip.mp4 a clip cover (its first 4 s, its first frame the poster), or
* still.png a still cover (also still.jpg / still.webp, or start.png);
* frame-2.png … the tile's other frames, in order, up to frame-6 (a carousel's slides, a contact sheet's cells);
- * meta.json { "rest": "end" } for a reveal: the clip is kept to its end and its last frame is the poster,
+ * meta.json { "rest": "end" } for a reveal: the clip is kept to its end and its last frame is the poster
+ * ({ "rest": 2.4 }: the frame at 2.4 s is, for a clip whose telling moment comes before its end),
* or { "same": "<preset id>" }: the tile shows that preset's cover (no files of its own),
* resting on its clip's peak frame when it has one (presetCoverEntry).
* The manifest is merged: other tiles' entries stay. A tile whose cover is newer than its masters is kept (force makes
@@ -250,7 +251,7 @@ export function templateCoversFromMasters(dir, opts = {}) {
continue;
}
const src = m.clip ?? m.still;
- const rest = kind === "video" && m.meta.rest === "end" ? "end" : undefined;
+ const rest = kind !== "video" ? undefined : m.meta.rest === "end" ? "end" : typeof m.meta.rest === "number" && Number.isFinite(m.meta.rest) && m.meta.rest >= 0 ? m.meta.rest : undefined;
const outDir = path.join(publicDir, "previews", "templates", group);
const base = path.join(outDir, safeName(id));
const frameFiles = m.frames.map((_, i) => `${base}-${i + 2}.jpg`);
diff --git a/scripts/kinetic/render-covers.mjs b/scripts/kinetic/render-covers.mjs
new file mode 100644
index 00000000..8ea7c355
--- /dev/null
+++ b/scripts/kinetic/render-covers.mjs
@@ -0,0 +1,111 @@
+#!/usr/bin/env node
+// Covers for Marketing's code-drawn templates, rendered by Kinetic Motion itself (no model, no GPU): each template
+// plays its showcase (src/lib/motion/showcase.ts) at its own size, 1080 on the short side, 30 fps, through the same
+// renderClip the Save button uses, on the development-only page /dev/kinetic-covers in the system Chrome (WebCodecs
+// H.264). Each clip is written as a cover master, then versioned into the site like every other template tile:
+//
+// node scripts/kinetic/render-covers.mjs <masters dir> [--url http://127.0.0.1:3540] [--only ms-kinetic-headline,…]
+// pnpm eval:covers --templates <masters dir>
+//
+// Without --url it starts `next dev` on 3540 (KINETIC_COVERS_PORT moves it) and stops it at the end. Writes
+// <masters>/marketing/<id>/clip.mp4, poster.png (its last frame, for a look) and meta.json { "rest": "end" }: the tile
+// rests on the finished piece, with every word set ({ "rest": seconds } for a piece whose words give way to its logo:
+// the moment they are all set).
+import { spawn, execSync } from "node:child_process";
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { createRequire } from "node:module";
+import { fileURLToPath } from "node:url";
+import { parseArgs } from "node:util";
+
+const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
+const { values: a, positionals } = parseArgs({ allowPositionals: true, options: { url: { type: "string" }, only: { type: "string" }, chrome: { type: "string" } } });
+const masters = positionals[0];
+if (!masters) {
+ console.error("usage: render-covers.mjs <masters dir> [--url http://127.0.0.1:3540] [--only id,id]");
+ process.exit(2);
+}
+const only = a.only ? new Set(a.only.split(",").map((s) => s.trim())) : null;
+
+function playwright() {
+ const req = createRequire(path.join(root, "package.json"));
+ for (const name of ["playwright-core", "playwright"]) {
+ try {
+ return req(name);
+ } catch {}
+ }
+ throw new Error("playwright-core isn't installed");
+}
+
+const wait = (ms) => new Promise((r) => setTimeout(r, ms));
+let server = null;
+let base = a.url?.replace(/\/$/, "");
+if (!base) {
+ const port = Number(process.env.KINETIC_COVERS_PORT ?? 3540);
+ base = `http://127.0.0.1:${port}`;
+ const data = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-covers-"));
+ server = spawn(process.execPath, [path.join(root, "node_modules/next/dist/bin/next"), "dev", "-p", String(port), "-H", "127.0.0.1"], {
+ cwd: root,
+ env: { ...process.env, NODE_ENV: "development", FUOBE_DATA_DIR: data, COMFYUI_URL: "http://127.0.0.1:9", OLLAMA_URL: "http://127.0.0.1:9" },
+ stdio: "ignore",
+ });
+}
+const stop = () => {
+ if (!server) return;
+ try {
+ if (process.platform === "win32") execSync(`taskkill /pid ${server.pid} /T /F`, { stdio: "ignore" });
+ else server.kill("SIGTERM");
+ } catch {}
+};
+process.on("exit", stop);
+for (const sig of ["SIGINT", "SIGTERM"]) process.on(sig, () => process.exit(1));
+
+let browser;
+let failed = 0;
+try {
+ for (let i = 0; i < 240; i++) {
+ try {
+ const r = await fetch(`${base}/dev/kinetic-covers`);
+ if (r.status === 200) break;
+ if (r.status === 404) throw new Error(`${base}/dev/kinetic-covers isn't there (a production build has no covers page)`);
+ } catch (e) {
+ if (/isn't there/.test(e.message)) throw e;
+ }
+ await wait(1000);
+ }
+ browser = await playwright().chromium.launch(a.chrome ? { executablePath: a.chrome } : { channel: "chrome" });
+ const page = await browser.newPage({ viewport: { width: 1000, height: 800 } });
+ page.on("pageerror", (e) => console.error("page:", e.message));
+ await page.goto(`${base}/dev/kinetic-covers`, { waitUntil: "load", timeout: 240_000 });
+ await page.waitForSelector("[data-kinetic-ready]", { timeout: 240_000 });
+ const list = await page.evaluate(() => window.__kinetic.showcases());
+ for (const s of list) {
+ if (only && !only.has(s.id)) continue;
+ const dir = path.join(path.resolve(masters), "marketing", s.id);
+ try {
+ const r = await page.evaluate((recipe) => window.__kinetic.render(recipe), s.recipe);
+ if (r.type !== "video/mp4") throw new Error(`made ${r.type}, not an MP4 (this Chrome has no H.264 encoder)`);
+ fs.mkdirSync(dir, { recursive: true });
+ fs.writeFileSync(path.join(dir, "clip.mp4"), Buffer.from(r.clip, "base64"));
+ fs.writeFileSync(path.join(dir, "poster.png"), Buffer.from(r.poster, "base64"));
+ // The tile rests on the finished piece, or just before the event its showcase names (the headline, all set).
+ let rest = "end";
+ if (s.poster) {
+ const { events } = await page.evaluate((recipe) => window.__kinetic.frames(recipe, []), s.recipe);
+ const at = events.find((e) => e[0] === s.poster)?.[1];
+ if (typeof at === "number") rest = Math.max(0, Math.round((at - 0.08) * 100) / 100);
+ }
+ fs.writeFileSync(path.join(dir, "meta.json"), `${JSON.stringify({ rest })}\n`);
+ console.log(`${s.id}: ${r.w}x${r.h}, ${r.frames} frames, ${Math.round(r.ms)} ms`);
+ } catch (e) {
+ failed++;
+ console.error(`${s.id}: ${e.message}`);
+ }
+ }
+} finally {
+ await browser?.close().catch(() => {});
+ stop();
+}
+console.log(failed ? `${failed} failed` : `Masters in ${path.resolve(masters)}. Next: pnpm eval:covers --templates ${path.resolve(masters)}`);
+process.exit(failed ? 1 : 0);
diff --git a/src/app/api/generations/local/route.ts b/src/app/api/generations/local/route.ts
index 0bed9afa..42e92a4e 100644
--- a/src/app/api/generations/local/route.ts
+++ b/src/app/api/generations/local/route.ts
@@ -72,8 +72,11 @@ function recipeFiles(extra: Record<string, unknown> | undefined): Record<string,
// (" /api/files/…" is no stored file's path: it is checked, and refused, as written.)
const logo = r.data.brand.logo;
if (logo?.includes("/api/files/")) out._logo = logo;
- if (r.data.media?.product) out._product = r.data.media.product;
- if (r.data.media?.images?.length) out._media = r.data.media.images;
+ // Fuobe's own sample pictures (/previews/…) are public: only stored files are checked.
+ const stored = (u: string) => u.startsWith("/api/files/");
+ if (r.data.media?.product && stored(r.data.media.product)) out._product = r.data.media.product;
+ const media = (r.data.media?.images ?? []).filter(stored);
+ if (media.length) out._media = media;
return out;
}
diff --git a/src/app/dev/kinetic-covers/covers.tsx b/src/app/dev/kinetic-covers/covers.tsx
new file mode 100644
index 00000000..08e5f953
--- /dev/null
+++ b/src/app/dev/kinetic-covers/covers.tsx
@@ -0,0 +1,90 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import { measureText } from "@/components/ads/render";
+import { drawDisplayList } from "@/components/motion/draw";
+import { fontsReady } from "@/components/motion/fonts";
+import { loadMotionInputs } from "@/components/motion/inputs";
+import { drawFrame, renderClip } from "@/components/motion/render";
+import { TEMPLATES } from "@/lib/catalog/marketing";
+import type { Recipe } from "@/lib/motion/recipe";
+import { loadScene } from "@/lib/motion/registry";
+import { SHOWCASES, showcaseRecipe } from "@/lib/motion/showcase";
+import { exportSize } from "@/lib/motion/sizes";
+
+/** Every code-drawn template with its showcase recipe (at its own length). */
+function showcases(): { id: string; name: string; recipe: Recipe; poster?: string }[] {
+ return TEMPLATES.filter((t) => t.render === "code" && t.scene).flatMap((t) => {
+ const r = showcaseRecipe(t.id, t.scene!, t.lengths?.default ?? t.duration ?? 5, { cover: true });
+ const poster = SHOWCASES[t.id]?.poster;
+ return r ? [{ id: t.id, name: t.name, recipe: r, ...(poster && { poster }) }] : [];
+ });
+}
+
+const b64 = async (b: Blob) => {
+ const buf = new Uint8Array(await b.arrayBuffer());
+ let s = "";
+ for (let i = 0; i < buf.length; i += 0x8000) s += String.fromCharCode(...buf.subarray(i, i + 0x8000));
+ return btoa(s);
+};
+
+async function prepare(recipe: Recipe) {
+ const inputs = await loadMotionInputs({ logo: recipe.brand.logo, product: recipe.media?.product });
+ await fontsReady([recipe.brand.fonts.heading, recipe.brand.fonts.body], { strict: true, text: Object.values(recipe.fields).join(" ") + recipe.brand.name });
+ const scene = await loadScene(recipe.scene);
+ return { inputs, scene };
+}
+
+declare global {
+ interface Window {
+ __kinetic?: {
+ showcases: typeof showcases;
+ render(recipe: Recipe): Promise<{ ms: number; frames: number; w: number; h: number; type: string; clip: string; poster: string }>;
+ frames(recipe: Recipe, times: number[], blur?: boolean): Promise<{ out: string[]; rest: number; overflow: string[]; events: [string, number, number][] }>;
+ };
+ }
+}
+
+export function KineticCovers() {
+ const [ready, setReady] = useState(false);
+ useEffect(() => {
+ window.__kinetic = {
+ showcases,
+ async render(recipe) {
+ const { inputs, scene } = await prepare(recipe);
+ const t0 = performance.now();
+ const r = await renderClip(scene, recipe, { ...inputs, measure: measureText, formats: ["mp4"] });
+ return { ms: performance.now() - t0, frames: r.frames, w: r.width, h: r.height, type: r.type, clip: await b64(r.blob), poster: await b64(r.poster) };
+ },
+ async frames(recipe, times, blur = true) {
+ const { inputs, scene } = await prepare(recipe);
+ const plan = scene.plan({ recipe, measure: measureText, logo: inputs.logo, images: inputs.images, outlines: inputs.outlines });
+ const { w, h } = exportSize(recipe.size);
+ const target = new OffscreenCanvas(w, h);
+ const scratch = new OffscreenCanvas(w, h);
+ const out: string[] = [];
+ for (const t of times) {
+ if (blur) drawFrame(plan, t, target, scratch, inputs.sources, { fps: recipe.fps, samples: recipe.export.blurSamples, shutter: recipe.export.shutter, duration: recipe.duration });
+ else drawDisplayList(target.getContext("2d", { alpha: false })!, plan.evaluate(t), inputs.sources);
+ out.push(await b64(await target.convertToBlob({ type: "image/png" })));
+ }
+ return { out, rest: plan.rest, overflow: plan.overflow, events: plan.timeline.events.map((e) => [e.id, +e.start.toFixed(3), +e.dur.toFixed(3)] as [string, number, number]) };
+ },
+ };
+ // Ready once the hooks are on window (a microtask later, not inside the effect itself).
+ queueMicrotask(() => setReady(true));
+ }, []);
+ return (
+ <main className="p-6 text-[13px]">
+ <h1 className="font-heading text-[22px]">Kinetic covers</h1>
+ <p data-kinetic-ready={ready || undefined}>{ready ? `${showcases().length} templates ready` : "Loading…"}</p>
+ <ul className="mt-2 list-disc pl-5">
+ {showcases().map((s) => (
+ <li key={s.id}>
+ {s.name} · {typeof s.recipe.size === "string" ? s.recipe.size : "custom"} · {s.recipe.duration}s
+ </li>
+ ))}
+ </ul>
+ </main>
+ );
+}
diff --git a/src/app/dev/kinetic-covers/page.tsx b/src/app/dev/kinetic-covers/page.tsx
new file mode 100644
index 00000000..eb4e702d
--- /dev/null
+++ b/src/app/dev/kinetic-covers/page.tsx
@@ -0,0 +1,11 @@
+import { notFound } from "next/navigation";
+import { KineticCovers } from "./covers";
+
+/**
+ * A development-only page that renders Marketing's code-drawn templates with the engine itself, for their covers
+ * (scripts/kinetic/render-covers.mjs drives it). It does not exist in a production build.
+ */
+export default function Page() {
+ if (process.env.NODE_ENV === "production") notFound();
+ return <KineticCovers />;
+}
diff --git a/src/components/ads/render.ts b/src/components/ads/render.ts
index 53e3069c..fe206b98 100644
--- a/src/components/ads/render.ts
+++ b/src/components/ads/render.ts
@@ -66,12 +66,41 @@ export function ensureFont(family: string | undefined, timeout = 2500): Promise<
}
let measureCtx: CanvasRenderingContext2D | null = null;
-export const measureText = (text: string, font: string) => {
+const oldstyleFaces = new Map<string, boolean>();
+
+/**
+ * Whether a face draws old-style figures by default: its "0" sits at x-height and its "8" rises above it (Cormorant,
+ * EB Garamond). Lining figures stand about as tall as each other.
+ */
+function oldstyle(family: string, weight: number): boolean {
+ const key = `${weight} ${family}`;
+ const known = oldstyleFaces.get(key);
+ if (known !== undefined) return known;
measureCtx ??= document.createElement("canvas").getContext("2d");
- if (!measureCtx) return text.length * 10;
- measureCtx.font = font;
- return measureCtx.measureText(text).width;
-};
+ if (!measureCtx) return false;
+ measureCtx.font = `${weight} 100px "${family}"`;
+ const tall = (s: string) => {
+ const m = measureCtx!.measureText(s);
+ return m.actualBoundingBoxAscent + m.actualBoundingBoxDescent;
+ };
+ const zero = tall("0");
+ const eight = tall("8");
+ const out = eight > 0 && zero < eight * 0.86;
+ // Cache only once the face itself is in (a fallback face measured before it loads says nothing about it).
+ if (document.fonts?.check?.(`${weight} 100px "${family}"`)) oldstyleFaces.set(key, out);
+ return out;
+}
+
+/** A text's width in a CSS font; `measureText.oldstyle` tells whether a face's default figures are old-style. */
+export const measureText = Object.assign(
+ (text: string, font: string) => {
+ measureCtx ??= document.createElement("canvas").getContext("2d");
+ if (!measureCtx) return text.length * 10;
+ measureCtx.font = font;
+ return measureCtx.measureText(text).width;
+ },
+ { oldstyle },
+);
function rounded(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r: number) {
ctx.beginPath();
diff --git a/src/components/marketing/end-card-motion.tsx b/src/components/marketing/end-card-motion.tsx
index 67bcf8e3..611435ca 100644
--- a/src/components/marketing/end-card-motion.tsx
+++ b/src/components/marketing/end-card-motion.tsx
@@ -81,9 +81,9 @@ export function useEndCardMotion(card: EndCardInput, colors: readonly string[],
/** Renders a recipe's clip here, in the brand's own fonts (a font that didn't load stops it). */
export async function renderRecipe(recipe: Recipe, inputs: MotionInputs, o: { formats: ("mp4" | "webm")[]; signal?: AbortSignal; onProgress?: (done: number, total: number) => void }): Promise<RenderResult> {
- await fontsReady([recipe.brand.fonts.heading, recipe.brand.fonts.body], { strict: true, text: Object.values(recipe.fields).join(" ") });
+ await fontsReady([recipe.brand.fonts.heading, recipe.brand.fonts.body], { strict: true, text: [...Object.values(recipe.fields), recipe.brand.name].join(" ") });
const scene = await loadScene(recipe.scene);
- return renderClip(scene, recipe, { sources: inputs.sources, logo: inputs.logo, measure: measureText, formats: o.formats, signal: o.signal, onProgress: (d, n) => o.onProgress?.(d, n) });
+ return renderClip(scene, recipe, { sources: inputs.sources, logo: inputs.logo, images: inputs.images, outlines: inputs.outlines, measure: measureText, formats: o.formats, signal: o.signal, onProgress: (d, n) => o.onProgress?.(d, n) });
}
/** The words a saved end card is listed and searched by. */
diff --git a/src/components/marketing/kinetic-template.tsx b/src/components/marketing/kinetic-template.tsx
new file mode 100644
index 00000000..92eff5f4
--- /dev/null
+++ b/src/components/marketing/kinetic-template.tsx
@@ -0,0 +1,199 @@
+"use client";
+
+import { Loader2, Save, X, Zap } from "lucide-react";
+import { useEffect, useMemo, useRef, useState } from "react";
+import { Button } from "@/components/ui/button";
+import { BrandRow, kitBrand, useStoredBrand } from "@/components/motion/brand-row";
+import { EasyChips, LengthSlider, SizeChips } from "@/components/motion/easy-chips";
+import { shortenLine, TemplateFields } from "@/components/motion/fields";
+import { KINETIC_FEATURE, MadeStrip } from "@/components/motion/made-strip";
+import { MotionPlayer, useMotionInputs, usePlan, useScene } from "@/components/motion/player";
+import { phaseLine, useMotionSave } from "@/components/motion/save";
+import { MediaSlot, type SlotValue } from "@/components/studio/media-slot";
+import { useIsOwner } from "@/lib/api";
+import type { BrandKit, MarketingTemplate } from "@/lib/catalog/marketing";
+import { SHOWCASE_PRODUCTS } from "@/lib/motion/showcase";
+import type { SizePreset } from "@/lib/motion/sizes";
+import { initialState, ownFiles, templateLengths, templateRecipe, templateSizes, templateWords, type TemplateBrand, type TemplateState } from "@/lib/motion/template";
+import { cn } from "@/lib/utils";
+import { renderRecipe } from "./end-card-motion";
+import { useBrands } from "./hooks";
+import { ProductSlot, type ProductChoice } from "./pickers";
+
+/**
+ * A Marketing template drawn by Fuobe Kinetic Motion: the person's exact words in their brand's fonts and colours,
+ * playing live as they type, in the four sizes the studio posts to. Nothing is generated by a model, so it's instant
+ * and free. Saving renders the clip here and keeps it in Fuobe (the Library, or an account's own runs), where it
+ * downloads; anyone can fill it in and play it, and Save asks first whoever couldn't keep it.
+ */
+
+const PREVIEW_WIDTH: Record<SizePreset, string> = {
+ "9:16": "max-w-[260px] sm:max-w-[320px]",
+ "4:5": "max-w-[320px] sm:max-w-[420px]",
+ "1:1": "max-w-[340px] sm:max-w-[440px]",
+ "16:9": "max-w-full",
+};
+
+const SAMPLES: { id: keyof typeof SHOWCASE_PRODUCTS; label: string }[] = [
+ { id: "perfume", label: "Sample: perfume bottle" },
+ { id: "heel", label: "Sample: red heel" },
+];
+
+function PicturePicker({ value, onChange, owner }: { value: string | null | undefined; onChange: (url: string | null) => void; owner: boolean }) {
+ const [own, setOwn] = useState<SlotValue | null>(null);
+ const [product, setProduct] = useState<ProductChoice | null>(null);
+ const tile = (on: boolean) => cn("relative size-14 shrink-0 overflow-hidden rounded-xl bg-muted outline-none focus-visible:ring-2 focus-visible:ring-ring", on && "ring-2 ring-primary ring-offset-2 ring-offset-background");
+ return (
+ <div className="min-w-0">
+ <p className="mb-1.5 text-[12px] font-medium text-muted-foreground">Picture</p>
+ <div role="group" aria-label="Picture" className="flex min-w-0 flex-wrap items-center gap-2">
+ {SAMPLES.map((s) => (
+ <button key={s.id} type="button" aria-pressed={value === SHOWCASE_PRODUCTS[s.id]} aria-label={s.label} onClick={() => onChange(SHOWCASE_PRODUCTS[s.id])} className={tile(value === SHOWCASE_PRODUCTS[s.id])}>
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+ <img src={SHOWCASE_PRODUCTS[s.id]} alt="" className="size-full object-contain p-1" />
+ </button>
+ ))}
+ {owner ? (
+ <ProductSlot
+ value={product}
+ onChange={(p) => {
+ setProduct(p);
+ onChange(p?.images[0] ?? SHOWCASE_PRODUCTS.perfume);
+ }}
+ />
+ ) : (
+ <MediaSlot
+ label="Your picture"
+ kind="image"
+ value={own}
+ onChange={(v) => {
+ setOwn(v);
+ if (!v) onChange(SHOWCASE_PRODUCTS.perfume);
+ else if (!v.uploading && v.ref.startsWith("/api/files/")) onChange(v.ref);
+ }}
+ />
+ )}
+ <p className="min-w-0 basis-full text-[11px] text-muted-foreground">A cut-out on a clear background traces best; a photo gets a frame.</p>
+ </div>
+ </div>
+ );
+}
+
+/** The owner's kits for the Brand row (only the owner has brand kits). */
+function OwnerBrand({ value, onChange, kitId, onKit }: { value: TemplateBrand; onChange: (b: TemplateBrand) => void; kitId: string | null; onKit: (id: string | null, kit?: BrandKit) => void }) {
+ const kits = useBrands().data?.filter((k) => k.status !== "researching");
+ return <BrandRow value={value} onChange={onChange} kits={kits} kitId={kitId} onKit={(id) => onKit(id, kits?.find((k) => k.id === id))} />;
+}
+
+export function KineticTemplate({ template: t, onClose, kitId, onKit }: { template: MarketingTemplate; onClose: () => void; kitId: string | null; onKit: (id: string | null) => void }) {
+ const owner = useIsOwner();
+ const [stored, setStored] = useStoredBrand();
+ const kits = useBrands();
+ const kit = owner && kitId ? kits.data?.find((k) => k.id === kitId) : undefined;
+ const [state, setState] = useState<TemplateState>(() => initialState(t, stored));
+ // The owner's kit fills the brand once it has loaded (a value changed here afterwards is for this piece only).
+ const appliedKit = useRef<string | null>(null);
+ useEffect(() => {
+ if (!kit || appliedKit.current === kit.id) return;
+ appliedKit.current = kit.id;
+ setState((s) => ({ ...s, brand: kitBrand(kit) }));
+ }, [kit]);
+
+ const recipe = useMemo(() => templateRecipe(t, state), [t, state]);
+ const inputs = useMotionInputs(recipe);
+ const scene = useScene(recipe.scene);
+ const plan = usePlan(scene, recipe, inputs);
+ const sizes = templateSizes(t);
+ const lengths = templateLengths(t);
+ const fields = t.fields ?? [];
+ const overflow = plan?.overflow ?? [];
+ const brandOver = overflow.includes("brand");
+
+ const saver = useMotionSave();
+ const line = phaseLine(saver.phase);
+ const words = templateWords(t, state);
+ const save = () =>
+ void saver.save({ recipe, feature: KINETIC_FEATURE, title: words.title, prompt: words.prompt, images: ownFiles(recipe) }, (signal, progress) => renderRecipe(recipe, inputs, { formats: ["mp4", "webm"], signal, onProgress: progress }));
+
+ const setBrand = (b: TemplateBrand) => {
+ setState((s) => ({ ...s, brand: b }));
+ // Kept in this browser so the next template opens in it (a kit's values changed for one piece aren't).
+ if (!kit) setStored(b);
+ };
+
+ return (
+ <section aria-labelledby="kinetic-template-title" data-kinetic-template={t.id} className="min-w-0 rounded-3xl border bg-background p-3 shadow-soft sm:p-5">
+ <div className="flex min-w-0 items-start gap-3">
+ <div className="min-w-0 flex-1">
+ <div className="flex min-w-0 flex-wrap items-center gap-2">
+ <h2 id="kinetic-template-title" className="font-heading text-[24px] leading-tight">
+ {t.name}
+ </h2>
+ <span className="inline-flex items-center gap-1 rounded-full bg-brand-faint px-2 py-0.5 text-[11px] font-medium text-brand-text">
+ <Zap className="size-3" /> Instant
+ </span>
+ </div>
+ <p className="mt-1 text-[13px] text-pretty text-muted-foreground">Your exact words in your brand&apos;s fonts and colours. It plays as you type; saving keeps the clip in Fuobe, ready to download.</p>
+ </div>
+ <button type="button" onClick={onClose} aria-label="Close template" className="grid size-11 shrink-0 place-items-center rounded-full text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring">
+ <X className="size-4" />
+ </button>
+ </div>
+
+ <div className="mt-4 grid min-w-0 gap-5 md:grid-cols-[minmax(0,1.05fr)_minmax(0,1fr)]">
+ <div className="min-w-0 md:sticky md:top-40 md:self-start">
+ <div className={cn("mx-auto w-full", PREVIEW_WIDTH[state.size])}>
+ <MotionPlayer plan={plan} sources={inputs.sources} size={recipe.size} duration={recipe.duration} fps={recipe.fps} label={`${t.name} preview: ${words.prompt}`} />
+ </div>
+ </div>
+
+ <div className="min-w-0 space-y-4">
+ <TemplateFields fields={fields} values={state.fields} onChange={(key, value) => setState((s) => ({ ...s, fields: { ...s.fields, [key]: value } }))} overflow={overflow} />
+ {t.picture === "product" && <PicturePicker value={state.product} onChange={(url) => setState((s) => ({ ...s, product: url }))} owner={owner} />}
+ {owner ? (
+ <OwnerBrand
+ value={state.brand}
+ onChange={setBrand}
+ kitId={kitId}
+ onKit={(id, k) => {
+ onKit(id);
+ appliedKit.current = id;
+ if (k) setState((s) => ({ ...s, brand: kitBrand(k) }));
+ }}
+ />
+ ) : (
+ <BrandRow value={state.brand} onChange={setBrand} />
+ )}
+ {brandOver && <p className="text-[12px] text-destructive">Shorten the brand name to fit</p>}
+ {t.easy && <EasyChips groups={t.easy} values={state.controls} onChange={(id, c) => setState((s) => ({ ...s, controls: { ...s.controls, [id]: c } }))} />}
+ <SizeChips sizes={sizes} value={state.size} onChange={(size) => setState((s) => ({ ...s, size }))} />
+ <LengthSlider min={lengths.min} max={lengths.max} value={recipe.duration} onChange={(duration) => setState((s) => ({ ...s, duration }))} />
+
+ <div className="space-y-2 pt-1">
+ <Button className="h-11 w-full" onClick={save} disabled={!!line || overflow.length > 0 || !plan}>
+ {line ? <Loader2 className="animate-spin" /> : <Save />} {line ?? saver.label}
+ </Button>
+ {overflow.length > 0 && (
+ <p className="text-[12px] text-muted-foreground" aria-live="polite">
+ {fields
+ .filter((f) => overflow.includes(f.key))
+ .map(shortenLine)
+ .concat(brandOver ? ["Shorten the brand name to fit"] : [])
+ .join(" · ")}
+ </p>
+ )}
+ {line && (
+ <Button variant="ghost" className="h-11 w-full" onClick={saver.cancel}>
+ Stop
+ </Button>
+ )}
+ </div>
+ </div>
+ </div>
+
+ <div className="mt-5 min-w-0">
+ <MadeStrip templateId={t.id} />
+ </div>
+ </section>
+ );
+}
diff --git a/src/components/marketing/marketing-studio.tsx b/src/components/marketing/marketing-studio.tsx
index 89a7fee7..deb843c6 100644
--- a/src/components/marketing/marketing-studio.tsx
+++ b/src/components/marketing/marketing-studio.tsx
@@ -13,7 +13,7 @@ import { BrandChip } from "@/components/brand/brand-dialog";
import { inputCls } from "@/components/brand/fields";
import { withoutOwnGpu } from "@/lib/catalog/engines";
import { Switch } from "@/components/ui/switch";
-import { DRAWN_WORDS_HINT, DRAWN_WORDS_LABEL, FORMATS, formatModels, looksLikeWebsite, pickable, MAX_PROMPT, openingAspect, TEMPLATE_INDEX, type FormatId, type MarketingCategory, type MarketingTemplate, type RunEstimate } from "@/lib/catalog/marketing";
+import { DRAWN_WORDS_HINT, DRAWN_WORDS_LABEL, FORMATS, formatModels, isCodeTemplate, looksLikeWebsite, pickable, MAX_PROMPT, openingAspect, TEMPLATE_INDEX, type FormatId, type MarketingCategory, type MarketingTemplate, type RunEstimate } from "@/lib/catalog/marketing";
import { SelfHostNote } from "@/components/self-host-note";
import { StarterSection } from "@/components/starters/starter-section";
import { formatCost } from "@/lib/format";
@@ -22,6 +22,7 @@ import { keepOffered, offered } from "@/lib/model-access";
import type { StarterCardData } from "@/lib/starters/types";
import { cn } from "@/lib/utils";
import { addRuns, send, useBrands, useEstimate, useProducts } from "./hooks";
+import { KineticTemplate } from "./kinetic-template";
import type { MarketingRun } from "@/lib/catalog/marketing";
import { toastError } from "@/lib/refusals";
import { templateCover } from "@/lib/template-covers";
@@ -333,6 +334,10 @@ export function MarketingStudio({ models, starters = [] }: { models: Record<stri
const set = (p: Partial<Draft>) => setDraft((d) => ({ ...d, ...p }));
const f = FORMATS[draft.format];
const template = draft.templateId ? TEMPLATE_INDEX.get(draft.templateId) : undefined;
+ // A template drawn by Kinetic Motion opens its own panel (words, brand, sizes, live preview, Save) instead of the
+ // composer: nothing is generated, so it is open to everyone and asks only on Save.
+ const code = isCodeTemplate(template);
+ const panel = useRef<HTMLDivElement>(null);
const kind = f.kind;
// The brand kit is remembered between visits (and dropped once it's deleted).
@@ -344,7 +349,8 @@ export function MarketingStudio({ models, starters = [] }: { models: Record<stri
const pickTemplate = (t: MarketingTemplate) => {
setDraft((d) => withTemplate(d, t));
- requestAnimationFrame(() => prompt.current?.focus({ preventScroll: true }));
+ if (isCodeTemplate(t)) requestAnimationFrame(() => panel.current?.scrollIntoView({ behavior: "smooth", block: "start" }));
+ else requestAnimationFrame(() => prompt.current?.focus({ preventScroll: true }));
};
const body = useMemo(
@@ -438,9 +444,14 @@ export function MarketingStudio({ models, starters = [] }: { models: Record<stri
Product shots, motion, UGC presenters, ads, posters and listings — from Fuobe&apos;s templates, on {engine === "open" ? (visitor ? "open-source models" : "your own GPU, free") : "Fuobe Marketing Image or partner models in the cloud"}.
</p>
</div>
- {noProducts && <StarterSection surface="marketing" starters={starters} center compact className="mt-6 mb-4" />}
+ {code && template && (
+ <div ref={panel} className="mt-4 scroll-mt-40">
+ <KineticTemplate key={template.id} template={template} onClose={() => setDraft((d) => withTemplate(d, null, d.format))} kitId={brandId} onKit={pickBrand} />
+ </div>
+ )}
+ {!code && noProducts && <StarterSection surface="marketing" starters={starters} center compact className="mt-6 mb-4" />}
{/* Under the ready shoots, so it doesn't read as an answer to them. */}
- {visitor && <SelfHostNote className="mx-auto mt-3 max-w-xl text-center">Marketing Studio isn&apos;t available here.</SelfHostNote>}
+ {visitor && !code && <SelfHostNote className="mx-auto mt-3 max-w-xl text-center">Marketing Studio isn&apos;t available here.</SelfHostNote>}
<div role="tablist" aria-label="View" className="mx-auto mt-4 flex w-fit rounded-full bg-muted p-0.5">
{(["templates", "generations"] as const).map((t) => (
<button key={t} role="tab" aria-selected={tab === t} onClick={() => setTab(t)} className={cn("h-8 rounded-full px-4 text-[13px] font-medium text-muted-foreground", tab === t && "bg-background text-foreground shadow-soft")}>
@@ -483,8 +494,8 @@ export function MarketingStudio({ models, starters = [] }: { models: Record<stri
</div>
</div>
- {/* Docked composer */}
- <div className="sticky bottom-chrome z-20 bg-gradient-to-t from-background via-background/95 to-transparent px-4 pt-8 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:px-6">
+ {/* Docked composer (a Kinetic template has its own panel) */}
+ <div hidden={code} className="sticky bottom-chrome z-20 bg-gradient-to-t from-background via-background/95 to-transparent px-4 pt-8 pb-[max(0.75rem,env(safe-area-inset-bottom))] sm:px-6">
<div
ref={composer}
data-slim={slim || undefined}
diff --git a/src/components/marketing/template-gallery.tsx b/src/components/marketing/template-gallery.tsx
index 2b410da2..6ae25bd7 100644
--- a/src/components/marketing/template-gallery.tsx
+++ b/src/components/marketing/template-gallery.tsx
@@ -1,10 +1,10 @@
"use client";
-import { Play, Search } from "lucide-react";
+import { Play, Search, Zap } from "lucide-react";
import { useDeferredValue, useMemo, useState } from "react";
import { useEdgeFade } from "@/components/studio/use-edge-fade";
import { useCoverPlayback } from "@/components/template-cover";
-import { CATEGORIES, FORMATS, interleaved, templatesFor, type MarketingCategory, type MarketingTemplate } from "@/lib/catalog/marketing";
+import { CATEGORIES, FORMATS, interleaved, isCodeTemplate, templatesFor, type MarketingCategory, type MarketingTemplate } from "@/lib/catalog/marketing";
import { templateCover } from "@/lib/template-covers";
import { cn } from "@/lib/utils";
import { TemplatePreview } from "./template-preview";
@@ -14,6 +14,8 @@ export type MediaFilter = "all" | "image" | "video";
export function TemplateCard({ t, selected, onPick }: { t: MarketingTemplate; selected: boolean; onPick: (t: MarketingTemplate) => void }) {
const f = FORMATS[t.format];
const video = f.kind === "video";
+ // Drawn by Kinetic Motion in the browser: no model, so it plays at once.
+ const instant = isCodeTemplate(t);
// Its real cover when it has one (a clip plays as the gallery cards' do), else its drawn preview.
const cover = templateCover("marketing", t.id);
const { ref, playing, asked, handlers } = useCoverPlayback<HTMLButtonElement>(`marketing/${t.id}`, cover);
@@ -29,6 +31,11 @@ export function TemplateCard({ t, selected, onPick }: { t: MarketingTemplate; se
<div className="relative aspect-[3/4] overflow-hidden rounded-2xl bg-muted transition-transform duration-300 ease-move group-hover/tpl:scale-[1.015]">
<TemplatePreview id={t.id} look={t.look} video={video} cover={cover} playing={playing} asked={asked} sizes="(max-width: 640px) 50vw, 220px" />
<span className="absolute top-2 left-2 rounded-full bg-black/45 px-2 py-0.5 text-[11px] font-medium text-white backdrop-blur">{f.cardLabel}</span>
+ {instant && (
+ <span className="absolute bottom-2 left-2 inline-flex items-center gap-1 rounded-full bg-black/45 px-2 py-0.5 text-[11px] font-medium text-white backdrop-blur">
+ <Zap className="size-3" /> Instant
+ </span>
+ )}
{video && (
<span className="absolute top-2 right-2 grid size-6 place-items-center rounded-full bg-black/45 text-white backdrop-blur" aria-hidden>
<Play className="size-3 fill-current" />
@@ -37,7 +44,7 @@ export function TemplateCard({ t, selected, onPick }: { t: MarketingTemplate; se
</div>
<p className="mt-2 truncate px-0.5 text-[13px] font-medium">{t.name}</p>
{/* Named by what it shows (the format chip, then the name), so speech users can say it. */}
- <span className="sr-only">{video ? ", video template" : ", template"}</span>
+ <span className="sr-only">{video ? ", video template" : ", template"}{instant ? ", instant" : ""}</span>
</button>
);
}
diff --git a/src/components/motion/brand-row.tsx b/src/components/motion/brand-row.tsx
new file mode 100644
index 00000000..4a3d85d8
--- /dev/null
+++ b/src/components/motion/brand-row.tsx
@@ -0,0 +1,181 @@
+"use client";
+
+import { ChevronDown } from "lucide-react";
+import { useCallback, useId, useState, useSyncExternalStore } from "react";
+import { POPULAR_FONTS } from "@/components/brand/fields";
+import { MediaSlot, type SlotValue } from "@/components/studio/media-slot";
+import type { BrandKit } from "@/lib/catalog/marketing";
+import type { TemplateBrand } from "@/lib/motion/template";
+import { cn } from "@/lib/utils";
+
+/**
+ * The compact Brand row of a code-drawn template: a name, two colours, a heading and a body font, and a logo. The
+ * owner can start from one of the studio's brand kits (and change a value for this piece without changing the kit).
+ * What someone sets here is kept in this browser as a convenience, so their next template opens in their brand; the
+ * page works the same without it.
+ */
+
+const KEY = "fuobe:kinetic-brand";
+const HEX = /^#[0-9a-f]{6}$/i;
+const listeners = new Set<() => void>();
+let cache: { raw: string | null; value: TemplateBrand | null } = { raw: null, value: null };
+
+function read(): TemplateBrand | null {
+ let raw: string | null = null;
+ try {
+ raw = localStorage.getItem(KEY);
+ } catch {
+ return null;
+ }
+ if (raw === cache.raw) return cache.value;
+ let value: TemplateBrand | null = null;
+ try {
+ const v = raw ? JSON.parse(raw) : null;
+ if (v && typeof v.name === "string" && Array.isArray(v.colors) && v.fonts && typeof v.fonts.heading === "string" && typeof v.fonts.body === "string") {
+ value = { name: v.name.slice(0, 120), colors: v.colors.filter((c: unknown) => typeof c === "string" && HEX.test(c)).slice(0, 2), fonts: { heading: v.fonts.heading.slice(0, 80), body: v.fonts.body.slice(0, 80) }, logo: typeof v.logo === "string" && v.logo.startsWith("/api/files/") ? v.logo : null };
+ if (value.colors.length === 0) value = null;
+ }
+ } catch {}
+ cache = { raw, value };
+ return value;
+}
+
+/** The brand this viewer set last (null: none yet), and a setter that remembers it here. */
+export function useStoredBrand(): [TemplateBrand | null, (b: TemplateBrand | null) => void] {
+ const value = useSyncExternalStore(
+ (cb) => {
+ listeners.add(cb);
+ return () => listeners.delete(cb);
+ },
+ read,
+ () => null,
+ );
+ const set = useCallback((b: TemplateBrand | null) => {
+ try {
+ if (b) localStorage.setItem(KEY, JSON.stringify(b));
+ else localStorage.removeItem(KEY);
+ } catch {}
+ listeners.forEach((l) => l());
+ }, []);
+ return [value, set];
+}
+
+/** A brand kit as a template's brand. */
+export function kitBrand(k: BrandKit): TemplateBrand {
+ const colors = k.colors.filter((c) => HEX.test(c));
+ return { name: k.name, colors: colors.length ? colors.slice(0, 2) : ["#111111", "#f5f2ec"], fonts: { heading: k.fonts?.heading || "Inter", body: k.fonts?.body || k.fonts?.heading || "Inter" }, logo: k.logo ?? null };
+}
+
+const field = "h-11 w-full min-w-0 rounded-xl border bg-background px-3 text-[14px] outline-none focus-visible:border-primary focus-visible:ring-4 focus-visible:ring-brand-faint";
+
+function Swatch({ label, value, onChange }: { label: string; value: string; onChange: (v: string) => void }) {
+ const [text, setText] = useState(value);
+ const [was, setWas] = useState(value);
+ if (was !== value) {
+ setWas(value);
+ setText(value);
+ }
+ return (
+ <div className="flex min-w-0 items-center gap-1.5">
+ <label className="relative grid size-11 shrink-0 cursor-pointer place-items-center rounded-xl border" style={{ background: value }}>
+ <span className="sr-only">{label}</span>
+ <input type="color" value={value} onChange={(e) => onChange(e.target.value)} className="absolute inset-0 size-full cursor-pointer opacity-0" />
+ </label>
+ <input
+ value={text}
+ onChange={(e) => {
+ const v = e.target.value.trim();
+ setText(v);
+ const hex = v.startsWith("#") ? v : `#${v}`;
+ if (HEX.test(hex)) onChange(hex.toLowerCase());
+ }}
+ maxLength={7}
+ spellCheck={false}
+ aria-label={`${label} (hex)`}
+ className={cn(field, "font-mono text-[13px] uppercase")}
+ />
+ </div>
+ );
+}
+
+function FontInput({ label, value, onChange }: { label: string; value: string; onChange: (v: string) => void }) {
+ const id = useId();
+ return (
+ <label className="block min-w-0 space-y-1">
+ <span className="text-[12px] font-medium text-muted-foreground">{label}</span>
+ <input list={`${id}-fonts`} value={value} onChange={(e) => onChange(e.target.value.slice(0, 80))} placeholder="Type a font name" className={field} style={{ fontFamily: value ? `"${value}", system-ui` : undefined }} />
+ <datalist id={`${id}-fonts`}>
+ {POPULAR_FONTS.map((f) => (
+ <option key={f} value={f} />
+ ))}
+ </datalist>
+ </label>
+ );
+}
+
+export function BrandRow({ value, onChange, kits, kitId, onKit }: { value: TemplateBrand; onChange: (b: TemplateBrand) => void; kits?: BrandKit[]; kitId?: string | null; onKit?: (id: string | null) => void }) {
+ const [open, setOpen] = useState(false);
+ const set = (p: Partial<TemplateBrand>) => onChange({ ...value, ...p });
+ const [c1, c2 = c1] = value.colors;
+ // While a logo uploads the tile shows it; once stored, the brand takes its address.
+ const [pending, setPending] = useState<SlotValue | null>(null);
+ const logoSlot: SlotValue | null = pending?.uploading ? pending : value.logo ? { ref: value.logo, preview: value.logo, kind: "image" } : null;
+ return (
+ <div className="min-w-0 rounded-2xl border">
+ <button type="button" onClick={() => setOpen((v) => !v)} aria-expanded={open} className="flex min-h-11 w-full min-w-0 items-center gap-2.5 rounded-2xl px-3 py-2 text-left outline-none hover:bg-accent/50 focus-visible:ring-2 focus-visible:ring-ring">
+ <span className="flex shrink-0 -space-x-1.5" aria-hidden>
+ <span className="size-5 rounded-full border-2 border-background" style={{ background: c1 }} />
+ <span className="size-5 rounded-full border-2 border-background" style={{ background: c2 }} />
+ </span>
+ <span className="min-w-0 flex-1">
+ <span className="block text-[12px] font-medium text-muted-foreground">Brand</span>
+ <span className="block truncate text-[14px] font-medium" style={{ fontFamily: `"${value.fonts.heading}", system-ui` }}>
+ {value.name || "Your brand"}
+ </span>
+ </span>
+ <span className="hidden truncate text-[12px] text-muted-foreground sm:block">
+ {value.fonts.heading} · {value.fonts.body}
+ </span>
+ <ChevronDown className={cn("size-4 shrink-0 text-muted-foreground transition-transform", open && "rotate-180")} />
+ </button>
+ {open && (
+ <div className="min-w-0 space-y-3 border-t px-3 pt-3 pb-3">
+ {kits && kits.length > 0 && onKit && (
+ <label className="block min-w-0 space-y-1">
+ <span className="text-[12px] font-medium text-muted-foreground">Brand kit</span>
+ <select value={kitId ?? ""} onChange={(e) => onKit(e.target.value || null)} className={field}>
+ <option value="">None</option>
+ {kits.map((k) => (
+ <option key={k.id} value={k.id}>
+ {k.name}
+ </option>
+ ))}
+ </select>
+ </label>
+ )}
+ <label className="block min-w-0 space-y-1">
+ <span className="text-[12px] font-medium text-muted-foreground">Name</span>
+ {/* A sample brand's lockup goes once the name changes: it spells the sample's name. */}
+ <input value={value.name} onChange={(e) => set({ name: e.target.value.slice(0, 120), ...(value.logo?.startsWith("/previews/") && { logo: null }) })} className={field} aria-label="Brand name" />
+ </label>
+ <div className="grid min-w-0 grid-cols-2 gap-2">
+ <Swatch label="Main colour" value={c1} onChange={(v) => set({ colors: [v, c2] })} />
+ <Swatch label="Second colour" value={c2} onChange={(v) => set({ colors: [c1, v] })} />
+ </div>
+ <div className="grid min-w-0 grid-cols-2 gap-2">
+ <FontInput label="Heading font" value={value.fonts.heading} onChange={(v) => set({ fonts: { ...value.fonts, heading: v } })} />
+ <FontInput label="Body font" value={value.fonts.body} onChange={(v) => set({ fonts: { ...value.fonts, body: v } })} />
+ </div>
+ <div className="flex min-w-0 items-center gap-3">
+ <MediaSlot label="Logo" kind="image" value={logoSlot} onChange={(v) => {
+ setPending(v);
+ if (!v) set({ logo: null });
+ else if (!v.uploading && v.ref.startsWith("/api/files/")) set({ logo: v.ref });
+ }} />
+ <p className="min-w-0 text-[12px] text-muted-foreground">Logo · a PNG or SVG with a clear background reads best</p>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/src/components/motion/draw.ts b/src/components/motion/draw.ts
index 109bf15e..580e0bb1 100644
--- a/src/components/motion/draw.ts
+++ b/src/components/motion/draw.ts
@@ -101,6 +101,7 @@ function roundRect(ctx: Ctx | Path2D, x: number, y: number, w: number, h: number
}
function clipTo(ctx: Ctx, c: ClipShape) {
+ if (c.type === "path") return void ctx.clip(new Path2D(c.d));
ctx.beginPath();
if (c.type === "rect") {
if (c.r) roundRect(ctx, c.x, c.y, c.w, c.h, c.r);
diff --git a/src/components/motion/easy-chips.tsx b/src/components/motion/easy-chips.tsx
new file mode 100644
index 00000000..d740e1ee
--- /dev/null
+++ b/src/components/motion/easy-chips.tsx
@@ -0,0 +1,69 @@
+"use client";
+
+import type { EasyGroup } from "@/lib/catalog/marketing";
+import type { SizePreset } from "@/lib/motion/sizes";
+import { cn } from "@/lib/utils";
+
+/** A template's quick choices (Pace, Look, Style…), its sizes and its length: chips at least 44 px tall. */
+
+const chip = (on: boolean) =>
+ cn("inline-flex h-11 min-w-0 items-center justify-center rounded-full px-3.5 text-[13px] font-medium whitespace-nowrap transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring", on ? "bg-foreground text-background" : "bg-secondary text-secondary-foreground hover:bg-accent");
+
+function Choices<T extends string>({ label, choices, value, onChange }: { label: string; choices: { id: T; label: string }[]; value: T; onChange: (v: T) => void }) {
+ return (
+ <div className="min-w-0">
+ <p className="mb-1.5 text-[12px] font-medium text-muted-foreground">{label}</p>
+ <div role="radiogroup" aria-label={label} className="flex min-w-0 flex-wrap gap-1.5">
+ {choices.map((c) => (
+ <button key={c.id} type="button" role="radio" aria-checked={value === c.id} onClick={() => onChange(c.id)} className={chip(value === c.id)}>
+ {c.label}
+ </button>
+ ))}
+ </div>
+ </div>
+ );
+}
+
+export function EasyChips({ groups, values, onChange }: { groups: EasyGroup[]; values: Record<string, string>; onChange: (id: string, choice: string) => void }) {
+ return (
+ <div className="space-y-3">
+ {groups.map((g) => (
+ <Choices key={g.id} label={g.label} choices={g.choices} value={values[g.id] ?? g.choices[0].id} onChange={(v) => onChange(g.id, v)} />
+ ))}
+ </div>
+ );
+}
+
+const SIZE_NAMES: Record<SizePreset, string> = { "9:16": "Story", "4:5": "Feed", "1:1": "Square", "16:9": "Wide" };
+
+export function SizeChips({ sizes, value, onChange }: { sizes: SizePreset[]; value: SizePreset; onChange: (s: SizePreset) => void }) {
+ return (
+ <div className="min-w-0">
+ <p className="mb-1.5 text-[12px] font-medium text-muted-foreground">Size</p>
+ <div role="radiogroup" aria-label="Size" className="grid min-w-0 grid-cols-4 gap-1.5">
+ {sizes.map((s) => {
+ const [w, h] = s.split(":").map(Number);
+ return (
+ <button key={s} type="button" role="radio" aria-checked={value === s} aria-label={`${s} ${SIZE_NAMES[s]}`} onClick={() => onChange(s)} className={cn("flex min-h-11 min-w-0 flex-col items-center justify-center gap-0.5 rounded-xl px-1 py-1.5 text-[12px] font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring", value === s ? "bg-foreground text-background" : "bg-secondary text-secondary-foreground hover:bg-accent")}>
+ <span aria-hidden className="block rounded-[3px] border-[1.5px] border-current opacity-80" style={{ width: (w / Math.max(w, h)) * 18, height: (h / Math.max(w, h)) * 18 }} />
+ <span className="tabular-nums">{s}</span>
+ </button>
+ );
+ })}
+ </div>
+ </div>
+ );
+}
+
+export function LengthSlider({ min, max, value, onChange }: { min: number; max: number; value: number; onChange: (v: number) => void }) {
+ if (max <= min) return null;
+ const step = max - min <= 2 ? 0.5 : 1;
+ return (
+ <div className="min-w-0">
+ <p className="mb-0.5 text-[12px] font-medium text-muted-foreground">
+ Length · <span className="tabular-nums">{value} s</span>
+ </p>
+ <input type="range" min={min} max={max} step={step} value={value} onChange={(e) => onChange(Number(e.target.value))} aria-label="Length in seconds" aria-valuetext={`${value} seconds`} className="h-11 w-full cursor-pointer accent-[var(--primary)]" />
+ </div>
+ );
+}
diff --git a/src/components/motion/fields.tsx b/src/components/motion/fields.tsx
new file mode 100644
index 00000000..50b92c4f
--- /dev/null
+++ b/src/components/motion/fields.tsx
@@ -0,0 +1,54 @@
+"use client";
+
+import type { TemplateField } from "@/lib/catalog/marketing";
+import { cn } from "@/lib/utils";
+
+/**
+ * A template's words, typed exactly as they will be set: each field with its count, its tip, and a plain line when the
+ * words don't fit the frame (the clip is never cut short; Save waits until they fit).
+ */
+
+const box = "w-full min-w-0 rounded-xl border bg-background px-3 text-[15px] outline-none transition-[border-color,box-shadow] placeholder:text-subtle-foreground focus-visible:border-primary focus-visible:ring-4 focus-visible:ring-brand-faint aria-invalid:border-destructive";
+
+export const shortenLine = (f: TemplateField) => `Shorten the ${f.label.toLowerCase()} to fit`;
+
+export function TemplateFields({ fields, values, onChange, overflow }: { fields: TemplateField[]; values: Record<string, string>; onChange: (key: string, value: string) => void; overflow: string[] }) {
+ return (
+ <div className="space-y-3">
+ {fields.map((f) => {
+ const v = values[f.key] ?? "";
+ const over = overflow.includes(f.key);
+ const id = `kinetic-field-${f.key}`;
+ const count = [...v].length;
+ return (
+ <div key={f.key} className="min-w-0 space-y-1">
+ <div className="flex items-baseline justify-between gap-2">
+ <label htmlFor={id} className="text-[12px] font-medium text-muted-foreground">
+ {f.label}
+ </label>
+ <span className={cn("font-mono text-[11px] tabular-nums text-muted-foreground", count >= f.max && "text-foreground")} aria-hidden>
+ {count}/{f.max}
+ </span>
+ </div>
+ {f.lines > 1 ? (
+ <textarea id={id} value={v} onChange={(e) => onChange(f.key, e.target.value)} maxLength={f.max} rows={Math.min(4, f.lines)} aria-invalid={over || undefined} aria-describedby={over || f.hint ? `${id}-note` : undefined} className={cn(box, "field-sizing-content min-h-11 resize-none py-2.5 leading-snug")} />
+ ) : (
+ <input id={id} value={v} onChange={(e) => onChange(f.key, e.target.value)} maxLength={f.max} aria-invalid={over || undefined} aria-describedby={over || f.hint ? `${id}-note` : undefined} className={cn(box, "h-11")} />
+ )}
+ {over ? (
+ <p id={`${id}-note`} role="status" className="text-[12px] text-destructive">
+ {shortenLine(f)}
+ </p>
+ ) : (
+ f.hint && (
+ <p id={`${id}-note`} className="text-[11px] text-muted-foreground">
+ {f.hint}
+ </p>
+ )
+ )}
+ </div>
+ );
+ })}
+ </div>
+ );
+}
diff --git a/src/components/motion/inputs.ts b/src/components/motion/inputs.ts
new file mode 100644
index 00000000..fd16004b
--- /dev/null
+++ b/src/components/motion/inputs.ts
@@ -0,0 +1,63 @@
+"use client";
+
+import { loadImage } from "@/components/ads/render";
+import { OUTLINE_GRID, traceOutline } from "@/lib/motion/outline";
+import type { LogoInfo, Outline } from "@/lib/motion/scene";
+import { logoInfoFor, type Sources } from "./draw";
+
+/**
+ * The pictures a recipe needs, loaded before its scene runs: the logo (with an SVG logo's outlines), the product, their
+ * sizes, and a cut-out product's outline traced from its transparency. A scene gets sizes and outlines, never the
+ * pictures themselves; the drawer gets the pictures.
+ */
+
+export interface LoadedInputs {
+ sources: Sources;
+ logo: LogoInfo | null;
+ images: Record<string, { w: number; h: number }>;
+ outlines: Record<string, Outline | null>;
+}
+
+const traced = new Map<string, Outline | null>();
+
+/** A picture's outline from its alpha, on a grid at most OUTLINE_GRID on its long side (null: no transparency). */
+export function outlineOf(url: string, img: HTMLImageElement): Outline | null {
+ if (traced.has(url)) return traced.get(url)!;
+ let out: Outline | null = null;
+ try {
+ const k = Math.min(1, OUTLINE_GRID / Math.max(img.naturalWidth, img.naturalHeight));
+ const w = Math.max(1, Math.round(img.naturalWidth * k));
+ const h = Math.max(1, Math.round(img.naturalHeight * k));
+ const c = Object.assign(document.createElement("canvas"), { width: w, height: h });
+ const ctx = c.getContext("2d", { willReadFrequently: true });
+ if (ctx) {
+ ctx.drawImage(img, 0, 0, w, h);
+ const rgba = ctx.getImageData(0, 0, w, h).data;
+ const alpha = new Uint8ClampedArray(w * h);
+ for (let i = 0; i < w * h; i++) alpha[i] = rgba[i * 4 + 3];
+ out = traceOutline(alpha, w, h);
+ }
+ } catch {
+ out = null;
+ }
+ traced.set(url, out);
+ return out;
+}
+
+/** The logo and the product a recipe names (recipe.brand.logo, recipe.media.product), loaded. */
+export async function loadMotionInputs(urls: { logo?: string | null; product?: string | null }): Promise<LoadedInputs> {
+ const logoUrl = urls.logo || null;
+ const productUrl = urls.product || null;
+ const [logoImg, productImg] = await Promise.all([logoUrl ? loadImage(logoUrl).catch(() => null) : null, productUrl ? loadImage(productUrl).catch(() => null) : null]);
+ const logo = logoImg && logoUrl ? await logoInfoFor(logoUrl, logoImg).catch(() => null) : null;
+ const images = new Map<string, CanvasImageSource>();
+ const sizes: LoadedInputs["images"] = {};
+ const outlines: LoadedInputs["outlines"] = {};
+ if (logoImg) images.set("logo", logoImg);
+ if (productImg && productUrl) {
+ images.set("product", productImg);
+ sizes.product = { w: productImg.naturalWidth, h: productImg.naturalHeight };
+ outlines.product = outlineOf(productUrl, productImg);
+ }
+ return { sources: { images }, logo, images: sizes, outlines };
+}
diff --git a/src/components/motion/made-strip.tsx b/src/components/motion/made-strip.tsx
new file mode 100644
index 00000000..bc6d0a04
--- /dev/null
+++ b/src/components/motion/made-strip.tsx
@@ -0,0 +1,49 @@
+"use client";
+
+import { Play } from "lucide-react";
+import { useMemo, useState } from "react";
+import { Viewer } from "@/components/studio/viewer";
+import { useGenerations, useIsGuest } from "@/lib/api";
+import type { Generation } from "@/lib/catalog/types";
+import { motionTemplateOf } from "@/lib/library";
+
+/**
+ * "Made with this template": the clips saved from a code-drawn template (the owner's Library, or an account's own
+ * runs: the list is scoped by the server). Each opens the normal result viewer, where it downloads.
+ */
+
+export const KINETIC_FEATURE = "marketing-kinetic";
+
+export function MadeStrip({ templateId }: { templateId: string }) {
+ const guest = useIsGuest();
+ // The server picks this template's clips, so a long Library never hides them.
+ const list = useGenerations({ features: [KINETIC_FEATURE], template: templateId, statuses: ["succeeded"], limit: 12 });
+ const mine = useMemo(() => (guest ? [] : (list.data ?? []).filter((g) => g.status === "succeeded" && g.outputs[0] && motionTemplateOf(g) === templateId).slice(0, 12)), [list.data, templateId, guest]);
+ const [open, setOpen] = useState<Generation | null>(null);
+ if (!mine.length) return null;
+ return (
+ <section aria-label="Made with this template" className="min-w-0">
+ <h3 className="mb-2 text-[13px] font-medium">Made with this template</h3>
+ <div className="scrollbar-none -mx-1 flex min-w-0 gap-2 overflow-x-auto px-1 pb-1">
+ {mine.map((g) => {
+ const o = g.outputs[0];
+ const poster = typeof o.meta?.poster === "string" ? o.meta.poster : undefined;
+ return (
+ <button key={g.id} type="button" onClick={() => setOpen(g)} aria-label={`Open saved clip: ${(g.request.prompt ?? "").slice(0, 80)}`} data-kinetic-made={g.id} className="relative h-28 shrink-0 overflow-hidden rounded-xl bg-muted outline-none focus-visible:ring-2 focus-visible:ring-ring" style={{ aspectRatio: o.width && o.height ? `${o.width} / ${o.height}` : "9 / 16" }}>
+ {poster ? (
+ // eslint-disable-next-line @next/next/no-img-element
+ <img src={poster} alt="" className="size-full object-cover" loading="lazy" />
+ ) : (
+ <video src={o.url} muted playsInline preload="metadata" className="size-full object-cover" />
+ )}
+ <span className="absolute right-1.5 bottom-1.5 grid size-6 place-items-center rounded-full bg-black/45 text-white backdrop-blur" aria-hidden>
+ <Play className="size-3 fill-current" />
+ </span>
+ </button>
+ );
+ })}
+ </div>
+ {open && <Viewer generation={open} index={0} onClose={() => setOpen(null)} />}
+ </section>
+ );
+}
diff --git a/src/components/motion/player.tsx b/src/components/motion/player.tsx
index 5fe4aea0..5076dfd0 100644
--- a/src/components/motion/player.tsx
+++ b/src/components/motion/player.tsx
@@ -2,13 +2,14 @@
import { Pause, Play, Repeat } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
-import { loadImage, measureText } from "@/components/ads/render";
+import { measureText } from "@/components/ads/render";
import type { Recipe } from "@/lib/motion/recipe";
import { loadScene } from "@/lib/motion/registry";
-import type { LogoInfo, Scene, ScenePlan } from "@/lib/motion/scene";
+import type { LogoInfo, Outline, Scene, ScenePlan } from "@/lib/motion/scene";
import { previewSize, type SizeSpec } from "@/lib/motion/sizes";
import { cn } from "@/lib/utils";
-import { drawDisplayList, logoInfoFor, type Sources } from "./draw";
+import { drawDisplayList, type Sources } from "./draw";
+import { loadMotionInputs } from "./inputs";
import { fontsReady } from "./fonts";
/**
@@ -22,6 +23,9 @@ export interface MotionInputs {
ready: boolean;
sources: Sources;
logo: LogoInfo | null;
+ /** The pictures' sizes and a cut-out's outline, by key ("product"). */
+ images?: Record<string, { w: number; h: number }>;
+ outlines?: Record<string, Outline | null>;
/** Bumps when the fonts or the logo arrive (the layout is measured again). */
version: number;
}
@@ -31,6 +35,7 @@ const EMPTY_SOURCES: Sources = { images: new Map() };
/** The logo and fonts a recipe needs, loaded (the preview draws with a fallback font until its own arrives). */
export function useMotionInputs(recipe: Recipe | null): MotionInputs {
const logoUrl = recipe?.brand.logo || null;
+ const productUrl = recipe?.media?.product || null;
const heading = recipe?.brand.fonts.heading;
const body = recipe?.brand.fonts.body;
const text = recipe ? Object.values(recipe.fields).join(" ") : "";
@@ -38,18 +43,15 @@ export function useMotionInputs(recipe: Recipe | null): MotionInputs {
useEffect(() => {
let live = true;
void (async () => {
- const img = logoUrl ? await loadImage(logoUrl).catch(() => null) : null;
- const logo = img && logoUrl ? await logoInfoFor(logoUrl, img).catch(() => null) : null;
+ const loaded = await loadMotionInputs({ logo: logoUrl, product: productUrl });
await fontsReady([heading, body], { text }).catch(() => undefined);
if (!live) return;
- const images = new Map<string, CanvasImageSource>();
- if (img) images.set("logo", img);
- setState((s) => ({ ready: true, sources: { images }, logo, version: s.version + 1 }));
+ setState((s) => ({ ready: true, ...loaded, version: s.version + 1 }));
})();
return () => {
live = false;
};
- }, [logoUrl, heading, body, text]);
+ }, [logoUrl, productUrl, heading, body, text]);
return state;
}
@@ -72,7 +74,7 @@ export function usePlan(scene: Scene | null, recipe: Recipe | null, inputs: Moti
const key = recipe ? JSON.stringify(recipe) : "";
return useMemo(() => {
if (!scene || !recipe || !inputs.ready) return null;
- return scene.plan({ recipe, measure: measureText, logo: inputs.logo });
+ return scene.plan({ recipe, measure: measureText, logo: inputs.logo, images: inputs.images, outlines: inputs.outlines });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [scene, key, inputs.version, inputs.ready]);
}
diff --git a/src/components/motion/render.ts b/src/components/motion/render.ts
index 140c9ce8..25fbc45b 100644
--- a/src/components/motion/render.ts
+++ b/src/components/motion/render.ts
@@ -4,7 +4,7 @@ import { avcCodec, encodeMp4, encodeVp8, pathVideoType, recordWithMediaRecorder,
import { listTravel, type DisplayList } from "@/lib/motion/display";
import type { Measure } from "@/lib/motion/layout";
import type { Recipe } from "@/lib/motion/recipe";
-import type { LogoInfo, Scene, ScenePlan } from "@/lib/motion/scene";
+import type { LogoInfo, Outline, Scene, ScenePlan } from "@/lib/motion/scene";
import { exportBitrate, exportSize } from "@/lib/motion/sizes";
import { frameCount } from "@/lib/motion/time";
import { drawDisplayList, type Sources } from "./draw";
@@ -25,6 +25,8 @@ export const NO_ENCODER_MESSAGE = "This browser can't make this video. Try Chrom
export interface RenderOptions {
sources: Sources;
logo: LogoInfo | null;
+ images?: Record<string, { w: number; h: number }>;
+ outlines?: Record<string, Outline | null>;
measure: Measure;
signal?: AbortSignal;
/** After each frame: how many are done, of how many, and the frame just drawn. */
@@ -127,7 +129,7 @@ export function drawFrame(plan: ScenePlan, t: number, target: AnyCanvas, scratch
/** Renders the whole clip (see the file's comment). Throws SHORTEN_MESSAGE when a typed field doesn't fit. */
export async function renderClip(scene: Scene, recipe: Recipe, o: RenderOptions): Promise<RenderResult> {
- const plan = scene.plan({ recipe, measure: o.measure, logo: o.logo });
+ const plan = scene.plan({ recipe, measure: o.measure, logo: o.logo, images: o.images, outlines: o.outlines });
if (plan.overflow.length) throw new Error(SHORTEN_MESSAGE);
const { w, h } = exportSize(recipe.size);
// H.264 wants even sides.
diff --git a/src/components/preset-icons.ts b/src/components/preset-icons.ts
index 46fa69dc..497f4ae8 100644
--- a/src/components/preset-icons.ts
+++ b/src/components/preset-icons.ts
@@ -1,4 +1,4 @@
// Generated by scripts/gen-icon-map.mjs — do not edit by hand.
-import { Activity, Angry, Aperture, AppWindow, ArrowDown, ArrowDownToDot, ArrowDownToLine, ArrowLeft, ArrowLeftRight, ArrowLeftToLine, ArrowRight, ArrowRightLeft, ArrowRightToLine, ArrowUp, ArrowUpFromLine, ArrowUpRight, ArrowUpWideNarrow, AtSign, Atom, AudioLines, AudioWaveform, Axis3d, BadgeDollarSign, Banana, Banknote, Bath, Bike, Binary, Biohazard, Bird, Blocks, Bomb, BookOpen, Bot, Box, Boxes, BriefcaseBusiness, Brush, Bug, Building, Building2, Cake, Camera, Candy, Car, CarFront, Castle, ChevronDown, ChevronUp, ChevronsDown, ChevronsLeft, ChevronsRight, ChevronsUp, Circle, CircleDashed, CircleDot, Citrus, Clapperboard, Clock, Cloud, CloudFog, CloudLightning, CloudRain, Cloudy, Coffee, Cog, Columns3, Combine, Contrast, Copy, Cpu, Crosshair, Crown, CupSoda, Diamond, Disc, Disc3, Dog, Drama, Droplet, Droplets, Dumbbell, Ear, Earth, Eraser, Expand, Eye, EyeOff, FastForward, Feather, FerrisWheel, FileImage, FileText, Film, Fingerprint, Fish, Flame, FlaskConical, Flower, Flower2, Focus, Footprints, Frame, Frown, GalleryHorizontal, Gamepad2, Gauge, Gem, Ghost, GitBranch, Glasses, Globe, Globe2, Grid2x2, Grid3x3, Grip, Hammer, Hand, Headphones, Heart, HeartHandshake, Hexagon, History, Hourglass, House, Image, ImageIcon, Images, Infinity, Joystick, Lamp, Landmark, Languages, Laugh, Layers, LayoutGrid, Leaf, Lightbulb, Link, Maximize, Maximize2, Megaphone, MessageCircle, MessageSquareText, Mic, Mic2, MicVocal, Microscope, Monitor, MonitorPlay, Moon, Mountain, MountainSnow, MousePointerClick, MoveDiagonal, MoveDiagonal2, MoveHorizontal, Music, Newspaper, Orbit, Package, PackageOpen, PackagePlus, Paintbrush, Palette, Palmtree, PanelTop, PartyPopper, Pause, PawPrint, PenLine, PenTool, Pencil, PencilRuler, PersonStanding, Pizza, Plane, Pointer, Presentation, Rabbit, Radar, Rainbow, Redo2, RefreshCw, Refrigerator, Repeat, Repeat2, Rocket, Rotate3d, RotateCcw, RotateCw, Rows2, Sailboat, Scaling, ScanEye, ScanFace, ScanLine, Scissors, Search, Send, Shapes, Shell, Shield, ShieldCheck, Shirt, Shuffle, Signpost, Skull, SlidersHorizontal, Smartphone, Smile, SmilePlus, Snail, Snowflake, Sparkle, Sparkles, Spline, SprayCan, Sprout, Square, SquareDashed, Star, Sticker, StickyNote, Store, Sun, SunDim, Sunrise, Sunset, Swords, Table, Thermometer, ThumbsUp, Ticket, Timer, Tornado, TrainFront, TrendingUp, Trophy, Truck, Tv, Type, Undo2, Unplug, User, UserRound, UserRoundCog, UserX, Users, Utensils, UtensilsCrossed, Video, Volleyball, Wand, Wand2, Waves, Waypoints, Wind, Wine, Worm, Zap, ZoomIn, ZoomOut, type LucideIcon } from "lucide-react";
+import { Activity, Angry, Aperture, AppWindow, ArrowDown, ArrowDownToDot, ArrowDownToLine, ArrowLeft, ArrowLeftRight, ArrowLeftToLine, ArrowRight, ArrowRightLeft, ArrowRightToLine, ArrowUp, ArrowUpFromLine, ArrowUpRight, ArrowUpWideNarrow, AtSign, Atom, AudioLines, AudioWaveform, Axis3d, BadgeDollarSign, Banana, Banknote, Bath, Bike, Binary, Biohazard, Bird, Blocks, Bomb, BookOpen, Bot, Box, Boxes, BriefcaseBusiness, Brush, Bug, Building, Building2, Cake, Camera, Candy, Car, CarFront, Castle, ChevronDown, ChevronUp, ChevronsDown, ChevronsLeft, ChevronsRight, ChevronsUp, Circle, CircleDashed, CircleDot, Citrus, Clapperboard, Clock, Cloud, CloudFog, CloudLightning, CloudRain, Cloudy, Coffee, Cog, Columns3, Combine, Contrast, Copy, Cpu, Crosshair, Crown, CupSoda, Diamond, Disc, Disc3, Dog, Drama, Droplet, Droplets, Dumbbell, Ear, Earth, Eraser, Expand, Eye, EyeOff, FastForward, Feather, FerrisWheel, FileImage, FileText, Film, Fingerprint, Fish, Flame, FlaskConical, Flower, Flower2, Focus, Footprints, Frame, Frown, GalleryHorizontal, Gamepad2, Gauge, Gem, Ghost, GitBranch, Glasses, Globe, Globe2, Grid2x2, Grid3x3, Grip, Hammer, Hand, Headphones, Heart, HeartHandshake, Hexagon, History, Hourglass, House, Image, ImageIcon, Images, Infinity, Joystick, Lamp, Landmark, Languages, Laugh, Layers, LayoutDashboard, LayoutGrid, Leaf, Lightbulb, Link, Maximize, Maximize2, Megaphone, MessageCircle, MessageSquareText, Mic, Mic2, MicVocal, Microscope, Monitor, MonitorPlay, Moon, Mountain, MountainSnow, MousePointerClick, MoveDiagonal, MoveDiagonal2, MoveHorizontal, Music, Newspaper, Orbit, Package, PackageOpen, PackagePlus, Paintbrush, Palette, Palmtree, PanelTop, PartyPopper, Pause, PawPrint, PenLine, PenTool, Pencil, PencilRuler, PersonStanding, Pizza, Plane, Pointer, Presentation, Rabbit, Radar, Rainbow, Redo2, RefreshCw, Refrigerator, Repeat, Repeat2, Rocket, Rotate3d, RotateCcw, RotateCw, Rows2, Sailboat, Scaling, ScanEye, ScanFace, ScanLine, Scissors, Search, Send, Shapes, Shell, Shield, ShieldCheck, Shirt, Shuffle, Signpost, Skull, SlidersHorizontal, Smartphone, Smile, SmilePlus, Snail, Snowflake, Sparkle, Sparkles, Spline, SprayCan, Sprout, Square, SquareDashed, Star, Sticker, StickyNote, Store, Sun, SunDim, Sunrise, Sunset, Swords, Table, Thermometer, ThumbsUp, Ticket, Timer, Tornado, TrainFront, TrendingUp, Trophy, Truck, Tv, Type, Undo2, Unplug, User, UserRound, UserRoundCog, UserX, Users, Utensils, UtensilsCrossed, Video, Volleyball, Wand, Wand2, Waves, Waypoints, Wind, Wine, Worm, Zap, ZoomIn, ZoomOut, type LucideIcon } from "lucide-react";
-export const PRESET_ICONS: Record<string, LucideIcon> = { Activity, Angry, Aperture, AppWindow, ArrowDown, ArrowDownToDot, ArrowDownToLine, ArrowLeft, ArrowLeftRight, ArrowLeftToLine, ArrowRight, ArrowRightLeft, ArrowRightToLine, ArrowUp, ArrowUpFromLine, ArrowUpRight, ArrowUpWideNarrow, AtSign, Atom, AudioLines, AudioWaveform, Axis3d, BadgeDollarSign, Banana, Banknote, Bath, Bike, Binary, Biohazard, Bird, Blocks, Bomb, BookOpen, Bot, Box, Boxes, BriefcaseBusiness, Brush, Bug, Building, Building2, Cake, Camera, Candy, Car, CarFront, Castle, ChevronDown, ChevronUp, ChevronsDown, ChevronsLeft, ChevronsRight, ChevronsUp, Circle, CircleDashed, CircleDot, Citrus, Clapperboard, Clock, Cloud, CloudFog, CloudLightning, CloudRain, Cloudy, Coffee, Cog, Columns3, Combine, Contrast, Copy, Cpu, Crosshair, Crown, CupSoda, Diamond, Disc, Disc3, Dog, Drama, Droplet, Droplets, Dumbbell, Ear, Earth, Eraser, Expand, Eye, EyeOff, FastForward, Feather, FerrisWheel, FileImage, FileText, Film, Fingerprint, Fish, Flame, FlaskConical, Flower, Flower2, Focus, Footprints, Frame, Frown, GalleryHorizontal, Gamepad2, Gauge, Gem, Ghost, GitBranch, Glasses, Globe, Globe2, Grid2x2, Grid3x3, Grip, Hammer, Hand, Headphones, Heart, HeartHandshake, Hexagon, History, Hourglass, House, Image, ImageIcon, Images, Infinity, Joystick, Lamp, Landmark, Languages, Laugh, Layers, LayoutGrid, Leaf, Lightbulb, Link, Maximize, Maximize2, Megaphone, MessageCircle, MessageSquareText, Mic, Mic2, MicVocal, Microscope, Monitor, MonitorPlay, Moon, Mountain, MountainSnow, MousePointerClick, MoveDiagonal, MoveDiagonal2, MoveHorizontal, Music, Newspaper, Orbit, Package, PackageOpen, PackagePlus, Paintbrush, Palette, Palmtree, PanelTop, PartyPopper, Pause, PawPrint, PenLine, PenTool, Pencil, PencilRuler, PersonStanding, Pizza, Plane, Pointer, Presentation, Rabbit, Radar, Rainbow, Redo2, RefreshCw, Refrigerator, Repeat, Repeat2, Rocket, Rotate3d, RotateCcw, RotateCw, Rows2, Sailboat, Scaling, ScanEye, ScanFace, ScanLine, Scissors, Search, Send, Shapes, Shell, Shield, ShieldCheck, Shirt, Shuffle, Signpost, Skull, SlidersHorizontal, Smartphone, Smile, SmilePlus, Snail, Snowflake, Sparkle, Sparkles, Spline, SprayCan, Sprout, Square, SquareDashed, Star, Sticker, StickyNote, Store, Sun, SunDim, Sunrise, Sunset, Swords, Table, Thermometer, ThumbsUp, Ticket, Timer, Tornado, TrainFront, TrendingUp, Trophy, Truck, Tv, Type, Undo2, Unplug, User, UserRound, UserRoundCog, UserX, Users, Utensils, UtensilsCrossed, Video, Volleyball, Wand, Wand2, Waves, Waypoints, Wind, Wine, Worm, Zap, ZoomIn, ZoomOut };
+export const PRESET_ICONS: Record<string, LucideIcon> = { Activity, Angry, Aperture, AppWindow, ArrowDown, ArrowDownToDot, ArrowDownToLine, ArrowLeft, ArrowLeftRight, ArrowLeftToLine, ArrowRight, ArrowRightLeft, ArrowRightToLine, ArrowUp, ArrowUpFromLine, ArrowUpRight, ArrowUpWideNarrow, AtSign, Atom, AudioLines, AudioWaveform, Axis3d, BadgeDollarSign, Banana, Banknote, Bath, Bike, Binary, Biohazard, Bird, Blocks, Bomb, BookOpen, Bot, Box, Boxes, BriefcaseBusiness, Brush, Bug, Building, Building2, Cake, Camera, Candy, Car, CarFront, Castle, ChevronDown, ChevronUp, ChevronsDown, ChevronsLeft, ChevronsRight, ChevronsUp, Circle, CircleDashed, CircleDot, Citrus, Clapperboard, Clock, Cloud, CloudFog, CloudLightning, CloudRain, Cloudy, Coffee, Cog, Columns3, Combine, Contrast, Copy, Cpu, Crosshair, Crown, CupSoda, Diamond, Disc, Disc3, Dog, Drama, Droplet, Droplets, Dumbbell, Ear, Earth, Eraser, Expand, Eye, EyeOff, FastForward, Feather, FerrisWheel, FileImage, FileText, Film, Fingerprint, Fish, Flame, FlaskConical, Flower, Flower2, Focus, Footprints, Frame, Frown, GalleryHorizontal, Gamepad2, Gauge, Gem, Ghost, GitBranch, Glasses, Globe, Globe2, Grid2x2, Grid3x3, Grip, Hammer, Hand, Headphones, Heart, HeartHandshake, Hexagon, History, Hourglass, House, Image, ImageIcon, Images, Infinity, Joystick, Lamp, Landmark, Languages, Laugh, Layers, LayoutDashboard, LayoutGrid, Leaf, Lightbulb, Link, Maximize, Maximize2, Megaphone, MessageCircle, MessageSquareText, Mic, Mic2, MicVocal, Microscope, Monitor, MonitorPlay, Moon, Mountain, MountainSnow, MousePointerClick, MoveDiagonal, MoveDiagonal2, MoveHorizontal, Music, Newspaper, Orbit, Package, PackageOpen, PackagePlus, Paintbrush, Palette, Palmtree, PanelTop, PartyPopper, Pause, PawPrint, PenLine, PenTool, Pencil, PencilRuler, PersonStanding, Pizza, Plane, Pointer, Presentation, Rabbit, Radar, Rainbow, Redo2, RefreshCw, Refrigerator, Repeat, Repeat2, Rocket, Rotate3d, RotateCcw, RotateCw, Rows2, Sailboat, Scaling, ScanEye, ScanFace, ScanLine, Scissors, Search, Send, Shapes, Shell, Shield, ShieldCheck, Shirt, Shuffle, Signpost, Skull, SlidersHorizontal, Smartphone, Smile, SmilePlus, Snail, Snowflake, Sparkle, Sparkles, Spline, SprayCan, Sprout, Square, SquareDashed, Star, Sticker, StickyNote, Store, Sun, SunDim, Sunrise, Sunset, Swords, Table, Thermometer, ThumbsUp, Ticket, Timer, Tornado, TrainFront, TrendingUp, Trophy, Truck, Tv, Type, Undo2, Unplug, User, UserRound, UserRoundCog, UserX, Users, Utensils, UtensilsCrossed, Video, Volleyball, Wand, Wand2, Waves, Waypoints, Wind, Wine, Worm, Zap, ZoomIn, ZoomOut };
diff --git a/src/lib/catalog/marketing.ts b/src/lib/catalog/marketing.ts
index 7efd8ae1..1a364be5 100644
--- a/src/lib/catalog/marketing.ts
+++ b/src/lib/catalog/marketing.ts
@@ -332,8 +332,54 @@ export interface MarketingTemplate {
/** Default on-image headline ("{product}" and "{brand}" fill in). */
headline?: string;
cta?: string;
+ /** Drawn by Fuobe Kinetic Motion in the browser (exact words, the brand's fonts and colours), not prompted to a model. */
+ render?: "code";
+ /** The Kinetic Motion scene that draws it (render: "code"). */
+ scene?: string;
+ /** The words the person types for it, in order. */
+ fields?: TemplateField[];
+ /** Its quick choices (2 to 4 groups). */
+ easy?: EasyGroup[];
+ /** It shows a picture: the product (a cut-out traces best), else the logo. */
+ picture?: "product";
+ /** Its length range when it differs from the format's (seconds). */
+ lengths?: { min: number; max: number; default: number };
}
+export interface TemplateField {
+ key: string;
+ label: string;
+ max: number;
+ /** Lines the box offers (1: a single-line field). */
+ lines: number;
+ /** A short tip under the field. */
+ hint?: string;
+}
+
+export interface EasyGroup {
+ id: string;
+ label: string;
+ choices: { id: string; label: string }[];
+ /** The choice picks the scene itself (`<scene family>/<choice id>`), as the end card's styles do. */
+ scene?: string;
+}
+
+/** The sizes a code-drawn template comes in. */
+export const KINETIC_SIZES = ["9:16", "4:5", "1:1", "16:9"] as const;
+
+const PACE: EasyGroup = { id: "pace", label: "Pace", choices: [{ id: "calm", label: "Calm" }, { id: "punchy", label: "Punchy" }] };
+const LOOK: EasyGroup = { id: "look", label: "Look", choices: [{ id: "light", label: "Light" }, { id: "dark", label: "Dark" }, { id: "brand", label: "Brand colour" }] };
+
+/** A code-drawn piece runs 5 to 8 seconds: its beats spread over the length, so a longer one has more to watch. */
+const CODE_LENGTHS = { min: 5, max: 8, default: 5 };
+
+/** A template drawn by code: its scene, the words it takes and its quick choices. */
+const code = (scene: string, fields: TemplateField[], extra: Partial<MarketingTemplate> = {}): Partial<MarketingTemplate> => ({ render: "code", scene, fields, easy: [PACE, LOOK], duration: 5, lengths: CODE_LENGTHS, ...extra });
+const field = (key: string, label: string, max: number, lines = 1, hint?: string): TemplateField => ({ key, label, max, lines, ...(hint && { hint }) });
+
+/** Whether a template is drawn by Kinetic Motion. */
+export const isCodeTemplate = (t: Pick<MarketingTemplate, "render"> | null | undefined): boolean => t?.render === "code";
+
const t = (id: string, name: string, format: FormatId, look: TemplateLook, prompt: string, extra: Partial<MarketingTemplate> = {}): MarketingTemplate => ({
id,
name,
@@ -373,9 +419,10 @@ export const TEMPLATES: MarketingTemplate[] = [
// Motion · 2D
t("m2-sticker-pop", "Sticker Pop", "motion-2d", { scene: "collage", hue: 330, hue2: 60 }, "Flat 2D animation: the product pops in as a die-cut sticker, bouncy squash and stretch, doodled stars and sparkles burst around it on a flat colour background", { duration: 5 }),
t("m2-paper-parade", "Paper Parade", "motion-2d", { scene: "collage", hue: 30, hue2: 200 }, "Paper cut-out animation: layered paper shapes slide in like a theatre set and the product rises from behind them, gentle stop-motion jitter", { duration: 5 }),
- t("m2-line-reveal", "Line-Art Reveal", "motion-2d", { scene: "kinetic", hue: 160, hue2: 160 }, "A single continuous line draws the outline of the product, then the real product fills in inside it, clean minimal background", { duration: 5 }),
+ t("m2-line-reveal", "Line-Art Reveal", "motion-2d", { scene: "kinetic", hue: 160, hue2: 160 }, "A single continuous line draws the outline of the product, then the real product fills in inside it, clean minimal background", code("marketing/line-reveal", [field("headline", "Headline", 60, 2), field("cta", "Call to action", 30)], { picture: "product", aspect: "9:16", easy: [PACE, LOOK, { id: "line", label: "Line", choices: [{ id: "fine", label: "Fine" }, { id: "bold", label: "Bold" }] }] })),
t("m2-comic-panels", "Comic Panels", "motion-2d", { scene: "split", hue: 50, hue2: 0 }, "Pop-art comic panels flip one after another, each showing the product from a new angle with halftone dots and bold outlines", { duration: 5 }),
- t("m2-retro-starburst", "Retro Starburst", "motion-2d", { scene: "burst", hue: 25, hue2: 330 }, "A rotating retro starburst background in warm colours while the product spins slowly in the centre, groovy 70s motion graphics", { duration: 5 }),
+ t("m2-retro-starburst", "Retro Starburst", "motion-2d", { scene: "burst", hue: 25, hue2: 330 }, "A rotating retro starburst background in warm colours while the product spins slowly in the centre, groovy 70s motion graphics", code("marketing/starburst", [field("headline", "Headline", 40, 2), field("badge", "Badge", 12, 2)], { picture: "product", aspect: "9:16" })),
+ t("m2-offer-badge", "Offer Badge", "motion-2d", { scene: "badge", hue: 350, hue2: 40 }, "A starburst offer badge pops and turns, the product slides in under it and the call to action follows", code("marketing/offer-badge", [field("offer", "Offer", 14, 2), field("headline", "Headline", 40, 2), field("cta", "Call to action", 24)], { picture: "product", aspect: "9:16" })),
t("m2-grid-shuffle", "Grid Shuffle", "motion-2d", { scene: "cards", hue: 200, hue2: 280 }, "A Swiss-style grid of colour tiles shuffles and slides; one tile opens to reveal the product, crisp geometric transitions", { duration: 5 }),
// Motion · hypermotion
@@ -396,11 +443,14 @@ export const TEMPLATES: MarketingTemplate[] = [
t("mm-halftone-collage", "Halftone Collage", "motion-mixed", { scene: "split", hue: 0, hue2: 50 }, "Halftone street-poster collage: cut-out shapes and the product slide in with punchy, rhythmic cuts"),
// Motion · SaaS
- t("ms-feature-cards", "Feature Cards", "motion-saas", { scene: "cards", hue: 250, hue2: 200 }, "Clean SaaS motion design: rounded feature cards fly in and stack, each one highlighting a benefit, soft gradients and smooth easing", { duration: 5 }),
- t("ms-kinetic-headline", "Kinetic Headline", "motion-saas", { scene: "kinetic", hue: 210, hue2: 260 }, "Kinetic typography: the product's promise types itself out word by word with confident motion, then resolves to the logo", { duration: 5 }),
+ t("ms-feature-cards", "Feature Cards", "motion-saas", { scene: "cards", hue: 250, hue2: 200 }, "Clean SaaS motion design: rounded feature cards fly in and stack, each one highlighting a benefit, soft gradients and smooth easing", code("marketing/feature-cards", [field("headline", "Headline", 60, 2), field("point1", "First benefit", 60, 2), field("point2", "Second benefit", 60, 2), field("point3", "Third benefit", 60, 2)], { aspect: "4:5" })),
+ t("ms-kinetic-headline", "Kinetic Headline", "motion-saas", { scene: "kinetic", hue: 210, hue2: 260 }, "Kinetic typography: the product's promise types itself out word by word with confident motion, then resolves to the logo", code("marketing/kinetic-headline", [field("headline", "Headline", 90, 3, "Put *stars* round a word to highlight it"), field("cta", "Call to action", 24), field("website", "Web address", 40)], { aspect: "9:16", easy: [PACE, LOOK, { id: "align", label: "Align", choices: [{ id: "centre", label: "Centred" }, { id: "left", label: "Left" }] }] })),
t("ms-device-float", "Device Float", "motion-saas", { scene: "float", hue: 220, hue2: 170 }, "A laptop and a phone float in a soft gradient space showing the app's interface, the camera drifts slowly between them", { duration: 5 }),
- t("ms-dashboard-zoom", "Dashboard Zoom", "motion-saas", { scene: "cards", hue: 160, hue2: 220, dark: true }, "The camera pushes into a sleek dark dashboard; charts animate up and a key number counts to its value", { duration: 5 }),
- t("ms-logo-sting", "Logo Sting", "motion-saas", { scene: "burst", hue: 270, hue2: 210 }, "A short logo sting: geometric shapes converge and click together into the brand mark with a light flare", { duration: 5 }),
+ t("ms-dashboard-zoom", "Dashboard Zoom", "motion-saas", { scene: "cards", hue: 160, hue2: 220, dark: true }, "The camera pushes into a sleek dark dashboard; charts animate up and a key number counts to its value", code("marketing/stat-dashboard", [field("stat", "Key number", 16, 1, "Type it as it should read, e.g. $1,284,000"), field("label", "What it measures", 60, 2)], { aspect: "4:5" })),
+ t("ms-logo-sting", "Logo Sting", "motion-saas", { scene: "burst", hue: 270, hue2: 210 }, "A short logo sting: geometric shapes converge and click together into the brand mark with a light flare", code("marketing/logo-sting", [field("tagline", "Line under the logo", 60, 2)], { aspect: "4:5" })),
+ t("ms-big-number", "Big Number", "motion-saas", { scene: "headline", hue: 230, hue2: 260, dark: true }, "One huge stat fills the frame and counts up to its value, a caption rises under it, and it ends on the logo", code("marketing/big-number", [field("stat", "The number", 12, 1, "Type it as it should read, e.g. 3× or 98%"), field("caption", "Caption", 60, 3)], { aspect: "4:5" })),
+ t("ms-five-star-quote", "Five-Star Quote", "motion-saas", { scene: "stars", hue: 45, hue2: 30 }, "Five stars fill one by one, then a customer's words set line by line with their name", code("marketing/quote", [field("quote", "Quote", 180, 5, "Their words exactly, with your own quotation marks"), field("name", "Name", 48, 2)], { aspect: "4:5" })),
+ t("ms-end-card", "Logo End Card", "motion-saas", { scene: "headline", hue: 160, hue2: 45, dark: true }, "An animated end card: the logo draws on, the line rises and the call-to-action pill pops", code("end-card/draw-on", [field("product", "Line", 60, 2), field("cta", "Call to action", 24), field("website", "Web address", 40)], { aspect: "9:16", duration: 2.5, lengths: { min: 2, max: 3, default: 2.5 }, easy: [{ id: "style", label: "Style", scene: "end-card", choices: [{ id: "draw-on", label: "Draw-on" }, { id: "rise", label: "Rise" }, { id: "iris", label: "Iris" }, { id: "split", label: "Split" }, { id: "glint", label: "Glint" }] }, { id: "mark", label: "Mark", choices: [{ id: "logo", label: "Logo" }, { id: "name", label: "Name" }] }] })),
// UGC · talking head
t("ugc-honest-review", "Honest Review", "ugc-talking", { scene: "selfie", hue: 25, hue2: 200 }, "A relaxed, honest review straight to the phone camera: what they liked, one small catch and why they'd still buy it again", { setting: "bedroom" }),
diff --git a/src/lib/library.ts b/src/lib/library.ts
index ab15012b..03e728e2 100644
--- a/src/lib/library.ts
+++ b/src/lib/library.ts
@@ -34,6 +34,8 @@ export interface FeedFilter {
* out unless this is set, so a list that must see every job (a count of running jobs) sets it.
*/
steps?: boolean;
+ /** Only clips saved from this Marketing template (code-drawn: its Kinetic Motion recipe names it). */
+ template?: string;
}
/** Which timestamp a list is ordered (and paged) by: deletedAt in the Trash, pinnedAt in a pinned list, else createdAt. */
@@ -67,6 +69,7 @@ export function filterToSearch(f: FeedFilter, before?: string | number): URLSear
if (f.pinned !== undefined) qs.set("pinned", f.pinned ? "1" : "0");
if (f.reviews?.length) qs.set("reviews", f.reviews.join(","));
if (f.steps) qs.set("steps", "1");
+ if (f.template) qs.set("template", f.template);
if (before) qs.set("before", String(before));
qs.set("limit", String(f.limit ?? 80));
return qs;
@@ -90,11 +93,19 @@ export function matchesFilter(g: Generation, f: FeedFilter): boolean {
if (f.pinned !== undefined && !!g.pinnedAt !== f.pinned) return false;
if (f.reviews?.length && !f.reviews.includes(g.review ?? "none")) return false;
if (!f.steps && !f.features?.length && isHelperFeature(g.feature)) return false;
+ if (f.template && motionTemplateOf(g) !== f.template) return false;
const q = f.q?.trim().toLowerCase();
if (q && !`${g.prompt ?? ""}\n${g.request.prompt ?? ""}`.toLowerCase().includes(q)) return false;
return true;
}
+/** The Marketing template a saved Kinetic clip was made from (its recipe's controls.template). */
+export function motionTemplateOf(g: Pick<Generation, "request">): string | undefined {
+ const extra = (g.request.params as { extra?: { motion?: { controls?: { template?: unknown } } } } | undefined)?.extra;
+ const t = extra?.motion?.controls?.template;
+ return typeof t === "string" ? t : undefined;
+}
+
const byIdDesc = (a: Generation, b: Generation) => (a.id < b.id ? 1 : a.id > b.id ? -1 : 0);
/** Newest first, as the server orders lists (ties: id descending). */
diff --git a/src/lib/motion/display.ts b/src/lib/motion/display.ts
index 1c0c0e7e..db34652d 100644
--- a/src/lib/motion/display.ts
+++ b/src/lib/motion/display.ts
@@ -54,7 +54,8 @@ export interface Stroke {
export type Blend = "source-over" | "multiply" | "screen" | "overlay" | "lighter" | "source-atop";
-export type ClipShape = { type: "rect"; x: number; y: number; w: number; h: number; r?: number } | { type: "ellipse"; cx: number; cy: number; rx: number; ry: number };
+/** What a group is clipped to: a (rounded) rectangle, an ellipse, or a closed path (path data in design units). */
+export type ClipShape = { type: "rect"; x: number; y: number; w: number; h: number; r?: number } | { type: "ellipse"; cx: number; cy: number; rx: number; ry: number } | { type: "path"; d: string };
export interface GroupNode {
type: "group";
diff --git a/src/lib/motion/layout.ts b/src/lib/motion/layout.ts
index f0bd65e2..d82688fa 100644
--- a/src/lib/motion/layout.ts
+++ b/src/lib/motion/layout.ts
@@ -68,6 +68,11 @@ export interface TextSpec {
step?: number;
/** Letter boxes too (each costs a measurement per letter). */
letters?: boolean;
+ /**
+ * Even lines: when the shortest line is under this share of the longest (a lone word left on a line), sizes down to
+ * 85 % of the first one that fits are tried for a more even break. Off by default.
+ */
+ even?: number;
}
/** Scripts written without spaces between words: they may break between the words Intl.Segmenter finds. */
@@ -164,17 +169,21 @@ function greedyCount(a: number, b: number, width: number, w: Width): number {
return lines;
}
-/** The break of atoms a..b into exactly `n` lines whose widths are closest to each other (least squares). */
+/**
+ * The break of atoms a..b into exactly `n` lines whose widths are closest to each other (least squares), a line of one
+ * lone word costing more when there are words enough to keep each line at two or more.
+ */
function balancedBreaks(a: number, b: number, n: number, width: number, w: Width): number[] {
if (n <= 1) return [a];
const avg = w(a, b) / n;
const count = b - a + 1;
+ const lone = count >= 2 * n ? (avg * 0.4) ** 2 : 0;
// cost[l][j]: the best l + 1 lines ending at atom a + j; from[l][j]: where the last of them starts.
const cost = Array.from({ length: n }, () => new Float64Array(count).fill(Infinity));
const from = Array.from({ length: n }, () => new Int32Array(count).fill(-1));
for (let j = 0; j < count; j++) {
const lw = w(a, a + j);
- if (lw <= width) cost[0][j] = (lw - avg) ** 2;
+ if (lw <= width) cost[0][j] = (lw - avg) ** 2 + (j === 0 ? lone : 0);
}
for (let l = 1; l < n; l++) {
for (let j = l; j < count; j++) {
@@ -183,7 +192,7 @@ function balancedBreaks(a: number, b: number, n: number, width: number, w: Width
if (prev === Infinity) continue;
const lw = w(a + i, a + j);
if (lw > width) continue;
- const c = prev + (lw - avg) ** 2;
+ const c = prev + (lw - avg) ** 2 + (i === j ? lone : 0);
if (c < cost[l][j]) {
cost[l][j] = c;
from[l][j] = i;
@@ -299,10 +308,23 @@ export function layoutText(spec: TextSpec, measure: Measure): TextLayout {
for (;;) {
const last = size <= spec.min;
const got = attempt(size, last);
- if (got) return got;
+ if (got) return spec.even && !got.overflow ? evener(got, spec.even, (s) => attempt(s, false), Math.max(spec.min, size * 0.85), step) : got;
size = Math.max(spec.min, size * step);
}
}
+/** How even a layout's lines are: the shortest line's share of the longest (1: a single line). */
+const evenness = (l: TextLayout): number => (l.lines.length < 2 ? 1 : Math.min(...l.lines.map((x) => x.width)) / Math.max(1, l.width));
+
+/** The first size from `got` down to `floor` whose lines are even enough, else the most even one tried (else `got`). */
+function evener(got: TextLayout, even: number, attempt: (size: number) => TextLayout | null, floor: number, step: number): TextLayout {
+ let best = got;
+ for (let size = got.size * step; size >= floor - 1e-9 && evenness(best) < even; size *= step) {
+ const l = attempt(size);
+ if (l && l.lines.length <= got.lines.length && evenness(l) > evenness(best) + 0.05) best = l;
+ }
+ return best;
+}
+
/** The typed text back from a layout's lines (gap + text), for checks. */
export const spelled = (pieces: readonly { gap?: string; text: string }[]): string => pieces.map((p) => (p.gap ?? "") + p.text).join("");
diff --git a/src/lib/motion/marks.ts b/src/lib/motion/marks.ts
new file mode 100644
index 00000000..9cf33705
--- /dev/null
+++ b/src/lib/motion/marks.ts
@@ -0,0 +1,26 @@
+/**
+ * Highlights the person marks in a typed field (pure): a pair of stars round a word or a run of words ("*radiance*")
+ * marks it, and the stars are not drawn. Every other star is part of the words and is kept exactly as typed: a lone
+ * one ("Rated 5* by guests", "Free delivery*"), one inside a word ("a*b"), an empty pair ("**"), or a pair whose
+ * inside starts or ends with a space ("5 * 4 *").
+ */
+
+/** A pair: a star, then words that neither start nor end with a space and hold no star, then a star. */
+const PAIR = /\*([^\s*](?:[^*]*[^\s*])?)\*/gu;
+
+/** The text to set (the pairs' stars removed, every other star kept) and the marked spans in it. */
+export function marked(text: string): { text: string; marks: [number, number][] } {
+ const marks: [number, number][] = [];
+ let out = "";
+ let from = 0;
+ for (const m of text.matchAll(PAIR)) {
+ out += text.slice(from, m.index);
+ marks.push([out.length, out.length + m[1].length]);
+ out += m[1];
+ from = m.index + m[0].length;
+ }
+ return { text: out + text.slice(from), marks };
+}
+
+/** The words as they are set: the marking stars gone, every other star kept. */
+export const unmarked = (text: string): string => marked(text).text;
diff --git a/src/lib/motion/outline.ts b/src/lib/motion/outline.ts
new file mode 100644
index 00000000..2b6d024f
--- /dev/null
+++ b/src/lib/motion/outline.ts
@@ -0,0 +1,282 @@
+/**
+ * A cut-out's outline (pure): the outer edge of a picture's opaque part, traced from its transparency on a small grid
+ * (at most 256 px on its long side). Marching squares find the edge at half opacity between pixels, the outer loop of
+ * the largest piece is kept, Ramer–Douglas–Peucker drops the points a straight line already passes, and the rest is
+ * joined with smooth curves (Catmull–Rom as cubic Béziers). The path starts at the lowest point, so a line drawn along
+ * the ground can run straight into it. A picture with no transparency gives null: it gets a drawn frame instead.
+ */
+
+import type { Outline } from "./scene";
+
+/** The grid's long side. */
+export const OUTLINE_GRID = 256;
+
+type Pt = [number, number];
+
+/** The largest 8-connected piece of `mask` (1 inside), as its own mask, and its size. */
+function largestPiece(mask: Uint8Array, w: number, h: number): { piece: Uint8Array; area: number } {
+ const label = new Int32Array(w * h);
+ const stack = new Int32Array(w * h);
+ let best = 0;
+ let bestArea = 0;
+ let next = 0;
+ for (let i = 0; i < w * h; i++) {
+ if (!mask[i] || label[i]) continue;
+ next++;
+ let area = 0;
+ let top = 0;
+ stack[top++] = i;
+ label[i] = next;
+ while (top) {
+ const p = stack[--top];
+ area++;
+ const x = p % w;
+ const y = (p - x) / w;
+ for (let dy = -1; dy <= 1; dy++) {
+ const yy = y + dy;
+ if (yy < 0 || yy >= h) continue;
+ for (let dx = -1; dx <= 1; dx++) {
+ const xx = x + dx;
+ if (xx < 0 || xx >= w || (!dx && !dy)) continue;
+ const q = yy * w + xx;
+ if (mask[q] && !label[q]) {
+ label[q] = next;
+ stack[top++] = q;
+ }
+ }
+ }
+ }
+ if (area > bestArea) {
+ bestArea = area;
+ best = next;
+ }
+ }
+ const piece = new Uint8Array(w * h);
+ for (let i = 0; i < w * h; i++) piece[i] = label[i] === best ? 1 : 0;
+ return { piece, area: bestArea };
+}
+
+/**
+ * The marching-squares loops of `field` (values 0..255, padded by a zero border) at `iso`. Edge points sit where the
+ * value crosses `iso` along a cell's side (interpolated), so the loop is sub-pixel smooth.
+ */
+function loops(field: Float32Array, W: number, H: number, iso: number): Pt[][] {
+ // Corners are pixel centres; cell (x, y) spans corners x..x+1, y..y+1.
+ const v = (x: number, y: number) => field[y * W + x];
+ const hKey = (x: number, y: number) => (y * W + x) * 2;
+ const vKey = (x: number, y: number) => (y * W + x) * 2 + 1;
+ const point = new Map<number, Pt>();
+ const at = (key: number): Pt => {
+ let p = point.get(key);
+ if (p) return p;
+ const cell = key >> 1;
+ const x = cell % W;
+ const y = (cell - x) / W;
+ if (key & 1) {
+ // Vertical side from (x, y) to (x, y + 1).
+ const a = v(x, y);
+ const b = v(x, y + 1);
+ p = [x, y + (iso - a) / (b - a || 1)];
+ } else {
+ const a = v(x, y);
+ const b = v(x + 1, y);
+ p = [x + (iso - a) / (b - a || 1), y];
+ }
+ point.set(key, p);
+ return p;
+ };
+ const links = new Map<number, number[]>();
+ const link = (a: number, b: number) => {
+ (links.get(a) ?? links.set(a, []).get(a)!).push(b);
+ (links.get(b) ?? links.set(b, []).get(b)!).push(a);
+ };
+ for (let y = 0; y < H - 1; y++) {
+ for (let x = 0; x < W - 1; x++) {
+ const tl = v(x, y) >= iso ? 8 : 0;
+ const tr = v(x + 1, y) >= iso ? 4 : 0;
+ const br = v(x + 1, y + 1) >= iso ? 2 : 0;
+ const bl = v(x, y + 1) >= iso ? 1 : 0;
+ const c = tl | tr | br | bl;
+ if (c === 0 || c === 15) continue;
+ const T = hKey(x, y);
+ const B = hKey(x, y + 1);
+ const L = vKey(x, y);
+ const R = vKey(x + 1, y);
+ const centre = (v(x, y) + v(x + 1, y) + v(x + 1, y + 1) + v(x, y + 1)) / 4 >= iso;
+ switch (c) {
+ case 1: case 14: link(L, B); break;
+ case 2: case 13: link(B, R); break;
+ case 3: case 12: link(L, R); break;
+ case 4: case 11: link(T, R); break;
+ case 6: case 9: link(T, B); break;
+ case 7: case 8: link(T, L); break;
+ case 5:
+ if (centre) {
+ link(T, L);
+ link(B, R);
+ } else {
+ link(T, R);
+ link(L, B);
+ }
+ break;
+ case 10:
+ if (centre) {
+ link(T, R);
+ link(L, B);
+ } else {
+ link(T, L);
+ link(B, R);
+ }
+ break;
+ }
+ }
+ }
+ const seen = new Set<number>();
+ const out: Pt[][] = [];
+ for (const start of links.keys()) {
+ if (seen.has(start)) continue;
+ const loop: Pt[] = [];
+ let prev = -1;
+ let cur = start;
+ for (;;) {
+ seen.add(cur);
+ loop.push(at(cur));
+ const nbrs = links.get(cur)!;
+ const nxt = nbrs[0] !== prev ? nbrs[0] : nbrs[1];
+ if (nxt === undefined || nxt === start || seen.has(nxt)) break;
+ prev = cur;
+ cur = nxt;
+ }
+ if (loop.length > 2) out.push(loop);
+ }
+ return out;
+}
+
+const perimeter = (pts: Pt[]) => pts.reduce((s, p, i) => s + Math.hypot(p[0] - pts[(i + 1) % pts.length][0], p[1] - pts[(i + 1) % pts.length][1]), 0);
+
+/** Ramer–Douglas–Peucker on an open polyline. */
+function simplify(pts: Pt[], eps: number): Pt[] {
+ if (pts.length < 3) return pts.slice();
+ const keep = new Uint8Array(pts.length);
+ keep[0] = keep[pts.length - 1] = 1;
+ const stack: [number, number][] = [[0, pts.length - 1]];
+ while (stack.length) {
+ const [a, b] = stack.pop()!;
+ const [ax, ay] = pts[a];
+ const [bx, by] = pts[b];
+ const len = Math.hypot(bx - ax, by - ay) || 1;
+ let far = -1;
+ let at = -1;
+ for (let i = a + 1; i < b; i++) {
+ const d = Math.abs((bx - ax) * (ay - pts[i][1]) - (ax - pts[i][0]) * (by - ay)) / len;
+ if (d > far) {
+ far = d;
+ at = i;
+ }
+ }
+ if (far > eps && at > 0) {
+ keep[at] = 1;
+ stack.push([a, at], [at, b]);
+ }
+ }
+ return pts.filter((_, i) => keep[i]);
+}
+
+const r2 = (n: number) => Math.round(n * 100) / 100;
+
+/** A closed loop through `pts` as smooth cubic Béziers (uniform Catmull–Rom), with its length. */
+export function smoothClosedPath(pts: Pt[]): { d: string; length: number } {
+ const n = pts.length;
+ const parts = [`M${r2(pts[0][0])} ${r2(pts[0][1])}`];
+ let length = 0;
+ for (let i = 0; i < n; i++) {
+ const p0 = pts[(i - 1 + n) % n];
+ const p1 = pts[i];
+ const p2 = pts[(i + 1) % n];
+ const p3 = pts[(i + 2) % n];
+ const c1: Pt = [p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6];
+ const c2: Pt = [p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6];
+ parts.push(`C${r2(c1[0])} ${r2(c1[1])} ${r2(c2[0])} ${r2(c2[1])} ${r2(p2[0])} ${r2(p2[1])}`);
+ // The curve's length, from 12 points along it.
+ let px = p1[0];
+ let py = p1[1];
+ for (let k = 1; k <= 12; k++) {
+ const t = k / 12;
+ const u = 1 - t;
+ const x = u * u * u * p1[0] + 3 * u * u * t * c1[0] + 3 * u * t * t * c2[0] + t * t * t * p2[0];
+ const y = u * u * u * p1[1] + 3 * u * u * t * c1[1] + 3 * u * t * t * c2[1] + t * t * t * p2[1];
+ length += Math.hypot(x - px, y - py);
+ px = x;
+ py = y;
+ }
+ }
+ parts.push("Z");
+ return { d: parts.join(""), length };
+}
+
+/**
+ * The outline of a picture's opaque part from its alpha (one byte a pixel, `w` × `h`, on the traced grid), or null
+ * when the picture has no real transparency or no piece big enough to trace.
+ */
+export function traceOutline(alpha: ArrayLike<number>, w: number, h: number): Outline | null {
+ const n = w * h;
+ if (!n) return null;
+ let clear = 0;
+ for (let i = 0; i < n; i++) if (alpha[i] < 128) clear++;
+ // Nearly no transparency: a photo, not a cut-out.
+ if (clear < n * 0.02) return null;
+ const mask = new Uint8Array(n);
+ for (let i = 0; i < n; i++) mask[i] = alpha[i] >= 128 ? 1 : 0;
+ const { piece, area } = largestPiece(mask, w, h);
+ if (area < n * 0.005) return null;
+ // The piece's own alpha on a grid with a clear border one pixel wide.
+ const W = w + 2;
+ const H = h + 2;
+ const field = new Float32Array(W * H);
+ for (let y = 0; y < h; y++) {
+ for (let x = 0; x < w; x++) {
+ const i = y * w + x;
+ // Pixels next to the piece keep their soft alpha (the edge stays smooth); the rest is clear.
+ let near = piece[i];
+ if (!near) {
+ for (let dy = -1; dy <= 1 && !near; dy++) for (let dx = -1; dx <= 1 && !near; dx++) {
+ const xx = x + dx;
+ const yy = y + dy;
+ if (xx >= 0 && yy >= 0 && xx < w && yy < h && piece[yy * w + xx]) near = 1;
+ }
+ }
+ field[(y + 1) * W + x + 1] = near ? alpha[i] : 0;
+ }
+ }
+ const all = loops(field, W, H, 127.5);
+ if (!all.length) return null;
+ const outer = all.reduce((a, b) => (perimeter(b) > perimeter(a) ? b : a));
+ // Back to picture pixels (the border shifts by one), the pixel centres at +0.5.
+ let pts: Pt[] = outer.map(([x, y]) => [x - 0.5, y - 0.5]);
+ // Clockwise on screen (y down): a positive signed area.
+ const signed = pts.reduce((s, p, i) => s + p[0] * pts[(i + 1) % pts.length][1] - pts[(i + 1) % pts.length][0] * p[1], 0);
+ if (signed < 0) pts.reverse();
+ // Start at the lowest point (nearest the middle on a flat base).
+ const maxY = Math.max(...pts.map((p) => p[1]));
+ const cx = pts.reduce((s, p) => s + p[0], 0) / pts.length;
+ let start = 0;
+ let best = Infinity;
+ pts.forEach((p, i) => {
+ if (p[1] < maxY - 0.75) return;
+ const d = Math.abs(p[0] - cx);
+ if (d < best) {
+ best = d;
+ start = i;
+ }
+ });
+ pts = [...pts.slice(start), ...pts.slice(0, start)];
+ // A closed loop is simplified as two halves, split at the point farthest from the start.
+ let far = 0;
+ pts.forEach((p, i) => {
+ if (Math.hypot(p[0] - pts[0][0], p[1] - pts[0][1]) > Math.hypot(pts[far][0] - pts[0][0], pts[far][1] - pts[0][1])) far = i;
+ });
+ const simple = [...simplify(pts.slice(0, far + 1), 0.6).slice(0, -1), ...simplify([...pts.slice(far), pts[0]], 0.6).slice(0, -1)];
+ if (simple.length < 3) return null;
+ const { d, length } = smoothClosedPath(simple);
+ return { w, h, d, length, start: [r2(simple[0][0]), r2(simple[0][1])] };
+}
diff --git a/src/lib/motion/recipe.ts b/src/lib/motion/recipe.ts
index afa6c840..48efe174 100644
--- a/src/lib/motion/recipe.ts
+++ b/src/lib/motion/recipe.ts
@@ -11,7 +11,11 @@ import { rng } from "./random";
export const RECIPE_MAX_BYTES = 64 * 1024;
const Hex = z.string().regex(/^#[0-9a-fA-F]{6}$/);
-const File = z.string().startsWith("/api/files/").max(500);
+/** A picture the clip is made from: the person's own stored file, or one of Fuobe's own sample pictures. */
+const File = z
+ .string()
+ .max(500)
+ .refine((u) => (u.startsWith("/api/files/") || u.startsWith("/previews/")) && !u.includes(".."), "A stored file or a sample picture");
export const RecipeSchema = z.object({
v: z.literal(1),
diff --git a/src/lib/motion/registry.ts b/src/lib/motion/registry.ts
index a38ec784..3683a759 100644
--- a/src/lib/motion/registry.ts
+++ b/src/lib/motion/registry.ts
@@ -10,6 +10,15 @@ const LOADERS: Record<string, () => Promise<{ default: Scene }>> = {
"end-card/iris": () => import("./scenes/end-card/iris"),
"end-card/split": () => import("./scenes/end-card/split"),
"end-card/glint": () => import("./scenes/end-card/glint"),
+ "marketing/kinetic-headline": () => import("./scenes/marketing/kinetic-headline"),
+ "marketing/line-reveal": () => import("./scenes/marketing/line-reveal"),
+ "marketing/logo-sting": () => import("./scenes/marketing/logo-sting"),
+ "marketing/feature-cards": () => import("./scenes/marketing/feature-cards"),
+ "marketing/stat-dashboard": () => import("./scenes/marketing/stat-dashboard"),
+ "marketing/starburst": () => import("./scenes/marketing/starburst"),
+ "marketing/offer-badge": () => import("./scenes/marketing/offer-badge"),
+ "marketing/big-number": () => import("./scenes/marketing/big-number"),
+ "marketing/quote": () => import("./scenes/marketing/quote"),
};
export const SCENE_IDS = Object.keys(LOADERS);
diff --git a/src/lib/motion/scene.ts b/src/lib/motion/scene.ts
index 3975a5c8..9845208c 100644
--- a/src/lib/motion/scene.ts
+++ b/src/lib/motion/scene.ts
@@ -34,7 +34,22 @@ export interface SceneInput {
recipe: Recipe;
measure: Measure;
logo: LogoInfo | null;
+ /** The pictures' natural sizes by key ("product"). */
images?: Record<string, { w: number; h: number }>;
+ /** A cut-out picture's outline by key (traced from its transparency; null: it has none, so it gets a frame). */
+ outlines?: Record<string, Outline | null>;
+}
+
+/** A cut-out's outer edge, traced from its transparency (outline.ts), in the traced grid's units. */
+export interface Outline {
+ /** The grid it was traced on (the picture scaled to it). */
+ w: number;
+ h: number;
+ /** A closed smooth path, starting at its lowest point and going round. */
+ d: string;
+ length: number;
+ /** Where the path starts (its lowest point). */
+ start: [number, number];
}
export interface ScenePlan {
diff --git a/src/lib/motion/scenes/end-card/shared.ts b/src/lib/motion/scenes/end-card/shared.ts
index ef485135..f49ae3d3 100644
--- a/src/lib/motion/scenes/end-card/shared.ts
+++ b/src/lib/motion/scenes/end-card/shared.ts
@@ -40,6 +40,8 @@ export interface TextBlock {
cx: number;
y: number;
color: string;
+ /** Set flush to one side instead of centred: lines start at `left` (a right-to-left line ends at left + width). */
+ flush?: { left: number; width: number };
}
export interface EndCardRest {
@@ -153,7 +155,11 @@ export function endCardRest(p: { theme: AdTheme; content: EndCardContent; logo:
// Text runs
/** Where line `i` of a block is drawn: its left edge and the top of its glyphs (as the still card's drawText). */
-export const lineLeft = (b: TextBlock, i: number) => b.cx - b.layout.lines[i].width / 2;
+export const lineLeft = (b: TextBlock, i: number) => {
+ const w = b.layout.lines[i].width;
+ if (!b.flush) return b.cx - w / 2;
+ return b.layout.dir === "rtl" ? b.flush.left + b.flush.width - w : b.flush.left;
+};
export const glyphTop = (b: TextBlock, i: number) => b.y + i * b.layout.lineHeight + (b.layout.lineHeight - b.layout.size) / 2;
export interface RunStyle {
@@ -346,9 +352,15 @@ export function endCardScene(variant: EndCardVariant, build: (c: StyleContext) =
const style = build({ rest, input, second: secondColour(input.recipe.brand.colors, theme.accent) });
const k = timeScale(input.recipe.duration);
const lead = (style.lead ?? 0) * k;
- const tl = timeline(scaleCues(style.cues, k).map((e) => ({ ...e, start: Math.round((e.start - lead) * 1e6) / 1e6 })));
// The last frame: the poster, the still card, and where the camera comes home.
const last = (frameCount(input.recipe.duration, input.recipe.fps) - 1) / input.recipe.fps;
+ const cued = scaleCues(style.cues, k).map((e) => ({ ...e, start: e.start - lead }));
+ // On its own (Marketing's Logo End Card, not the tail of an ad) the card's beats spread out until it settles at
+ // about 70 % of its length; each move keeps its own speed.
+ const own = typeof input.recipe.controls?.template === "string";
+ const ends = Math.max(0.3, ...cued.map((e) => e.start + e.dur));
+ const f = own ? Math.max(1, Math.min(2.4, (last * 0.72) / ends)) : 1;
+ const tl = timeline(cued.map((e) => ({ ...e, start: Math.round((e.start > 0 ? e.start * f : e.start) * 1e6) / 1e6 })));
const settled = Math.min(last, tl.rest);
const still: DisplayList = { w: design.w, h: design.h, background: theme.accent, nodes: restNodes(rest) };
const drift = curve("drift");
diff --git a/src/lib/motion/scenes/marketing/big-number.ts b/src/lib/motion/scenes/marketing/big-number.ts
new file mode 100644
index 00000000..00e9553b
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/big-number.ts
@@ -0,0 +1,59 @@
+/**
+ * Big Number: one stat as big as the frame allows, edge to edge, rolling up figure by figure to the value the person
+ * typed (tabular cells, their own separators and signs, in lining figures); the caption rises under it, and the piece
+ * ends on the logo (or the brand's name) settling in at the foot. The beats spread over the clip's length.
+ */
+
+import { about, group, type DisplayNode } from "../../display";
+import { brandMark, centreFigures, counterLayout, counterNode, ev, figureFamily, marketingScene, risingLines, setText, spread, textBlock } from "./kit";
+
+export default marketingScene({
+ id: "marketing/big-number",
+ name: "Big Number",
+ look: "brand",
+ build(c) {
+ const { S, safe, palette: pal, design } = c;
+ const markH = S * (c.wide ? 0.085 : 0.08);
+ const mark = brandMark(c, { maxW: S * 0.5, h: markH, color: pal.ink, minName: 0.04 });
+ const footH = mark?.h ?? 0;
+ const room = safe.h - (footH ? footH + S * 0.06 : 0);
+ const stat = centreFigures(counterLayout("stat", c.field("stat", "0"), figureFamily(c, 800), 800, safe.w, Math.min(S * 0.8, room * 0.58), S * 0.1, c.measure), c.measure);
+ const caption = setText(c, c.field("caption"), { weight: 700, width: Math.min(safe.w, S * 1.3), maxLines: 3, max: S * 0.075, min: S * 0.05, lineHeight: 1.12 });
+ const statH = stat.size * 1.0;
+ const gap = S * 0.04;
+ const stackH = statH + (caption ? gap + caption.height : 0);
+ const top = safe.y + Math.max(0, (room - stackH) / 2);
+ const statLeft = (design.w - stat.width) / 2;
+ // The figures' glyphs sit a little low in their line box: lift them so the stack is optically centred.
+ const statTop = top - stat.size * 0.06;
+ const capB = caption ? textBlock("caption", caption, { y: top + statH + gap, color: pal.ink, cx: design.w / 2 }) : null;
+ const footY = safe.y + safe.h - footH;
+
+ // Three beats over the clip: the count, the caption, the sign-off.
+ const k = spread(c, 1.8, 2.4);
+ const lines = caption?.lines.length ?? 0;
+ const events = [
+ ev("count", "move", 0.12, Math.min(2.4, 1.45 * k), "linear"),
+ ev("stat.in", "enter", 0.1, 0.7, "settle"),
+ ...Array.from({ length: lines }, (_, i) => ev(`cap.${i}`, "enter", 0.9 * k + i * 0.09, 0.55, "glide", { group: "caption", unit: "elements" })),
+ ...(mark ? [ev("mark", "enter", 1.5 * k, 0.6, "settle")] : []),
+ ];
+
+ return {
+ events,
+ overflow: [...(stat.overflow ? ["stat"] : []), ...(caption?.overflow ? ["caption"] : []), ...(mark?.overflow ? ["brand"] : [])],
+ signature: 0.12 + 0.6 * k,
+ frame(_t, P, Lp) {
+ const nodes: DisplayNode[] = [];
+ const lin = Lp("stat.in");
+ if (lin > 0) {
+ const s = 1.08 - 0.08 * P("stat.in");
+ nodes.push(group([counterNode(stat, statLeft, statTop, pal.ink, Lp("count"))], { transform: about(design.w / 2, statTop + stat.size / 2, s), ...(lin < 0.25 && { opacity: lin / 0.25 }) }));
+ }
+ if (capB) nodes.push(...risingLines(capB, (i) => P(`cap.${i}`)));
+ if (mark) nodes.push(...mark.draw(design.w / 2, footY, P("mark"), Lp("mark")));
+ return { nodes };
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/feature-cards.ts b/src/lib/motion/scenes/marketing/feature-cards.ts
new file mode 100644
index 00000000..5d55bb34
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/feature-cards.ts
@@ -0,0 +1,122 @@
+/**
+ * Feature Cards: the headline rises, then up to three rounded cards fly in from near the camera (bigger, tilted, from
+ * below) and settle into a stack, one beat apart, each ticking its check as it lands; the headline drifts less than the
+ * cards, so the stack reads in depth, and the camera keeps a slow drift the whole clip long. The brand signs off at the
+ * foot (its logo, else its name). Each card carries one benefit, set exactly as typed, its lines kept even. A tall frame
+ * stacks them, bigger, and centres the whole; a wide one sets them side by side.
+ */
+
+import { about, group, multiply, translate, type DisplayNode } from "../../display";
+import { lineRuns } from "../end-card/shared";
+import { brandMark, ev, marketingScene, MIN_BODY, MIN_HEAD, risingLines, setText, shadowOf, spread, textBlock } from "./kit";
+import type { TextLayout } from "../../layout";
+
+export const FEATURE_FIELDS = ["point1", "point2", "point3"] as const;
+
+export default marketingScene({
+ id: "marketing/feature-cards",
+ name: "Feature Cards",
+ look: "light",
+ build(c) {
+ const { S, safe, palette: pal, design } = c;
+ const row = c.wide;
+ // A tall frame has room to spare: everything a size up.
+ // Set at a scale (a tall frame has room to spare: everything a size up), then a step down while the whole does not
+ // fit over the sign-off.
+ const points = FEATURE_FIELDS.map((f) => ({ field: f, text: c.field(f) })).filter((p) => p.text);
+ const set = (g: number) => {
+ const head = setText(c, c.field("headline"), { weight: 800, width: row ? Math.min(safe.w, S * 1.4) : safe.w, maxLines: c.tall ? 3 : 2, max: S * (row ? 0.085 : 0.1 * g), min: S * MIN_HEAD, lineHeight: 1.06 });
+ // The brand signs the stack off at the foot.
+ const mark = brandMark(c, { maxW: S * (row ? 0.36 : 0.52), h: S * (row ? 0.07 : 0.08 * g), color: pal.ink, minName: 0.04 });
+ const footH = mark ? mark.h + S * 0.055 : 0;
+ const pad = S * 0.042 * g;
+ const badge = S * 0.074 * g;
+ const gap = S * (row ? 0.032 : 0.03 * g);
+ const cardW = row ? (safe.w - gap * (Math.max(1, points.length) - 1)) / Math.max(1, points.length) : Math.min(safe.w, S * 0.96);
+ const textW = row ? cardW - 2 * pad : cardW - 3 * pad - badge;
+ const texts: { field: string; L: TextLayout | null }[] = points.map((p) => ({ field: p.field, L: setText(c, p.text, { family: "body", weight: 700, width: textW, maxLines: row ? 4 : 2, max: S * 0.05 * g, min: S * MIN_BODY, lineHeight: 1.22 }) }));
+ const textHs = texts.map((t) => t.L?.height ?? 0);
+ const cardH = row ? badge + pad * 0.7 + Math.max(0, ...textHs) + 2 * pad : 0;
+ const heights = texts.map((_, i) => (row ? cardH : Math.max(badge, textHs[i]) + 2 * pad));
+ const stackH = row ? cardH : heights.reduce((s, h) => s + h, 0) + gap * Math.max(0, heights.length - 1);
+ const headGap = S * 0.07 * g;
+ const total = (head ? head.height + headGap : 0) + stackH;
+ return { g, head, mark, footH, pad, badge, gap, cardW, textW, texts, cardH, heights, headGap, total };
+ };
+ let L = set(c.tall ? 1.22 : 1);
+ for (let i = 0; i < 4 && L.total + L.footH > safe.h; i++) L = set(L.g * 0.9);
+ const { head, mark, footH, pad, badge, gap, cardW, textW, texts, cardH, heights, headGap, total, g } = L;
+ // Centred in what the sign-off leaves.
+ const top = safe.y + Math.max(0, (safe.h - footH - total) / 2);
+ const footY = safe.y + safe.h - (mark?.h ?? 0);
+ const headB = head ? textBlock("headline", head, { y: top, color: pal.ink, cx: design.w / 2 }) : null;
+ let y = top + (head ? head.height + headGap : 0);
+ const left0 = row ? safe.x : (design.w - cardW) / 2;
+ const cards = texts.map((t, i) => {
+ const box = row ? { x: left0 + i * (cardW + gap), y, w: cardW, h: cardH } : { x: left0, y, w: cardW, h: heights[i] };
+ if (!row) y += heights[i] + gap;
+ const bx = box.x + pad + badge / 2;
+ const by = row ? box.y + pad + badge / 2 : box.y + box.h / 2;
+ const tx = row ? box.x + pad : box.x + 2 * pad + badge;
+ const ty = row ? box.y + pad + badge + pad * 0.7 : box.y + (box.h - (t.L?.height ?? 0)) / 2;
+ const block = t.L ? textBlock(t.field, t.L, { y: ty, color: pal.surfaceInk, left: tx, width: textW }) : null;
+ return { box, badge: { cx: bx, cy: by, r: badge / 2 }, block };
+ });
+
+ // The beats, spread over the length: the headline, the cards one by one, the sign-off.
+ const k = spread(c, 2.6);
+ const lines = head?.lines.length ?? 0;
+ const cardAt = 0.15 + (lines ? 0.35 + lines * 0.09 : 0) * k;
+ const fly = 0.62;
+ const each = Math.min(0.45, 0.14 * k * k);
+ const landed = cardAt + each * Math.max(0, cards.length - 1) + fly;
+ const events = [
+ ...Array.from({ length: lines }, (_, i) => ev(`head.${i}`, "enter", 0.15 + i * 0.09, 0.55, "glide", { group: "head", unit: "elements" })),
+ ...cards.map((_, i) => ev(`card.${i}`, "enter", cardAt + i * each, fly, "enter")),
+ ...cards.map((_, i) => ev(`check.${i}`, "draw", cardAt + i * each + fly * 0.7, 0.35, "draw")),
+ ev("pan", "camera", 0, c.last, "drift"),
+ ...(mark ? [ev("brand", "enter", landed + 0.25 * k, 0.6, "glide")] : []),
+ ];
+ const tilt = (i: number) => (i % 2 ? 0.07 : -0.08);
+ const shadow = shadowOf(pal.ground, pal.look === "light" ? 0.1 : 0.32);
+ const radius = S * 0.034 * g;
+
+ return {
+ events,
+ overflow: [...(head?.overflow ? ["headline"] : []), ...(mark?.overflow ? ["brand"] : []), ...texts.filter((t) => t.L?.overflow).map((t) => t.field)],
+ signature: cardAt + each + fly * 0.45,
+ frame(_t, P, Lp) {
+ // The slow drift: the cards travel a little farther than the headline (depth), home on the last frame.
+ const pan = (1 - P("pan")) * S * 0.05;
+ const nodes: DisplayNode[] = [];
+ if (headB) nodes.push(group(risingLines(headB, (i) => P(`head.${i}`)), { transform: translate(pan * 0.35, 0) }));
+ cards.forEach((card, i) => {
+ const q = P(`card.${i}`);
+ const lin = Lp(`card.${i}`);
+ if (lin <= 0) return;
+ const { box } = card;
+ const ccx = box.x + box.w / 2;
+ const ccy = box.y + box.h / 2;
+ const u = 1 - q;
+ // From near the camera: bigger, tilted, from below (beside, on a wide frame), then down into the stack.
+ const m = multiply(translate(pan + (row ? 0 : u * S * 0.05 * (i % 2 ? 1 : -1)), u * S * (row ? 0.22 : 0.3)), about(ccx, ccy, 1 + 0.16 * u, tilt(i) * u));
+ const check = P(`check.${i}`);
+ const r = card.badge.r;
+ const children: DisplayNode[] = [
+ { type: "rect", x: box.x, y: box.y + S * 0.014 + u * S * 0.02, w: box.w, h: box.h, r: radius, fill: shadow },
+ { type: "rect", x: box.x, y: box.y, w: box.w, h: box.h, r: radius, fill: pal.surface },
+ { type: "ellipse", cx: card.badge.cx, cy: card.badge.cy, rx: r, ry: r, fill: pal.highlight.fill },
+ ];
+ if (check > 0) {
+ const d = `M${card.badge.cx - r * 0.42} ${card.badge.cy + r * 0.02}L${card.badge.cx - r * 0.1} ${card.badge.cy + r * 0.34}L${card.badge.cx + r * 0.45} ${card.badge.cy - r * 0.3}`;
+ children.push({ type: "path", d, stroke: { paint: pal.highlight.ink, width: r * 0.2, trim: check, length: r * 1.3, cap: "round", join: "round" } });
+ }
+ if (card.block) children.push(lineRuns(card.block));
+ nodes.push(group(children, { transform: m, ...(lin < 0.3 && { opacity: lin / 0.3 }) }));
+ });
+ if (mark) nodes.push(...mark.draw(design.w / 2, footY, P("brand"), Lp("brand")));
+ return { nodes };
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/kinetic-headline.ts b/src/lib/motion/scenes/marketing/kinetic-headline.ts
new file mode 100644
index 00000000..96d98c2f
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/kinetic-headline.ts
@@ -0,0 +1,141 @@
+/**
+ * Kinetic Headline: the promise sets word by word on a beat. Each word lands with a spring and the words the person
+ * marked with *stars* get a swatch in the kit's highlight colour (a lone star is part of the words and is drawn). The
+ * camera leans in as each new line starts and keeps a slow push while the words are read. Then the words lift away and
+ * the piece resolves to the logo with the Draw-on end card: on a dark brand colour the ground is that colour already,
+ * so the card simply sets on it; otherwise the brand colour opens out from the middle of the frame.
+ */
+
+import { group, translate, type DisplayNode, type TextRun } from "../../display";
+import { sample, type Key } from "../../tween";
+import drawOn from "../end-card/draw-on";
+import { glyphTop, lineLeft } from "../end-card/shared";
+import { ev, marked, marketingScene, MIN_HEAD, setText, textBlock } from "./kit";
+
+/** The end card's share of the clip. */
+const CARD = 2.3;
+
+export default marketingScene({
+ id: "marketing/kinetic-headline",
+ name: "Kinetic Headline",
+ look: "light",
+ build(c) {
+ const { S, safe, palette: pal, design, recipe, pace } = c;
+ const typed = c.field("headline") || recipe.brand.name.trim();
+ const m = marked(typed);
+ const lead = m.text.length - m.text.trimStart().length;
+ const text = m.text.trim();
+ const marks = m.marks.map(([a, b]) => [a - lead, b - lead] as const);
+ const flushLeft = recipe.controls?.align === "left";
+ const width = c.wide ? Math.min(safe.w, S * 1.45) : safe.w;
+ const L = setText(c, text, { weight: 800, width, maxLines: c.tall ? 5 : c.wide ? 3 : 4, max: S * (c.tall ? 0.17 : c.wide ? 0.13 : 0.145), min: S * MIN_HEAD, lineHeight: 1.08 });
+ const y = L ? safe.y + (safe.h - L.height) / 2 - S * 0.02 : safe.y;
+ const left = (design.w - width) / 2;
+ const block = L ? textBlock("headline", L, { y, color: pal.ink, ...(flushLeft ? { left, width } : { cx: design.w / 2 }) }) : null;
+
+ // The words in reading order, each with where it sits and whether it's marked.
+ interface Word {
+ line: number;
+ text: string;
+ gap: string;
+ x: number;
+ y: number;
+ w: number;
+ hot: boolean;
+ }
+ const words: Word[] = [];
+ if (block && L) {
+ let at = 0;
+ L.lines.forEach((line, i) => {
+ const x0 = lineLeft(block, i);
+ const top = glyphTop(block, i);
+ for (const w of line.words) {
+ at += w.gap.length;
+ const a = at;
+ const b = at + w.text.length;
+ at = b;
+ words.push({ line: i, text: w.text, gap: w.gap, x: x0 + w.x, y: top, w: w.w, hot: marks.some(([p, q]) => p < b && q > a) });
+ }
+ });
+ }
+
+ // The end card: the logo (or the name), the call to action and the address, drawn by the Draw-on style.
+ const T0 = recipe.duration - CARD;
+ const card = drawOn.plan({
+ ...c.input,
+ recipe: { ...recipe, scene: "end-card/draw-on", duration: CARD, fields: { brand: recipe.brand.name, product: "", ...(c.field("cta") && { cta: c.field("cta") }), ...(c.field("website") && { website: c.field("website") }) } },
+ });
+ const exitAt = T0 - 0.45;
+ const read = Math.max(0.7, 0.28 * exitAt);
+ const n = Math.max(1, words.length);
+ const pop = 0.5 * pace;
+ const beat = n > 1 ? Math.min(0.42 * pace, Math.max(0.09, (exitAt - read - pop - 0.12) / (n - 1))) : 0;
+ const events = words.flatMap((w, i) => {
+ const s = 0.12 + i * beat;
+ return [ev(`word.${i}`, "pop", s, pop, "pop"), ...(w.hot ? [ev(`mark.${i}`, "draw", s + 0.05, 0.36, "snap")] : [])];
+ });
+ events.push(ev("words.exit", "exit", exitAt, 0.4, "exit"), ev("panel", "enter", exitAt + 0.05, 0.5, "move"));
+ for (const e of card.timeline.events) events.push({ ...e, id: `card.${e.id}`, start: Math.round((e.start + T0) * 1e6) / 1e6 });
+
+ // The camera leans in a little as each line starts, and follows it.
+ const lines = L?.lines.length ?? 0;
+ const firstOf = (line: number) => words.findIndex((w) => w.line === line);
+ const zoom: Key[] = [{ t: 0, v: 1 }];
+ const pan: Key[] = [{ t: 0, v: 0 }];
+ for (let k = 1; k < lines; k++) {
+ const s = 0.12 + firstOf(k) * beat;
+ const mid = block && L ? glyphTop(block, k) + L.size / 2 - (y + L.height / 2) : 0;
+ zoom.push({ t: s - 0.05, v: zoom[zoom.length - 1].v }, { t: s + 0.55, v: 1 + 0.025 * k, ease: "move" });
+ pan.push({ t: s - 0.05, v: pan[pan.length - 1].v }, { t: s + 0.55, v: -mid * 0.12, ease: "move" });
+ }
+
+ // A slow push while the words are read, up to the moment they leave.
+ const z0 = zoom[zoom.length - 1];
+ if (exitAt > z0.t + 0.3) zoom.push({ t: exitAt, v: z0.v + 0.03, ease: "move" });
+ const cardGround = card.evaluate(0).background;
+ const same = typeof cardGround === "string" && cardGround.toLowerCase() === pal.ground.toLowerCase();
+ const R = Math.hypot(design.w, design.h) / 2 + 2;
+ const size = L?.size ?? S * 0.1;
+ return {
+ events,
+ breath: false,
+ cuts: [T0],
+ overflow: [...(L?.overflow ? ["headline"] : []), ...card.overflow.filter((f) => f !== "product")],
+ signature: 0.12 + Math.min(n - 1, 2) * beat + pop * 0.6,
+ camera: (t) => ({ zoom: sample(zoom, t), x: 0, y: sample(pan, t) }),
+ frame(t, P, Lp) {
+ if (t >= T0) {
+ const list = card.evaluate(t >= c.last ? card.rest : t - T0);
+ return { nodes: [], over: [{ type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: list.background }, ...list.nodes] };
+ }
+ const swatches: DisplayNode[] = [];
+ const runs: TextRun[] = [];
+ words.forEach((w, i) => {
+ const p = P(`word.${i}`);
+ if (p <= 0 && Lp(`word.${i}`) <= 0) return;
+ const appear = Math.min(1, Lp(`word.${i}`) * 5);
+ const s = 1.32 - 0.32 * p;
+ const cx = w.x + w.w / 2;
+ const cy = w.y + size / 2;
+ if (w.hot) {
+ const q = P(`mark.${i}`);
+ if (q > 0) {
+ const pad = size * 0.14;
+ const full = w.w + pad * 2;
+ const rtl = L?.dir === "rtl";
+ swatches.push({ type: "rect", x: rtl ? w.x - pad + full * (1 - q) : w.x - pad, y: w.y - size * 0.06, w: full * q, h: size * 1.12, r: size * 0.12, fill: pal.highlight.fill });
+ }
+ }
+ const fill = w.hot && P(`mark.${i}`) > 0.35 ? pal.highlight.ink : pal.ink;
+ runs.push({ text: w.text, gap: w.gap, font: L!.font, x: w.x, y: w.y - (1 - p) * size * 0.12, fill, ...(appear < 1 && { opacity: appear }), ...(Math.abs(s - 1) > 1e-4 && { transform: [s, 0, 0, s, cx - s * cx, cy - s * cy] }), ...(L!.dir === "rtl" && { dir: "rtl" as const }) });
+ });
+ const e = P("words.exit");
+ const content: DisplayNode[] = [...swatches, { type: "text", field: "headline", runs }];
+ const nodes: DisplayNode[] = e > 0 ? [group(content, { transform: translate(0, -e * S * 0.06), opacity: 1 - e })] : content;
+ const rise = P("panel");
+ const over: DisplayNode[] = rise > 0 && !same ? [{ type: "ellipse", cx: design.w / 2, cy: design.h / 2, rx: R * rise, ry: R * rise, fill: cardGround }] : [];
+ return { nodes, over };
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/kit.ts b/src/lib/motion/scenes/marketing/kit.ts
new file mode 100644
index 00000000..6091243d
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/kit.ts
@@ -0,0 +1,664 @@
+/**
+ * What Marketing's code-drawn templates share (pure): the look (a light, dark or brand-colour ground, with the words,
+ * cards and highlights in kit colours that read on it), the frame's safe area, the pace, text blocks set exactly as
+ * typed, a rolling counter, and the scene wrapper. A template is a timeline of events laid out in the time the clip
+ * allows (everything set at least a second before the end), a frame function, and a camera that comes to rest on the
+ * last frame, so the poster, the last frame and the still are one picture.
+ */
+
+import { contrast, luminance, readableOn, themeFrom, type AdTheme } from "@/components/ads/layout";
+import { about, group, mixHex, multiply, translate, withAlpha, type DisplayList, type DisplayNode, type TextRun } from "../../display";
+import { curve, type CurveName } from "../../ease";
+import { layoutText, type Measure, type TextLayout } from "../../layout";
+import type { Recipe } from "../../recipe";
+import type { Outline, Scene, SceneInput, ScenePlan } from "../../scene";
+import { designSize, type SizeSpec } from "../../sizes";
+import { frameCount, local } from "../../time";
+import { DURATION_LIMITS, timeline, type EventKind, type MotionEvent, type StaggerUnit, type Timeline } from "../../tween";
+import { cardColours, lineLeft, lineRun, lineRuns, secondColour, type TextBlock } from "../end-card/shared";
+
+export type LookId = "light" | "dark" | "brand";
+
+export interface Palette {
+ look: LookId;
+ ground: string;
+ /** Words on the ground. */
+ ink: string;
+ /** Quieter words on the ground (still at least 4.5:1). */
+ muted: string;
+ accent: string;
+ second: string;
+ /** A card or panel on the ground, and the words on it. */
+ surface: string;
+ surfaceInk: string;
+ /** Shapes and lines that stand apart from the ground. */
+ mark: string;
+ mark2: string;
+ /** A marked word's swatch and the words on it. */
+ highlight: { fill: string; ink: string };
+}
+
+const HEX = /^#[0-9a-f]{6}$/i;
+
+/** The first colour that reads on `bg` (4.5:1), else white or near-black. */
+export function readable(bg: string, ...prefs: (string | undefined)[]): string {
+ for (const c of prefs) if (c && HEX.test(c) && contrast(c, bg) >= 4.5) return c;
+ return readableOn(bg);
+}
+
+/** A colour that stands apart from `bg` as a shape (`min`:1), else the nearest shade of it that does. */
+function standOut(c: string, bg: string, min = 1.6): string {
+ if (contrast(c, bg) >= min) return c;
+ const towards = luminance(bg) > 0.4 ? "#000000" : "#ffffff";
+ for (let k = 0.1; k <= 0.8; k += 0.1) {
+ const m = mixHex(c, towards, k);
+ if (contrast(m, bg) >= min) return m;
+ }
+ return mixHex(c, towards, 0.8);
+}
+
+/** Of two colours for a shape on `bg`, the one that stands apart more (the first when they tie). */
+function bolder(a: string, b: string, bg: string): string {
+ return contrast(b, bg) > contrast(a, bg) + 0.05 ? b : a;
+}
+
+/** The look's colours from the kit. */
+export function paletteFor(look: LookId, theme: AdTheme, colors: readonly string[]): Palette {
+ const accent = theme.accent;
+ const second = secondColour(colors, accent);
+ if (look === "brand") {
+ const { ink, pill, label } = cardColours(theme, colors);
+ const surface = mixHex(theme.paper, accent, 0.04);
+ return {
+ look,
+ ground: accent,
+ ink,
+ muted: ink,
+ accent,
+ second,
+ surface,
+ surfaceInk: readable(surface, theme.ink, accent),
+ mark: standOut(second, accent),
+ mark2: standOut(mixHex(accent, contrast(accent, "#000000") > contrast(accent, "#ffffff") ? "#000000" : "#ffffff", 0.3), accent),
+ highlight: { fill: pill, ink: label },
+ };
+ }
+ if (look === "dark") {
+ // A brand colour that is itself dark (emerald, navy, oxblood) is the ground: the piece reads as the brand, and it
+ // meets its end card (drawn on the brand colour) without a change of ground. Else a near-black tinted by it.
+ const deep = luminance(accent) < 0.045 && contrast(accent, "#ffffff") >= 9 ? accent : luminance(theme.ink) < 0.03 && contrast(theme.ink, accent) >= 1.8 ? mixHex(theme.ink, accent, 0.1) : mixHex(accent, "#050507", 0.86);
+ const ink = readable(deep, theme.paper, "#ffffff");
+ const mutedTry = mixHex(ink, deep, 0.3);
+ const surface = mixHex(deep, "#ffffff", 0.07);
+ // The brand's second colour wherever it reads better on the deep ground than a lightened accent (gold on emerald).
+ const fill = bolder(standOut(accent, deep, 2.2), standOut(second, deep, 2.2), deep);
+ const own = standOut(accent, deep, 3);
+ const mark = bolder(own, standOut(second, deep, 3), deep);
+ return {
+ look,
+ ground: deep,
+ ink,
+ muted: contrast(mutedTry, deep) >= 4.5 ? mutedTry : ink,
+ accent,
+ second,
+ surface,
+ surfaceInk: readable(surface, ink),
+ mark,
+ mark2: mark === own ? standOut(second, deep, 2.2) : standOut(accent, deep, 2.2),
+ highlight: { fill, ink: readable(fill, deep, theme.paper, theme.ink) },
+ };
+ }
+ const paper = theme.paper && luminance(theme.paper) > 0.85 ? theme.paper : "#faf8f5";
+ const ground = mixHex(paper, accent, 0.06);
+ const ink = readable(ground, theme.ink, "#121212");
+ const mutedTry = mixHex(ink, ground, 0.3);
+ const fill = bolder(standOut(accent, ground, 2.2), standOut(second, ground, 2.2), ground);
+ const own = standOut(accent, ground, 3);
+ const mark = bolder(own, standOut(second, ground, 3), ground);
+ return {
+ look,
+ ground,
+ ink,
+ muted: contrast(mutedTry, ground) >= 4.5 ? mutedTry : ink,
+ accent,
+ second,
+ surface: "#ffffff",
+ surfaceInk: readable("#ffffff", ink),
+ mark,
+ mark2: mark === own ? standOut(second, ground, 2.2) : standOut(accent, ground, 2.2),
+ highlight: { fill, ink: readable(fill, paper, ground, theme.ink) },
+ };
+}
+
+/**
+ * Where words may go: 6 % of the short side in from every edge; a tall 9:16 frame keeps its top 12 % and bottom 18 %
+ * clear for the platform's own buttons and captions.
+ */
+export function safeArea(d: { w: number; h: number }): { x: number; y: number; w: number; h: number } {
+ const S = Math.min(d.w, d.h);
+ const side = Math.round(S * 0.06);
+ if (d.h / d.w > 1.7) return { x: side, y: Math.round(d.h * 0.12), w: d.w - 2 * side, h: Math.round(d.h * 0.7) };
+ return { x: side, y: side, w: d.w - 2 * side, h: d.h - 2 * side };
+}
+
+/** The smallest sizes words may take (of the short side): body 3.2 %, headlines 6 %. */
+export const MIN_BODY = 0.032;
+export const MIN_HEAD = 0.06;
+
+/**
+ * How far apart a scene's beats are, for the time the clip allows (`room`): 1 is the scene's own timing for `base`
+ * seconds; a longer clip spaces its beats out (up to `hi`), the pace makes it calmer or quicker. Each move keeps its
+ * own length (within its kind's limits); only the beats spread, so a longer clip has more to watch, not slower moves.
+ */
+export const spread = (c: { room: number; pace: number }, base: number, hi = 2.2): number => Math.max(0.9, Math.min(hi, (c.room / base) * c.pace, c.room / base));
+
+/** How much slower (> 1) or quicker the pace is. */
+export const paceOf = (controls: Recipe["controls"]): number => (controls?.pace === "calm" ? 1.2 : controls?.pace === "punchy" ? 0.82 : 1);
+
+/** An event, its length held to its kind's limits. */
+export function ev(id: string, kind: EventKind, start: number, dur: number, c: CurveName, g?: { group: string; unit: StaggerUnit }): MotionEvent {
+ const [lo, hi] = DURATION_LIMITS[kind];
+ return { id, kind, start: Math.round(start * 1e6) / 1e6, dur: Math.round(Math.min(hi, Math.max(lo, dur)) * 1e6) / 1e6, curve: c, ...(g && { group: g.group, unit: g.unit }) };
+}
+
+/** A text block set as typed (layoutText) and placed: centred on `cx`, or flush from `left` across `width`. */
+export function textBlock(field: string, layout: TextLayout, place: { y: number; color: string; cx?: number; left?: number; width?: number }): TextBlock {
+ const width = place.width ?? layout.width;
+ return {
+ field,
+ layout,
+ y: place.y,
+ color: place.color,
+ cx: place.cx ?? (place.left ?? 0) + width / 2,
+ ...(place.left !== undefined && { flush: { left: place.left, width } }),
+ };
+}
+
+/** The words of a typed field with *stars* round the marked ones (paired stars only; every other star is kept). */
+export { marked } from "../../marks";
+
+// ---------------------------------------------------------------------------
+// The rolling counter (tabular figures)
+
+/** A measure that can also tell whether a face draws old-style figures by default (components/ads/render). */
+export type FigureMeasure = Measure & { oldstyle?: (family: string, weight: number) => boolean };
+
+/**
+ * The face a number is set in: the heading face, unless its default figures are old-style (Cormorant's "1" sits at
+ * x-height and its "8" rises, so "1,284" reads uneven and a rolling count jumps up and down); then the body face, when
+ * its figures line up.
+ */
+export function figureFamily(c: Pick<MarketingContext, "measure" | "theme">, weight: number): string {
+ const old = (c.measure as FigureMeasure).oldstyle;
+ if (!old?.(c.theme.heading, weight)) return c.theme.heading;
+ return old(c.theme.body, weight) ? c.theme.heading : c.theme.body;
+}
+
+export interface CounterCell {
+ /** The typed character (a digit, or anything else: kept as typed). */
+ ch: string;
+ digit: number | null;
+ /** The typed whitespace before it. */
+ gap: string;
+ x: number;
+ w: number;
+}
+
+export interface CounterLayout {
+ field: string;
+ font: string;
+ size: number;
+ cells: CounterCell[];
+ width: number;
+ /** The digits' cell width (the widest figure). */
+ figure: number;
+ overflow: boolean;
+}
+
+/**
+ * A stat ("$1,284,000", "38%", "4.9/5") laid out for a rolling count: every figure gets a cell as wide as the widest
+ * figure (tabular), everything else its own width, so the count never shifts sideways. Sized to fit `width`, from
+ * `max` down to `min`.
+ */
+export function counterLayout(field: string, typed: string, family: string, weight: number, width: number, max: number, min: number, measure: Measure): CounterLayout {
+ const text = typed.trim();
+ const chars = [...text];
+ let size = max;
+ for (;;) {
+ const font = `${weight} ${Math.round(size * 100) / 100}px "${family}"`;
+ const figure = Math.max(...[..."0123456789"].map((d) => measure(d, font)));
+ const cells: CounterCell[] = [];
+ let x = 0;
+ let gap = "";
+ for (const ch of chars) {
+ if (/\s/.test(ch)) {
+ gap += ch;
+ x += measure(" ", font);
+ continue;
+ }
+ const digit = /[0-9]/.test(ch) ? Number(ch) : null;
+ const w = digit === null ? measure(ch, font) : figure;
+ cells.push({ ch, digit, gap, x, w });
+ gap = "";
+ x += w;
+ }
+ const fits = x <= width;
+ if (fits || size <= min) return { field, font, size, cells, width: x, figure, overflow: !fits };
+ size = Math.max(min, size * 0.95);
+ }
+}
+
+/**
+ * The counter at progress `p` (0: every figure at 0; 1: the typed stat): each figure rolls up through its digits in
+ * its own cell (the right-hand figures roll further, as an odometer's), clipped to the cell; everything else stands.
+ */
+export function counterNode(c: CounterLayout, left: number, top: number, fill: string, p: number): DisplayNode {
+ const runs: TextRun[] = [];
+ const clips: DisplayNode[] = [];
+ const figures = c.cells.filter((x) => x.digit !== null).length;
+ let k = 0;
+ const lineH = c.size * 1.18;
+ for (const cell of c.cells) {
+ const x = left + cell.x;
+ if (cell.digit === null) {
+ runs.push({ text: cell.ch, gap: cell.gap, font: c.font, x, y: top, fill });
+ continue;
+ }
+ const i = k++;
+ const laps = Math.min(1, i);
+ const span = cell.digit + 10 * laps;
+ // The left-hand figures land first; the last one lands at p = 1.
+ const q = curve("glide")(local(p, 0, figures > 1 ? 0.7 + (0.3 * i) / (figures - 1) : 1));
+ const v = span * q;
+ const base = Math.floor(v + 1e-9);
+ const f = v - base;
+ if (f < 1e-6) {
+ runs.push({ text: String(base % 10), gap: cell.gap, font: c.font, x, y: top, fill });
+ continue;
+ }
+ const cellRuns: TextRun[] = [
+ { text: String(base % 10), gap: cell.gap, font: c.font, x, y: top - f * lineH, fill },
+ { text: String((base + 1) % 10), gap: "", font: c.font, x, y: top + (1 - f) * lineH, fill },
+ ];
+ clips.push(group([{ type: "text", field: c.field, runs: cellRuns }], { clip: { type: "rect", x: x - c.size * 0.05, y: top - c.size * 0.08, w: cell.w + c.size * 0.1, h: c.size * 1.16 } }));
+ }
+ // Every figure in its place: one text node, the typed stat exactly.
+ if (!clips.length) return { type: "text", field: c.field, runs };
+ return group([{ type: "text", field: c.field, runs }, ...clips]);
+}
+
+/** Each figure centred in its cell: the counter's runs, shifted per figure. */
+export function centreFigures(c: CounterLayout, measure: Measure): CounterLayout {
+ return {
+ ...c,
+ cells: c.cells.map((cell) => (cell.digit === null ? cell : { ...cell, x: cell.x + (c.figure - measure(cell.ch, c.font)) / 2 })),
+ };
+}
+
+// ---------------------------------------------------------------------------
+// The scene wrapper
+
+export interface MarketingContext {
+ recipe: Recipe;
+ input: SceneInput;
+ measure: Measure;
+ design: { w: number; h: number };
+ /** The short side (1080). */
+ S: number;
+ safe: { x: number; y: number; w: number; h: number };
+ theme: AdTheme;
+ palette: Palette;
+ /** > 1: calmer. */
+ pace: number;
+ /** Everything is set by then (the last second holds). */
+ room: number;
+ /** The last frame's time. */
+ last: number;
+ wide: boolean;
+ tall: boolean;
+ /** A typed field (trimmed), or the fallback. */
+ field(key: string, fallback?: string): string;
+}
+
+export interface Built {
+ events: MotionEvent[];
+ background?: string;
+ overflow: string[];
+ /** What is drawn at `t` (P: an event's eased progress, L: its plain progress). Under and over stay out of the camera. */
+ frame(t: number, P: (id: string) => number, L: (id: string) => number): { under?: DisplayNode[]; nodes: DisplayNode[]; over?: DisplayNode[] };
+ /** The scene's own camera at `t`: zoom about the middle, then a pan (design units). Home (1, 0, 0) on the last frame. */
+ camera?: (t: number) => { zoom: number; x: number; y: number; roll?: number };
+ cuts?: number[];
+ signature?: number;
+ /** The whole clip's slow breath in (default on); a scene with its own resolve turns it off. */
+ breath?: boolean;
+ /** The ground's slow light (default on). */
+ light?: boolean;
+}
+
+/**
+ * The ground's light: a soft pool of light that drifts slowly across the frame the whole clip long and comes to rest
+ * on the last frame (high and a little off centre), over a gentle falloff to the corners, so a flat ground has depth
+ * and the frame never stands quite still. On a dark ground the light is the brand's own colour.
+ */
+function groundLight(c: MarketingContext): (t: number) => DisplayNode[] {
+ const { design, palette: pal, last } = c;
+ const R = Math.max(design.w, design.h) * 0.85;
+ const dark = pal.look === "dark";
+ const tone = dark ? pal.mark : "#ffffff";
+ const a = dark ? 0.22 : pal.look === "brand" ? 0.2 : 0.55;
+ const corner = shadowOf(pal.ground, dark ? 0.35 : pal.look === "brand" ? 0.22 : 0.07);
+ const vignette: DisplayNode = { type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: { kind: "radial", cx: design.w / 2, cy: design.h * 0.42, r0: Math.min(design.w, design.h) * 0.35, r1: Math.hypot(design.w, design.h) * 0.62, stops: [{ at: 0, color: shadowOf(pal.ground, 0) }, { at: 1, color: corner }] } };
+ const drift = curve("drift");
+ return (t) => {
+ const u = drift(last > 0 ? Math.min(1, Math.max(0, t / last)) : 1);
+ const lx = design.w * (0.3 + 0.24 * u);
+ const ly = design.h * (0.22 + 0.12 * u);
+ return [
+ { type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: { kind: "radial", cx: lx, cy: ly, r0: 0, r1: R, stops: [{ at: 0, color: withAlpha(tone, a) }, { at: 0.5, color: withAlpha(tone, a * 0.3) }, { at: 1, color: withAlpha(tone, 0) }] } },
+ vignette,
+ ];
+ };
+}
+
+export interface MarketingSceneDef {
+ id: string;
+ name: string;
+ durations?: { min: number; max: number; default: number };
+ /** The look when the recipe doesn't choose. */
+ look?: LookId;
+ build(c: MarketingContext): Built;
+}
+
+/** 5 to 8 seconds: the beats spread over the length, so a longer clip never just holds still for longer. */
+export const MARKETING_DURATIONS = { min: 5, max: 8, default: 5 } as const;
+export const MARKETING_SIZES: SizeSpec[] = ["9:16", "1:1", "16:9", "4:5"];
+
+/** The whole clip breathes in by this much and comes to rest on the last frame. */
+const BREATH = 0.025;
+
+export function marketingScene(def: MarketingSceneDef): Scene {
+ return {
+ id: def.id,
+ name: def.name,
+ durations: def.durations ?? MARKETING_DURATIONS,
+ sizes: MARKETING_SIZES,
+ plan(input: SceneInput): ScenePlan {
+ const recipe = input.recipe;
+ const design = designSize(recipe.size);
+ const S = Math.min(design.w, design.h);
+ const theme = themeFrom({ colors: recipe.brand.colors, fonts: recipe.brand.fonts });
+ const lookId = (["light", "dark", "brand"] as const).find((l) => l === recipe.controls?.look) ?? def.look ?? "light";
+ const last = (frameCount(recipe.duration, recipe.fps) - 1) / recipe.fps;
+ const ctx: MarketingContext = {
+ recipe,
+ input,
+ measure: input.measure,
+ design,
+ S,
+ safe: safeArea(design),
+ theme,
+ palette: paletteFor(lookId, theme, recipe.brand.colors),
+ pace: paceOf(recipe.controls),
+ room: Math.max(1.5, recipe.duration - 1.3),
+ last,
+ wide: design.w / design.h > 1.2,
+ tall: design.h / design.w > 1.5,
+ field: (key, fallback = "") => (recipe.fields[key] ?? fallback).trim(),
+ };
+ const built = def.build(ctx);
+ const tl: Timeline = timeline(built.events);
+ const settled = Math.min(last, built.events.filter((e) => e.kind !== "camera").reduce((m, e) => Math.max(m, e.start + e.dur), 0));
+ const drift = curve("drift");
+ const P = (t: number) => (id: string) => {
+ const e = tl.byId.get(id);
+ return e ? curve(e.curve)(local(t, e.start, e.start + e.dur)) : 1;
+ };
+ const L = (t: number) => (id: string) => {
+ const e = tl.byId.get(id);
+ return e ? local(t, e.start, e.start + e.dur) : 1;
+ };
+ const cx = design.w / 2;
+ const cy = design.h / 2;
+ const glow = built.background || built.light === false ? () => [] : groundLight(ctx);
+ const draw = (t: number, home: boolean): DisplayList => {
+ const f = built.frame(t, P(t), L(t));
+ let nodes = f.nodes;
+ if (!home) {
+ const cam = built.camera?.(t) ?? { zoom: 1, x: 0, y: 0 };
+ const z = (built.breath === false ? 1 : 1 - BREATH + BREATH * drift(last > 0 ? Math.min(1, t / last) : 1)) * cam.zoom;
+ const m = multiply(translate(cam.x, cam.y), about(cx, cy, z, cam.roll ?? 0));
+ nodes = [group(nodes, { id: "camera", transform: m })];
+ }
+ return { w: design.w, h: design.h, background: built.background ?? ctx.palette.ground, nodes: [...glow(t), ...(f.under ?? []), ...nodes, ...(f.over ?? [])] };
+ };
+ const still = draw(last, true);
+ return {
+ design,
+ timeline: tl,
+ rest: last,
+ settled,
+ ...(built.signature !== undefined && { signature: Math.min(last, built.signature) }),
+ cuts: built.cuts ?? [],
+ overflow: built.overflow,
+ evaluate: (t) => (t >= last ? still : draw(Math.max(0, t), false)),
+ still: (t) => t >= last,
+ };
+ },
+ };
+}
+
+/** Lay out a field (layoutText with the kit's font), or null when it's empty. */
+export function setText(c: MarketingContext, text: string, o: { family?: "heading" | "body" | "figures"; weight: number; width: number; maxLines: number; max: number; min: number; lineHeight?: number; letters?: boolean; even?: number }): TextLayout | null {
+ if (!text.trim()) return null;
+ // "figures": the heading face, unless its figures are old-style and the words hold a figure (then the body face).
+ const family = o.family === "body" ? c.theme.body : o.family === "figures" && /\p{Nd}/u.test(text) ? figureFamily(c, o.weight) : c.theme.heading;
+ // Lines kept even by default (no lone word left on a line).
+ return layoutText({ text, family, weight: o.weight, width: o.width, maxLines: o.maxLines, max: o.max, min: o.min, lineHeight: o.lineHeight, letters: o.letters, even: o.even ?? 0.5 }, c.measure);
+}
+
+/** A picture fitted inside a box (contain), centred, its foot on the box's bottom when `ground`. */
+export function fitBox(img: { w: number; h: number }, box: { x: number; y: number; w: number; h: number }, ground = false): { x: number; y: number; w: number; h: number } {
+ const s = Math.min(box.w / img.w, box.h / img.h);
+ const w = img.w * s;
+ const h = img.h * s;
+ return { x: box.x + (box.w - w) / 2, y: ground ? box.y + box.h - h : box.y + (box.h - h) / 2, w, h };
+}
+
+/** A soft contact shadow under a picture standing at `foot`: a round falloff squashed flat. */
+export function contactShadow(cx: number, foot: number, width: number, ground: string, strength = 0.34, opacity = 1): DisplayNode {
+ const r = width * 0.46;
+ const stops = [
+ { at: 0, color: shadowOf(ground, strength) },
+ { at: 0.45, color: shadowOf(ground, strength * 0.45) },
+ { at: 1, color: shadowOf(ground, 0) },
+ ];
+ const disc: DisplayNode = { type: "ellipse", cx, cy: foot, rx: r, ry: r, fill: { kind: "radial", cx, cy: foot, r0: 0, r1: r, stops } };
+ return group([disc], { transform: about(cx, foot, 1, 0, 0.14), ...(opacity < 1 && { opacity }) });
+}
+
+/** An n-pointed star (or a burst: many points, a high inner ratio) round (cx, cy) as path data. */
+export function starPath(cx: number, cy: number, outer: number, inner: number, points: number, rot = -Math.PI / 2): string {
+ const parts: string[] = [];
+ for (let i = 0; i < points * 2; i++) {
+ const r = i % 2 ? inner : outer;
+ const a = rot + (i * Math.PI) / points;
+ parts.push(`${i ? "L" : "M"}${(cx + Math.cos(a) * r).toFixed(2)} ${(cy + Math.sin(a) * r).toFixed(2)}`);
+ }
+ return `${parts.join("")}Z`;
+}
+
+/** A shade of `c` for a shadow on `ground` (deeper and see-through). */
+export const shadowOf = (ground: string, a = 0.28) => {
+ const deep = mixHex(ground, "#000000", luminance(ground) > 0.3 ? 0.55 : 0.75);
+ const h = deep.replace("#", "");
+ return `rgba(${parseInt(h.slice(0, 2), 16)},${parseInt(h.slice(2, 4), 16)},${parseInt(h.slice(4, 6), 16)},${a})`;
+};
+
+/** The picture a scene shows: the product when there is one, else the logo (null: neither). */
+export function heroOf(c: MarketingContext): { src: "product" | "logo"; w: number; h: number } | null {
+ const product = c.recipe.media?.product ? c.input.images?.product : undefined;
+ if (product && product.w > 0 && product.h > 0) return { src: "product", ...product };
+ if (c.input.logo) return { src: "logo", w: c.input.logo.w, h: c.input.logo.h };
+ return null;
+}
+
+/**
+ * The brand's sign-off: its logo (a wide lockup at most `maxW` wide, at most `h` tall), else its name set in the
+ * heading face. `draw` places it centred on `cx` with its top at `top`, settling up into place as `p` runs to 1.
+ */
+export interface BrandMark {
+ w: number;
+ h: number;
+ overflow: boolean;
+ draw(cx: number, top: number, p: number, lin: number, color?: string): DisplayNode[];
+}
+
+/**
+ * Fuobe's own sample marks (the showcase brands' lockups, /previews/…) are drawn in one colour, so a scene sets them in
+ * the look's ink; a person's own logo is always drawn as it is.
+ */
+export const sampleMark = (c: Pick<MarketingContext, "recipe">): boolean => !!c.recipe.brand.logo?.startsWith("/previews/");
+
+/** The logo in a box: as it is, or (a sample mark) in `color`. */
+export function logoNode(c: Pick<MarketingContext, "recipe">, box: { x: number; y: number; w: number; h: number }, color: string): DisplayNode {
+ const img: DisplayNode = { type: "image", src: "logo", ...box };
+ if (!sampleMark(c)) return img;
+ const pad = 2;
+ return group([img, group([{ type: "rect", x: box.x - pad, y: box.y - pad, w: box.w + 2 * pad, h: box.h + 2 * pad, fill: color }], { blend: "source-atop" })], { isolate: { x: box.x - pad, y: box.y - pad, w: box.w + 2 * pad, h: box.h + 2 * pad } });
+}
+
+export function brandMark(c: MarketingContext, o: { maxW: number; h: number; color: string; minName?: number }): BrandMark | null {
+ const logo = c.input.logo;
+ const rise = (p: number, lin: number, children: DisplayNode[]): DisplayNode[] => (lin <= 0 ? [] : p >= 1 && lin >= 1 ? children : [group(children, { transform: translate(0, (1 - p) * c.S * 0.025), ...(lin < 0.45 && { opacity: lin / 0.45 }) })]);
+ if (logo && logo.w > 0 && logo.h > 0) {
+ const s = Math.min(o.maxW / logo.w, o.h / logo.h);
+ const w = logo.w * s;
+ const h = logo.h * s;
+ return { w, h, overflow: false, draw: (cx, top, p, lin, color) => rise(p, lin, [logoNode(c, { x: cx - w / 2, y: top, w, h }, color ?? o.color)]) };
+ }
+ const name = setText(c, c.recipe.brand.name, { weight: 700, width: o.maxW, maxLines: 1, max: o.h * 0.82, min: c.S * (o.minName ?? MIN_BODY) });
+ if (!name) return null;
+ return {
+ w: name.width,
+ h: name.height,
+ overflow: name.overflow,
+ draw: (cx, top, p, lin, color) => rise(p, lin, [lineRuns(textBlock("brand", name, { y: top, color: color ?? o.color, cx }))]),
+ };
+}
+
+/**
+ * A slow float that keeps a held piece alive and is exactly still at `from` and at `to` (the last frame): one gentle
+ * rise and fall over the hold (`n` of them), in design units, and a turn in radians.
+ */
+export function holdFloat(t: number, from: number, to: number, amp: number, turn = 0, n = 1): { dy: number; roll: number } {
+ if (to - from < 0.5 || t <= from || t >= to) return { dy: 0, roll: 0 };
+ const u = (t - from) / (to - from);
+ const s = Math.sin(Math.PI * n * u);
+ // Eased in and out at both ends, so it starts and stops without a kick.
+ const env = Math.sin(Math.PI * u);
+ return { dy: -amp * s * env, roll: turn * Math.sin(Math.PI * 2 * u) * env };
+}
+
+/** A block's lines, each rising out of its own line box (`p(i)`: line i's progress); whole lines once in place. */
+export function risingLines(b: TextBlock, p: (i: number) => number, shift?: (i: number) => number): DisplayNode[] {
+ const L = b.layout;
+ const out: DisplayNode[] = [];
+ L.lines.forEach((line, i) => {
+ const q = p(i);
+ if (q <= 0) return;
+ const dx = shift?.(i) ?? 0;
+ if (q >= 1) return void out.push(lineRun(b, i, dx ? { dx } : undefined));
+ const top = b.y + i * L.lineHeight;
+ out.push(group([lineRun(b, i, { dx, dy: (1 - q) * L.lineHeight })], { clip: { type: "rect", x: lineLeft(b, i) + dx - L.size * 0.25, y: top - L.size * 0.1, w: line.width + L.size * 0.5, h: L.lineHeight + L.size * 0.2 } }));
+ });
+ return out;
+}
+
+/** A picture revealed from the bottom up with a soft edge (`p` 0: hidden, 1: whole). */
+export function riseReveal(children: DisplayNode[], box: { x: number; y: number; w: number; h: number }, p: number, feather: number): DisplayNode {
+ if (p >= 1) return group(children);
+ const edge = box.y + box.h + feather - (box.h + 2 * feather) * p;
+ return group(children, {
+ mask: { kind: "linear", x0: 0, y0: edge + feather, x1: 0, y1: edge, stops: [{ at: 0, color: "rgba(0,0,0,1)" }, { at: 1, color: "rgba(0,0,0,0)" }], bounds: { x: box.x - feather, y: box.y - feather, w: box.w + 2 * feather, h: box.h + 2 * feather } },
+ });
+}
+
+/** Points along a traced outline (its curve ends and handles), placed in design units over the picture's box. */
+export function outlinePoints(outline: Outline, box: { x: number; y: number; w: number; h: number }): [number, number][] {
+ const n = (outline.d.match(/-?\d+(?:\.\d+)?/g) ?? []).map(Number);
+ const k = box.w / outline.w;
+ const out: [number, number][] = [];
+ for (let i = 0; i + 1 < n.length; i += 2) out.push([box.x + n[i] * k, box.y + n[i + 1] * k]);
+ return out;
+}
+
+/** Whether (x, y) is inside a closed polygon (even-odd). */
+export function insidePolygon(pts: readonly [number, number][], x: number, y: number): boolean {
+ let inside = false;
+ for (let i = 0, j = pts.length - 1; i < pts.length; j = i++) {
+ const [xi, yi] = pts[i];
+ const [xj, yj] = pts[j];
+ if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) inside = !inside;
+ }
+ return inside;
+}
+
+/** How much of a disc (cx, cy, r) lies over the shape (0 to 1), sampled on a small grid. */
+export function discCover(pts: readonly [number, number][], cx: number, cy: number, r: number): number {
+ let hit = 0;
+ let all = 0;
+ for (let gy = -4; gy <= 4; gy++)
+ for (let gx = -4; gx <= 4; gx++) {
+ const x = cx + (gx / 4) * r;
+ const y = cy + (gy / 4) * r;
+ if (Math.hypot(x - cx, y - cy) > r) continue;
+ all++;
+ if (insidePolygon(pts, x, y)) hit++;
+ }
+ return all ? hit / all : 0;
+}
+
+export interface BadgeSpot {
+ cx: number;
+ cy: number;
+ r: number;
+ /** How much of the badge lies over the product (0: clear of it). */
+ cover: number;
+}
+
+/**
+ * Where a round badge sits by a product so it covers the least of it: of the spots round the picture's upper corners
+ * and sides (and just past them, inside `bounds`), the one with the least of the badge over the product's outline
+ * (point in polygon, so a spot inside the shape never counts as clear), nearer the top when two tie. The badge is sized
+ * to the product (its radius at most `maxShare` of the product's width, never more than `r`), and shrinks (down to 70 %) while every spot
+ * still covers the product. A photo without an outline: its upper right corner, overlapping by a third.
+ */
+export function badgeSpot(img: { x: number; y: number; w: number; h: number }, outline: Outline | null, r: number, bounds: { x: number; y: number; w: number; h: number }, maxShare = 0.45): BadgeSpot {
+ const R0 = Math.min(r, Math.max(r * 0.7, img.w * maxShare));
+ const clampIn = (x: number, y: number, rr: number): [number, number] => [Math.min(bounds.x + bounds.w - rr, Math.max(bounds.x + rr, x)), Math.min(bounds.y + bounds.h - rr, Math.max(bounds.y + rr, y))];
+ if (!outline) {
+ const [cx, cy] = clampIn(img.x + img.w - R0 * 0.35, img.y + R0 * 0.35, R0);
+ return { cx, cy, r: R0, cover: 0.5 };
+ }
+ const pts = outlinePoints(outline, img);
+ let best = null as BadgeSpot | null;
+ // Spots round the picture's top and sides: from a badge's width beyond its left edge to as far beyond its right,
+ // from just over its top to its middle, kept inside the bounds.
+ const score = (s: BadgeSpot) => {
+ // Less cover first; then nearer the product (it reads as its badge), nearer the top, and the larger badge.
+ const gx = Math.max(0, img.x - s.cx, s.cx - (img.x + img.w)) / Math.max(1, s.r);
+ return s.cover * 10 + gx * 0.35 + ((s.cy - img.y) / Math.max(1, img.h)) * 0.6 - s.r / r;
+ };
+ for (let rr = R0; rr >= r * 0.7 - 1e-6; rr -= r * 0.1) {
+ for (let i = 0; i <= 8; i++) {
+ for (const fy of [-0.04, 0.08, 0.2, 0.34, 0.48]) {
+ const [cx, cy] = clampIn(img.x - rr * 1.1 + ((img.w + rr * 2.2) * i) / 8, img.y + img.h * fy + (fy < 0 ? -rr * 0.3 : 0), rr);
+ const spot = { cx, cy, r: rr, cover: discCover(pts, cx, cy, rr) };
+ if (!best || score(spot) < score(best)) best = spot;
+ }
+ }
+ if (best && best.cover <= 0.04) break;
+ }
+ return best!;
+}
diff --git a/src/lib/motion/scenes/marketing/line-reveal.ts b/src/lib/motion/scenes/marketing/line-reveal.ts
new file mode 100644
index 00000000..c9e70ae1
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/line-reveal.ts
@@ -0,0 +1,150 @@
+/**
+ * Line-Art Reveal: one continuous line in the brand's colour runs in along the ground, traces the product's outline
+ * (from the cut-out's own edge), and runs on out; then an arch of the brand's colour rises behind the product as it
+ * fills in from the ground up, the line steps back, the headline and the call to action set under it with a drawn
+ * underline, and the brand signs off (its logo, else its name). A photo without transparency gets a rounded frame traced
+ * round it instead. Editorial and quiet: a fine line, generous space; the beats spread over the clip's length.
+ */
+
+import { group, mixHex, type DisplayNode, type Matrix } from "../../display";
+import { lineRuns } from "../end-card/shared";
+import { brandMark, contactShadow, ev, fitBox, heroOf, logoNode, marketingScene, MIN_HEAD, riseReveal, risingLines, setText, spread, textBlock } from "./kit";
+
+/** A rounded frame as path data from its bottom centre, clockwise on screen (left first), and its length. */
+export function framePath(x: number, y: number, w: number, h: number, r: number): { d: string; length: number } {
+ const rr = Math.max(0, Math.min(r, w / 2, h / 2));
+ const cx = x + w / 2;
+ const b = y + h;
+ const d = [`M${cx} ${b}`, `H${x + rr}`, `A${rr} ${rr} 0 0 1 ${x} ${b - rr}`, `V${y + rr}`, `A${rr} ${rr} 0 0 1 ${x + rr} ${y}`, `H${x + w - rr}`, `A${rr} ${rr} 0 0 1 ${x + w} ${y + rr}`, `V${b - rr}`, `A${rr} ${rr} 0 0 1 ${x + w - rr} ${b}`, "Z"].join(" ");
+ return { d, length: 2 * (w - 2 * rr) + 2 * (h - 2 * rr) + 2 * Math.PI * rr };
+}
+
+/** An arch (a round top on straight sides) standing on y = foot. */
+const archPath = (cx: number, foot: number, w: number, h: number): string => {
+ const r = w / 2;
+ return `M${cx - r} ${foot}V${foot - h + r}A${r} ${r} 0 0 1 ${cx + r} ${foot - h + r}V${foot}Z`;
+};
+
+export default marketingScene({
+ id: "marketing/line-reveal",
+ name: "Line-Art Reveal",
+ look: "light",
+ build(c) {
+ const { S, safe, palette: pal, design } = c;
+ const hero = heroOf(c);
+ const width = c.recipe.controls?.line === "bold" ? S * 0.008 : S * 0.0045;
+ const line = pal.mark;
+ // The picture's box, and where the words go.
+ const side = c.wide;
+ const textLeft = side ? safe.x + safe.w * 0.54 : safe.x;
+ const textW = side ? safe.w * 0.46 : safe.w;
+ const head = setText(c, c.field("headline"), { weight: 700, width: textW, maxLines: 3, max: S * (side ? 0.09 : c.tall ? 0.105 : 0.09), min: S * MIN_HEAD, lineHeight: 1.08 });
+ const cta = setText(c, c.field("cta"), { family: "body", weight: 600, width: textW, maxLines: 1, max: S * (c.tall ? 0.05 : 0.045), min: S * 0.036 });
+ // The sign-off: on top of a tall or square frame, under the words on a wide one. A logo that is the picture already
+ // (no product) is not shown twice.
+ const signs = !(hero?.src === "logo");
+ const mark = signs ? brandMark(c, { maxW: S * (side ? 0.32 : 0.42), h: S * (c.tall ? 0.08 : 0.065), color: pal.ink, minName: 0.036 }) : null;
+ const markRoom = mark && !side ? mark.h + S * 0.06 : 0;
+ const gapT = S * 0.035;
+ const ctaH = cta ? cta.size * 1.6 : 0;
+ const textH = (head?.height ?? 0) + (cta ? (head ? gapT : 0) + ctaH : 0) + (mark && side ? S * 0.06 + mark.h : 0);
+ // Stacked, the picture takes what the words leave, and the whole is centred.
+ const gapPic = S * 0.08;
+ const avail = safe.h - markRoom;
+ const picH = side ? safe.h * 0.84 : Math.min(avail * 0.66, avail - textH - gapPic);
+ const block = picH + gapPic + textH;
+ const picTop = safe.y + markRoom + Math.max(0, (avail - block) / 2);
+ const picBox = side ? { x: safe.x + safe.w * 0.02, y: safe.y + safe.h * 0.08, w: safe.w * 0.44, h: picH } : { x: safe.x + safe.w * 0.05, y: picTop, w: safe.w * 0.9, h: picH };
+
+ // The picture standing on its line.
+ const img = hero ? fitBox(hero, picBox, true) : null;
+ const outline = hero?.src === "product" ? (c.input.outlines?.product ?? null) : null;
+ let trace: { d: string; length: number; m?: Matrix; scale: number } | null = null;
+ let start: [number, number] = [design.w / 2, picBox.y + picBox.h];
+ if (img && outline) {
+ const k = img.w / outline.w;
+ trace = { d: outline.d, length: outline.length, m: [k, 0, 0, k, img.x, img.y], scale: k };
+ start = [img.x + outline.start[0] * k, img.y + outline.start[1] * k];
+ } else if (img) {
+ const pad = S * 0.03;
+ const f = framePath(img.x - pad, img.y - pad, img.w + 2 * pad, img.h + 2 * pad, S * 0.035);
+ trace = { ...f, scale: 1 };
+ start = [img.x + img.w / 2, img.y + img.h + pad];
+ }
+ const foot = start[1];
+ const lineFrom = side ? picBox.x : safe.x;
+ const lineTo = side ? picBox.x + picBox.w : safe.x + safe.w;
+ // The arch of the brand's colour behind the product (a soft tint of it on the ground).
+ const archW = img ? Math.min(picBox.w * 0.92, Math.max(img.w * 1.35, img.h * 0.62)) : 0;
+ const archH = img ? Math.min(foot - picBox.y + S * 0.02, Math.max(img.h * 1.08, archW * 0.9)) : 0;
+ const archFill = mixHex(pal.ground, pal.look === "light" ? pal.accent : pal.mark, pal.look === "light" ? 0.12 : 0.2);
+ const arch = img ? archPath(start[0], foot, archW, archH) : "";
+ const archBox = { x: start[0] - archW / 2, y: foot - archH, w: archW, h: archH };
+
+ // The words under the picture (beside it on a wide frame).
+ const textTop = side ? safe.y + (safe.h - textH) / 2 : Math.min(safe.y + safe.h - textH, foot + gapPic);
+ const headB = head ? textBlock("headline", head, { y: textTop, color: pal.ink, ...(side ? { left: textLeft, width: textW } : { cx: design.w / 2 }) }) : null;
+ const ctaY = textTop + (head ? head.height + gapT : 0);
+ const ctaB = cta ? textBlock("cta", cta, { y: ctaY, color: pal.ink, ...(side ? { left: textLeft, width: textW } : { cx: design.w / 2 }) }) : null;
+ const markTop = side ? ctaY + ctaH + S * 0.06 : safe.y;
+ const markCx = side ? textLeft + (mark?.w ?? 0) / 2 : design.w / 2;
+
+ // Paced to the clip: a longer one draws more slowly (up to a point) and leaves more room between the beats.
+ const k = spread(c, 3.1, 1.8);
+ const traceDur = Math.min(1.8, 1.25 * k);
+ const lines = head?.lines.length ?? 0;
+ const fillAt = 0.32 * k + traceDur * 0.75;
+ const wordsAt = fillAt + 0.55 * k;
+ const ctaAt = wordsAt + 0.3 * k + lines * 0.09;
+ const events = [
+ ev("ground.a", "draw", 0, 0.4 * k, "draw"),
+ ...(trace ? [ev("trace", "draw", 0.32 * k, traceDur, "draw")] : []),
+ ev("ground.b", "draw", 0.32 * k + traceDur - 0.08, 0.35 * k, "draw"),
+ ...(img ? [ev("arch", "draw", fillAt - 0.15, 0.85 * k, "glide"), ev("fill", "draw", fillAt, 0.75 * k, "glide"), ev("shadow", "fade", fillAt + 0.1, 0.6, "enter"), ev("trace.out", "fade", fillAt + 0.55 * k, 0.5, "enter")] : []),
+ ...Array.from({ length: lines }, (_, i) => ev(`head.${i}`, "enter", wordsAt + i * 0.09, 0.55, "glide", { group: "head", unit: "elements" })),
+ ...(cta ? [ev("cta", "enter", ctaAt, 0.45, "glide"), ev("cta.line", "draw", ctaAt + 0.15, 0.5, "draw")] : []),
+ ...(mark ? [ev("brand", "enter", ctaAt + 0.45 * k, 0.6, "glide")] : []),
+ ];
+
+ return {
+ events,
+ overflow: [...(head?.overflow ? ["headline"] : []), ...(cta?.overflow ? ["cta"] : []), ...(mark?.overflow ? ["brand"] : [])],
+ signature: 0.32 * k + traceDur * 0.6,
+ frame(_t, P, Lp) {
+ const nodes: DisplayNode[] = [];
+ const a = P("arch");
+ if (a > 0 && img) nodes.push(riseReveal([{ type: "path", d: arch, fill: archFill }], archBox, a, archH * 0.1));
+ const ga = P("ground.a");
+ const gb = P("ground.b");
+ if (ga > 0) nodes.push({ type: "path", d: `M${lineFrom} ${foot}H${start[0]}`, stroke: { paint: line, width, trim: ga, length: start[0] - lineFrom, cap: "round" } });
+ if (gb > 0) nodes.push({ type: "path", d: `M${start[0]} ${foot}H${lineTo}`, stroke: { paint: line, width, trim: gb, length: lineTo - start[0], cap: "round" } });
+ if (img && hero) {
+ const sh = P("shadow");
+ if (sh > 0) nodes.push(contactShadow(start[0], foot, img.w * 0.8, archFill, 0.3, sh));
+ const fill = P("fill");
+ const pic: DisplayNode = hero.src === "logo" ? logoNode(c, img, pal.ink) : { type: "image", src: hero.src, x: img.x, y: img.y, w: img.w, h: img.h };
+ if (fill > 0) nodes.push(riseReveal([pic], img, fill, img.h * 0.12));
+ }
+ if (trace) {
+ const tr = P("trace");
+ const out = P("trace.out");
+ if (tr > 0 && out < 1) nodes.push({ type: "path", d: trace.d, ...(trace.m && { transform: trace.m }), stroke: { paint: line, width: width / trace.scale, trim: tr, length: trace.length, cap: "round", join: "round" }, ...(out > 0 && { opacity: 1 - out }) });
+ }
+ if (headB) nodes.push(...risingLines(headB, (i) => P(`head.${i}`)));
+ if (ctaB && cta) {
+ const p = P("cta");
+ if (p > 0) nodes.push(group([lineRuns(ctaB)], { transform: [1, 0, 0, 1, 0, (1 - p) * S * 0.02], ...(p < 1 && { opacity: p }) }));
+ const u = P("cta.line");
+ if (u > 0) {
+ const w0 = cta.lines[0]?.width ?? 0;
+ const x0 = side ? (cta.dir === "rtl" ? textLeft + textW - w0 : textLeft) : design.w / 2 - w0 / 2;
+ const y0 = ctaY + cta.size * 1.32;
+ nodes.push({ type: "path", d: `M${x0} ${y0}H${x0 + w0}`, stroke: { paint: pal.mark, width: Math.max(2, S * 0.004), trim: u, length: w0, cap: "round" } });
+ }
+ }
+ if (mark) nodes.push(...mark.draw(markCx, markTop, P("brand"), Lp("brand")));
+ return { nodes };
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/logo-sting.ts b/src/lib/motion/scenes/marketing/logo-sting.ts
new file mode 100644
index 00000000..9ee55758
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/logo-sting.ts
@@ -0,0 +1,221 @@
+/**
+ * Logo Sting: the mark is made from itself. Two hairlines sweep out from the middle and fall away; then the mark
+ * assembles: an SVG logo traces its own outlines on and fills in, any other logo (or the brand's name set in type) comes
+ * together from shards cut out of it, which drift or fly home from round the frame. The instant it is whole, a flash
+ * and a ring of light go out from it, it settles, a glint crosses it, and the line under it rises.
+ *
+ * The Pace sets the language: Calm is fine and quiet (short drifts, little turn, long hairlines), Punchy flies the shards
+ * in from farther with more turn and a kick of the camera. The shards' cuts and paths come from the recipe's seed.
+ */
+
+import { about, group, multiply, translate, withAlpha, type DisplayNode } from "../../display";
+import { noise1, rng, rngRange } from "../../random";
+import { local } from "../../time";
+import { lineRuns, logoPaths } from "../end-card/shared";
+import { ev, logoNode, marketingScene, MIN_BODY, MIN_HEAD, sampleMark, setText, spread, textBlock } from "./kit";
+
+interface Shard {
+ d: string;
+ /** Its middle, and where it starts from (relative), its turn and when it leaves. */
+ cx: number;
+ cy: number;
+ dx: number;
+ dy: number;
+ turn: number;
+ at: number;
+}
+
+/** A box cut into triangles on a jittered grid (the inner points moved by the seed), as closed paths. */
+export function shardCuts(box: { x: number; y: number; w: number; h: number }, cols: number, rows: number, seed: number): { d: string; cx: number; cy: number }[] {
+ const pt = (i: number, j: number): [number, number] => {
+ const inner = i > 0 && i < cols && j > 0 && j < rows;
+ const jx = inner ? rngRange(-0.32, 0.32, seed, "jx", i, j) : 0;
+ const jy = inner ? rngRange(-0.32, 0.32, seed, "jy", i, j) : 0;
+ return [box.x + ((i + jx) / cols) * box.w, box.y + ((j + jy) / rows) * box.h];
+ };
+ const out: { d: string; cx: number; cy: number }[] = [];
+ const tri = (a: [number, number], b: [number, number], c: [number, number]) =>
+ out.push({ d: `M${a[0].toFixed(2)} ${a[1].toFixed(2)}L${b[0].toFixed(2)} ${b[1].toFixed(2)}L${c[0].toFixed(2)} ${c[1].toFixed(2)}Z`, cx: (a[0] + b[0] + c[0]) / 3, cy: (a[1] + b[1] + c[1]) / 3 });
+ for (let j = 0; j < rows; j++)
+ for (let i = 0; i < cols; i++) {
+ const p00 = pt(i, j);
+ const p10 = pt(i + 1, j);
+ const p01 = pt(i, j + 1);
+ const p11 = pt(i + 1, j + 1);
+ // The diagonal alternates, so the cuts read as facets, not a grid.
+ if ((i + j) % 2 === 0) {
+ tri(p00, p10, p11);
+ tri(p00, p11, p01);
+ } else {
+ tri(p00, p10, p01);
+ tri(p10, p11, p01);
+ }
+ }
+ return out;
+}
+
+export default marketingScene({
+ id: "marketing/logo-sting",
+ name: "Logo Sting",
+ look: "brand",
+ build(c) {
+ const { S, safe, palette: pal, design, recipe } = c;
+ const seed = recipe.seed;
+ const cx = design.w / 2;
+ const logo = c.input.logo;
+ const calm = recipe.controls?.pace === "calm";
+ const punchy = recipe.controls?.pace === "punchy";
+ // The mark's box, a little above the middle.
+ const markW = Math.min(safe.w * 0.86, S * 0.84);
+ const markH = S * (logo && logo.w / logo.h > 3 ? 0.24 : 0.32);
+ const tagline = setText(c, c.field("tagline"), { family: "body", weight: 500, width: Math.min(safe.w, S * 1.1), maxLines: 2, max: S * 0.056, min: S * MIN_BODY, lineHeight: 1.25 });
+ const name = !logo ? setText(c, recipe.brand.name, { weight: 800, width: Math.min(safe.w, S * 1.2), maxLines: 2, max: S * 0.14, min: S * MIN_HEAD, lineHeight: 1.04 }) : null;
+ const box = logo
+ ? (() => {
+ const s = Math.min(markW / logo.w, markH / logo.h);
+ return { w: logo.w * s, h: logo.h * s };
+ })()
+ : name
+ ? { w: name.width, h: name.height }
+ : { w: S * 0.2, h: S * 0.1 };
+ const gap = S * 0.06;
+ const stackH = box.h + (tagline ? gap + tagline.height : 0);
+ const top = design.h / 2 - stackH / 2 - S * 0.02;
+ const mark = { x: cx - box.w / 2, y: top, w: box.w, h: box.h };
+ const mcx = mark.x + mark.w / 2;
+ const mcy = mark.y + mark.h / 2;
+ const nameB = name ? textBlock("brand", name, { y: top, color: pal.ink, cx }) : null;
+ const tagB = tagline ? textBlock("tagline", tagline, { y: top + box.h + gap, color: pal.muted, cx }) : null;
+ const tint = !!logo && sampleMark(c);
+
+ /** The mark as it rests (a sample lockup set in the look's ink; a person's own logo as it is). */
+ const whole = (): DisplayNode[] => (logo ? [logoNode(c, mark, pal.ink)] : nameB ? [lineRuns(nameB)] : []);
+ /** The mark's raw pieces (untinted), for the shards. */
+ const raw = (): DisplayNode[] => (logo ? [{ type: "image", src: "logo", ...mark }] : nameB ? [lineRuns(nameB)] : []);
+
+ // An SVG logo traces its own outlines; anything else assembles from shards of itself.
+ const svg = logo?.kind === "svg" && logo.paths?.length ? logoPaths(logo, mark) : null;
+ const traceGroups = svg ? Math.min(svg.length, 8) : 0;
+ const pad = S * 0.01;
+ const cutBox = { x: mark.x - pad, y: mark.y - pad, w: mark.w + 2 * pad, h: mark.h + 2 * pad };
+ const cols = Math.max(3, Math.min(8, Math.round((cutBox.w / cutBox.h) * 2)));
+ const rows = cutBox.h / cutBox.w > 0.5 ? 3 : 2;
+ const reach = S * (calm ? 0.09 : punchy ? 0.5 : 0.3);
+ const spin = calm ? 0.18 : punchy ? 1.3 : 0.7;
+ const shards: Shard[] = svg
+ ? []
+ : shardCuts(cutBox, cols, rows, seed).map((s, i) => {
+ // Out from the middle of the mark, bent a little by the seed.
+ const a = Math.atan2(s.cy - mcy, (s.cx - mcx) * 0.6) + rngRange(-0.5, 0.5, seed, "a", i);
+ const r = reach * rngRange(0.65, 1.15, seed, "r", i);
+ return { ...s, dx: Math.cos(a) * r, dy: Math.sin(a) * r * 0.8, turn: rngRange(-1, 1, seed, "t", i) * spin, at: rng(seed, "at", i) };
+ });
+
+ // The beats, spread over the length.
+ const k = spread(c, 2.8, 2.4);
+ const lines0 = 0.05;
+ const lineDur = (calm ? 0.95 : 0.7) * Math.min(1.4, k);
+ const build0 = lines0 + lineDur * 0.45;
+ const buildDur = (calm ? 1.35 : punchy ? 0.95 : 1.1) * Math.min(1.5, k);
+ const fly = calm ? 0.95 * Math.min(1.4, k) : punchy ? 0.6 : 0.75;
+ const click = build0 + buildDur;
+ const events = [
+ ev("lines", "draw", lines0, lineDur, "draw"),
+ ev("lines.out", "exit", lines0 + lineDur * 0.8, 0.5 * Math.min(1.4, k), "move"),
+ ...(svg
+ ? [
+ ...Array.from({ length: traceGroups }, (_, g) => ev(`trace.${g}`, "draw", build0 + g * Math.min(0.08, Math.max(0.04, (buildDur - 0.7) / Math.max(1, traceGroups))), 0.7, "draw", { group: "trace", unit: "words" })),
+ ev("fill", "fade", click - 0.25, 0.4, "enter"),
+ ]
+ : shards.map((s, i) => ev(`shard.${i}`, "enter", build0 + s.at * (buildDur - fly), fly, calm ? "glide" : "enter"))),
+ ev("flash", "fade", click, 0.45, "enter"),
+ ev("ring", "fade", click - 0.02, 0.75, "enter"),
+ ev("settle", "enter", click, 0.8, "settle"),
+ ev("glint", "move", click + 0.35 * k, 0.9, "move"),
+ ...(tagline ? [ev("tagline", "enter", click + 0.5 * k, 0.6, "glide")] : []),
+ ];
+ const shake = punchy ? { from: click, to: click + 0.3, amp: S * 0.007 } : null;
+ const hair = Math.max(1.2, S * 0.0022);
+ const span = Math.min(safe.w * 0.48, mark.w * 0.75 + S * 0.08);
+ const ly = [mark.y - S * 0.05, mark.y + mark.h + S * 0.05 - (tagline ? gap * 0.3 : 0)];
+ const flashTone = pal.look === "light" ? pal.mark : "#ffffff";
+
+ return {
+ events,
+ overflow: [...(name?.overflow ? ["brand"] : []), ...(tagline?.overflow ? ["tagline"] : [])],
+ signature: click - 0.12,
+ cuts: [],
+ camera: (t) => {
+ if (!shake || t < shake.from || t >= shake.to) return { zoom: 1, x: 0, y: 0 };
+ const fade = 1 - local(t, shake.from, shake.to);
+ return { zoom: 1 + 0.01 * fade, x: noise1(seed, "kx", t * 38) * shake.amp * fade, y: noise1(seed, "ky", t * 38) * shake.amp * fade };
+ },
+ frame(_t, P, Lp) {
+ const nodes: DisplayNode[] = [];
+ // The hairlines: out from the middle above and below, then away to the sides.
+ const grow = P("lines");
+ const gone = P("lines.out");
+ if (grow > 0 && gone < 1)
+ for (const y of ly)
+ for (const dir of [-1, 1]) {
+ const a = cx + dir * span * gone;
+ const b = cx + dir * span * Math.max(gone, grow);
+ if (Math.abs(b - a) > 0.5) nodes.push({ type: "path", d: `M${a.toFixed(2)} ${y.toFixed(2)}H${b.toFixed(2)}`, stroke: { paint: pal.mark, width: hair, cap: "round" } });
+ }
+ // The ring of light where it comes together.
+ const ring = Lp("ring");
+ if (ring > 0 && ring < 1) {
+ const r = Math.max(mark.w, mark.h) * (0.45 + 0.4 * P("ring"));
+ nodes.push({ type: "ellipse", cx: mcx, cy: mcy, rx: r, ry: r * (mark.h / mark.w > 0.6 ? 1 : 0.62), stroke: { paint: pal.mark, width: hair * 1.4 + S * 0.006 * (1 - ring) }, opacity: 1 - ring });
+ }
+ const settle = P("settle");
+ const s = Lp("settle") > 0 ? 1.035 - 0.035 * settle : 1;
+ const fill = svg ? P("fill") : Lp("flash") > 0 ? 1 : 0;
+ const ms: DisplayNode[] = [];
+ if (svg) {
+ // The outlines trace on in the words' colour, and the mark fills in under them.
+ if (fill > 0) ms.push(fill < 1 ? group(whole(), { opacity: fill }) : group(whole()));
+ if (fill < 1) {
+ const width = Math.max(1.2, mark.h * 0.012);
+ svg.forEach((p, i) => {
+ const trim = P(`trace.${Math.floor((i * traceGroups) / svg.length)}`);
+ if (trim > 0) ms.push({ type: "path", d: p.d, transform: p.m, stroke: { paint: pal.ink, width: width / p.scale, trim, length: p.length, cap: "round", join: "round" }, ...(fill > 0 && { opacity: 1 - fill }) });
+ });
+ }
+ } else if (fill >= 1) ms.push(...whole());
+ else {
+ // The shards of the mark, each clipped to its own cut, coming home.
+ const pieces: DisplayNode[] = [];
+ shards.forEach((sh, i) => {
+ const lin = Lp(`shard.${i}`);
+ if (lin <= 0) return;
+ const u = 1 - P(`shard.${i}`);
+ const m = multiply(translate(u * sh.dx, u * sh.dy), about(sh.cx, sh.cy, 1 + u * (calm ? 0.08 : 0.25), u * sh.turn));
+ pieces.push(group(raw(), { clip: { type: "path", d: sh.d }, transform: m, ...(lin < 0.35 && { opacity: lin / 0.35 }) }));
+ });
+ if (pieces.length) ms.push(tint ? group([...pieces, group([{ type: "rect", x: 0, y: 0, w: design.w, h: design.h, fill: pal.ink }], { blend: "source-atop" })], { isolate: { x: 0, y: 0, w: design.w, h: design.h } }) : group(pieces));
+ }
+ // The glint crosses the whole mark once it has settled.
+ const g = Lp("glint");
+ if (fill >= 1 && g > 0 && g < 1) {
+ const band = mark.w * 0.3;
+ const x = mark.x - band + (mark.w + 2 * band) * P("glint");
+ const glint: DisplayNode = { type: "rect", x: x - band, y: mark.y - mark.h, w: band * 2, h: mark.h * 3, fill: { kind: "linear", x0: x - band, y0: 0, x1: x + band, y1: 0, stops: [{ at: 0, color: "rgba(255,255,255,0)" }, { at: 0.5, color: pal.look === "light" ? "rgba(255,255,255,0.7)" : "rgba(255,255,255,0.5)" }, { at: 1, color: "rgba(255,255,255,0)" }] } };
+ const ink: DisplayNode[] = tint ? [group([{ type: "rect", x: mark.x - 4, y: mark.y - 4, w: mark.w + 8, h: mark.h + 8, fill: pal.ink }], { blend: "source-atop" })] : [];
+ nodes.push(group([...raw(), ...ink, group([glint], { blend: "source-atop" })], { transform: about(mcx, mcy, s), isolate: { x: mark.x - 6, y: mark.y - 6, w: mark.w + 12, h: mark.h + 12 } }));
+ } else if (ms.length) nodes.push(s !== 1 ? group(ms, { transform: about(mcx, mcy, s) }) : ms.length === 1 ? ms[0] : group(ms));
+ // The flash: a bloom of light off the mark the instant it is whole.
+ const f = P("flash");
+ if (Lp("flash") > 0 && f < 1) {
+ const R = Math.max(mark.w, mark.h) * 0.62;
+ nodes.push(group([{ type: "ellipse", cx: mcx, cy: mcy, rx: R, ry: R * 0.7, fill: { kind: "radial", cx: mcx, cy: mcy, r0: 0, r1: R, stops: [{ at: 0, color: withAlpha(flashTone, 0.22 * (1 - f)) }, { at: 1, color: withAlpha(flashTone, 0) }] } }], { blend: pal.look === "light" ? "multiply" : "screen" }));
+ }
+ if (tagB) {
+ const p = P("tagline");
+ if (p > 0) nodes.push(group([lineRuns(tagB)], { transform: translate(0, (1 - p) * S * 0.025), ...(p < 1 && { opacity: p }) }));
+ }
+ return { nodes };
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/offer-badge.ts b/src/lib/motion/scenes/marketing/offer-badge.ts
new file mode 100644
index 00000000..01a8f89e
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/offer-badge.ts
@@ -0,0 +1,121 @@
+/**
+ * Offer Badge: a starburst badge pops on with a turn that settles a few degrees off square, the offer set on it as
+ * typed; the product slides in under it from the side and lands on its shadow; the headline rises line by line and the
+ * call-to-action pill pops last. The badge sits where it covers none of the product (its own outline, not just its
+ * box), sized to the product; when no spot is clear the product steps back a little. While it holds, the product floats
+ * and the badge rocks gently. Without a product the logo (or the name) takes its place.
+ */
+
+import { about, group, multiply, translate, type DisplayNode } from "../../display";
+import { lineRuns } from "../end-card/shared";
+import { badgeSpot, contactShadow, ev, fitBox, heroOf, holdFloat, logoNode, marketingScene, MIN_BODY, MIN_HEAD, readable, risingLines, setText, spread, starPath, textBlock, type BadgeSpot } from "./kit";
+
+export default marketingScene({
+ id: "marketing/offer-badge",
+ name: "Offer Badge",
+ look: "light",
+ build(c) {
+ const { S, safe, palette: pal, design, recipe } = c;
+ const hero = heroOf(c);
+ const side = c.wide;
+ const textW = side ? safe.w * 0.46 : safe.w;
+ const textLeft = side ? safe.x + safe.w * 0.54 : safe.x;
+ const head = setText(c, c.field("headline"), { weight: 800, width: textW, maxLines: 2, max: S * (side ? 0.1 : c.tall ? 0.13 : 0.11), min: S * MIN_HEAD, lineHeight: 1.04 });
+ const ctaSize = S * (c.tall ? 0.056 : 0.05);
+ const cta = setText(c, c.field("cta"), { family: "body", weight: 700, width: textW - ctaSize * 2.4, maxLines: 1, max: ctaSize, min: S * MIN_BODY });
+ const bMax = S * (side ? 0.15 : 0.17);
+ const pillH = cta ? cta.size * 2.3 : 0;
+ const gap = S * 0.05;
+ // Where things go: the headline over the product and the pill under it (beside it on a wide frame).
+ let heroBox: { x: number; y: number; w: number; h: number };
+ let headY: number;
+ let pillY: number;
+ if (side) {
+ heroBox = { x: safe.x, y: safe.y + safe.h * 0.08, w: safe.w * 0.48, h: safe.h * 0.86 };
+ const stack = (head?.height ?? 0) + (cta ? gap + pillH : 0);
+ headY = safe.y + (safe.h - stack) / 2;
+ pillY = headY + (head ? head.height + gap : 0);
+ } else {
+ headY = safe.y;
+ const top = headY + (head ? head.height + gap : 0);
+ pillY = safe.y + safe.h - pillH;
+ heroBox = { x: safe.x + safe.w * 0.06, y: top + bMax * 0.3, w: safe.w * 0.88, h: pillY - gap - (top + bMax * 0.3) };
+ }
+ const product = hero?.src === "product" ? (c.input.outlines?.product ?? null) : null;
+ const name = !hero ? setText(c, recipe.brand.name, { weight: 800, width: heroBox.w * 0.8, maxLines: 2, max: S * 0.12, min: S * MIN_HEAD, lineHeight: 1.04 }) : null;
+ const nameB = name ? textBlock("brand", name, { y: heroBox.y + (heroBox.h - name.height) / 2, color: pal.ink, cx: heroBox.x + heroBox.w / 2 }) : null;
+ // The badge by the product, under the headline and over the pill.
+ const below = side ? safe.y : headY + (head ? head.height + gap * 0.3 : 0);
+ const bounds = { x: side ? heroBox.x : safe.x, y: below, w: side ? heroBox.w : safe.w, h: (side ? safe.y + safe.h : pillY - gap * 0.3) - below };
+ let img = hero ? fitBox(hero, heroBox, hero.src === "product") : null;
+ let spot: BadgeSpot;
+ const pic = () => img ?? (nameB && name ? { x: nameB.cx - name.width / 2, y: nameB.y, w: name.width, h: name.height } : heroBox);
+ spot = badgeSpot(pic(), product, bMax, bounds);
+ // No clear spot: the product steps back (smaller, on the same foot) until one is.
+ for (let i = 0; img && product && spot.cover > 0.04 && i < 3; i++) {
+ const k = 0.88;
+ img = { x: img.x + (img.w * (1 - k)) / 2, y: img.y + img.h * (1 - k), w: img.w * k, h: img.h * k };
+ spot = badgeSpot(img, product, bMax, bounds);
+ }
+ const bc: [number, number] = [spot.cx, spot.cy];
+ const bR = spot.r;
+ const offer = setText(c, c.field("offer"), { family: "figures", weight: 800, width: bR * 1.3, maxLines: 2, max: bR * 0.5, min: S * 0.035, lineHeight: 0.98 });
+ const headB = head ? textBlock("headline", head, { y: headY, color: pal.ink, ...(side ? { left: textLeft, width: textW } : { cx: design.w / 2 }) }) : null;
+ const pillW = cta ? Math.min(textW, cta.width + cta.size * 2.4) : 0;
+ const pillX = side ? (cta?.dir === "rtl" ? textLeft + textW - pillW : textLeft) : design.w / 2 - pillW / 2;
+ const ctaB = cta ? textBlock("cta", cta, { y: pillY + (pillH - cta.size * 1.12) / 2, color: pal.highlight.ink, cx: pillX + pillW / 2 }) : null;
+ const badgeFill = pal.mark;
+ const offerB = offer ? textBlock("offer", offer, { y: bc[1] - offer.height / 2, color: readable(badgeFill, pal.ground, pal.highlight.ink, pal.ink), cx: bc[0] }) : null;
+
+ // The beats, spread over the length: the badge, the product, the headline, the pill.
+ const k = spread(c, 1.95, 2.4);
+ const lines = head?.lines.length ?? 0;
+ const slideAt = 0.5 * k;
+ const headAt = 0.95 * k;
+ const ctaAt = 1.45 * k + lines * 0.09;
+ const events = [
+ ...(offer ? [ev("badge", "pop", 0.12, 0.6, "pop"), ev("badge.turn", "enter", 0.12, 0.7, "settle")] : []),
+ ev("slide", "enter", slideAt, 0.7, "enter"),
+ ev("shadow", "fade", slideAt + 0.2, 0.45, "enter"),
+ ...Array.from({ length: lines }, (_, i) => ev(`head.${i}`, "enter", headAt + i * 0.09, 0.55, "glide", { group: "head", unit: "elements" })),
+ ...(cta ? [ev("cta", "pop", ctaAt, 0.45, "pop")] : []),
+ ];
+ const holdFrom = slideAt + 0.75;
+
+ return {
+ events,
+ overflow: [...(offer?.overflow ? ["offer"] : []), ...(head?.overflow ? ["headline"] : []), ...(cta?.overflow ? ["cta"] : []), ...(name?.overflow ? ["brand"] : [])],
+ signature: slideAt + 0.35,
+ frame(t, P, Lp) {
+ const nodes: DisplayNode[] = [];
+ if (headB) nodes.push(...risingLines(headB, (i) => P(`head.${i}`)));
+ // The product slides in from the right and lands on its shadow, then floats while it holds.
+ const s = P("slide");
+ const lin = Lp("slide");
+ const fl = holdFloat(t, holdFrom, c.last, S * 0.012, 0.01);
+ if (img && hero) {
+ const sh = P("shadow");
+ if (sh > 0 && hero.src === "product") nodes.push(contactShadow(img.x + img.w / 2, img.y + img.h, img.w * 0.85 * (1 + fl.dy / (S * 0.2)), pal.ground, 0.3, sh));
+ const pic: DisplayNode = hero.src === "logo" ? logoNode(c, img, pal.ink) : { type: "image", src: hero.src, x: img.x, y: img.y, w: img.w, h: img.h };
+ if (lin > 0) nodes.push(group([pic], { transform: multiply(translate((1 - s) * S * 0.7, fl.dy), about(img.x + img.w / 2, img.y + img.h, 1, (1 - s) * 0.12 + fl.roll)), ...(lin < 0.25 && { opacity: lin / 0.25 }) }));
+ } else if (nameB && lin > 0) nodes.push(group([lineRuns(nameB)], { transform: translate((1 - s) * S * 0.5, 0), ...(lin < 0.25 && { opacity: lin / 0.25 }) }));
+ if (offerB) {
+ const b = P("badge");
+ const rock = holdFloat(t, 0.9, c.last, 0, 0.05).roll;
+ if (Lp("badge") > 0) nodes.push(group([{ type: "path", d: starPath(bc[0], bc[1], bR, bR * 0.86, 20), fill: badgeFill }, lineRuns(offerB)], { transform: about(bc[0], bc[1], Math.max(0, b), 0.14 - 0.65 * (1 - P("badge.turn")) + rock) }));
+ }
+ if (ctaB && cta) {
+ const p = P("cta");
+ const l = Lp("cta");
+ if (l > 0) {
+ const label = Math.min(1, Math.max(0, (l - 0.08) / 0.3));
+ const children: DisplayNode[] = [{ type: "rect", x: pillX, y: pillY, w: pillW, h: pillH, r: pillH / 2, fill: pal.highlight.fill }];
+ if (label > 0) children.push({ ...lineRuns(ctaB), ...(label < 1 && { opacity: label }) });
+ nodes.push(group(children, { transform: about(pillX + pillW / 2, pillY + pillH / 2, 0.6 + 0.4 * p), ...(l < 0.12 && { opacity: l / 0.12 }) }));
+ }
+ }
+ return { nodes };
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/quote.ts b/src/lib/motion/scenes/marketing/quote.ts
new file mode 100644
index 00000000..c7865545
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/quote.ts
@@ -0,0 +1,93 @@
+/**
+ * Five-Star Quote: five stars draw their outlines and fill one by one with a small spring, then the customer's words
+ * set line by line, exactly as typed (their own quotation marks, hung in the margin so the letters line up), the name
+ * follows under a short rule, and the brand signs off at the foot (its logo, else its name). The whole is centred in
+ * the frame, and the beats spread over the clip's length.
+ */
+
+import { group, translate, type DisplayNode } from "../../display";
+import { lineRuns } from "../end-card/shared";
+import { brandMark, ev, marketingScene, MIN_BODY, risingLines, setText, spread, starPath, textBlock } from "./kit";
+
+/** Opening quotation marks that hang into the margin. */
+const OPENERS = new Set(["“", '"', "‘", "'", "«", "„", "‹", "「", "『"]);
+
+export default marketingScene({
+ id: "marketing/quote",
+ name: "Five-Star Quote",
+ look: "light",
+ build(c) {
+ const { S, safe, palette: pal, design } = c;
+ const width = c.wide ? Math.min(safe.w, S * 1.4) : safe.w;
+ const left0 = (design.w - width) / 2;
+ const text = c.field("quote");
+ const first = [...text][0] ?? "";
+ const mark = brandMark(c, { maxW: S * (c.wide ? 0.32 : 0.46), h: S * (c.tall ? 0.085 : 0.065), color: pal.ink, minName: 0.04 });
+ const footH = mark ? mark.h + S * 0.07 : 0;
+ // Probe the size first, then hang the opening mark by its own width.
+ const size = { weight: 500, maxLines: c.tall ? 8 : 6, max: S * (c.tall ? 0.13 : c.wide ? 0.08 : 0.1), min: S * 0.045, lineHeight: 1.16 };
+ const probe = setText(c, text, { ...size, width });
+ const hang = probe && probe.dir === "ltr" && OPENERS.has(first) ? c.measure(first, probe.font) : 0;
+ const quote = hang ? setText(c, text, { ...size, width: width - hang }) : probe;
+ const name = setText(c, c.field("name"), { family: "body", weight: 600, width: width - S * 0.075, maxLines: 2, max: S * (c.tall ? 0.056 : 0.048), min: S * 0.038, lineHeight: 1.25 });
+ const star = S * (c.wide ? 0.06 : c.tall ? 0.075 : 0.068);
+ const starGap = star * 0.32;
+ const g1 = S * 0.06;
+ const g2 = S * 0.055;
+ const total = star + g1 + (quote?.height ?? 0) + (name ? g2 + name.height : 0);
+ const top = safe.y + Math.max(0, (safe.h - footH - total) / 2);
+ const quoteLeft = left0 + hang;
+ const quoteB = quote ? textBlock("quote", quote, { y: top + star + g1, color: pal.ink, left: quoteLeft, width: width - hang }) : null;
+ const nameY = top + star + g1 + (quote?.height ?? 0) + g2;
+ // A short rule leads the name (left-to-right names; a right-to-left one is set without it).
+ const ruleW = name && name.dir !== "rtl" ? S * 0.05 : 0;
+ const nameB = name ? textBlock("name", name, { y: nameY, color: pal.muted, left: left0 + (ruleW ? ruleW + S * 0.025 : 0), width: width - (ruleW ? ruleW + S * 0.025 : 0) }) : null;
+ const stars = Array.from({ length: 5 }, (_, i) => ({ cx: left0 + star / 2 + i * (star + starGap), cy: top + star / 2 }));
+ const starD = stars.map((s) => starPath(s.cx, s.cy, star / 2, star * 0.21, 5));
+ const footY = safe.y + safe.h - (mark?.h ?? 0);
+
+ // The beats, spread over the length: the stars, the words, the name, the sign-off.
+ const k = spread(c, 2.4);
+ const lines = quote?.lines.length ?? 0;
+ const qAt = 0.6 * k;
+ const each = Math.max(0.08, Math.min(0.14, 0.11 * k));
+ const nameAt = qAt + lines * each + 0.3 * k;
+ const events = [
+ ev("outline", "fade", 0.08, 0.35, "enter"),
+ ...stars.map((_, i) => ev(`star.${i}`, "pop", 0.2 + i * 0.08 * Math.max(1, Math.min(1.5, k)), 0.45, "pop", { group: "stars", unit: "elements" })),
+ ...Array.from({ length: lines }, (_, i) => ev(`line.${i}`, "enter", qAt + i * each, 0.6, "glide", { group: "quote", unit: "elements" })),
+ ...(name ? [ev("rule", "draw", nameAt - 0.1, 0.45, "draw"), ev("name", "enter", nameAt, 0.5, "glide")] : []),
+ ...(mark ? [ev("brand", "enter", nameAt + 0.55 * k, 0.6, "glide")] : []),
+ ];
+ const outlineW = Math.max(1.5, star * 0.045);
+
+ return {
+ events,
+ overflow: [...(quote?.overflow ? ["quote"] : []), ...(name?.overflow ? ["name"] : []), ...(mark?.overflow ? ["brand"] : [])],
+ signature: 0.2 + 0.18,
+ frame(_t, P, Lp) {
+ const nodes: DisplayNode[] = [];
+ const o = P("outline");
+ stars.forEach((s, i) => {
+ const f = P(`star.${i}`);
+ const l = Lp(`star.${i}`);
+ if (o > 0 && f < 1) nodes.push({ type: "path", d: starD[i], stroke: { paint: pal.mark, width: outlineW, join: "round" }, opacity: o });
+ if (l > 0) {
+ const sc = Math.max(0, 0.4 + 0.6 * f);
+ nodes.push(group([{ type: "path", d: starD[i], fill: pal.mark }], { transform: [sc, 0, 0, sc, s.cx - sc * s.cx, s.cy - sc * s.cy], ...(l < 0.2 && { opacity: l / 0.2 }) }));
+ }
+ });
+ if (quoteB) nodes.push(...risingLines(quoteB, (i) => P(`line.${i}`), (i) => (i === 0 ? -hang : 0)));
+ if (nameB && name) {
+ const r = P("rule");
+ const ry = nameY + name.lineHeight / 2;
+ if (r > 0 && ruleW) nodes.push({ type: "path", d: `M${left0} ${ry}H${left0 + ruleW}`, stroke: { paint: pal.mark, width: Math.max(1.5, S * 0.003), trim: r, length: ruleW, cap: "round" } });
+ const p = P("name");
+ if (p > 0) nodes.push(group([lineRuns(nameB)], { transform: translate(0, (1 - p) * S * 0.02), ...(p < 1 && { opacity: p }) }));
+ }
+ if (mark) nodes.push(...mark.draw(design.w / 2, footY, P("brand"), Lp("brand")));
+ return { nodes };
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/starburst.ts b/src/lib/motion/scenes/marketing/starburst.ts
new file mode 100644
index 00000000..e714570b
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/starburst.ts
@@ -0,0 +1,142 @@
+/**
+ * Retro Starburst: 24 rays in two kit colours turn slowly behind the product the whole clip long. The product drops in
+ * with a squash and a half turn that springs square onto a disc of light, and then sways and floats while it holds,
+ * well inside the disc; an optional sticker badge pops on with a tilt where it covers none of the product; and the
+ * headline, set big, lands on a full-width band at the foot that slides in at a slight tilt, so it reads on any ray.
+ * Without a product the logo (or the name) takes its place.
+ */
+
+import { contrast } from "@/components/ads/layout";
+import { about, group, mixHex, multiply, translate, type DisplayNode } from "../../display";
+import { lineRuns } from "../end-card/shared";
+import { badgeSpot, contactShadow, ev, fitBox, heroOf, holdFloat, logoNode, marketingScene, MIN_BODY, MIN_HEAD, readable, risingLines, setText, spread, starPath, textBlock } from "./kit";
+
+const RAYS = 24;
+
+/** The rays as one path: every other wedge of a full turn, from (cx, cy) out to radius r, turned by `rot`. */
+export function raysPath(cx: number, cy: number, r: number, rot: number, n = RAYS): string {
+ const parts: string[] = [];
+ const step = (Math.PI * 2) / n;
+ for (let i = 0; i < n; i += 2) {
+ const a = rot + i * step;
+ const b = a + step;
+ parts.push(`M${cx.toFixed(1)} ${cy.toFixed(1)}L${(cx + Math.cos(a) * r).toFixed(1)} ${(cy + Math.sin(a) * r).toFixed(1)}L${(cx + Math.cos(b) * r).toFixed(1)} ${(cy + Math.sin(b) * r).toFixed(1)}Z`);
+ }
+ return parts.join("");
+}
+
+/** The band's tilt (radians): a poster's slant, square enough to read. */
+const TILT = -0.035;
+
+export default marketingScene({
+ id: "marketing/starburst",
+ name: "Retro Starburst",
+ look: "brand",
+ build(c) {
+ const { S, safe, palette: pal, design, recipe } = c;
+ const hero = heroOf(c);
+ // The headline is the hero type: big, on a band that runs off both edges.
+ const head = setText(c, c.field("headline"), { weight: 800, width: safe.w * 0.9, maxLines: 2, max: S * (c.tall ? 0.16 : c.wide ? 0.11 : 0.13), min: S * MIN_HEAD, lineHeight: 1.0 });
+ const badge = setText(c, c.field("badge"), { weight: 800, width: S * 0.2, maxLines: 2, max: S * 0.056, min: S * MIN_BODY, lineHeight: 1.0 });
+ const bandPad = S * (c.tall ? 0.05 : 0.04);
+ const bandH = head ? head.height + bandPad * 2 : 0;
+ const gapB = S * 0.06;
+ // The disc: as big as the room over the band allows; the product holds inside 70 % of it.
+ const roomH = safe.h - (head ? bandH + gapB : 0);
+ const R = Math.min(safe.w * 0.5, roomH * 0.5);
+ const stackH = 2 * R + (head ? gapB + bandH : 0);
+ const top = safe.y + Math.max(0, (safe.h - stackH) / 2);
+ const centre: [number, number] = [design.w / 2, top + R];
+ const hold = { x: centre[0] - R * 0.7, y: centre[1] - R * 0.7, w: R * 1.4, h: R * 1.4 };
+ const img = hero ? fitBox(hero, hold, hero.src === "product") : null;
+ const bandY = top + 2 * R + gapB;
+ const name = !hero ? setText(c, recipe.brand.name, { weight: 800, width: R * 1.3, maxLines: 2, max: S * 0.13, min: S * MIN_HEAD, lineHeight: 1.04 }) : null;
+ const dark = pal.look === "dark";
+ // The rays: the brand's second colour over the brand colour (Brand colour); a rich tint of the bolder kit colour on
+ // the light and dark looks.
+ const rayColour = pal.look === "brand" ? pal.mark : mixHex(pal.ground, pal.mark, pal.look === "light" ? 0.34 : 0.3);
+ const apart = (x: string) => Math.min(contrast(x, rayColour), contrast(x, pal.ground));
+ const discColour = pal.look === "brand" ? mixHex(pal.ground, "#ffffff", 0.18) : dark ? mixHex(pal.ground, pal.mark, 0.22) : "#ffffff";
+ const nameB = name ? textBlock("brand", name, { y: centre[1] - name.height / 2, color: readable(discColour, pal.ink, pal.highlight.fill), cx: centre[0] }) : null;
+ // The band stands apart from both the rays and the ground: the highlight, a paper white or a deep shade, whichever
+ // does best against the nearer of the two.
+ const deepBand = mixHex(pal.ground, "#000000", 0.45);
+ const bandFill = [pal.highlight.fill, mixHex("#ffffff", pal.ground, 0.06), deepBand].reduce((best, x) => (apart(x) > apart(best) + 0.2 ? x : best));
+ const headB = head ? textBlock("headline", head, { y: bandY + bandPad, color: readable(bandFill, bandFill === pal.highlight.fill ? pal.highlight.ink : pal.ground, pal.ink, pal.mark), cx: design.w / 2 }) : null;
+ const reach = Math.hypot(design.w, design.h);
+ // The badge: a sticker by the product where it covers none of it.
+ const product = hero?.src === "product" ? (c.input.outlines?.product ?? null) : null;
+ const spot = img ? badgeSpot(img, product, S * 0.13, { x: safe.x, y: safe.y, w: safe.w, h: bandY - safe.y }) : { cx: centre[0] + R * 0.62, cy: centre[1] - R * 0.62, r: S * 0.12, cover: 0 };
+ const bR = spot.r;
+ const badgeFill = pal.look === "brand" ? pal.ink : pal.mark;
+ const badgeB = badge ? textBlock("badge", badge, { y: spot.cy - badge.height / 2, color: readable(badgeFill, pal.ground, pal.highlight.ink), cx: spot.cx }) : null;
+
+ const k = spread(c, 1.7, 2.4);
+ const dropAt = 0.3 * k;
+ const bandAt = 1.15 * k;
+ const events = [
+ ev("rays", "fade", 0, 0.6, "enter"),
+ ev("halo", "enter", 0.15 * k, 0.7, "enter"),
+ ev("drop", "pop", dropAt, 0.65, "pop"),
+ ev("spin", "enter", dropAt, 0.7, "settle"),
+ ev("shadow", "fade", dropAt + 0.25, 0.5, "enter"),
+ ...(badge ? [ev("badge", "pop", 0.85 * k, 0.55, "pop")] : []),
+ ...(head ? [ev("band", "enter", bandAt, 0.6, "snap"), ...head.lines.map((_, i) => ev(`head.${i}`, "enter", bandAt + 0.12 + i * 0.09, 0.55, "glide", { group: "head", unit: "elements" }))] : []),
+ ];
+ const holdFrom = dropAt + 0.7;
+ // The rays turn the whole clip long and stop on the last frame's angle.
+ const turn = (t: number) => -0.2 + (Math.min(t, c.last) / Math.max(1, c.last)) * 0.2;
+
+ return {
+ events,
+ overflow: [...(head?.overflow ? ["headline"] : []), ...(badge?.overflow ? ["badge"] : []), ...(name?.overflow ? ["brand"] : [])],
+ signature: dropAt + 0.25,
+ frame(t, P, Lp) {
+ const r = P("rays");
+ const under: DisplayNode[] = [{ type: "path", d: raysPath(centre[0], centre[1], reach, turn(t)), fill: rayColour, ...(r < 1 && { opacity: r }) }];
+ const nodes: DisplayNode[] = [];
+ const h = P("halo");
+ if (h > 0) {
+ const hr = R * (0.6 + 0.4 * h);
+ nodes.push({ type: "ellipse", cx: centre[0], cy: centre[1], rx: hr, ry: hr, fill: discColour, ...(h < 1 && { opacity: h }) });
+ }
+ // While it holds: a slow sway and float, still again on the last frame.
+ const fl = holdFloat(t, holdFrom, c.last, S * 0.014, 0.045);
+ if (img && hero) {
+ const sh = P("shadow");
+ if (sh > 0 && hero.src === "product") nodes.push(contactShadow(centre[0], img.y + img.h, img.w * 0.8, discColour, 0.4, sh));
+ const d = P("drop");
+ const lin = Lp("drop");
+ if (lin > 0) {
+ // Squash on landing: wide and short as it hits, springing back to its shape.
+ const over = d - 1;
+ const sx = 1 + over * 0.9;
+ const sy = 1 - over * 0.9;
+ const foot = img.y + img.h;
+ const m = multiply(translate(0, -(1 - Math.min(1, d)) * S * 0.45 + fl.dy), multiply(about(centre[0], foot, sx, fl.roll, sy), about(centre[0], img.y + img.h / 2, 0.7 + 0.3 * Math.min(1, d), (1 - P("spin")) * -0.35)));
+ const pic: DisplayNode = hero.src === "logo" ? logoNode(c, img, pal.ink) : { type: "image", src: hero.src, x: img.x, y: img.y, w: img.w, h: img.h };
+ nodes.push(group([pic], { transform: m, ...(lin < 0.15 && { opacity: lin / 0.15 }) }));
+ }
+ } else if (nameB) {
+ const d = P("drop");
+ if (Lp("drop") > 0) nodes.push(group([lineRuns(nameB)], { transform: multiply(translate(0, fl.dy), about(centre[0], centre[1], 0.6 + 0.4 * d, (1 - P("spin")) * -0.5 + fl.roll)) }));
+ }
+ if (badgeB) {
+ const b = P("badge");
+ if (Lp("badge") > 0) nodes.push(group([{ type: "path", d: starPath(spot.cx, spot.cy, bR, bR * 0.84, 16), fill: badgeFill }, lineRuns(badgeB)], { transform: about(spot.cx, spot.cy, Math.max(0, b), 0.14 * b - 0.4 * (1 - b)) }));
+ }
+ if (headB) {
+ const band = P("band");
+ const lin = Lp("band");
+ if (lin > 0) {
+ // The band runs off both edges, sliding in from the left; the words rise on it.
+ const over = S * 0.2;
+ const children: DisplayNode[] = [{ type: "rect", x: -over - (1 - band) * (design.w + over), y: bandY, w: design.w + 2 * over, h: bandH, fill: bandFill }, ...risingLines(headB, (i) => P(`head.${i}`))];
+ nodes.push(group(children, { transform: about(design.w / 2, bandY + bandH / 2, 1, TILT) }));
+ }
+ }
+ return { under, nodes };
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/scenes/marketing/stat-dashboard.ts b/src/lib/motion/scenes/marketing/stat-dashboard.ts
new file mode 100644
index 00000000..e39a7523
--- /dev/null
+++ b/src/lib/motion/scenes/marketing/stat-dashboard.ts
@@ -0,0 +1,165 @@
+/**
+ * Dashboard Zoom: a designed dashboard panel rises, its grid fades up, the bars grow one by one, a trend line draws over
+ * them and its last point pops, while the key number rolls up to the value the person typed (figure by figure, in
+ * tabular cells, with their own separators) and the camera pushes in from a slight angle to rest square on the panel.
+ * The panel carries the brand (its logo, else its name) in its header, and the number is set in lining figures (a face
+ * whose default figures are old-style hands the number to the body face). The beats spread over the clip's length, and
+ * the push runs the whole clip long. The last frame shows the typed number exactly.
+ */
+
+import { about, group, multiply, translate, withAlpha, mixHex, type DisplayNode } from "../../display";
+import { rngRange } from "../../random";
+import { lineRuns } from "../end-card/shared";
+import { centreFigures, counterLayout, counterNode, ev, figureFamily, logoNode, marketingScene, MIN_BODY, readable, setText, shadowOf, spread, textBlock } from "./kit";
+
+/** An open smooth curve through points (Catmull–Rom as cubic Béziers), and its length. */
+export function smoothOpenPath(pts: [number, number][]): { d: string; length: number } {
+ const n = pts.length;
+ const parts = [`M${pts[0][0].toFixed(2)} ${pts[0][1].toFixed(2)}`];
+ let length = 0;
+ for (let i = 0; i < n - 1; i++) {
+ const p0 = pts[Math.max(0, i - 1)];
+ const p1 = pts[i];
+ const p2 = pts[i + 1];
+ const p3 = pts[Math.min(n - 1, i + 2)];
+ const c1 = [p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6];
+ const c2 = [p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6];
+ parts.push(`C${c1[0].toFixed(2)} ${c1[1].toFixed(2)} ${c2[0].toFixed(2)} ${c2[1].toFixed(2)} ${p2[0].toFixed(2)} ${p2[1].toFixed(2)}`);
+ let px = p1[0];
+ let py = p1[1];
+ for (let k = 1; k <= 10; k++) {
+ const t = k / 10;
+ const u = 1 - t;
+ const x = u * u * u * p1[0] + 3 * u * u * t * c1[0] + 3 * u * t * t * c2[0] + t * t * t * p2[0];
+ const y = u * u * u * p1[1] + 3 * u * u * t * c1[1] + 3 * u * t * t * c2[1] + t * t * t * p2[1];
+ length += Math.hypot(x - px, y - py);
+ px = x;
+ py = y;
+ }
+ }
+ return { d: parts.join(""), length };
+}
+
+const BARS = 12;
+
+export default marketingScene({
+ id: "marketing/stat-dashboard",
+ name: "Dashboard Zoom",
+ look: "dark",
+ build(c) {
+ const { S, safe, palette: pal, design, recipe } = c;
+ const panel = c.wide ? { x: safe.x + safe.w * 0.05, y: safe.y, w: safe.w * 0.9, h: safe.h } : c.tall ? { x: safe.x, y: safe.y + safe.h * 0.07, w: safe.w, h: safe.h * 0.8 } : { x: safe.x, y: safe.y, w: safe.w, h: safe.h };
+ const P0 = S * 0.055;
+ const inner = panel.w - 2 * P0;
+ const ink = pal.surfaceInk;
+ const quiet = readable(pal.surface, mixHex(ink, pal.surface, 0.28), ink);
+ // The header: the logo (at most this tall), else the name.
+ const logo = c.input.logo;
+ const logoH = S * 0.07;
+ const logoBox = logo ? (() => {
+ const s = Math.min((inner * 0.6) / logo.w, logoH / logo.h);
+ return { x: panel.x + P0, y: panel.y + P0, w: logo.w * s, h: logo.h * s };
+ })() : null;
+ const brand = !logo ? setText(c, recipe.brand.name, { family: "body", weight: 700, width: inner * 0.7, maxLines: 1, max: S * 0.038, min: S * MIN_BODY }) : null;
+ const statText = c.field("stat", "0");
+ const stat = centreFigures(counterLayout("stat", statText, figureFamily(c, 800), 800, inner, S * (c.wide ? 0.15 : 0.16), S * 0.07, c.measure), c.measure);
+ const label = setText(c, c.field("label"), { family: "body", weight: 500, width: inner, maxLines: 2, max: S * 0.042, min: S * MIN_BODY, lineHeight: 1.25 });
+ const headTop = panel.y + P0;
+ const statTop = headTop + (logoBox ? logoBox.h + S * 0.045 : brand ? brand.size * 1.2 + S * 0.045 : 0);
+ const labelTop = statTop + stat.size * 1.12 + S * 0.012;
+ const chartTop = labelTop + (label ? label.height : 0) + S * 0.06;
+ const chartBottom = panel.y + panel.h - P0;
+ const chartH = Math.max(S * 0.12, chartBottom - chartTop);
+ const numberInk = readable(pal.surface, pal.accent, ink);
+ const brandB = brand ? textBlock("brand", brand, { y: headTop, color: quiet, left: panel.x + P0, width: inner * 0.7 }) : null;
+ const labelB = label ? textBlock("label", label, { y: labelTop, color: quiet, left: panel.x + P0, width: inner }) : null;
+
+ // The data: a seeded climb, the last bar the highest.
+ const values = Array.from({ length: BARS }, (_, i) => Math.min(1, Math.max(0.14, 0.24 + 0.62 * (i / (BARS - 1)) ** 1.25 + rngRange(-0.09, 0.09, recipe.seed, "bar", i))));
+ values[BARS - 1] = 1;
+ const slot = inner / BARS;
+ const barW = slot * 0.56;
+ const bars = values.map((v, i) => ({ x: panel.x + P0 + i * slot + (slot - barW) / 2, h: v * chartH * 0.86 }));
+ const pts = bars.map((b, i) => [b.x + barW / 2, chartBottom - b.h - chartH * 0.08 - rngRange(0, 0.05, recipe.seed, "pt", i) * chartH] as [number, number]);
+ const line = smoothOpenPath(pts);
+ const area = `${line.d}L${pts[BARS - 1][0]} ${chartBottom}L${pts[0][0]} ${chartBottom}Z`;
+ const barColour = mixHex(pal.surface, pal.mark2, pal.look === "light" ? 0.32 : 0.45);
+ const grid = mixHex(pal.surface, ink, 0.1);
+
+ const k = spread(c, 1.95);
+ const events = [
+ ev("panel", "enter", 0.08, 0.65, "enter"),
+ ev("grid", "fade", 0.35 * k, 0.5, "enter"),
+ ...bars.map((_, i) => ev(`bar.${i}`, "enter", 0.5 * k + i * 0.08, 0.5, "enter", { group: "bars", unit: "elements" })),
+ ev("line", "draw", 0.75 * k, 1.2, "draw"),
+ ev("area", "fade", 0.75 * k + 0.9, 0.6, "enter"),
+ ev("dot", "pop", 0.75 * k + 1.05, 0.4, "pop"),
+ ev("count", "move", 0.45 * k, Math.min(2.2, 1.5 * k), "linear"),
+ ev("brand", "fade", 0.3, 0.4, "enter"),
+ ...(label ? [ev("label", "enter", 0.62 * k, 0.45, "glide")] : []),
+ ev("push", "camera", 0, c.last, "drift"),
+ ];
+ const shadow = shadowOf(pal.ground, pal.look === "light" ? 0.14 : 0.45);
+ // Pulses 1.6 s apart from when the point lands, the last one done before the last frame.
+ const dotEnd = 0.75 * k + 1.45;
+ const pulse = (t: number): number => {
+ if (t <= dotEnd) return 0;
+ const n = Math.floor((t - dotEnd) / 1.6);
+ return dotEnd + (n + 1) * 1.6 > c.last ? 0 : ((t - dotEnd) % 1.6) / 1.6;
+ };
+
+ return {
+ events,
+ overflow: [...(stat.overflow ? ["stat"] : []), ...(label?.overflow ? ["label"] : []), ...(brand?.overflow ? ["brand"] : [])],
+ signature: 0.75 * k + 0.7,
+ camera: () => ({ zoom: 1, x: 0, y: 0 }),
+ frame(t, P, Lp) {
+ // The push: from a little farther out and turned, square on the panel at rest.
+ const push = P("push");
+ const cam = multiply(translate(0, (1 - push) * S * 0.05), about(design.w / 2, panel.y + panel.h * 0.4, 0.88 + 0.12 * push, -0.035 * (1 - push)));
+ const pe = P("panel");
+ const children: DisplayNode[] = [
+ { type: "rect", x: panel.x, y: panel.y + S * 0.02, w: panel.w, h: panel.h, r: S * 0.04, fill: shadow },
+ { type: "rect", x: panel.x, y: panel.y, w: panel.w, h: panel.h, r: S * 0.04, fill: pal.surface },
+ ];
+ // Window dots, top right.
+ for (let i = 0; i < 3; i++) children.push({ type: "ellipse", cx: panel.x + panel.w - P0 - i * S * 0.03, cy: headTop + S * 0.017, rx: S * 0.008, ry: S * 0.008, fill: grid });
+ const g = P("grid");
+ if (g > 0) for (let i = 0; i < 4; i++) children.push({ type: "rect", x: panel.x + P0, y: chartBottom - (i / 3) * chartH * 0.92, w: inner, h: Math.max(1.5, S * 0.002), fill: grid, opacity: g });
+ bars.forEach((b, i) => {
+ const q = P(`bar.${i}`);
+ if (q <= 0) return;
+ const h = b.h * q;
+ children.push({ type: "rect", x: b.x, y: chartBottom - h, w: barW, h, r: Math.min(barW * 0.22, h / 2), fill: i === BARS - 1 ? pal.highlight.fill : barColour });
+ });
+ const a = P("area");
+ if (a > 0) children.push({ type: "path", d: area, fill: { kind: "linear", x0: 0, y0: chartTop, x1: 0, y1: chartBottom, stops: [{ at: 0, color: withAlpha(pal.mark, 0.32) }, { at: 1, color: withAlpha(pal.mark, 0) }] }, opacity: a });
+ const l = P("line");
+ if (l > 0) children.push({ type: "path", d: line.d, stroke: { paint: pal.mark, width: S * 0.0065, trim: l, length: line.length, cap: "round", join: "round" } });
+ const dot = P("dot");
+ if (Lp("dot") > 0) {
+ const end = pts[BARS - 1];
+ const r = S * 0.014 * Math.max(0, dot);
+ children.push({ type: "ellipse", cx: end[0], cy: end[1], rx: r * 1.9, ry: r * 1.9, fill: withAlpha(pal.mark, 0.25) }, { type: "ellipse", cx: end[0], cy: end[1], rx: r, ry: r, fill: pal.mark });
+ // The live point keeps a slow pulse while the piece holds (none on the last frame).
+ const ph = pulse(t);
+ if (ph > 0 && ph < 1) children.push({ type: "ellipse", cx: end[0], cy: end[1], rx: S * 0.014 * (1.9 + 3.2 * ph), ry: S * 0.014 * (1.9 + 3.2 * ph), stroke: { paint: pal.mark, width: Math.max(1.5, S * 0.003) }, opacity: 0.55 * (1 - ph) });
+ }
+ if (logoBox) {
+ const b = P("brand");
+ if (b > 0) children.push(b < 1 ? group([logoNode(c, logoBox, quiet)], { opacity: b }) : logoNode(c, logoBox, quiet));
+ } else if (brandB) {
+ const b = P("brand");
+ if (b > 0) children.push({ ...lineRuns(brandB), ...(b < 1 && { opacity: b }) });
+ }
+ if (Lp("count") > 0) children.push(counterNode(stat, panel.x + P0, statTop, numberInk, Lp("count")));
+ if (labelB) {
+ const q = P("label");
+ if (q > 0) children.push(group([lineRuns(labelB)], { transform: translate(0, (1 - q) * S * 0.02), ...(q < 1 && { opacity: q }) }));
+ }
+ const lin = Lp("panel");
+ return { nodes: lin > 0 ? [group([group(children, { transform: translate(0, (1 - pe) * S * 0.08), ...(lin < 0.35 && { opacity: lin / 0.35 }) })], { transform: cam })] : [] };
+ },
+ };
+ },
+});
diff --git a/src/lib/motion/showcase.ts b/src/lib/motion/showcase.ts
new file mode 100644
index 00000000..112740cf
--- /dev/null
+++ b/src/lib/motion/showcase.ts
@@ -0,0 +1,90 @@
+/**
+ * Showcase recipes for Marketing's code-drawn templates (pure): fictional premium brands, each with a deliberate
+ * palette and a Google font pairing, and words written to read as real campaigns. They make each template's cover
+ * (rendered by the engine itself: scripts/kinetic/render-covers.mjs) and fill a template when it first opens, so the
+ * live preview starts from a finished piece that the person then makes their own.
+ */
+
+import { DEFAULT_EXPORT, type Recipe } from "./recipe";
+import type { SizePreset } from "./sizes";
+
+export interface ShowcaseBrand {
+ name: string;
+ colors: string[];
+ fonts: { heading: string; body: string };
+ /** Its lockup (symbol and wordmark as outlines, in one colour), drawn by Fuobe: /previews/kinetic/marks/…svg. */
+ logo: string;
+}
+
+export const SHOWCASE_BRANDS = {
+ ardent: { name: "Maison Ardent", colors: ["#2f3b2c", "#c9a46a"], fonts: { heading: "Playfair Display", body: "Inter" }, logo: "/previews/kinetic/marks/ardent.svg?v=9d6992d9" },
+ lumen: { name: "Lumen Labs", colors: ["#3d5afe", "#9fe7ff"], fonts: { heading: "Space Grotesk", body: "Inter" }, logo: "/previews/kinetic/marks/lumen.svg?v=5383c502" },
+ ledgerly: { name: "Ledgerly", colors: ["#0f5c5a", "#f4b860"], fonts: { heading: "Space Grotesk", body: "Inter" }, logo: "/previews/kinetic/marks/ledgerly.svg?v=04360c5d" },
+ vesper: { name: "Vesper", colors: ["#c8102e", "#f4b43c"], fonts: { heading: "Fraunces", body: "Manrope" }, logo: "/previews/kinetic/marks/vesper.svg?v=7c2c68c7" },
+ sora: { name: "Sora Skin", colors: ["#b5532f", "#e9b872"], fonts: { heading: "Fraunces", body: "Manrope" }, logo: "/previews/kinetic/marks/sora.svg?v=0b4eecd2" },
+ aurele: { name: "Aurèle", colors: ["#0e3b2f", "#cfae6e"], fonts: { heading: "Cormorant Garamond", body: "Manrope" }, logo: "/previews/kinetic/marks/aurele.svg?v=55ea21a5" },
+} satisfies Record<string, ShowcaseBrand>;
+
+export type ShowcaseBrandId = keyof typeof SHOWCASE_BRANDS;
+
+/** Fuobe's own sample products, cut out (with their versions). */
+export const SHOWCASE_PRODUCTS = {
+ perfume: "/previews/kinetic/perfume.webp?v=118749e2",
+ heel: "/previews/kinetic/heel.webp?v=2ce2f692",
+} as const;
+
+export interface Showcase {
+ brand: ShowcaseBrandId;
+ fields: Record<string, string>;
+ controls: Record<string, string>;
+ product?: keyof typeof SHOWCASE_PRODUCTS;
+ size: SizePreset;
+ /** The scene, when a choice picks it (the end card's style). */
+ scene?: string;
+ /**
+ * Where its cover rests, when the telling moment comes before the end: just before this event starts (the headline
+ * fully set, before it gives way to the logo). By default the cover rests on the last frame.
+ */
+ poster?: string;
+ /**
+ * The size its cover is made at, when not its own: a tall piece's cover is made at 4:5, so the gallery's 3:4 tile
+ * shows all of it (a 9:16 frame cropped to 3:4 loses its top and its foot).
+ */
+ cover?: SizePreset;
+}
+
+/** Each code-drawn template's showcase, by template id. */
+export const SHOWCASES: Record<string, Showcase> = {
+ "ms-kinetic-headline": { brand: "lumen", size: "9:16", fields: { headline: "Invoices that *chase* themselves.", cta: "Start free", website: "lumenlabs.io" }, controls: { pace: "punchy", look: "dark", align: "centre" }, poster: "words.exit", cover: "4:5" },
+ "m2-line-reveal": { brand: "ardent", size: "9:16", product: "perfume", fields: { headline: "Quietly exceptional.", cta: "Discover the scent" }, controls: { pace: "calm", look: "light", line: "fine" }, cover: "4:5" },
+ "ms-logo-sting": { brand: "lumen", size: "4:5", fields: { tagline: "Software that ships itself" }, controls: { pace: "punchy", look: "dark" } },
+ "ms-feature-cards": { brand: "ledgerly", size: "4:5", fields: { headline: "Month-end, minus the panic", point1: "Invoices that chase themselves", point2: "Payroll in two taps", point3: "Books that close on Friday" }, controls: { pace: "calm", look: "light" } },
+ "ms-dashboard-zoom": { brand: "ledgerly", size: "4:5", fields: { stat: "$1,284,000", label: "Revenue this quarter, up 38%" }, controls: { pace: "calm", look: "dark" } },
+ "m2-retro-starburst": { brand: "vesper", size: "9:16", product: "heel", fields: { headline: "Made to be noticed.", badge: "New!" }, controls: { pace: "punchy", look: "brand" }, cover: "4:5" },
+ "m2-offer-badge": { brand: "sora", size: "9:16", product: "perfume", fields: { offer: "20% off", headline: "The gifting edit", cta: "Shop the edit" }, controls: { pace: "punchy", look: "light" }, cover: "4:5" },
+ "ms-big-number": { brand: "ledgerly", size: "4:5", fields: { stat: "3×", caption: "faster month-end close" }, controls: { pace: "punchy", look: "brand" } },
+ "ms-five-star-quote": { brand: "sora", size: "4:5", fields: { quote: "“The only serum I’ve ever bought three times.”", name: "Amara K., verified buyer" }, controls: { pace: "calm", look: "light" } },
+ "ms-end-card": { brand: "aurele", size: "9:16", scene: "end-card/draw-on", fields: { product: "Le Sérum Nuit", cta: "Discover the ritual", website: "aurele-paris.com" }, controls: { style: "draw-on", mark: "logo" }, cover: "4:5" },
+};
+
+/** A template's showcase as a full recipe (its scene, 30 fps, its own length; `cover`: at its cover's size). */
+export function showcaseRecipe(id: string, scene: string, duration = 5, o: { cover?: boolean } = {}): Recipe | null {
+ const s = SHOWCASES[id];
+ if (!s) return null;
+ const b = SHOWCASE_BRANDS[s.brand];
+ // The end card's "Name" choice sets the name in type even when there is a logo.
+ const logo = s.controls.mark === "name" ? undefined : b.logo;
+ return {
+ v: 1,
+ scene: s.scene ?? scene,
+ seed: 7,
+ size: (o.cover && s.cover) || s.size,
+ fps: 30,
+ duration,
+ fields: s.brand === "aurele" ? { brand: b.name, ...s.fields } : { ...s.fields },
+ brand: { name: b.name, colors: [...b.colors], fonts: { ...b.fonts }, ...(logo && { logo }) },
+ ...(s.product && { media: { product: SHOWCASE_PRODUCTS[s.product] } }),
+ controls: { template: id, ...s.controls },
+ export: DEFAULT_EXPORT,
+ };
+}
diff --git a/src/lib/motion/template.ts b/src/lib/motion/template.ts
new file mode 100644
index 00000000..8548145f
--- /dev/null
+++ b/src/lib/motion/template.ts
@@ -0,0 +1,129 @@
+/**
+ * A code-drawn Marketing template as a recipe (pure): what the person typed and picked on the template's page (its
+ * words, quick choices, size, length, brand and picture), made into the Kinetic Motion recipe that plays in the preview
+ * and is saved with the result. The page starts from the template's showcase, so it opens on a finished piece.
+ */
+
+import { FORMATS, KINETIC_SIZES, type MarketingTemplate } from "@/lib/catalog/marketing";
+import { unmarked } from "./marks";
+import { DEFAULT_EXPORT, type Recipe } from "./recipe";
+import { SHOWCASE_BRANDS, SHOWCASE_PRODUCTS, SHOWCASES } from "./showcase";
+import type { SizePreset } from "./sizes";
+
+export interface TemplateBrand {
+ name: string;
+ /** The main colour first, then the second. */
+ colors: string[];
+ fonts: { heading: string; body: string };
+ /** A stored logo (/api/files/…). */
+ logo?: string | null;
+}
+
+export interface TemplateState {
+ fields: Record<string, string>;
+ controls: Record<string, string>;
+ size: SizePreset;
+ duration: number;
+ brand: TemplateBrand;
+ /** The picture the template shows (a stored file, or one of Fuobe's sample products). */
+ product?: string | null;
+}
+
+const HEX = /^#[0-9a-f]{6}$/i;
+
+/** The sizes this template comes in: the four Kinetic sizes, its own first. */
+export function templateSizes(t: MarketingTemplate): SizePreset[] {
+ const own = KINETIC_SIZES.find((s) => s === t.aspect);
+ return own ? [own, ...KINETIC_SIZES.filter((s) => s !== own)] : [...KINETIC_SIZES];
+}
+
+/** The lengths it can be (seconds). */
+export function templateLengths(t: MarketingTemplate): { min: number; max: number; default: number } {
+ return t.lengths ?? FORMATS[t.format].durations ?? { min: 5, max: 15, default: t.duration ?? 5 };
+}
+
+/** The scene a state plays: a choice that picks the scene (the end card's style) wins. */
+export function templateScene(t: MarketingTemplate, controls: Record<string, string>): string {
+ for (const g of t.easy ?? []) {
+ if (!g.scene) continue;
+ const pick = g.choices.find((c) => c.id === controls[g.id]) ?? g.choices[0];
+ return `${g.scene}/${pick.id}`;
+ }
+ return t.scene ?? "";
+}
+
+/** The showcase brand a template opens with. */
+export function showcaseBrand(t: MarketingTemplate): TemplateBrand {
+ const b = SHOWCASE_BRANDS[SHOWCASES[t.id]?.brand ?? "lumen"];
+ return { name: b.name, colors: [...b.colors], fonts: { ...b.fonts }, logo: b.logo };
+}
+
+/** The state a template opens in: its showcase words and choices, and the person's own brand when they set one. */
+export function initialState(t: MarketingTemplate, brand?: TemplateBrand | null): TemplateState {
+ const s = SHOWCASES[t.id];
+ const sizes = templateSizes(t);
+ const lengths = templateLengths(t);
+ const controls: Record<string, string> = {};
+ for (const g of t.easy ?? []) controls[g.id] = s?.controls[g.id] ?? g.choices[0].id;
+ const fields: Record<string, string> = {};
+ for (const f of t.fields ?? []) fields[f.key] = s?.fields[f.key] ?? "";
+ return {
+ fields,
+ controls,
+ size: s?.size && sizes.includes(s.size) ? s.size : sizes[0],
+ duration: lengths.default,
+ brand: brand ?? showcaseBrand(t),
+ product: t.picture === "product" ? (s?.product ? SHOWCASE_PRODUCTS[s.product] : SHOWCASE_PRODUCTS.perfume) : null,
+ };
+}
+
+/** Whether the scene is the end card (its brand name is a field of its own, and its mark a choice). */
+const isEndCard = (scene: string) => scene.startsWith("end-card/");
+
+/** The state as the recipe the preview plays and the result keeps. */
+export function templateRecipe(t: MarketingTemplate, s: TemplateState): Recipe {
+ const scene = templateScene(t, s.controls);
+ const lengths = templateLengths(t);
+ const colors = s.brand.colors.filter((c) => HEX.test(c)).slice(0, 8);
+ const fields: Record<string, string> = {};
+ for (const f of t.fields ?? []) {
+ const v = s.fields[f.key] ?? "";
+ if (v.trim()) fields[f.key] = v.slice(0, f.max);
+ }
+ const endCard = isEndCard(scene);
+ if (endCard) fields.brand = s.brand.name;
+ // The end card's "Name" choice sets the brand name in type even when there is a logo.
+ const logo = s.brand.logo && !(endCard && s.controls.mark === "name") ? s.brand.logo : undefined;
+ const controls: Record<string, string> = { template: t.id };
+ for (const g of t.easy ?? []) if (!g.scene && s.controls[g.id]) controls[g.id] = s.controls[g.id];
+ const product = t.picture === "product" && s.product ? s.product : undefined;
+ return {
+ v: 1,
+ scene,
+ seed: 7,
+ size: s.size,
+ fps: 30,
+ duration: Math.min(lengths.max, Math.max(lengths.min, s.duration)),
+ fields,
+ brand: { name: s.brand.name.slice(0, 120), colors, fonts: { heading: s.brand.fonts.heading, body: s.brand.fonts.body }, ...(logo && { logo }) },
+ ...(product && { media: { product } }),
+ controls,
+ export: DEFAULT_EXPORT,
+ };
+}
+
+/** Whether a template's field takes *stars* round the words it highlights. */
+export const marks = (t: MarketingTemplate, key: string): boolean => t.scene === "marketing/kinetic-headline" && key === "headline";
+
+/** What a saved result is listed and searched by: "Kinetic Headline · Invoices that chase", and the typed words. */
+export function templateWords(t: MarketingTemplate, s: TemplateState): { title: string; prompt: string } {
+ // Only the Kinetic Headline's headline takes *marks*; every other field reads exactly as typed.
+ const typed = (t.fields ?? []).map((f) => (marks(t, f.key) ? unmarked(s.fields[f.key] ?? "") : (s.fields[f.key] ?? "")).trim()).filter(Boolean);
+ const first = (typed[0] ?? s.brand.name).split(/\s+/).slice(0, 5).join(" ");
+ return { title: `${t.name} · ${first}`.slice(0, 200), prompt: [s.brand.name, ...typed].filter(Boolean).join(" · ").slice(0, 2000) };
+}
+
+/** The person's own stored files a recipe was made from (their logo, their picture). */
+export function ownFiles(r: Recipe): string[] {
+ return [r.brand.logo, r.media?.product].filter((u): u is string => !!u?.startsWith("/api/files/"));
+}
diff --git a/src/lib/template-covers.generated.ts b/src/lib/template-covers.generated.ts
index 25f9dec2..96024e66 100644
--- a/src/lib/template-covers.generated.ts
+++ b/src/lib/template-covers.generated.ts
@@ -19,10 +19,19 @@ export const TEMPLATE_COVERS: Record<string, TemplateCoverEntry> = {
"canvas/effect-chain-superstar": {"poster":"/previews/presets/peak/effect-superstar.jpg?v=8eb5e622","video":"/previews/presets/effect-superstar.mp4?v=c0066397","at":3.5625},
"content-factory/what-if": "9eab5dcb",
"marketing/m2-comic-panels": "5b751ae1",
+ "marketing/m2-line-reveal": {"poster":"/previews/templates/marketing/m2-line-reveal.jpg?v=491dce17","video":"/previews/templates/marketing/m2-line-reveal.mp4?v=20ad54f8","at":4.958},
+ "marketing/m2-offer-badge": {"poster":"/previews/templates/marketing/m2-offer-badge.jpg?v=9fc5d192","video":"/previews/templates/marketing/m2-offer-badge.mp4?v=eaf7a5ea","at":4.958},
"marketing/m2-paper-parade": "a21bc137",
- "marketing/m2-retro-starburst": "14e505c2",
+ "marketing/m2-retro-starburst": {"poster":"/previews/templates/marketing/m2-retro-starburst.jpg?v=acaa97da","video":"/previews/templates/marketing/m2-retro-starburst.mp4?v=62109bf0","at":4.958},
"marketing/m2-sticker-pop": "eb15d9a1",
"marketing/mk-clean-listing": "875102cc",
+ "marketing/ms-big-number": {"poster":"/previews/templates/marketing/ms-big-number.jpg?v=3e1010ed","video":"/previews/templates/marketing/ms-big-number.mp4?v=3c367720","at":4.958},
+ "marketing/ms-dashboard-zoom": {"poster":"/previews/templates/marketing/ms-dashboard-zoom.jpg?v=f0ad33cd","video":"/previews/templates/marketing/ms-dashboard-zoom.mp4?v=167a025e","at":4.958},
+ "marketing/ms-end-card": {"poster":"/previews/templates/marketing/ms-end-card.jpg?v=58ec3d0b","video":"/previews/templates/marketing/ms-end-card.mp4?v=f94937c8","at":2.458},
+ "marketing/ms-feature-cards": {"poster":"/previews/templates/marketing/ms-feature-cards.jpg?v=6fbd49de","video":"/previews/templates/marketing/ms-feature-cards.mp4?v=d712e5b3","at":4.958},
+ "marketing/ms-five-star-quote": {"poster":"/previews/templates/marketing/ms-five-star-quote.jpg?v=98ffea8f","video":"/previews/templates/marketing/ms-five-star-quote.mp4?v=5683f816","at":4.958},
+ "marketing/ms-kinetic-headline": {"poster":"/previews/templates/marketing/ms-kinetic-headline.jpg?v=05317779","video":"/previews/templates/marketing/ms-kinetic-headline.mp4?v=39b0f451","at":2.167},
+ "marketing/ms-logo-sting": {"poster":"/previews/templates/marketing/ms-logo-sting.jpg?v=5ae33292","video":"/previews/templates/marketing/ms-logo-sting.mp4?v=013ae409","at":4.958},
"marketing/po-retro-sunburst": "4c19058c",
"marketing/po-riso-bloom": "69f64638",
"marketing/po-swiss-grid": "3c9c9370",
diff --git a/src/server/generations.ts b/src/server/generations.ts
index ba85dcd5..5837aab7 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -267,6 +267,8 @@ export interface ListOptions {
favorites?: boolean;
status?: string;
statuses?: string[];
+ /** Only clips saved from this Marketing template (a Kinetic Motion recipe that names it). */
+ template?: string;
/** Only the Trash, newest deletion first (`before` is then a deletedAt cursor). Otherwise the Trash is left out. */
trashed?: boolean;
folderId?: string;
@@ -326,6 +328,7 @@ export function listGenerations(o: ListOptions = {}): Generation[] {
if (o.favorites) add("g.favorite = 1");
if (o.status) add("g.status = ?", o.status);
if (o.statuses?.length) oneOf("g.status", o.statuses);
+ if (o.template) add("json_extract(g.request_json, '$.params.extra.motion.controls.template') = ?", o.template);
if (o.folderId) add("fi.folder_id = ?", o.folderId);
if (o.folderIds?.length) oneOf("fi.folder_id", o.folderIds);
if (o.pinned !== undefined) add(o.pinned ? "g.pinned_at IS NOT NULL" : "g.pinned_at IS NULL");
diff --git a/src/server/library.ts b/src/server/library.ts
index 1c2df445..d766451f 100644
--- a/src/server/library.ts
+++ b/src/server/library.ts
@@ -73,6 +73,7 @@ export function listOptionsFrom(sp: URLSearchParams): ListOptions {
favorites: sp.get("favorites") === "1",
status: sp.get("status") ?? undefined,
statuses: list("statuses")?.filter((s) => STATUSES.has(s)),
+ template: sp.get("template")?.slice(0, 80) || undefined,
folderId: sp.get("folder") ?? undefined,
folderIds: list("folders")?.filter((id) => id.length <= 40).slice(0, MAX_IDS),
trashed: sp.get("trash") === "1",
diff --git a/src/server/marketing.ts b/src/server/marketing.ts
index 9588ce4a..cefbcb14 100644
--- a/src/server/marketing.ts
+++ b/src/server/marketing.ts
@@ -31,6 +31,7 @@ import {
snapDuration,
styleById,
TEMPLATE_INDEX,
+ isCodeTemplate,
UGC_MODELS,
wordBudget,
wordsOnTop,
@@ -295,11 +296,15 @@ export interface PlanContext {
script?: string;
}
+/** Templates drawn in the browser (exact words in the brand's fonts) never go to a model. */
+export const CODE_TEMPLATE_REFUSAL = "This template is made in your browser: open it in Marketing Studio";
+
/** Marketing Studio: one run of a template (images) or a pipeline (motion over several shots, UGC). */
export function planMarketing(input: MarketingInput, ctx: PlanContext): RunPlan {
const f = FORMATS[input.format as FormatId];
const tpl: MarketingTemplate | undefined = input.templateId ? TEMPLATE_INDEX.get(input.templateId) : undefined;
if (input.templateId && !tpl) throw new PlanError("This preset is no longer available.");
+ if (tpl && isCodeTemplate(tpl)) throw new PlanError(CODE_TEMPLATE_REFUSAL);
if (tpl && tpl.format !== f.id) throw new PlanError("That template belongs to another format");
const open = input.engine === "open";
const product = ctx.product ?? null;
@@ -1250,6 +1255,7 @@ export async function runMarketing(input: MarketingInput): Promise<{ runs: Marke
const ctx = context(input);
const f = FORMATS[input.format];
const tpl = input.templateId ? TEMPLATE_INDEX.get(input.templateId) : undefined;
+ if (tpl && isCodeTemplate(tpl)) throw new PlanError(CODE_TEMPLATE_REFUSAL);
let script: string | undefined;
if (f.pipeline === "ugc") {
const hook = hookById(input.hookId === undefined ? tpl?.hook : input.hookId);
diff --git a/tests/__snapshots__/home-studios.html b/tests/__snapshots__/home-studios.html
index d80eed06..3b583814 100644
--- a/tests/__snapshots__/home-studios.html
+++ b/tests/__snapshots__/home-studios.html
@@ -91,7 +91,7 @@
</svg>
</span>
</p>
-<p class="mt-0.5 text-[12px] leading-snug text-muted-foreground">From a product link to a finished ad. 84 ad templates.</p>
+<p class="mt-0.5 text-[12px] leading-snug text-muted-foreground">From a product link to a finished ad. 88 ad templates.</p>
</div>
</a>
</div>
diff --git a/tests/assist-polish.test.ts b/tests/assist-polish.test.ts
index fa7b72fe..8e163eb1 100644
--- a/tests/assist-polish.test.ts
+++ b/tests/assist-polish.test.ts
@@ -37,10 +37,12 @@ describe("the 390 px sweep visits dynamic routes", () => {
for (const p of patterns) expect(byPattern[p]?.length, p).toBeGreaterThan(0);
expect(urls.filter((u) => /\[/.test(u))).toEqual([]);
expect(urls).toEqual(expect.arrayContaining(["/cinema/c1", "/cinema/does-not-exist", "/canvas/v1", "/canvas/does-not-exist", "/assist/projects/p1", "/apps/does-not-exist"]));
- // Dialogs and tabs a query opens: a skill's Run form, Genjutsu's From picture and Finish tabs.
+ // Dialogs and tabs a query opens: a skill's Run form, Genjutsu's From picture and Finish tabs, Marketing's
+ // code-drawn templates.
const genjutsu = ["/genjutsu?mode=picture", "/genjutsu?mode=finish"];
- expect(querySamples({ recipeSkill: "lamp" })).toEqual(["/assist/skills?run=lamp", "/assist/skills?run=does-not-exist", ...genjutsu]);
- expect(querySamples()).toEqual(["/assist/skills?run=does-not-exist", ...genjutsu]);
+ const kinetic = ["ms-kinetic-headline", "ms-feature-cards", "m2-line-reveal", "ms-end-card"].map((id) => `/marketing?template=${id}`);
+ expect(querySamples({ recipeSkill: "lamp" })).toEqual(["/assist/skills?run=lamp", "/assist/skills?run=does-not-exist", ...genjutsu, ...kinetic]);
+ expect(querySamples()).toEqual(["/assist/skills?run=does-not-exist", ...genjutsu, ...kinetic]);
});
it("gives a route added later (another branch's /faceless/[id]/[episode]) a not-found sample by itself", () => {
diff --git a/tests/e2e/_routes.mjs b/tests/e2e/_routes.mjs
index 4be8aadd..0cf54cc6 100644
--- a/tests/e2e/_routes.mjs
+++ b/tests/e2e/_routes.mjs
@@ -74,6 +74,8 @@ export function dynamicSamples(root, ids = {}) {
* /assist/skills?run=…); an unknown one is visited too (the form says so in the dialog).
*/
export function querySamples(ids = {}) {
- // Genjutsu's From picture and Finish tabs (a visitor lands on Motion transfer until they open).
- return [ids.recipeSkill && `/assist/skills?run=${ids.recipeSkill}`, "/assist/skills?run=does-not-exist", "/genjutsu?mode=picture", "/genjutsu?mode=finish"].filter(Boolean);
+ // Genjutsu's From picture and Finish tabs (a visitor lands on Motion transfer until they open), and Marketing's
+ // code-drawn templates open in their own panel (a tall one, a 4:5 one with cards, one with a picture, the end card).
+ const kinetic = ["ms-kinetic-headline", "ms-feature-cards", "m2-line-reveal", "ms-end-card"].map((id) => `/marketing?template=${id}`);
+ return [ids.recipeSkill && `/assist/skills?run=${ids.recipeSkill}`, "/assist/skills?run=does-not-exist", "/genjutsu?mode=picture", "/genjutsu?mode=finish", ...kinetic].filter(Boolean);
}
diff --git a/tests/e2e/kinetic-endcard.mjs b/tests/e2e/kinetic-endcard.mjs
index a295babf..73f00fb8 100644
--- a/tests/e2e/kinetic-endcard.mjs
+++ b/tests/e2e/kinetic-endcard.mjs
@@ -198,7 +198,7 @@ try {
await page.screenshot({ path: path.join(out, "click-to-ad-endcard-1440.png"), fullPage: false });
// Iris: render, upload, Generate.
- await page.getByRole("button", { name: /^Iris/ }).first().click();
+ await page.getByRole("group", { name: "End card style" }).getByRole("button", { name: /^Iris/ }).first().click();
await page.waitForTimeout(800);
uploads.length = 0;
const started = Date.now();
@@ -227,7 +227,7 @@ try {
const styles = ["draw-on", "rise", "iris", "split", "glint"];
timings.saveMs = {};
for (const s of styles) {
- await page.getByRole("button", { name: new RegExp(`^${s === "draw-on" ? "Draw-on" : s[0].toUpperCase() + s.slice(1)}`) }).first().click();
+ await page.getByRole("group", { name: "End card style" }).getByRole("button", { name: new RegExp(`^${s === "draw-on" ? "Draw-on" : s[0].toUpperCase() + s.slice(1)}`) }).first().click();
await page.waitForTimeout(500);
uploads.length = 0;
const t0 = Date.now();
diff --git a/tests/e2e/kinetic-templates.mjs b/tests/e2e/kinetic-templates.mjs
new file mode 100644
index 00000000..4850c1da
--- /dev/null
+++ b/tests/e2e/kinetic-templates.mjs
@@ -0,0 +1,316 @@
+// Marketing's code-drawn templates, end to end (Kinetic Motion phase 2). Starts `next dev` on 3540 with a throwaway
+// data folder, the owner's password, public sign-up on, Demo mode on and a stand-in fal.ai on 3541 for an account's
+// own key. Uses the system Chrome (WebCodecs H.264). Everything it starts is stopped at the end.
+//
+// node tests/e2e/kinetic-templates.mjs [evidence folder]
+//
+// KINETIC_PORT moves the app (and the stand-in to the next port).
+//
+// Checks. Owner: Kinetic Headline opens in its own panel, takes a headline with *stars*, and plays; Save to Library
+// shows its progress and the toast, and the Library lists the clip by its title with its recipe in params.extra.motion;
+// it shows under "Made with this template", opens in the viewer and downloads as the stored MP4 (1080 × 1920, 150
+// frames). Account with a stand-in key: Logo Sting with its own logo from the Brand row, saved to its own runs, listed
+// in its strip and downloaded; the owner's Library doesn't list it, the owner's Accounts' runs does. Account with
+// neither: Save opens the Connect card and nothing is uploaded. Guest: the fields and preview work, Save opens the
+// sign-up card before anything renders, a code template shows no "not available" note while an AI template still does.
+// Covers: the ten code templates' tiles show their versioned cover and clip. Phone 390 and desktop 1440 for each
+// viewer: no sideways scroll, controls at least 44 px. Evidence: screenshots, the saved clips, timings.
+import { spawn, execSync } from "node:child_process";
+import crypto from "node:crypto";
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import sharp from "sharp";
+import { DESKTOP, launch, PHONE, root } from "./_browser.mjs";
+import { startFakeFal } from "../helpers/fake-cloud.ts";
+
+const PORT = Number(process.env.KINETIC_PORT ?? 3540);
+const APP = `http://127.0.0.1:${PORT}`;
+const out = path.resolve(process.argv[2] ?? fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-kinetic-templates-")));
+fs.mkdirSync(out, { recursive: true });
+const data = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-kinetic-templates-data-"));
+const PASSWORD = "owner password for kinetic templates";
+const ACCT_FAL = "acct-templates-key:acct-templates-secret";
+const CODE_TEMPLATES = ["ms-kinetic-headline", "m2-line-reveal", "ms-logo-sting", "ms-feature-cards", "ms-dashboard-zoom", "m2-retro-starburst", "m2-offer-badge", "ms-big-number", "ms-five-star-quote", "ms-end-card"];
+
+const failures = [];
+const notes = [];
+const check = (ok, what) => {
+ console.log(`${ok ? "ok " : "FAIL"} ${what}`);
+ if (!ok) failures.push(what);
+};
+const note = (s) => {
+ console.log(`note ${s}`);
+ notes.push(s);
+};
+const wait = (ms) => new Promise((r) => setTimeout(r, ms));
+
+const fal = await startFakeFal(PORT + 1);
+fal.keys[ACCT_FAL] = "good";
+
+const log = fs.openSync(path.join(out, "server.log"), "w");
+const server = spawn(process.execPath, [path.join(root, "node_modules/next/dist/bin/next"), "dev", "-p", String(PORT), "-H", "127.0.0.1"], {
+ cwd: root,
+ env: {
+ ...process.env,
+ NODE_ENV: "development",
+ FUOBE_DATA_DIR: data,
+ FUOBE_PASSWORD: PASSWORD,
+ FUOBE_PUBLIC_SIGNUP: "1",
+ FUOBE_DEMO_MODE: "on",
+ FUOBE_DEV_FAL_URL: fal.url,
+ COMFYUI_URL: "http://127.0.0.1:9",
+ OLLAMA_URL: "http://127.0.0.1:9",
+ LMSTUDIO_URL: "http://127.0.0.1:9",
+ UNSLOTH_URL: "http://127.0.0.1:9",
+ FUOBE_ACCOUNT_DISK_FREE_GB: "0",
+ },
+ stdio: ["ignore", log, log],
+});
+
+async function stopAll() {
+ try {
+ if (process.platform === "win32") execSync(`taskkill /pid ${server.pid} /T /F`, { stdio: "ignore" });
+ else server.kill("SIGTERM");
+ } catch {}
+ await fal.close();
+}
+
+const api = async (route, { method = "GET", body, cookie } = {}) => {
+ const res = await fetch(APP + route, { method, headers: { Origin: APP, "Content-Type": "application/json", ...(cookie && { cookie }) }, ...(body !== undefined && { body: JSON.stringify(body) }) });
+ const buf = Buffer.from(await res.arrayBuffer());
+ let json = null;
+ try {
+ json = JSON.parse(buf.toString("utf8"));
+ } catch {}
+ return { status: res.status, json, buf, headers: res.headers };
+};
+const cookieOf = (res) => /fuobe_session=[^;]+/.exec(res.headers.get("set-cookie") ?? "")?.[0];
+const sha = (b) => crypto.createHash("sha256").update(b).digest("hex");
+/** The MP4's sample count, from its stsz box. */
+const mp4Frames = (buf) => {
+ const i = buf.indexOf(Buffer.from("stsz"));
+ return i < 0 ? -1 : buf.readUInt32BE(i + 12);
+};
+/** The MP4's picture size, from its first avc1 sample entry. */
+const mp4Size = (buf) => {
+ const i = buf.indexOf(Buffer.from("avc1"), buf.indexOf(Buffer.from("stsd")));
+ return i < 0 ? null : { w: buf.readUInt16BE(i + 28), h: buf.readUInt16BE(i + 30) };
+};
+const mainCanvas = 'canvas[data-kinetic-player="main"]';
+const pixels = (page) => page.evaluate((sel) => document.querySelector(sel).toDataURL(), mainCanvas);
+
+/** Opens a template's panel and waits for its preview. */
+async function openTemplate(page, id) {
+ page.on("pageerror", (e) => console.log("pageerror", e.message));
+ await page.goto(`/marketing?template=${id}`, { waitUntil: "load", timeout: 240_000 });
+ await page.locator(`[data-kinetic-template="${id}"] ${mainCanvas}`).waitFor({ timeout: 120_000 });
+ await page.waitForTimeout(1800);
+}
+
+/** No sideways scroll, and every control in the panel at least 44 px tall. */
+async function layoutChecks(page, who, name) {
+ const sideways = await page.evaluate(() => document.scrollingElement.scrollWidth - window.innerWidth);
+ check(sideways <= 0, `${who} ${name}: no sideways scroll (${sideways} px)`);
+ const small = await page.$$eval("[data-kinetic-template] button, [data-kinetic-template] input:not([type=color]):not([type=file]), [data-kinetic-template] textarea", (els) =>
+ // (A picture tile's own corner buttons, Remove and Choose from library, sit on its 56 px tile, which is the control.)
+ els.filter((e) => e.getClientRects().length && !e.closest("[data-kinetic-made]") && !(e.closest(".group\\/slot") && e.getBoundingClientRect().height <= 24)).map((e) => [e.getAttribute("aria-label") || e.textContent?.trim().slice(0, 20) || e.tagName, Math.round(e.getBoundingClientRect().height)]).filter(([, h]) => h < 44),
+ );
+ check(small.length === 0, `${who} ${name}: every control in the panel is at least 44 px (${JSON.stringify(small)})`);
+}
+
+const timings = {};
+let browser;
+try {
+ for (let i = 0; i < 300; i++) {
+ try {
+ const r = await fetch(`${APP}/login`);
+ if (r.status < 500) break;
+ } catch {}
+ await wait(1000);
+ }
+ const owner = cookieOf(await api("/api/auth/login", { method: "POST", body: { password: PASSWORD } }));
+ check(!!owner, "owner signs in");
+ browser = await launch({ channel: "chrome" });
+ const withCookie = async (cookie, opts) => {
+ const ctx = await browser.newContext({ ...opts, baseURL: APP });
+ if (cookie) {
+ const [n, v] = cookie.split("=");
+ await ctx.addCookies([{ name: n, value: v, url: APP }]);
+ }
+ return ctx;
+ };
+
+ // ---- Owner, desktop: Kinetic Headline with a marked word, saved to the Library.
+ const desk = await withCookie(owner, DESKTOP);
+ const page = await desk.newPage();
+ const uploads = [];
+ page.on("response", (r) => {
+ if (r.url().endsWith("/api/uploads") && r.request().method() === "POST") uploads.push({ type: r.request().headers()["content-type"], answer: r.json().catch(() => null) });
+ });
+ await openTemplate(page, "ms-kinetic-headline");
+ check(!(await page.getByText("Marketing Studio isn't available here.").isVisible().catch(() => false)), "owner: no note on a code template");
+ check(await page.getByRole("textbox", { name: "Prompt" }).isHidden(), "owner: the composer gives way to the template's panel");
+ const headline = "Close the month *before* lunch.";
+ await page.getByRole("textbox", { name: "Headline", exact: true }).fill(headline);
+ await page.waitForTimeout(900);
+ const p1 = await pixels(page);
+ await page.waitForTimeout(500);
+ const p2 = await pixels(page);
+ check(p1 !== p2, "owner: the preview plays the typed headline");
+ await layoutChecks(page, "owner", "1440");
+ await page.locator("[data-kinetic-template]").screenshot({ path: path.join(out, "owner-kinetic-headline-1440.png") });
+
+ const t0 = Date.now();
+ const recorded = page.waitForResponse((r) => r.url().endsWith("/api/generations/local") && r.request().method() === "POST", { timeout: 180_000 });
+ // Watched from before the press: the render is quick, and the toast goes after a few seconds.
+ const sawProgress = page.waitForFunction(() => /Rendering \d+ of \d+/.test(document.querySelector("[data-kinetic-template]")?.textContent ?? ""), null, { timeout: 60_000, polling: 16 }).then(() => true, () => false);
+ const sawToast = page.getByText("Saved to your Library").first().waitFor({ timeout: 120_000 }).then(() => true, () => false);
+ await page.getByRole("button", { name: "Save to Library" }).click();
+ check((await recorded).status() === 201, "owner: the clip is recorded");
+ timings.ownerSaveMs = Date.now() - t0;
+ check(await sawProgress, "owner: the progress line runs while it renders");
+ check(await sawToast, "owner: the toast says it's saved");
+ note(`5 s at 1080 × 1920, 30 fps, blur 8: rendered and saved in ${timings.ownerSaveMs} ms`);
+ const lib = await api("/api/generations?features=marketing-kinetic&limit=20", { cookie: owner });
+ const g = (lib.json?.items ?? []).find((x) => x.modelId === "local-motion");
+ check(!!g && g.feature === "marketing-kinetic" && g.status === "succeeded", "owner: the Library lists the clip as a Kinetic result");
+ const motion = g?.request?.params?.extra?.motion;
+ check(motion?.scene === "marketing/kinetic-headline" && motion?.fields?.headline === headline && motion?.controls?.template === "ms-kinetic-headline", "owner: its recipe (the headline exactly as typed) is in params.extra.motion");
+ check(/Close the month before lunch\./.test(g?.request?.prompt ?? ""), `owner: it is listed by its words (${g?.request?.prompt})`);
+ const file = g ? await api(g.outputs[0].url, { cookie: owner }) : null;
+ const sentClip = await uploads.find((u) => /video\//.test(u.type ?? ""))?.answer;
+ check(!!file && sentClip?.url === g.outputs[0].url && sentClip.size === file.buf.length, "owner: the stored file is the uploaded clip");
+ check(file && mp4Frames(file.buf) === 150, `owner: 150 frames (5 s at 30 fps): ${file && mp4Frames(file.buf)}`);
+ const size = file && mp4Size(file.buf);
+ check(size?.w === 1080 && size?.h === 1920, `owner: 1080 × 1920 (${JSON.stringify(size)})`);
+ if (file) fs.writeFileSync(path.join(out, "owner-kinetic-headline-1080x1920.mp4"), file.buf);
+
+ // "Made with this template" opens it in the viewer, which downloads the same bytes.
+ const tile = page.locator(`[data-kinetic-made="${g?.id}"]`);
+ check(await tile.waitFor({ timeout: 20_000 }).then(() => true, () => false), "owner: it shows under Made with this template");
+ await tile.click();
+ await page.waitForTimeout(1200);
+ const dl = page.waitForEvent("download", { timeout: 30_000 });
+ await page.getByRole("dialog").getByRole("link", { name: /^Download$/ }).or(page.getByRole("dialog").getByRole("button", { name: /^Download$/ })).first().click();
+ const download = await dl.catch(() => null);
+ const dlPath = download && path.join(out, "owner-download.mp4");
+ if (download) await download.saveAs(dlPath);
+ check(!!download && sha(fs.readFileSync(dlPath)) === sha(file.buf), "owner: Download in the viewer gives the saved clip");
+ await page.keyboard.press("Escape");
+
+ // Covers: every code template's tile shows its versioned cover and clip.
+ await page.goto("/marketing", { waitUntil: "load", timeout: 120_000 });
+ await page.waitForTimeout(2500);
+ const html = await page.content();
+ const missing = CODE_TEMPLATES.filter((id) => !new RegExp(`templates/marketing/${id}\\.jpg\\?v=[0-9a-f]{8}`).test(html.replaceAll("%2F", "/").replaceAll("&amp;", "&")));
+ check(missing.length === 0, `the ten code templates' tiles show their versioned covers (missing: ${missing.join(", ") || "none"})`);
+ const instant = await page.getByText("Instant", { exact: true }).count();
+ check(instant >= CODE_TEMPLATES.length, `their tiles say Instant (${instant})`);
+ await page.screenshot({ path: path.join(out, "gallery-1440.png") });
+ await desk.close();
+
+ // ---- Owner, phone.
+ const ownerPhone = await withCookie(owner, { ...PHONE, deviceScaleFactor: 3 });
+ const op = await ownerPhone.newPage();
+ await openTemplate(op, "m2-line-reveal");
+ await layoutChecks(op, "owner", "390");
+ await op.screenshot({ path: path.join(out, "owner-line-reveal-390.png"), fullPage: true });
+ await ownerPhone.close();
+
+ // ---- An account with a stand-in fal.ai key: Logo Sting with its own logo, saved to its own runs.
+ const acct = cookieOf(await api("/api/auth/signup", { method: "POST", body: { email: "[email protected]", password: "account password" } }));
+ check(!!acct, "an account signs up");
+ check((await api("/api/account/keys/fal", { method: "PUT", cookie: acct, body: { key: ACCT_FAL } })).status === 200, "the account adds its own key");
+ const logo = await sharp(Buffer.from("<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><circle cx='300' cy='300' r='250' fill='#f2e6d8'/><path d='M190 420V180h70l40 130 40-130h70v240' fill='none' stroke='#c8643c' stroke-width='44' stroke-linejoin='round'/></svg>")).png().toBuffer();
+ const logoFile = path.join(out, "account-logo.png");
+ fs.writeFileSync(logoFile, logo);
+ for (const [name, vp] of [["1440", DESKTOP], ["390", { ...PHONE, deviceScaleFactor: 3 }]]) {
+ const ctx = await withCookie(acct, vp);
+ const ap = await ctx.newPage();
+ await openTemplate(ap, "ms-logo-sting");
+ await ap.getByRole("button", { name: /^Brand/ }).click();
+ await ap.getByRole("textbox", { name: "Brand name", exact: true }).fill("Sora Skin");
+ if (name === "1440") {
+ await ap.locator("[data-kinetic-template] input[type=file]").first().setInputFiles(logoFile);
+ await ap.waitForTimeout(2500);
+ }
+ await layoutChecks(ap, "account", name);
+ await ap.locator("[data-kinetic-template]").screenshot({ path: path.join(out, `account-logo-sting-${name}.png`) });
+ if (name === "1440") {
+ const rec = ap.waitForResponse((r) => r.url().endsWith("/api/generations/local") && r.request().method() === "POST", { timeout: 180_000 });
+ await ap.getByRole("button", { name: "Save to your runs" }).click();
+ check((await rec).status() === 201, "account: its clip is recorded");
+ check(await ap.getByText("Saved to your runs").first().waitFor({ timeout: 30_000 }).then(() => true, () => false), "account: the toast says it's in its runs");
+ const theirs = await api("/api/generations?features=marketing-kinetic&limit=20", { cookie: acct });
+ const ag = (theirs.json?.items ?? [])[0];
+ check(ag?.request?.params?.extra?.motion?.brand?.logo?.startsWith("/api/files/") && ag?.request?.params?.extra?.motion?.brand?.name === "Sora Skin", "account: the clip was made with its own logo and name");
+ check(await ap.locator(`[data-kinetic-made="${ag?.id}"]`).waitFor({ timeout: 20_000 }).then(() => true, () => false), "account: it shows in its Made with this template strip");
+ const f = ag ? await api(ag.outputs[0].url, { cookie: acct }) : null;
+ check(f?.status === 200 && mp4Frames(f.buf) === 150, "account: it downloads its clip from Fuobe");
+ if (f) fs.writeFileSync(path.join(out, "account-logo-sting-1080x1350.mp4"), f.buf);
+ const ownerList = await api("/api/generations?limit=200", { cookie: owner });
+ check(!(ownerList.json?.items ?? []).some((x) => x.id === ag?.id), "the owner's Library doesn't list the account's clip");
+ const admin = await api("/api/admin/generations?limit=50", { cookie: owner });
+ check((admin.json?.items ?? []).some((x) => x.id === ag?.id), "the owner's Accounts' runs lists it");
+ }
+ await ctx.close();
+ }
+
+ // ---- An account with neither a GPU nor a key: Save asks it to connect one, before anything renders.
+ const bare = cookieOf(await api("/api/auth/signup", { method: "POST", body: { email: "[email protected]", password: "account password" } }));
+ const bctx = await withCookie(bare, DESKTOP);
+ const bp = await bctx.newPage();
+ let bareUploads = 0;
+ bp.on("request", (r) => r.url().endsWith("/api/uploads") && bareUploads++);
+ await openTemplate(bp, "ms-big-number");
+ await bp.getByRole("button", { name: "Save to your runs" }).click();
+ check(await bp.getByText(/Connect your GPU/).first().waitFor({ timeout: 10_000 }).then(() => true, () => false), "account without a GPU or key: Save opens the Connect card");
+ check(!(await bp.getByText(/^Rendering \d+ of/).isVisible().catch(() => false)) && bareUploads === 0, `account without a GPU or key: nothing renders or uploads (${bareUploads} uploads)`);
+ await bp.screenshot({ path: path.join(out, "account-bare-save.png") });
+ await bctx.close();
+
+ // ---- Guest: fields and preview work, Save asks to sign up first, AI templates keep their note.
+ for (const [name, vp] of [["390", { ...PHONE, deviceScaleFactor: 3 }], ["1440", DESKTOP]]) {
+ const gctx = await withCookie(null, vp);
+ const gp = await gctx.newPage();
+ let guestUploads = 0;
+ gp.on("request", (r) => r.url().endsWith("/api/uploads") && guestUploads++);
+ await openTemplate(gp, "ms-five-star-quote");
+ check(!(await gp.getByText("Marketing Studio isn't available here.").isVisible().catch(() => false)), `guest ${name}: no "not available" note on a code template`);
+ await gp.getByRole("textbox", { name: "Quote", exact: true }).fill("“Worth every penny — I’m on my third bottle.”");
+ await gp.waitForTimeout(900);
+ const g1 = await pixels(gp);
+ await gp.waitForTimeout(450);
+ check(g1 !== (await pixels(gp)), `guest ${name}: the preview plays their words`);
+ await layoutChecks(gp, "guest", name);
+ await gp.locator("[data-kinetic-template]").screenshot({ path: path.join(out, `guest-quote-${name}.png`) });
+ await gp.getByRole("button", { name: "Save to Library" }).click();
+ check(await gp.getByText(/Create a free account/).first().waitFor({ timeout: 10_000 }).then(() => true, () => false), `guest ${name}: Save opens the sign-up card`);
+ check(!(await gp.getByText(/^Rendering \d+ of/).isVisible().catch(() => false)) && guestUploads === 0, `guest ${name}: nothing renders or uploads first`);
+ await gp.screenshot({ path: path.join(out, `guest-quote-${name}-save.png`) });
+ await gp.goto("/marketing?template=m2-sticker-pop", { waitUntil: "load", timeout: 120_000 });
+ await gp.waitForTimeout(1500);
+ check(await gp.getByText("Marketing Studio isn't available here.").first().isVisible(), `guest ${name}: an AI template still says Marketing Studio isn't available here`);
+ await gctx.close();
+ }
+
+ // ---- Reduced motion: the rest frame, no autoplay.
+ const calm = await withCookie(null, { ...DESKTOP, reducedMotion: "reduce" });
+ const cp = await calm.newPage();
+ await openTemplate(cp, "ms-big-number");
+ const r1 = await pixels(cp);
+ await cp.waitForTimeout(700);
+ check(r1 === (await pixels(cp)), "reduced motion: the preview holds its rest frame");
+ await calm.close();
+} catch (e) {
+ failures.push(`crashed: ${e?.stack ?? e}`);
+ console.error(e);
+} finally {
+ await browser?.close().catch(() => {});
+ await stopAll();
+}
+
+fs.writeFileSync(path.join(out, "e2e-result.json"), JSON.stringify({ failures, notes, timings }, null, 2));
+console.log(failures.length ? `\n${failures.length} failed` : "\nall passed");
+process.exit(failures.length ? 1 : 0);
diff --git a/tests/marketing-code-refusal.test.ts b/tests/marketing-code-refusal.test.ts
new file mode 100644
index 00000000..6eee8f15
--- /dev/null
+++ b/tests/marketing-code-refusal.test.ts
@@ -0,0 +1,42 @@
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, describe, expect, it } from "vitest";
+
+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-code-refusal-"));
+process.env.FUOBE_DATA_DIR = dir;
+process.env.COMFYUI_URL = "http://127.0.0.1:9";
+process.env.OLLAMA_URL = "http://127.0.0.1:9";
+
+const { isCodeTemplate, TEMPLATES } = await import("@/lib/catalog/marketing");
+const mk = await import("@/server/marketing");
+
+// The database keeps its file open on Windows; the folder is temporary either way.
+afterAll(() => {
+ try {
+ fs.rmSync(dir, { recursive: true, force: true });
+ } catch {}
+});
+
+// Templates drawn in the browser never reach a video or image model: an old tab, a saved draft or an API caller that
+// names one is refused before anything is planned, priced or started.
+const CODE = TEMPLATES.filter(isCodeTemplate);
+
+describe("code-drawn templates on the server", () => {
+ it("are the ten Kinetic templates", () => expect(CODE).toHaveLength(10));
+
+ for (const t of CODE) {
+ const input = { engine: "cloud" as const, format: t.format, templateId: t.id, prompt: "A bottle on a plinth" };
+ it(`${t.id}: planning, pricing and running are refused`, async () => {
+ expect(() => mk.planMarketing(input, {})).toThrow(mk.CODE_TEMPLATE_REFUSAL);
+ expect(() => mk.estimateMarketing(input)).toThrow(mk.CODE_TEMPLATE_REFUSAL);
+ await expect(mk.runMarketing(input)).rejects.toThrow(mk.CODE_TEMPLATE_REFUSAL);
+ expect(mk.listRuns("marketing").some((r) => (r.meta as { templateId?: string } | undefined)?.templateId === t.id)).toBe(false);
+ });
+ }
+
+ it("other motion templates still plan", () => {
+ const other = TEMPLATES.find((t) => t.id === "m2-sticker-pop")!;
+ expect(() => mk.planMarketing({ engine: "cloud", format: other.format, templateId: other.id, prompt: "A bottle on a plinth" }, {})).not.toThrow(mk.CODE_TEMPLATE_REFUSAL);
+ });
+});
diff --git a/tests/marketing-kinetic-templates.test.ts b/tests/marketing-kinetic-templates.test.ts
new file mode 100644
index 00000000..785e749c
--- /dev/null
+++ b/tests/marketing-kinetic-templates.test.ts
@@ -0,0 +1,119 @@
+import { describe, expect, it } from "vitest";
+import { isCodeTemplate, TEMPLATES } from "@/lib/catalog/marketing";
+import { RecipeSchema } from "@/lib/motion/recipe";
+import { hasScene, loadScene } from "@/lib/motion/registry";
+import { SHOWCASES } from "@/lib/motion/showcase";
+import { initialState, ownFiles, templateRecipe, templateScene, templateSizes, templateWords } from "@/lib/motion/template";
+import { templateCover } from "@/lib/template-covers";
+import type { Generation } from "@/lib/catalog/types";
+import { filterToSearch, matchesFilter } from "@/lib/library";
+import { measure } from "./helpers/motion";
+
+// Marketing's templates drawn by Kinetic Motion: each names a registered scene, the words it takes and its quick
+// choices, opens on a showcase that fits every size, saves as a recipe the record route takes, and has a real cover made
+// by the engine (a clip with its version, resting on a moment where its words are set).
+
+const CODE = TEMPLATES.filter(isCodeTemplate);
+
+describe("the catalog's code-drawn templates", () => {
+ it("are the six switched templates and the four new ones", () => {
+ expect(CODE.map((t) => t.id).sort()).toEqual(
+ ["ms-kinetic-headline", "m2-line-reveal", "ms-logo-sting", "ms-feature-cards", "ms-dashboard-zoom", "m2-retro-starburst", "m2-offer-badge", "ms-big-number", "ms-five-star-quote", "ms-end-card"].sort(),
+ );
+ // Scenes, not type, stay on the video models.
+ for (const id of ["m2-sticker-pop", "m2-paper-parade", "m2-comic-panels", "m2-grid-shuffle", "ms-device-float"]) expect(isCodeTemplate(TEMPLATES.find((t) => t.id === id))).toBe(false);
+ });
+
+ it("each has a registered scene, fields, 2 to 4 groups of quick choices, a showcase and a cover", () => {
+ for (const t of CODE) {
+ expect(t.scene && hasScene(t.scene), t.id).toBe(true);
+ expect(t.fields?.length, t.id).toBeGreaterThan(0);
+ for (const f of t.fields!) expect(f.max > 0 && f.lines >= 1 && f.label.length > 0, `${t.id} ${f.key}`).toBe(true);
+ expect(t.easy!.length, t.id).toBeGreaterThanOrEqual(2);
+ expect(t.easy!.length, t.id).toBeLessThanOrEqual(4);
+ for (const g of t.easy!) {
+ // A group that picks the scene (the end card's five styles) has one choice per style; the others 2 or 3.
+ if (g.scene) for (const c of g.choices) expect(hasScene(`${g.scene}/${c.id}`), `${t.id} ${c.id}`).toBe(true);
+ else expect(g.choices.length >= 2 && g.choices.length <= 3, `${t.id} ${g.id}`).toBe(true);
+ }
+ expect(SHOWCASES[t.id], t.id).toBeDefined();
+ const cover = templateCover("marketing", t.id);
+ expect(cover?.video, t.id).toMatch(/^\/previews\/templates\/marketing\/[a-z0-9-]+\.mp4\?v=[0-9a-f]{8}$/);
+ expect(cover?.poster, t.id).toMatch(/\.jpg\?v=[0-9a-f]{8}$/);
+ expect(cover?.at, t.id).toBeGreaterThan(1);
+ }
+ });
+
+ it("offer the four Kinetic sizes, their own first", () => {
+ for (const t of CODE) {
+ const sizes = templateSizes(t);
+ expect([...sizes].sort(), t.id).toEqual(["16:9", "1:1", "4:5", "9:16"]);
+ if (t.aspect) expect(sizes[0], t.id).toBe(t.aspect);
+ }
+ });
+});
+
+describe("a template's recipe", () => {
+ it("opens on its showcase, which fits every size and the record route's recipe schema", async () => {
+ for (const t of CODE) {
+ const s = initialState(t);
+ for (const size of templateSizes(t)) {
+ const r = templateRecipe(t, { ...s, size });
+ expect(() => RecipeSchema.parse(r), `${t.id} ${size}`).not.toThrow();
+ expect(r.controls?.template).toBe(t.id);
+ const scene = await loadScene(r.scene);
+ const plan = scene.plan({ recipe: r, measure, logo: null, images: r.media?.product ? { product: { w: 800, h: 1000 } } : undefined, outlines: {} });
+ expect(plan.overflow, `${t.id} ${size}`).toEqual([]);
+ }
+ }
+ });
+
+ it("keeps the typed words exactly, the end card's style as its scene, and its brand's name as the end card's", () => {
+ const end = CODE.find((t) => t.id === "ms-end-card")!;
+ const s = initialState(end);
+ expect(templateScene(end, { ...s.controls, style: "glint" })).toBe("end-card/glint");
+ const r = templateRecipe(end, { ...s, controls: { ...s.controls, style: "iris", mark: "logo" }, brand: { ...s.brand, name: "Maison Ardent", logo: "/api/files/2026/11/logo.png" }, fields: { ...s.fields, product: " Le Sérum Nuit " } });
+ expect(r.scene).toBe("end-card/iris");
+ expect(r.fields.brand).toBe("Maison Ardent");
+ expect(r.fields.product).toBe(" Le Sérum Nuit ");
+ expect(r.brand.logo).toBe("/api/files/2026/11/logo.png");
+ expect(r.controls).toEqual({ template: "ms-end-card", mark: "logo" });
+ // "Name" sets the brand name in type even with a logo.
+ expect(templateRecipe(end, { ...s, controls: { style: "iris", mark: "name" }, brand: { ...s.brand, logo: "/api/files/2026/11/logo.png" } }).brand.logo).toBeUndefined();
+ });
+
+ it("holds the length to the template's range and names its own files only", () => {
+ const head = CODE.find((t) => t.id === "ms-kinetic-headline")!;
+ const s = initialState(head);
+ expect(templateRecipe(head, { ...s, duration: 99 }).duration).toBe(8);
+ expect(templateRecipe(head, { ...s, duration: 1 }).duration).toBe(5);
+ const line = CODE.find((t) => t.id === "m2-line-reveal")!;
+ const l = initialState(line);
+ expect(l.product).toMatch(/^\/previews\/kinetic\/perfume\.webp\?v=/);
+ expect(ownFiles(templateRecipe(line, l))).toEqual([]);
+ expect(ownFiles(templateRecipe(line, { ...l, product: "/api/files/2026/11/bottle.png", brand: { ...l.brand, logo: "/api/files/2026/11/mark.png" } }))).toEqual(["/api/files/2026/11/mark.png", "/api/files/2026/11/bottle.png"]);
+ });
+
+ it("is listed by the template's name and its first words, without the highlight's stars", () => {
+ const head = CODE.find((t) => t.id === "ms-kinetic-headline")!;
+ const w = templateWords(head, initialState(head));
+ expect(w.title).toBe("Kinetic Headline · Invoices that chase themselves.");
+ expect(w.prompt).toBe("Lumen Labs · Invoices that chase themselves. · Start free · lumenlabs.io");
+ // A star that marks nothing is part of the words.
+ const s = initialState(head);
+ expect(templateWords(head, { ...s, fields: { ...s.fields, headline: "Rated 5* by *guests*" } }).title).toBe("Kinetic Headline · Rated 5* by guests");
+ const offer = CODE.find((t) => t.id === "m2-offer-badge")!;
+ const o = initialState(offer);
+ expect(templateWords(offer, { ...o, fields: { ...o.fields, offer: "*2 for 1*" } }).title).toBe("Offer Badge · *2 for 1*");
+ });
+});
+
+describe("Made with this template", () => {
+ it("asks the server for the template's own clips, and a live update matches them the same way", () => {
+ expect(filterToSearch({ features: ["marketing-kinetic"], template: "ms-big-number", limit: 12 }).get("template")).toBe("ms-big-number");
+ const g = (template?: string) => ({ ...({} as Generation), feature: "marketing-kinetic", kind: "video", modelId: "local-motion", status: "succeeded", createdAt: 1, request: { prompt: "", params: { extra: { motion: { controls: { template } } } } } }) as unknown as Generation;
+ expect(matchesFilter(g("ms-big-number"), { features: ["marketing-kinetic"], template: "ms-big-number" })).toBe(true);
+ expect(matchesFilter(g("ms-end-card"), { features: ["marketing-kinetic"], template: "ms-big-number" })).toBe(false);
+ expect(matchesFilter(g(), { features: ["marketing-kinetic"], template: "ms-big-number" })).toBe(false);
+ });
+});
diff --git a/tests/motion-continuity.test.ts b/tests/motion-continuity.test.ts
index 0263a9be..8c48aa99 100644
--- a/tests/motion-continuity.test.ts
+++ b/tests/motion-continuity.test.ts
@@ -10,7 +10,9 @@ import { input, measure, RASTER_LOGO, recipe, SVG_LOGO } from "./helpers/motion"
// to the settled card, the settled card to the last frame), every letter, the logo and the pill stay where they were
// within 1 unit. Checked for every style, size and kind of mark, across every frame and every event's edges.
-const scenes: Scene[] = await Promise.all(SCENE_IDS.map(loadScene));
+// The end card's five styles (Marketing's scenes have their own checks: motion-marketing.test.ts).
+const END_CARD_IDS = SCENE_IDS.filter((id) => id.startsWith("end-card/"));
+const scenes: Scene[] = await Promise.all(END_CARD_IDS.map(loadScene));
const SIZES: SizeSpec[] = ["9:16", "1:1", "16:9", "4:5"];
const apply = (m: Matrix, x: number, y: number): [number, number] => [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]];
diff --git a/tests/motion-marketing.test.ts b/tests/motion-marketing.test.ts
new file mode 100644
index 00000000..91352053
--- /dev/null
+++ b/tests/motion-marketing.test.ts
@@ -0,0 +1,351 @@
+import { describe, expect, it } from "vitest";
+import { contrast } from "@/components/ads/layout";
+import { IDENTITY, multiply, textNodes, type DisplayList, type DisplayNode, type Matrix } from "@/lib/motion/display";
+import { spelled } from "@/lib/motion/layout";
+import { traceOutline } from "@/lib/motion/outline";
+import type { Recipe } from "@/lib/motion/recipe";
+import { loadScene, SCENE_IDS } from "@/lib/motion/registry";
+import type { LogoInfo, Outline, Scene, SceneInput } from "@/lib/motion/scene";
+import { counterLayout, counterNode, marked, safeArea } from "@/lib/motion/scenes/marketing/kit";
+import { designSize, type SizeSpec } from "@/lib/motion/sizes";
+import { DURATION_LIMITS, STAGGER_LIMITS } from "@/lib/motion/tween";
+import { measure, RASTER_LOGO, SVG_LOGO } from "./helpers/motion";
+
+// Marketing's code-drawn templates: every scene is deterministic, sets every field exactly as typed, keeps the timing
+// rules and a held last second, keeps its words inside the safe area, and every word reads on what is behind it.
+
+const MARKETING = SCENE_IDS.filter((id) => id.startsWith("marketing/"));
+const scenes: Scene[] = await Promise.all(MARKETING.map(loadScene));
+const SIZES: SizeSpec[] = ["9:16", "1:1", "16:9", "4:5"];
+const cp = (...c: number[]) => String.fromCodePoint(...c);
+
+/** A disc's alpha on a grid (a cut-out product). */
+function discAlpha(w: number, h: number, r: number): Uint8ClampedArray {
+ const a = new Uint8ClampedArray(w * h);
+ for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
+ const d = Math.hypot(x + 0.5 - w / 2, y + 0.5 - h / 2);
+ a[y * w + x] = Math.round(255 * Math.min(1, Math.max(0, r - d + 0.5)));
+ }
+ return a;
+}
+const DISC: Outline = traceOutline(discAlpha(200, 256, 80), 200, 256)!;
+
+/** Each scene's fields, as a showcase recipe fills them. */
+const FIELDS: Record<string, Record<string, string>> = {
+ "marketing/kinetic-headline": { headline: "Invoices that *chase* themselves.", cta: "Start free", website: "lumenlabs.io" },
+ "marketing/line-reveal": { headline: "Quietly exceptional.", cta: "Discover the scent" },
+ "marketing/logo-sting": { tagline: "Software that ships itself" },
+ "marketing/feature-cards": { headline: "Everything your team needs", point1: "Invoices that chase themselves", point2: "Payroll in two taps", point3: "Books that close on Friday" },
+ "marketing/stat-dashboard": { stat: "$1,284,000", label: "Revenue this quarter" },
+ "marketing/starburst": { headline: "Sunshine, bottled.", badge: "New!" },
+ "marketing/offer-badge": { offer: "20% off", headline: "The winter edit", cta: "Shop the sale" },
+ "marketing/big-number": { stat: "3×", caption: "faster month-end close" },
+ "marketing/quote": { quote: "“The only serum I've bought three times.”", name: "Amara K., verified buyer" },
+};
+
+function recipe(scene: string, over: Partial<Recipe> = {}): Recipe {
+ return {
+ v: 1,
+ scene,
+ seed: 11,
+ size: "9:16",
+ fps: 30,
+ duration: 5,
+ fields: FIELDS[scene] ?? {},
+ brand: { name: "Maison Ardent", colors: ["#6b1d2a", "#e9d8b4"], fonts: { heading: "Playfair Display", body: "Inter" } },
+ media: { product: "/previews/kinetic/product.png" },
+ export: { format: "mp4", blurSamples: 8, shutter: 180 },
+ ...over,
+ };
+}
+
+const input = (r: Recipe, logo: LogoInfo | null = RASTER_LOGO, outline: Outline | null = DISC): SceneInput => ({ recipe: r, measure, logo, images: { product: { w: 800, h: 1024 } }, outlines: { product: outline } });
+
+/** What a field should read: as typed (trimmed), the *stars* of a marked headline removed. */
+const typedOf = (r: Recipe, field: string) => {
+ const raw = (r.fields[field] ?? (field === "brand" ? r.brand.name : "")).trim();
+ return field === "headline" && r.scene === "marketing/kinetic-headline" ? marked(raw).text.trim() : raw;
+};
+
+describe("the registry", () => {
+ it("has the nine Marketing scenes", () => {
+ expect(MARKETING.sort()).toEqual(Object.keys(FIELDS).sort());
+ for (const s of scenes) expect(s.durations).toEqual({ min: 5, max: 8, default: 5 });
+ });
+});
+
+describe("determinism", () => {
+ it("gives the same display list at a time whatever was asked before, for every scene, size and look", () => {
+ for (const scene of scenes) {
+ for (const size of SIZES) {
+ for (const look of ["light", "dark", "brand"]) {
+ const r = recipe(scene.id, { size, controls: { look, pace: "punchy" } });
+ const a = scene.plan(input(r));
+ const b = scene.plan(input(r));
+ const times = Array.from({ length: 30 }, (_, i) => (i / 29) * r.duration);
+ const forward = times.map((t) => JSON.stringify(a.evaluate(t)));
+ for (let i = times.length - 1; i >= 0; i--) expect(JSON.stringify(a.evaluate(times[i]))).toBe(forward[i]);
+ for (let k = 0; k < 60; k++) {
+ const i = (k * 37 + 11) % times.length;
+ expect(JSON.stringify(b.evaluate(times[i])), `${scene.id} ${size} t=${times[i]}`).toBe(forward[i]);
+ }
+ expect(a.design).toEqual(designSize(size));
+ for (const t of times) for (const n of walk(a.evaluate(t).nodes)) expect(JSON.stringify(n)).not.toMatch(/NaN|Infinity|null/);
+ }
+ }
+ }
+ });
+});
+
+function walk(nodes: readonly DisplayNode[], out: DisplayNode[] = []): DisplayNode[] {
+ for (const n of nodes) {
+ out.push(n);
+ if (n.type === "group") walk(n.children, out);
+ }
+ return out;
+}
+
+describe("spelling", () => {
+ const hostile = ["iPhone® 15 — 20 % off!", `ÉCOLE ${cp(0xfb01)} ligature`, `${cp(0x1f469, 0x200d, 0x1f469, 0x200d, 0x1f467)} family`, "العربية", " two spaces ", "Q"];
+
+ it("sets every field exactly as typed at rest, and never draws a letter that wasn't typed", () => {
+ for (const scene of scenes) {
+ for (const field of Object.keys(FIELDS[scene.id])) {
+ if (field === "stat") continue;
+ for (const text of hostile) {
+ const base = recipe(scene.id);
+ const r = recipe(scene.id, { fields: { ...base.fields, [field]: text } });
+ const plan = scene.plan(input(r));
+ if (plan.overflow.length) continue;
+ // The kinetic headline's words lift away for its end card: they are read just before they go.
+ const exit = plan.timeline.byId.get("words.exit");
+ const at = field === "headline" && exit ? exit.start - 0.01 : plan.rest;
+ const rest = textNodes(plan.evaluate(at).nodes).filter((n) => n.field === field);
+ // The kinetic headline's call to action and address show on its end card.
+ expect(rest.length, `${scene.id} ${field}`).toBeGreaterThan(0);
+ expect(spelled(rest.flatMap((n) => n.runs)), `${scene.id} ${field} "${text}"`).toBe(typedOf(r, field));
+ for (let i = 0; i <= 30; i++) {
+ const t = (i / 30) * r.duration;
+ for (const n of textNodes(plan.evaluate(t).nodes)) {
+ const typed = typedOf(r, n.field);
+ for (const run of n.runs) for (const ch of run.text) expect(typed.includes(ch) || (n.field === "stat" && /[0-9]/.test(ch)), `${scene.id} ${n.field} "${ch}" at ${t}`).toBe(true);
+ }
+ }
+ }
+ }
+ }
+ });
+
+ it("never draws the stars that mark the headline's words", () => {
+ const s = scenes.find((x) => x.id === "marketing/kinetic-headline")!;
+ const r = recipe(s.id, { fields: { headline: "Ship *faster* with *less*." } });
+ const plan = s.plan(input(r));
+ for (let i = 0; i <= 20; i++) for (const n of textNodes(plan.evaluate((i / 20) * 2.5).nodes)) for (const run of n.runs) expect(run.text).not.toContain("*");
+ const words = textNodes(plan.evaluate(2).nodes).find((n) => n.field === "headline")!;
+ expect(spelled(words.runs)).toBe("Ship faster with less.");
+ });
+
+ it("marks only paired stars round words, and keeps every other star as typed", () => {
+ expect(marked("5* hotel")).toEqual({ text: "5* hotel", marks: [] });
+ expect(marked("a*b")).toEqual({ text: "a*b", marks: [] });
+ expect(marked("*x*")).toEqual({ text: "x", marks: [[0, 1]] });
+ expect(marked("Free delivery*")).toEqual({ text: "Free delivery*", marks: [] });
+ expect(marked("Rated 5* by 4* guests")).toEqual({ text: "Rated 5* by 4* guests", marks: [] });
+ expect(marked("** and *")).toEqual({ text: "** and *", marks: [] });
+ expect(marked("Wake to *pure radiance* daily")).toEqual({ text: "Wake to pure radiance daily", marks: [[8, 21]] });
+ expect(marked("5* stays, *free* nights")).toEqual({ text: "5* stays, free nights", marks: [[10, 14]] });
+ // In the clip: a lone star is drawn as typed.
+ const s = scenes.find((x) => x.id === "marketing/kinetic-headline")!;
+ const r = recipe(s.id, { fields: { headline: "Rated 5* by *guests*" } });
+ const plan = s.plan(input(r));
+ const exit = plan.timeline.byId.get("words.exit")!;
+ const words = textNodes(plan.evaluate(exit.start - 0.01).nodes).find((n) => n.field === "headline")!;
+ expect(spelled(words.runs)).toBe("Rated 5* by guests");
+ });
+
+ it("names a field that doesn't fit instead of cutting it", () => {
+ for (const scene of scenes) {
+ const field = Object.keys(FIELDS[scene.id]).find((f) => f !== "stat")!;
+ const r = recipe(scene.id, { fields: { ...recipe(scene.id).fields, [field]: "Supercalifragilisticexpialidociously ".repeat(14).trim() } });
+ expect(scene.plan(input(r)).overflow, scene.id).toContain(field);
+ }
+ });
+});
+
+describe("timing", () => {
+ it("keeps every move within its kind's limits, staggers in range, and holds the last second", () => {
+ for (const scene of scenes) {
+ for (const duration of [5, 6.5, 8]) {
+ for (const pace of ["calm", "punchy"]) {
+ for (const logo of [RASTER_LOGO, SVG_LOGO, null]) {
+ const r = recipe(scene.id, { duration, controls: { pace } });
+ const plan = scene.plan(input(r, logo));
+ const events = plan.timeline.events;
+ expect(events.length, scene.id).toBeGreaterThan(2);
+ for (const e of events) {
+ const [lo, hi] = DURATION_LIMITS[e.kind];
+ expect(e.dur, `${scene.id} ${e.id}`).toBeGreaterThanOrEqual(lo - 1e-9);
+ expect(e.dur, `${scene.id} ${e.id}`).toBeLessThanOrEqual(hi + 1e-9);
+ expect(e.start, `${scene.id} ${e.id}`).toBeGreaterThanOrEqual(-0.15);
+ }
+ const groups = new Map<string, number[]>();
+ for (const e of events) if (e.group) groups.set(e.group, [...(groups.get(e.group) ?? []), e.start]);
+ for (const [g, starts] of groups) {
+ const [lo, hi] = STAGGER_LIMITS[events.find((e) => e.group === g)!.unit!];
+ for (let i = 1; i < starts.length; i++) {
+ expect(starts[i] - starts[i - 1], `${scene.id} ${g}`).toBeGreaterThanOrEqual(lo - 1e-6);
+ expect(starts[i] - starts[i - 1], `${scene.id} ${g}`).toBeLessThanOrEqual(hi + 1e-6);
+ }
+ }
+ expect(duration - plan.settled, `${scene.id} ${duration}s ${pace} hold`).toBeGreaterThanOrEqual(1);
+ expect(plan.rest).toBeCloseTo((Math.round(duration * r.fps) - 1) / r.fps, 9);
+ expect(JSON.stringify(plan.evaluate(duration))).toBe(JSON.stringify(plan.evaluate(plan.rest)));
+ // Something moves between the start and the rest.
+ expect(JSON.stringify(plan.evaluate(plan.settled * 0.4))).not.toBe(JSON.stringify(plan.evaluate(plan.rest)));
+ }
+ }
+ }
+ }
+ });
+});
+
+// ---------------------------------------------------------------------------
+// The rest frame: words in the safe area, and readable
+
+interface Placed {
+ field: string;
+ text: string;
+ fill: string;
+ box: { x0: number; y0: number; x1: number; y1: number };
+}
+
+const apply = (m: Matrix, x: number, y: number): [number, number] => [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]];
+
+function boxOf(m: Matrix, x: number, y: number, w: number, h: number) {
+ const pts = [apply(m, x, y), apply(m, x + w, y), apply(m, x, y + h), apply(m, x + w, y + h)];
+ return { x0: Math.min(...pts.map((p) => p[0])), y0: Math.min(...pts.map((p) => p[1])), x1: Math.max(...pts.map((p) => p[0])), y1: Math.max(...pts.map((p) => p[1])) };
+}
+
+/** Every solid shape and text run in drawing order, placed in design units. */
+function flatten(nodes: readonly DisplayNode[], m: Matrix = IDENTITY, alpha = 1, out: ({ kind: "shape"; fill: string; box: Placed["box"]; ellipse?: { cx: number; cy: number; r: number }; path?: boolean } | ({ kind: "text" } & Placed))[] = []) {
+ for (const n of nodes) {
+ const a = alpha * ("opacity" in n && n.opacity !== undefined ? n.opacity : 1);
+ if (n.type === "group") {
+ if (n.blend && n.blend !== "source-over") continue;
+ flatten(n.children, n.transform ? multiply(m, n.transform) : m, a, out);
+ } else if (n.type === "text") {
+ for (const r of n.runs) {
+ const size = Number(/(\d+(\.\d+)?)px/.exec(r.font)![1]);
+ const rm = r.transform ? multiply(m, r.transform) : m;
+ out.push({ kind: "text", field: n.field, text: r.text, fill: typeof r.fill === "string" ? r.fill : "", box: boxOf(rm, r.x, r.y, measure(r.text, r.font), size) });
+ }
+ } else if ((n.type === "rect" || n.type === "ellipse" || n.type === "path") && typeof n.fill === "string" && /^#/.test(n.fill) && a >= 0.999) {
+ if (n.type === "rect") out.push({ kind: "shape", fill: n.fill, box: boxOf(m, n.x, n.y, n.w, n.h) });
+ else if (n.type === "ellipse") {
+ const [cx, cy] = apply(m, n.cx, n.cy);
+ out.push({ kind: "shape", fill: n.fill, box: boxOf(m, n.cx - n.rx, n.cy - n.ry, 2 * n.rx, 2 * n.ry), ellipse: { cx, cy, r: Math.min(n.rx, n.ry) * Math.sqrt(Math.abs(m[0] * m[3] - m[1] * m[2])) } });
+ } else {
+ const nums = (n.d.match(/-?\d+(\.\d+)?/g) ?? []).map(Number);
+ const xs = nums.filter((_, i) => i % 2 === 0);
+ const ys = nums.filter((_, i) => i % 2 === 1);
+ const pm = n.transform ? multiply(m, n.transform) : m;
+ // A star or burst: its inner circle (the part sure to be filled).
+ const bx = boxOf(pm, Math.min(...xs), Math.min(...ys), Math.max(...xs) - Math.min(...xs), Math.max(...ys) - Math.min(...ys));
+ const cx = (bx.x0 + bx.x1) / 2;
+ const cy = (bx.y0 + bx.y1) / 2;
+ out.push({ kind: "shape", fill: n.fill, box: bx, ellipse: { cx, cy, r: (Math.min(bx.x1 - bx.x0, bx.y1 - bx.y0) / 2) * 0.8 }, path: true });
+ }
+ }
+ }
+ return out;
+}
+
+function behind(list: DisplayList, at: number, x: number, y: number, flat: ReturnType<typeof flatten>): string {
+ for (let i = at - 1; i >= 0; i--) {
+ const s = flat[i];
+ if (s.kind !== "shape") continue;
+ // Full-frame ray paths are not solid everywhere: a word on them must sit on a shape of its own.
+ if (s.path && s.box.x1 - s.box.x0 >= list.w * 0.99 && s.box.y1 - s.box.y0 >= list.h * 0.99) continue;
+ const inside = s.ellipse ? Math.hypot(x - s.ellipse.cx, y - s.ellipse.cy) <= s.ellipse.r : x >= s.box.x0 && x <= s.box.x1 && y >= s.box.y0 && y <= s.box.y1;
+ if (inside) return s.fill;
+ }
+ return list.background;
+}
+
+describe("the rest frame", () => {
+ it("keeps every word inside the safe area and readable (4.5:1) on what is behind it, for every look and size", () => {
+ for (const scene of scenes) {
+ for (const size of SIZES) {
+ for (const look of ["light", "dark", "brand"]) {
+ for (const colors of [["#6b1d2a", "#e9d8b4"], ["#1f6feb", "#0b0f19"], ["#f2c94c", "#ffffff"], ["#0f5132", "#d4af37"]]) {
+ for (const logo of [RASTER_LOGO, null]) {
+ const r = recipe(scene.id, { size, controls: { look }, brand: { name: "Maison Ardent", colors, fonts: { heading: "Playfair Display", body: "Inter" } } });
+ const plan = scene.plan(input(r, logo));
+ if (plan.overflow.length) continue;
+ const list = plan.evaluate(plan.rest);
+ const safe = safeArea(list);
+ const flat = flatten(list.nodes);
+ flat.forEach((item, i) => {
+ if (item.kind !== "text") return;
+ const tag = `${scene.id} ${size} ${look} ${colors} ${item.field} "${item.text}"`;
+ // The kinetic headline ends on the end card, which keeps its own margins.
+ if (scene.id !== "marketing/kinetic-headline") {
+ expect(item.box.x0, tag).toBeGreaterThanOrEqual(safe.x - 1);
+ expect(item.box.x1, tag).toBeLessThanOrEqual(safe.x + safe.w + 1);
+ expect(item.box.y0, tag).toBeGreaterThanOrEqual(safe.y - 1);
+ expect(item.box.y1, tag).toBeLessThanOrEqual(safe.y + safe.h + 1);
+ }
+ const bg = behind(list, i, (item.box.x0 + item.box.x1) / 2, (item.box.y0 + item.box.y1) / 2, flat);
+ expect(contrast(item.fill, bg), `${tag} on ${bg}`).toBeGreaterThanOrEqual(4.5);
+ });
+ }
+ }
+ }
+ }
+ }
+ });
+});
+
+describe("outline (outline.ts)", () => {
+ it("traces a disc's edge as a closed path within 2 % of its circumference", () => {
+ expect(DISC).not.toBeNull();
+ expect(DISC.d.endsWith("Z")).toBe(true);
+ expect(Math.abs(DISC.length - 2 * Math.PI * 80) / (2 * Math.PI * 80)).toBeLessThan(0.02);
+ // It starts at the lowest point.
+ expect(DISC.start[1]).toBeGreaterThan(128 + 78);
+ });
+
+ it("gives null for a picture with no transparency (it gets a frame instead)", () => {
+ expect(traceOutline(new Uint8ClampedArray(64 * 64).fill(255), 64, 64)).toBeNull();
+ expect(traceOutline(new Uint8ClampedArray(64 * 64), 64, 64)).toBeNull();
+ });
+
+ it("frames a photo's product (Line-Art Reveal without an outline still draws)", () => {
+ const s = scenes.find((x) => x.id === "marketing/line-reveal")!;
+ const plan = s.plan(input(recipe(s.id), RASTER_LOGO, null));
+ const mid = walk(plan.evaluate(1.2).nodes).filter((n) => n.type === "path");
+ expect(mid.length).toBeGreaterThan(0);
+ });
+});
+
+describe("counters", () => {
+ const L = (text: string) => counterLayout("stat", text, "Inter", 800, 4000, 100, 40, measure);
+ const runsAt = (text: string, p: number) => textNodes([counterNode(L(text), 0, 0, "#000000", p)]).flatMap((n) => n.runs);
+
+ it("ends on the typed stat exactly", () => {
+ for (const s of ["$1,284,000", "38%", "4.9/5", "12 480 €", "+212%", "3×", "1.234,56"]) expect(spelled(runsAt(s, 1))).toBe(s);
+ });
+
+ it("keeps the typed separators and signs in place while counting", () => {
+ const text = "$1,284,000";
+ const at = (p: number) => runsAt(text, p).filter((r) => !/[0-9]/.test(r.text));
+ const end = at(1);
+ for (const p of [0, 0.2, 0.5, 0.8]) expect(at(p).map((r) => [r.text, r.x])).toEqual(end.map((r) => [r.text, r.x]));
+ });
+
+ it("rolls every figure in a cell as wide as the widest figure", () => {
+ const l = L("1,111");
+ const figures = l.cells.filter((c) => c.digit !== null);
+ expect(new Set(figures.map((c) => c.w)).size).toBe(1);
+ });
+});
diff --git a/tests/motion-scenes.test.ts b/tests/motion-scenes.test.ts
index 5f31300a..e0e6afef 100644
--- a/tests/motion-scenes.test.ts
+++ b/tests/motion-scenes.test.ts
@@ -15,13 +15,15 @@ import { input, measure, RASTER_LOGO, recipe, SVG_LOGO, allNodes } from "./helpe
// Every registered scene: determinism under any order of seeks, exact spelling, the timing rules, and (for the end
// card) a rest frame that is the still card's own layout.
-const scenes: Scene[] = await Promise.all(SCENE_IDS.map(loadScene));
+// The end card's five styles (Marketing's scenes have their own checks: motion-marketing.test.ts).
+const END_CARD_IDS = SCENE_IDS.filter((id) => id.startsWith("end-card/"));
+const scenes: Scene[] = await Promise.all(END_CARD_IDS.map(loadScene));
const SIZES: SizeSpec[] = [{ w: 720, h: 1280 }, "9:16", "1:1", "16:9", "4:5"];
const cp = (...c: number[]) => String.fromCodePoint(...c);
describe("the registry", () => {
it("has the five end-card styles", () => {
- expect(SCENE_IDS.sort()).toEqual(END_CARD_VARIANTS.map((v) => `end-card/${v}`).sort());
+ expect(END_CARD_IDS.sort()).toEqual(END_CARD_VARIANTS.map((v) => `end-card/${v}`).sort());
for (const s of scenes) expect(s.durations).toEqual({ min: 2, max: 3, default: 2.5 });
});
});
diff --git a/tests/template-covers.test.ts b/tests/template-covers.test.ts
index 4df56a40..80600820 100644
--- a/tests/template-covers.test.ts
+++ b/tests/template-covers.test.ts
@@ -131,10 +131,10 @@ describe("the template covers manifest", () => {
lines.push(` ${JSON.stringify(key)}: ${JSON.stringify(gen.slimEntry(key, { poster: e.poster, ...(e.video && { video: e.video }), ...(e.at && { at: e.at }), ...(e.frames && { frames: e.frames }) }))}`);
}
}
- // The studios' tiles (242, with Keyframes → animation, Outfit lookbook and Music video), Fuobe Soul's looks (139),
- // AI Influencer's types (9), the empty pages' examples (6) and the studios' ready-made starters with a cover of their
- // own (24).
- expect(lines).toHaveLength(242 + 139 + 9 + 6 + 24);
+ // The studios' tiles (246, with Keyframes → animation, Outfit lookbook, Music video and Marketing's four code-drawn
+ // templates), Fuobe Soul's looks (139), AI Influencer's types (9), the empty pages' examples (6) and the studios'
+ // ready-made starters with a cover of their own (24).
+ expect(lines).toHaveLength(246 + 139 + 9 + 6 + 24);
const text = `{\n${lines.join(",\n")}\n}`;
expect(text.length).toBeLessThan(37_000);
expect(gzipSync(text).length).toBeLessThan(8_000);
@@ -174,6 +174,7 @@ describe.skipIf(!hasFfmpeg)("pnpm eval:covers --templates", () => {
put("marketing/ps-sunlit-plinth", { "still.png": still });
put("marketing/m2-sticker-pop", { "clip.mp4": SAMPLE_CLIP });
put("shorts/shorts-warm-glow", { "clip.mp4": SAMPLE_CLIP, "meta.json": '{"rest":"end"}' });
+ put("marketing/ms-kinetic-headline", { "clip.mp4": SAMPLE_CLIP, "meta.json": '{"rest":0.5}' });
put("photodump/zen", { "still.png": still, "frame-2.png": still, "frame-3.png": still, "frame-4.png": still });
put("mixed-media/mixed-sketch", { "meta.json": JSON.stringify({ same: sameId }) });
put("mixed-media/mixed-paper", { "meta.json": JSON.stringify({ same: peakId }) });
@@ -187,6 +188,7 @@ describe.skipIf(!hasFfmpeg)("pnpm eval:covers --templates", () => {
const r = run();
expect(r.covers.map((c) => c.key).sort()).toEqual([
"marketing/m2-sticker-pop",
+ "marketing/ms-kinetic-headline",
"marketing/ps-sunlit-plinth",
"mixed-media/mixed-paper",
"mixed-media/mixed-sketch",
@@ -202,6 +204,10 @@ describe.skipIf(!hasFfmpeg)("pnpm eval:covers --templates", () => {
const reveal = m["shorts/shorts-warm-glow"];
expect(reveal.at).toBeGreaterThan(1);
expect(reveal.video).toMatch(VERSIONED);
+ // A clip whose telling moment comes earlier rests on it (the frame nearest that time), kept whole too.
+ const moment = m["marketing/ms-kinetic-headline"];
+ expect(moment.at).toBeCloseTo(0.5, 1);
+ expect(moment.video).toMatch(VERSIONED);
expect(m["photodump/zen"].frames).toEqual([2, 3, 4].map((k) => `/previews/templates/photodump/zen-${k}.jpg?v=${sha8(out(`photodump/zen-${k}.jpg`), out(`photodump/thumbs/zen-${k}.jpg`))}`));
expect(m["mixed-media/mixed-sketch"]).toEqual({ poster: PRESET_PREVIEWS[sameId].poster, ...(PRESET_PREVIEWS[sameId].video && { video: PRESET_PREVIEWS[sameId].video }) });
// A clip with a peak rests on it: the look, not the photo the clip starts from (and the versions stay the peak's own).
@@ -228,11 +234,11 @@ describe.skipIf(!hasFfmpeg)("pnpm eval:covers --templates", () => {
expect(fs.existsSync(path.join(publicDir, "previews/templates/photodump/zen-4.jpg"))).toBe(false);
expect(fs.existsSync(path.join(publicDir, "previews/templates/photodump/thumbs/zen-4.jpg"))).toBe(false);
// The other tiles stay as they were.
- expect(Object.keys(m)).toHaveLength(6);
+ expect(Object.keys(m)).toHaveLength(7);
});
it("versions the manifest from the files as they are (--versions), and finds nothing to do when it's current", () => {
- expect(gen.versionTemplateCovers({ publicDir, manifest, dryRun: true })).toMatchObject({ entries: 6, changed: 0, thumbs: [], unversioned: [] });
+ expect(gen.versionTemplateCovers({ publicDir, manifest, dryRun: true })).toMatchObject({ entries: 7, changed: 0, thumbs: [], unversioned: [] });
// A still replaced by hand: its copy is made again first, then both get a new version.
const poster = path.join(publicDir, "previews/templates/marketing/ps-sunlit-plinth.jpg");
const was = gen.readTemplateManifest(manifest)["marketing/ps-sunlit-plinth"].poster;