Skip to content

A Claude Code plugin that turns a story into a finished anime

Ruby

Replace RTS-specific helpers with focused animation asset tools

Francesco 'makevoid' Canessafab2729c436c
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index 6cb3cc0..8da7e16 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "make-an-anime",
- "version": "0.5.0",
+ "version": "0.6.0",
"license": "MIT",
"description": "Create anime from a story: character sheets (GPT Image 2.6 Sunburst), cinematic MiniMax H3 shots, green-screen layered composites, ElevenLabs v4 character voices, ElevenLabs Music v2.5 scores, p5 titles and subtitles, SFX and Swift VFX. Works from a 12-second scene to a full episode.",
"author": {
diff --git a/README.md b/README.md
index 5616720..eec7d0e 100644
--- a/README.md
+++ b/README.md
@@ -83,7 +83,7 @@ Each stage reads prompts from `prompts/<run>/` and writes to `output/<run>/`, so
6. **Sound.** `sfx:gen` creates sound effects with Stable Audio, and `sfx:mix` places them from a cue list and levels them against the mix.
7. **Finish.** `vfx:render` adds grain, glow or impact effects with Swift Core Image, on frame-accurate cues. The optional `vfx:bake` pass preserves the plain picture so repeating the finish does not accumulate effects.
-For detailed staging and playback review, see [Staging and review](skills/make-an-anime/references/staging-and-review.md). Local graphics tools include [deterministic particles and light-only glow](skills/make-an-anime/references/particles-and-glow.md), plus [game screens and asset cutting](skills/make-an-anime/references/game-screens.md).
+For detailed staging and playback review, see [Staging and review](skills/make-an-anime/references/staging-and-review.md). Local graphics tools include [deterministic particles and light-only glow](skills/make-an-anime/references/particles-and-glow.md), plus [animation asset preparation](skills/make-an-anime/references/animation-assets.md).
The same steps as commands, once a project and its prompts exist:
diff --git a/docs/production-improvements.md b/docs/production-improvements.md
index 90f2a35..b69cc2e 100644
--- a/docs/production-improvements.md
+++ b/docs/production-improvements.md
@@ -1,4 +1,4 @@
-# Production feedback incorporated in 0.5.0
+# Production feedback and animation tools
The local production trial supplied sixteen improvement notes. This integration carries reusable instructions and code into the plugin, without its story, reference photos, generated media, private paths or character identities.
@@ -10,15 +10,27 @@ The local production trial supplied sixteen improvement notes. This integration
| 11–12: voice and timing | Audible `speech_at` in timeline checks; skipped frames included in source duration; short-source rejection; skipped-prefix retiming. Existing repeated-word validation remains in place. |
| 13: character performance | Purposeful motion and readable reactions, with intentional holds still available when the approved visual direction calls for them. |
| 14–15: reuse, stale mix, dialogue, staging | `from_take` with source digests; mix settings/audio fingerprints; stale soundtrack refusal; music-only gain default; local muffled voices; running-water false-positive fix; practical door and missed-shot staging guidance. |
-| 16: graphics | Deterministic particles, a separate light layer and Swift halo, repeatable VFX bake, configurable RTS/mission/court helpers, sheet cutters, and face-icon collage recipes. |
+| 16: graphics | Deterministic particles, a separate light layer and Swift halo, repeatable VFX bake, animation sheet cutters and portrait-collage recipes. The initial game-specific helpers were removed in 0.6.0. |
The new references are linked from the skill and task guide. Executable behavior is exercised with synthetic local fixtures, including real FFmpeg, Python, Chrome/p5 and Swift rendering. Paid model output quality still requires production review; offline fixtures cannot establish it.
Automatic airborne-only retiming, arbitrary perspective-quad compositing, generalized room reconstruction and heuristic changes to transcription acceptance were not ported. Those require a separate design and evidence. The trial's ban on held characters was a film preference, so it became review guidance rather than a universal rule. Generated art, font files and project media are not bundled.
-## Verification
+## Animation scope in 0.6.0
+
+Removed the RTS, mission-map and court libraries, their screen example and five game-art prompts. Their layouts, units, factions, counters and drill simulation were tightly coupled to one production. The existing p5 timeline and transform helpers already cover general motion, so no replacement framework was added.
+
+Kept sheet cutting, flat frame apertures, image fitting, portrait collages, deterministic particles and light passes. The public commands are now `assets:cut` and `assets:faces`, backed by `Media::AnimationAssets`. A small cut-out prop example demonstrates time-driven movement over transparency. The animation-assets reference documents the recipes and migration; no project media or initialized project copies were changed.
+
+## 0.5.0 verification
- `ruby skills/make-an-anime/scripts/mv.rb test`: 96 offline examples, zero failures, including Chrome/p5 and Swift. Fal credentials were unset; no paid calls ran.
- `npm audit`: zero vulnerabilities.
- Strict Claude plugin and marketplace validation passed on an export containing only repository files. Gitleaks found no secrets in that export.
- The skill-creator quick validator rejects the existing `compatibility` frontmatter field because its allowed-key list omits it; the strict Claude validator accepts the plugin. No metadata was removed to bypass that older helper.
+
+## 0.6.0 verification
+
+- Full offline suite: 96 examples, zero failures, including the renamed asset commands, real sheet/portrait processing, deterministic sprite motion and Swift light passes. No paid generation ran.
+- Strict Claude plugin validation passed on a repository-file export.
+- `cloc` for the former game-screen tool subset: 1,249 code lines in seven files became 374 in four files (70% fewer). Shared particles/VFX, tests and docs are excluded from both counts.
diff --git a/skills/make-an-anime/SKILL.md b/skills/make-an-anime/SKILL.md
index c19c134..bf1248e 100644
--- a/skills/make-an-anime/SKILL.md
+++ b/skills/make-an-anime/SKILL.md
@@ -61,7 +61,7 @@ Order of work, each step reviewed before the next:
4. **Keyframes** (`Steps::Keyframes`): one composed first frame per shot, edited from the cast/location sheets (`base: false`, `refs: [...]`).
5. **Shots** (`Steps::Shots`): H3 Max animates each keyframe at **768P** by default, with the shot's camera move written as its own `camera:` direction and the speaking character's mouth track as target audio. Still holds and solid inserts cost nothing. `review:camera` measures the move each shot actually made, and `review:believable` checks the prompts and takes for action on green and treadmill runs (`gen:clips` and `gen:shots` refuse the written failures before any paid call).
6. **Panels and layers, only for people who stay put** (`Steps::Clips`): two people far apart talk on one screen through painted panels with a paper cut (`key: none`, `Anim.paperCutPanels`), see [believable-motion.md](references/believable-motion.md). A keyed green performance is the last resort, for a still figure with no action; read [layered-scenes.md](references/layered-scenes.md) first.
-7. **Overlay** (`Steps::Overlay`): p5 draws screens, UI, title cards, subtitles and transitions over the plate, using `tools/p5/lib/screens.js` (code editor, typing, subtitles, place cards) and `tools/p5/lib/battle.js` (title slam, speed lines, impacts, camera roll). For generated game interfaces, see [game-screens.md](references/game-screens.md); for deterministic particles and light-only glow, see [particles-and-glow.md](references/particles-and-glow.md). Bake a scene light pass with `vfx:bake[run]` before `sfx:mix` when configured, or finish to a distinct VFX output.
+7. **Overlay** (`Steps::Overlay`): p5 draws screens, UI, title cards, subtitles and transitions over the plate, using `tools/p5/lib/screens.js` (code editor, typing, subtitles, place cards) and `tools/p5/lib/battle.js` (title slam, speed lines, impacts, camera roll). For animation asset sheets and portrait collages, see [animation-assets.md](references/animation-assets.md); for deterministic particles and light-only glow, see [particles-and-glow.md](references/particles-and-glow.md). Bake a scene light pass with `vfx:bake[run]` before `sfx:mix` when configured, or finish to a distinct VFX output.
Delegate production to sub-agents in waves (**2 assets first → 3–4 → 4–8 → 6–10 repeatedly**) with `work:next`, `work:log`, `work:watch` and `work:accept`, as described in [production.md](references/production.md). A short pilot can run serially; say so. Schedule the opening and the emotional peak early. Never let concurrent workers edit shared config, cast or identity sheets.
diff --git a/skills/make-an-anime/assets/game-screens/console.txt b/skills/make-an-anime/assets/game-screens/console.txt
deleted file mode 100644
index 10f84ad..0000000
--- a/skills/make-an-anime/assets/game-screens/console.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-Video game interface art asset for an original 2004 PC real-time strategy game, high-end pre-rendered look of that era. Not from any existing game: an original design.
-
-The image is one wide bottom HUD console, seen straight on, flat, front view, no perspective. It runs edge to edge across the full width of the image and fills only the bottom 30 percent of the image. Everything above the console is one flat, even, pure magenta colour (#FF00FF), with no gradient, no shadow and no texture, so it can be keyed out.
-
-The console: heavy sci-fi armour plating in dark gunmetal and brushed steel, with chamfered edges, rivets, small vents, thin cobalt-blue glowing trim lines and a few amber status lamps. Its top edge is not straight: it steps up into a raised armoured pod at the far left and a second, lower raised pod at the far right, joined by a lower middle section.
-
-Recessed into the console, from left to right, five empty screens, each with a bevelled metal bezel and a flat, solid black inside (#000000), with nothing drawn in them:
-1. in the raised left pod, a tall portrait screen, about one tenth of the image wide;
-2. a square minimap screen next to it;
-3. in the middle, one wide, low rectangular information screen, about a third of the image wide;
-4. a narrow vertical slot beside it;
-5. in the raised right pod, a command-card area: a grid of 4 columns by 3 rows of empty square button sockets, each socket flat solid black inside.
-
-Crisp, clean, symmetrical bevels, sharp detail, readable at small size. No text, no letters, no numbers, no symbols, no icons, no logos, no buttons with drawings on them, no characters, no units, no map, no watermark.
diff --git a/skills/make-an-anime/assets/game-screens/face-icons.txt b/skills/make-an-anime/assets/game-screens/face-icons.txt
deleted file mode 100644
index f29a6a7..0000000
--- a/skills/make-an-anime/assets/game-screens/face-icons.txt
+++ /dev/null
@@ -1 +0,0 @@
-Redraw each face in this grid as a small stylised game-unit portrait of the same character, in the same cell. Keep their age, face shape, hair, clothing and distinguishing features. Preserve the grid, spacing, background and character order. One portrait per cell; no extra portraits. Use original icon frames with clear silhouettes. No text, letters, numbers, labels, logos or watermarks. Do not imitate an existing game.
diff --git a/skills/make-an-anime/assets/game-screens/icons.txt b/skills/make-an-anime/assets/game-screens/icons.txt
deleted file mode 100644
index 9f7a8dc..0000000
--- a/skills/make-an-anime/assets/game-screens/icons.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Video game interface art asset: an icon sheet of command buttons for an original 2004 PC real-time strategy game. Original designs, not from any existing game.
-
-Exactly 12 square icons in a grid of 4 columns by 3 rows, evenly spaced, all the same size, each with a clear gap of flat black between them, on a flat, even, pure black background (#000000). Each icon is a small square button: a dark gunmetal bevelled tile with a thin glowing cobalt-blue rim, and in the middle one bold, simple painted emblem in bright steel, white, cyan and amber, readable at very small size:
-row 1: a boot print with a forward arrow (move), an octagonal shield with a palm (stop), a crosshair over a short blade (attack), two curved arrows chasing each other in a circle (patrol);
-row 2: a planted kite shield with a down arrow (hold position), a wrench crossed with a hammer (build), a laser rifle with a bright muzzle glint (fire), a round grenade with a spark (grenade);
-row 3: a radar dish with wave arcs (scan), a hexagon shield with a plus (shield boost), a flag on a pole (rally point), a small rocket rising with a flame (missile).
-
-Crisp clean edges, high-end pre-rendered look of that era. No text, no letters, no numbers, no hotkey letters, no logos, no watermark.
diff --git a/skills/make-an-anime/assets/game-screens/map.txt b/skills/make-an-anime/assets/game-screens/map.txt
deleted file mode 100644
index 6109b9b..0000000
--- a/skills/make-an-anime/assets/game-screens/map.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Video game art asset: the battlefield terrain of an original 2004 PC real-time strategy game, as the player sees it, a high overhead camera looking down at about 60 degrees, a slight isometric three-quarter angle, the whole image filled with ground to every edge. High-end pre-rendered 2D terrain tiles of that era, crisp and detailed, readable at small size.
-
-An alien frontier world at night, lit by cold blue moonlight with warm amber work lights: a wide plateau of dusty ochre-grey dirt and cracked rock in the middle, raised rocky cliff ledges with sharp highlights along the top and the bottom edges, one ramp up between them, a dark chasm with glowing teal fissures in the lower left corner, a field of tall glowing blue crystals at the far left, a small green gas vent with a faint plume on the right, scattered boulders, metal debris, a few scorch marks and tread tracks across the open ground, a broken road of metal plates crossing from left to right.
-
-Only terrain: no units, no vehicles, no soldiers, no creatures, no buildings, no interface, no cursor, no selection marks, no minimap, no text, no letters, no numbers, no logos, no watermark.
diff --git a/skills/make-an-anime/assets/game-screens/portrait.txt b/skills/make-an-anime/assets/game-screens/portrait.txt
deleted file mode 100644
index 5e3a97b..0000000
--- a/skills/make-an-anime/assets/game-screens/portrait.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Video game art asset: the unit portrait for an original 2004 PC real-time strategy game, the face that talks in the console's portrait screen. High-end pre-rendered 3D CGI look of that era, cinematic, dramatic rim light. An original character design, not from any existing game.
-
-A head-and-shoulders bust, centred, filling the middle third of the image from the top of the head to the upper chest, turned slightly to the left with the eyes looking at the viewer. An original tall alien warrior in ornate ceremonial armour: a closed helmet with a high, swept-back crest made of three bronze fins and two short curled horns at the temples, a smooth mouthless faceplate of dark ivory with fine engraved lines, two narrow glowing eyes of hot amber-orange light behind the faceplate, a high armoured collar, layered pauldrons of deep violet enamel edged with polished bronze filigree and small inset green gemstones, a short cloak of dark teal cloth on one shoulder. No weapons, no blades, no energy blades, no tentacles, no tubes from the head.
-
-Behind the bust, a dark smoky blue-green background with faint soft light, plain, so the portrait can sit in a small screen. No text, no letters, no numbers, no logos, no interface, no frame, no watermark.
diff --git a/skills/make-an-anime/assets/game-screens/units.txt b/skills/make-an-anime/assets/game-screens/units.txt
deleted file mode 100644
index d3dafec..0000000
--- a/skills/make-an-anime/assets/game-screens/units.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-Video game sprite sheet for an original 2004 PC real-time strategy game: small game units for two factions, each seen from a high overhead camera at about 60 degrees, a slight isometric three-quarter angle, the way they look on the battlefield. High-end pre-rendered 3D sprites of that era, crisp, clean silhouettes, strong rim light, readable at small size. Original designs, not from any existing game.
-
-The background is one flat, even, pure magenta colour (#FF00FF) everywhere, with no shadows on it, no floor, no gradient, no texture, so the sprites can be keyed out. Each unit stands alone with wide empty magenta space around it, nothing touching, and no shadow under it.
-
-Exactly 8 units in a grid of 4 columns by 2 rows, evenly spaced:
-Top row, the blue faction, steel-blue and white armour with cobalt lights, all facing right: 1) an armoured infantry trooper with a long rifle and a big shoulder lamp, 2) a squat two-legged walker mech with twin cannons, 3) a low hover tank with a long barrel, 4) a small delta-wing gunship.
-Bottom row, the red faction, crimson and black plating with orange glowing vents, all facing left: 5) a four-legged spider drone with a single red eye, 6) a heavy armoured crawler with a spiked ram, 7) a fast raider skiff with two blades, 8) a tall stilt-legged war walker with a glowing core.
-
-No text, no letters, no numbers, no labels, no health bars, no selection circles, no interface, no logos, no watermark.
diff --git a/skills/make-an-anime/assets/portrait-grid.txt b/skills/make-an-anime/assets/portrait-grid.txt
new file mode 100644
index 0000000..0981afa
--- /dev/null
+++ b/skills/make-an-anime/assets/portrait-grid.txt
@@ -0,0 +1 @@
+Redraw each portrait in this grid in the approved animation style, keeping the same character in the same cell. Preserve age, face shape, hair, clothing and distinguishing features. Keep the grid, spacing, background and character order. One portrait per cell, with clear silhouettes; no extra portraits, text, labels, logos or watermarks.
diff --git a/skills/make-an-anime/references/animation-assets.md b/skills/make-an-anime/references/animation-assets.md
new file mode 100644
index 0000000..569688f
--- /dev/null
+++ b/skills/make-an-anime/references/animation-assets.md
@@ -0,0 +1,66 @@
+# Animation asset preparation
+
+Use these local tools to separate props, poses, decorative elements or portraits from generated sheets. They prepare images for an animation; layout, styling and choreography belong to the project's sketch. Paid artwork generation follows the approved production plan.
+
+## Sheet cutting
+
+Inspect whether the sheet actually has transparency, magenta or black behind the artwork. Use the matching `key`, and give each intended output a unique plain identifier. The cutter finds rows and then elements left-to-right from visible coverage; it stops when the detected count differs from the supplied names. It does not infer identities or animation frame order.
+
+Save a JSON recipe, then run it from an initialized project:
+
+```json
+{"mode":"sprites","source":"output/prop-sheet/01_ref_base.png","out":"output/art/props","names":["leaf","flower"],"key":"alpha"}
+```
+
+```sh
+ruby mv.rb 'assets:cut[config/cut-sprites.json]'
+```
+
+| Mode | Required recipe fields | Options |
+| --- | --- | --- |
+| `sprites` | `source`, `out` directory, `names` array | `key` (default alpha), `min_px`, `min_len`, `gap`, `margin` |
+| `grid` | `source`, `out` directory, `names` array | `key` (default black), `min_px`, `min_len`, `gap`, `size`, `inset` |
+| `frame` | `source`, `out` PNG, `slots` JSON | `key` (default alpha), `dark`, `scale`, `min_area` |
+| `fit` | `source`, `out`, `width` | `crop: [x,y,w,h]` |
+
+`sprites` preserves each cut-out's proportions and alpha. `grid` produces square tiles while preserving their background; its `key` is used for detection, not background removal. Use it for illustrated panels or icons. A pose sheet is not automatically a coherent motion cycle: inspect order, registration and transitions before animating it.
+
+`frame` finds connected dark rectangular apertures in decorative artwork, makes them transparent and writes their measured bounds to `slots` as `{w,h,top,slots:[[x,y,w,h],...]}`. Bounds are sorted by descending area; they have no assigned meaning. Inspect them before placing content underneath. This is a flat image operation, not perspective projection. `fit` optionally crops and then resizes an opaque background or portrait to the requested width.
+
+## Portrait collages
+
+Crop accepted character faces into a consistent reference grid for one image edit, then split the edited result. The spec selects source sheets and measured face boxes:
+
+```json
+{"cols":2,"rows":1,"cell":[460,520],"gap":40,"margin":60,"faces":[{"name":"lead","sheet":"output/char-lead/01_ref_base.png","box":[600,400,240]},{"name":"friend","sheet":"output/char-friend/01_ref_base.png","box":[600,400,240]}]}
+```
+
+`box` is centre x/y and crop width; optional `scale` converts measurements taken from a downscaled inspection image. Crop height follows the cell aspect ratio. Use a build recipe:
+
+```json
+{"mode":"build","spec":"config/faces.json","out":"output/portrait-collage.png"}
+```
+
+```sh
+ruby mv.rb 'assets:faces[config/build-faces.json]'
+```
+
+Adapt `assets/portrait-grid.txt` to the approved art direction for the image edit. For the returned sheet, run the same task with `{"mode":"cut","spec":"config/faces.json","source":"output/portraits-edited.png","out":"output/art/portraits","size":256}`. The cutter removes the detected background and pads each portrait to a square.
+
+Ambiguous counts stop the cutter. Set `grid_fallback: true` only after inspecting the sheet; it evenly divides the detected content bounds and still needs identity review. Verify every returned portrait against its named source. Neither the collage tool nor the prompt imposes a particular genre or character proportions.
+
+## Animate with the existing timeline
+
+Use `Anim.progress`, `Anim.tween`, `Anim.envelope` and normal p5 transforms to place and move prepared artwork. Derive every frame from time so isolated previews match full renders. `scripts/tools/p5/examples/sprite-motion.js` moves a prop over transparency without any interface or game layout. Its data JSON is `{"sprite":"/output/art/props/leaf.png"}`. Render from a project Ruby recipe:
+
+```ruby
+Media::Anim.new.render("tools/p5/examples/sprite-motion.js", "output/prop-motion",
+ width: 320, height: 180, fps: 24, frames: 48,
+ data: { assets: "config/assets.json" })
+```
+
+Renderer image paths start at the project root. For timed video cut-outs use `Anim.clip`; for emitted light and atmospheric effects see [particles-and-glow.md](particles-and-glow.md). Moving a static prop is useful for layered composition, but moving an entire character image does not supply body performance.
+
+## Migration from 0.5.0
+
+`game:cut` and `game:faces` are now `assets:cut` and `assets:faces`; recipe fields are unchanged. Ruby callers use `Media::AnimationAssets` from `lib/media/animation_assets.rb`. The RTS, mission-map and court modules, their screen example and genre-specific art prompts have been removed. Existing initialized projects retain their own toolkit copies; their files are not automatically rewritten by a plugin update.
diff --git a/skills/make-an-anime/references/animation-audio-vfx.md b/skills/make-an-anime/references/animation-audio-vfx.md
index 17d02ae..4ed9c06 100644
--- a/skills/make-an-anime/references/animation-audio-vfx.md
+++ b/skills/make-an-anime/references/animation-audio-vfx.md
@@ -6,7 +6,7 @@ H3 supplies the characters and their world together, in one full-frame take; p5
## p5 scenes and overlays
-The renderer loads `tools/p5/lib/{core,time,fx,type,paper,riso,screens,battle,particles,rts,mission,court}.js` and calls a sketch for each frame at `t=frame/24`. Per-frame random seeds make repeats deterministic. Full-scene sketches draw on a background plate selected for the scene; overlay sketches leave transparent areas over an H3 plate. Load project fonts chosen for the approved art direction through `Anim.fonts`. Select drawing, texture and typography helpers to suit that direction. Library names and bundled examples do not prescribe a visual style.
+The renderer loads `tools/p5/lib/{core,time,fx,type,paper,riso,screens,battle,particles}.js` and calls a sketch for each frame at `t=frame/24`. Per-frame random seeds make repeats deterministic. Full-scene sketches draw on a background plate selected for the scene; overlay sketches leave transparent areas over an H3 plate. Load project fonts chosen for the approved art direction through `Anim.fonts`. Select drawing, texture and typography helpers to suit that direction. Library names and bundled examples do not prescribe a visual style.
### Project fonts
@@ -117,4 +117,4 @@ The Swift service builds the package through Ruby, uses FFmpeg rawvideo pipes an
## Generated interfaces and particle light passes
-[Game screens](game-screens.md) describes reusable original artwork, local sheet cutting, face collages and the RTS/mission/court helpers. [Particles and glow](particles-and-glow.md) documents deterministic emitters, `halo`, and `vfx:bake[run]` between overlay and SFX. The light pass blooms only explicitly emitted light, preserving the surrounding painting and readable HUD.
+[Animation assets](animation-assets.md) describes reusable original artwork, local sheet cutting, portrait collages and a time-driven sprite example. [Particles and glow](particles-and-glow.md) documents deterministic emitters, `halo`, and `vfx:bake[run]` between overlay and SFX. The light pass blooms only explicitly emitted light, preserving the surrounding painting and readable text.
diff --git a/skills/make-an-anime/references/game-screens.md b/skills/make-an-anime/references/game-screens.md
deleted file mode 100644
index e459c62..0000000
--- a/skills/make-an-anime/references/game-screens.md
+++ /dev/null
@@ -1,54 +0,0 @@
-# A game on a screen
-
-Use this for an original game interface inside a film, or for an intentional game-like diagram. Generate artwork without text, cut it locally, then draw all readable words, numbers, cursors and event timing in p5. Choose art and UI conventions for the story's era without copying a specific game's units, branding or layout. Use fonts licensed for the intended delivery; no font files are bundled.
-
-The optional modules `Anim.rts`, `Anim.mission` and `Anim.court` are loaded after `Anim.particles`. They provide a concrete RTS composition, mission-map primitives and court diagrams; other genres can reuse the asset tools and particles independently.
-
-## Artwork and cutting
-
-Starter prompts in `assets/game-screens/` cover `console.txt`, `map.txt`, `units.txt`, `icons.txt` and `portrait.txt`. Adapt them to the approved visual direction and register each as a normal `gen:ref_base` run. Paid calls follow the production plan and existing credential workflow. A 4-second screen does not require generating a full video if p5 can animate the planned action from these sheets.
-
-The console should contain empty flat-black screens; the sprites should have clear gaps. Inspect whether the returned file actually uses transparency, magenta or black. The cutting tools support all three; do not assume a requested key colour was returned.
-
-Run local tools through Ruby with JSON recipes, which allow commas and spaces inside paths and arrays:
-
-```json
-{"mode":"sprites","source":"output/game-units/01_ref_base.png","out":"output/game-art/units","names":["trooper","walker","tank","gunship","spider","crawler","skiff","stilt"],"key":"alpha"}
-```
-
-```sh
-ruby mv.rb 'game:cut[config/cut-units.json]'
-```
-
-| `mode` | Required recipe fields | Options |
-| --- | --- | --- |
-| `sprites` | `source`, `out` directory, `names` array | `key` (default alpha), `min_px`, `min_len`, `gap`, `margin` |
-| `grid` | `source`, `out` directory, `names` array | `key` (default black), `min_px`, `min_len`, `gap`, `size`, `inset` |
-| `frame` | `source`, `out` PNG, `slots` JSON | `key` (default alpha), `dark`, `scale`, `min_area` |
-| `fit` | `source`, `out`, `width` | `crop: [x,y,w,h]` |
-
-Sprite/icon names must be unique plain identifiers. A count mismatch stops instead of silently dropping a cell. `frame` locates connected dark rectangular areas, makes them transparent and writes their measured bounds. Inspect the holes and slot ordering; merged or decorative black regions can require a cleaner source or adjusted thresholds. `fit` resizes terrain/portraits and can crop first.
-
-`Anim.rts.load({dir, units, icons})` expects `map.jpg`, `console.png`, `console_slots.json`, `portrait.png`, and `units/<name>.png` / `icons/<name>.png` below `dir`. It assigns the large console slots left-to-right to portrait/minimap/info/gauge and small slots to commands; `game.hud.screens` overrides the large-slot labels. Keep the required empty screens distinct.
-
-## Choreography
-
-`scripts/tools/p5/examples/game-screen.js` is a generic starting sketch. Supply a data JSON such as `{"dir":"/output/game-art","units":["trooper"],"icons":["move"]}` via the renderer's `game` data entry when calling `Media::Anim#render` from a project Ruby recipe. The header of `rts.js` documents its game object: unit positions as functions of time, deaths, events, camera, selection, cursor, commands, portrait activity, minimap and counters.
-
-Keep named event times in one place and derive visual, light and sound cues from them. A cursor should travel to the button it presses. Minimap positions should follow the actual units. Tiny sprites may slide convincingly for a brief screen insert; larger or longer shots need pose cycles and facing changes. Single-pose art is not a walking animation.
-
-`Anim.mission` adds floor, fog, beacon, path and unit helpers. Configure `R.bezel = {box: [x,y,w,h], inset: [left,top,right,bottom], corner: pixels}` from your measured console art before calling `begin`/`end`; there is no universal pixel crop. Its bezel is nine-sliced. `Anim.court.half(box)` and `.full(box)` produce diagram geometry; the included court lines are illustrative and must be adapted to the sport, era and intended proportions. `drillSim` is an illustrative eight-second drill derived from a formation configuration; frames may be requested out of order. Longer or different choreography needs its own simulation or time functions.
-
-See [particles-and-glow.md](particles-and-glow.md) for `mode: 'light'`, occlusion and the `halo` pass. Size a screen effect's sound for the in-scene speakers; distant desktop audio need not have cinematic sub-bass. Measure the surrounding mix and inspect flashes for whiteouts.
-
-## Face icons
-
-Crop accepted character faces into a consistent grid, request one edit using `assets/game-screens/face-icons.txt`, then cut the result. The input spec describes only the chosen sheets and measured face boxes:
-
-```json
-{"cols":2,"rows":1,"cell":[460,520],"gap":40,"margin":60,"faces":[{"name":"pilot","sheet":"output/char-pilot/01_ref_base.png","box":[600,400,240]},{"name":"rival","sheet":"output/char-rival/01_ref_base.png","box":[600,400,240]}]}
-```
-
-`box` is centre x/y and crop width; optional `scale` converts measurements from a downscaled inspection image. Use a `game:faces` recipe `{"mode":"build","spec":"config/faces.json","out":"output/faces-collage.png"}`. After the approved image edit, use `{"mode":"cut","spec":"config/faces.json","source":"output/faces-edited.png","out":"output/game-art/faces","size":256}`.
-
-The cutter stops on ambiguous counts. Inspect the sheet before explicitly setting `grid_fallback: true`; this evenly splits the detected content bounds and still needs visual identity review. Verify every returned cell against its source face before using the name mapping. Project-specific face sheets, photos and character names are not part of the plugin.
diff --git a/skills/make-an-anime/references/tasks.md b/skills/make-an-anime/references/tasks.md
index aeea982..cb0cf8a 100644
--- a/skills/make-an-anime/references/tasks.md
+++ b/skills/make-an-anime/references/tasks.md
@@ -227,12 +227,12 @@ VFX=finish-vfx ruby scripts/mv.rb --project /absolute/project 'vfx:stills[0,24,1
VFX=finish-vfx ruby scripts/mv.rb --project /absolute/project 'vfx:clip[96,144]'
VFX=finish-vfx ruby scripts/mv.rb --project /absolute/project vfx:render
ruby scripts/mv.rb --project /absolute/project 'vfx:bake[ep01-s01]'
-ruby scripts/mv.rb --project /absolute/project 'game:cut[config/cut-units.json]'
-ruby scripts/mv.rb --project /absolute/project 'game:faces[config/build-faces.json]'
+ruby scripts/mv.rb --project /absolute/project 'assets:cut[config/cut-sprites.json]'
+ruby scripts/mv.rb --project /absolute/project 'assets:faces[config/build-faces.json]'
ruby scripts/mv.rb --project /absolute/project 'media:twitter[output/finished.mp4,output/delivery-1080.mp4]'
```
-For local particles and a repeatable light-only halo pass, see [particles-and-glow.md](particles-and-glow.md). For game artwork recipes and p5 screen/mission/court helpers, see [game-screens.md](game-screens.md). `vfx:bake` requires the documented cues paths, preserves the plain picture, and finishes before `sfx:mix`.
+For local particles and a repeatable light-only halo pass, see [particles-and-glow.md](particles-and-glow.md). For animation artwork recipes and sprite motion, see [animation-assets.md](animation-assets.md). `vfx:bake` requires the documented cues paths, preserves the plain picture, and finishes before `sfx:mix`.
`media:probe`, `media:sheet`, `media:frame`, `media:cut`, `media:cutout`, `media:sprite_box`, `media:style`, `media:concat`, `media:mux`, `media:upload` and `media:youtube` are listed by `-T` with their arguments. Export names denote encoding presets; they do not publish to platforms. For unlisted operations, add an OOP service under `lib/` and a thin registry delegate. Keep backend code under `tools/` and tests in `spec/`.
diff --git a/skills/make-an-anime/references/testing.md b/skills/make-an-anime/references/testing.md
index 6c3fd7e..0ba73d3 100644
--- a/skills/make-an-anime/references/testing.md
+++ b/skills/make-an-anime/references/testing.md
@@ -26,7 +26,7 @@ Offline synthetic media is deliberately simple so placement/alpha/timing are mea
The media profile also checks seeded alpha-component cleanup through the public Ruby task: retained subject RGBA and soft alpha remain exact, detached lettering disappears, the original file remains unchanged, and invalid/missing seeds fail without publishing a partial sequence.
-Production regression examples cover source-length rejection before assembly, skipped-prefix retiming, cross-scene take reuse and replacement detection, gated speech timelines, water-versus-running language, audio/settings cache invalidation, and local muffled dialogue. Graphics fixtures verify deterministic particle frames in and out of order, a separate light layer, RTS/mission/court rendering, sheet and face cutting (including ambiguous-count rejection), and repeatable halo baking that preserves remixed audio and leaves the final unchanged on invalid cues.
+Production regression examples cover source-length rejection before assembly, skipped-prefix retiming, cross-scene take reuse and replacement detection, gated speech timelines, water-versus-running language, audio/settings cache invalidation, and local muffled dialogue. Graphics fixtures verify deterministic particle frames in and out of order, a separate light layer, time-driven cut-out sprite motion, sheet and face cutting (including ambiguous-count rejection), and repeatable halo baking that preserves remixed audio and leaves the final unchanged on invalid cues.
## Paid live E2E
diff --git a/skills/make-an-anime/scripts/lib/media/game_assets.rb b/skills/make-an-anime/scripts/lib/media/animation_assets.rb
similarity index 98%
rename from skills/make-an-anime/scripts/lib/media/game_assets.rb
rename to skills/make-an-anime/scripts/lib/media/animation_assets.rb
index fa96f9e..a179878 100644
--- a/skills/make-an-anime/scripts/lib/media/game_assets.rb
+++ b/skills/make-an-anime/scripts/lib/media/animation_assets.rb
@@ -1,7 +1,7 @@
require_relative "python"
module Media
# JSON recipes avoid comma-separated task arguments for names, crops and paths.
- class GameAssets
+ class AnimationAssets
def cut(recipe)
r = JSON.parse(File.read(recipe))
mode = r.fetch("mode")
diff --git a/skills/make-an-anime/scripts/lib/toolkit/mcp_server.rb b/skills/make-an-anime/scripts/lib/toolkit/mcp_server.rb
index ab0c2a2..c6d19dc 100644
--- a/skills/make-an-anime/scripts/lib/toolkit/mcp_server.rb
+++ b/skills/make-an-anime/scripts/lib/toolkit/mcp_server.rb
@@ -154,7 +154,7 @@ module Toolkit
when "initialize"
requested = params["protocolVersion"]
{ protocolVersion: PROTOCOLS.include?(requested) ? requested : PROTOCOLS.first,
- capabilities: { tools: {} }, serverInfo: { name: "anime", version: "0.5.0" } }
+ capabilities: { tools: {} }, serverInfo: { name: "anime", version: "0.6.0" } }
when "ping" then {}
when "tools/list" then { tools: TOOLS }
when "tools/call" then call_tool(params)
diff --git a/skills/make-an-anime/scripts/lib/toolkit/operations.rb b/skills/make-an-anime/scripts/lib/toolkit/operations.rb
index a6b6da0..383ccf1 100644
--- a/skills/make-an-anime/scripts/lib/toolkit/operations.rb
+++ b/skills/make-an-anime/scripts/lib/toolkit/operations.rb
@@ -1,5 +1,5 @@
require_relative "../media/vfx_bake"
-require_relative "../media/game_assets"
+require_relative "../media/animation_assets"
require_relative "../workflow/approval"
require_relative "../workflow/waves"
require_relative "../workflow/journal"
@@ -62,8 +62,8 @@ module Toolkit
"media:upload" => "Upload [path] to Fal CDN",
"ref:import" => "Reuse existing hosted identity [new_run,local_image,original_manifest.json] (no upload)",
"vfx:bake" => "Bake a scene light pass without stacking it: [run] (local)",
- "game:cut" => "Cut generated game sheets using a JSON recipe: [recipe.json] (local)",
- "game:faces" => "Build or cut a face-icon collage using a JSON recipe: [recipe.json] (local)",
+ "assets:cut" => "Cut animation asset sheets using a JSON recipe: [recipe.json] (local)",
+ "assets:faces" => "Build or cut a face-icon collage using a JSON recipe: [recipe.json] (local)",
"vfx:build" => "Build Swift Core Image renderer (macOS)",
"vfx:analyze" => "Analyze VFX source beats and cuts; VFX=name",
"vfx:stills" => "Preview cued VFX frames [0,24,...]; VFX=name",
@@ -88,8 +88,8 @@ module Toolkit
def call(name, a)
case name
when "vfx:bake" then required(a, 1); emit Media::VfxBake.new(a[0]).bake
- when "game:cut" then required(a, 1); emit Media::GameAssets.new.cut(a[0])
- when "game:faces" then required(a, 1); emit Media::GameAssets.new.faces(a[0])
+ when "assets:cut" then required(a, 1); emit Media::AnimationAssets.new.cut(a[0])
+ when "assets:faces" then required(a, 1); emit Media::AnimationAssets.new.faces(a[0])
when "doctor" then doctor
when "setup" then setup
when "fonts:list" then emit Fonts.new.list
diff --git a/skills/make-an-anime/scripts/spec/graphics_tools_spec.rb b/skills/make-an-anime/scripts/spec/graphics_tools_spec.rb
index bffad6a..9a46e70 100644
--- a/skills/make-an-anime/scripts/spec/graphics_tools_spec.rb
+++ b/skills/make-an-anime/scripts/spec/graphics_tools_spec.rb
@@ -19,60 +19,52 @@ RSpec.describe "Deterministic graphics and asset tools", :media do
expect(alpha.max).to be > 0
end
- it "cuts game sprites through the Ruby recipe task and refuses mismatched names" do
+ it "cuts animation sprites through the Ruby recipe task and refuses mismatched names" do
sheet = file("sheet.png")
magick.run("magick", "-size", "200x100", "xc:none", "-fill", "red", "-draw", "rectangle 10,10 70,80", "-fill", "blue", "-draw", "rectangle 120,10 180,80", sheet)
- json(file("cut.json"), mode: "sprites", source: sheet, out: file("units"), names: %w[red blue])
- out, err, status = cli("game:cut[#{file('cut.json')}]")
+ json(file("cut.json"), mode: "sprites", source: sheet, out: file("sprites"), names: %w[red blue])
+ out, err, status = cli("assets:cut[#{file('cut.json')}]")
expect(status.success?).to be(true), err
expect(JSON.parse(out)["sprites"].keys).to eq(%w[red blue])
- expect(pixels(file("units/red.png"))).to include([255, 0, 0, 255])
+ expect(pixels(file("sprites/red.png"))).to include([255, 0, 0, 255])
json(file("bad.json"), mode: "sprites", source: sheet, out: file("bad"), names: %w[red])
- _, err, status = cli("game:cut[#{file('bad.json')}]")
+ _, err, status = cli("assets:cut[#{file('bad.json')}]")
expect(status.success?).to be(false)
expect(err).to include("found 2 sprites, expected 1")
expect(Dir[File.join(file("bad"), "*.png")]).to be_empty
end
- it "renders the RTS example and mission/court helpers using local fixture art" do
- assets = file("game-art"); FileUtils.mkdir_p(File.join(assets, "units")); FileUtils.mkdir_p(File.join(assets, "icons"))
- magick.run("magick", "-size", "960x540", "gradient:#203040-#607050", File.join(assets, "map.jpg"))
- magick.run("magick", "-size", "960x540", "xc:none", "-fill", "#304050", "-draw", "rectangle 0,400 959,539", File.join(assets, "console.png"))
- magick.run("magick", "-size", "100x100", "xc:#708090", File.join(assets, "portrait.png"))
- magick.run("magick", "-size", "40x60", "xc:#3090ff", File.join(assets, "units/trooper.png"))
- json(File.join(assets, "console_slots.json"), w: 960, h: 540, top: 400, slots: [[20, 420, 100, 100], [140, 420, 100, 100], [260, 420, 280, 100], [560, 420, 50, 100], [650, 430, 20, 20], [680, 430, 20, 20], [710, 430, 20, 20], [740, 430, 20, 20]])
- json(file("game.json"), dir: "/" + assets.delete_prefix("#{RT}/"), units: ["trooper"], icons: [])
+ it "animates a cut-out prop over transparency with deterministic frame selection" do
+ magick.run("magick", "-size", "40x60", "xc:none", "-fill", "#3090ff", "-draw", "ellipse 20,30 16,26 0,360", file("leaf.png"))
+ json(file("assets.json"), sprite: "/" + file("leaf.png").delete_prefix("#{RT}/"))
renderer = Media::Anim.new
- renderer.render(File.join(RT, "tools/p5/examples/game-screen.js"), file("game"), width: 960, height: 540, fps: 24, frames: 12, only: [0, 10], data: { game: file("game.json") })
- expect(pixels(file("game/0000.png"))).not_to eq(pixels(file("game/0010.png")))
- File.write(file("court.js"), <<~JS)
- Anim.sketch({
- async load(){this.R=await Anim.rts.load(Anim.data('game'));this.R.bezel={box:[0,400,120,120],inset:[8,8,8,8],corner:16}},
- draw(t){
- background('#102030'); const box={x:80,y:80,w:560,h:300};
- Anim.mission.begin(this.R,box,{s:1});
- Anim.mission.floor(box,{seed:'fixture',tile:40});
- Anim.court.lines(Anim.court.full(box));
- Anim.court.ball(t,300,230,{dribble:true});
- Anim.mission.end(this.R,box,{s:1,logo:false});
- }
- });
- JS
- renderer.render(file("court.js"), file("court"), width: 720, height: 480, fps: 24, frames: 6, only: [0, 5], data: { game: file("game.json") })
- expect(pixels(file("court/0000.png"))).not_to eq(pixels(file("court/0005.png")))
+ sketch = File.join(RT, "tools/p5/examples/sprite-motion.js")
+ args = { width: 320, height: 180, fps: 24, frames: 25, data: { assets: file("assets.json") } }
+ renderer.render(sketch, file("motion"), **args)
+ renderer.render(sketch, file("isolated"), **args, only: [24, 0])
+ [0, 24].each do |frame|
+ name = format("%04d.png", frame)
+ expect(pixels(file("isolated/#{name}"))).to eq(pixels(file("motion/#{name}")))
+ end
+ center = ->(path) do
+ points = pixels(path).each_with_index.filter_map { |pixel, i| i % 320 if pixel.last > 128 }
+ points.sum.fdiv(points.length)
+ end
+ expect(center.call(file("motion/0024.png")) - center.call(file("motion/0000.png"))).to be > 80
+ expect(pixels(file("motion/0024.png")).first.last).to eq(0)
end
- it "cuts icon grids, detects HUD holes and fits art through the recipe service" do
+ it "cuts icon grids, detects frame apertures and fits art through the recipe service" do
sheet = file("icons.png")
magick.run("magick", "-size", "200x100", "xc:black", "-fill", "red", "-draw", "rectangle 10,10 70,80", "-fill", "blue", "-draw", "rectangle 120,10 180,80", sheet)
- service = Media::GameAssets.new
- json(file("grid.json"), mode: "grid", source: sheet, out: file("icons"), names: %w[attack move], size: 64)
- expect(service.cut(file("grid.json"))["tiles"].keys).to eq(%w[attack move])
- magick.run("magick", "-size", "240x120", "xc:#808080", "-fill", "black", "-draw", "rectangle 20,20 100,100", file("console.png"))
- json(file("frame.json"), mode: "frame", source: file("console.png"), out: file("cut-console.png"), slots: file("slots.json"), scale: 1, min_area: 100)
+ service = Media::AnimationAssets.new
+ json(file("grid.json"), mode: "grid", source: sheet, out: file("icons"), names: %w[sun moon], size: 64)
+ expect(service.cut(file("grid.json"))["tiles"].keys).to eq(%w[sun moon])
+ magick.run("magick", "-size", "240x120", "xc:#808080", "-fill", "black", "-draw", "rectangle 20,20 100,100", file("frame.png"))
+ json(file("frame.json"), mode: "frame", source: file("frame.png"), out: file("cut-frame.png"), slots: file("slots.json"), scale: 1, min_area: 100)
expect(service.cut(file("frame.json"))["slots"]).to eq(1)
- expect(pixels(file("cut-console.png"))[60 * 240 + 60].last).to eq(0)
- json(file("fit.json"), mode: "fit", source: sheet, out: file("map.jpg"), width: 100)
+ expect(pixels(file("cut-frame.png"))[60 * 240 + 60].last).to eq(0)
+ json(file("fit.json"), mode: "fit", source: sheet, out: file("background.jpg"), width: 100)
expect(service.cut(file("fit.json"))["size"]).to eq([100, 50])
end
@@ -85,8 +77,10 @@ RSpec.describe "Deterministic graphics and asset tools", :media do
] }
json(file("faces.json"), spec)
json(file("build.json"), mode: "build", spec: file("faces.json"), out: file("collage.png"))
- service = Media::GameAssets.new
- expect(service.faces(file("build.json"))["cells"]).to eq(2)
+ service = Media::AnimationAssets.new
+ out, err, status = cli("assets:faces[#{file('build.json')}]")
+ expect(status.success?).to be(true), err
+ expect(JSON.parse(out)["cells"]).to eq(2)
json(file("split.json"), mode: "cut", spec: file("faces.json"), source: file("collage.png"), out: file("faces"), size: 64)
expect(service.faces(file("split.json"))["icons"].keys).to eq(%w[pilot rival])
expect(pixels(file("faces/pilot.png"))).to include([255, 0, 0, 255])
diff --git a/skills/make-an-anime/scripts/tools/p5/examples/game-screen.js b/skills/make-an-anime/scripts/tools/p5/examples/game-screen.js
deleted file mode 100644
index 7d6c25e..0000000
--- a/skills/make-an-anime/scripts/tools/p5/examples/game-screen.js
+++ /dev/null
@@ -1,25 +0,0 @@
-// Supply --data game=recipe.json where recipe has {dir, units:[...], icons:[...]}.
-// Art is produced with the game-screens guide; no generated media is bundled.
-Anim.sketch({
- async load() {
- const config = Anim.data('game');
- this.art = await Anim.rts.load(config);
- const kind = config.units[0];
- this.game = {
- title: 'Orbital Command', logo: { text: 'ORBITAL', sub: 'COMMAND' },
- fonts: { ui: 'sans-serif', uiBold: 'sans-serif', logo: 'sans-serif' },
- map: { scale: 1, cam: t => [20 * t, 0] },
- kinds: { [kind]: { w: 70 } },
- units: [{ id: 'scout', kind, team: 'blue', at: t => [400 + 45 * t, 300] }],
- selected: () => true,
- events: [{ type: 'laser', id: 'shot', at: 0.3, dur: 0.3, from: [430, 265], to: [680, 250] }],
- timer: t => `00:${String(Math.floor(t)).padStart(2, '0')}`,
- resources: () => [{ icon: 'crystal', text: '120' }],
- commands: config.icons || [], gauge: () => 0.7,
- cursor: t => ({ x: 650 + 20 * t, y: 300, mode: 'target' })
- };
- },
- draw(t, frame) {
- Anim.rts.screen(t, this.art, this.game, { frame, mode: ANIM.data.vfx !== undefined ? 'light' : 'color' });
- }
-});
diff --git a/skills/make-an-anime/scripts/tools/p5/examples/sprite-motion.js b/skills/make-an-anime/scripts/tools/p5/examples/sprite-motion.js
new file mode 100644
index 0000000..1aa7cb1
--- /dev/null
+++ b/skills/make-an-anime/scripts/tools/p5/examples/sprite-motion.js
@@ -0,0 +1,15 @@
+// A cut-out prop moving over transparency using the existing animation timeline.
+// --data assets=config/assets.json: {"sprite":"/output/art/leaf.png"}
+Anim.sketch({
+ async load() {
+ this.sprite = await loadImage(Anim.data('assets').sprite);
+ },
+ draw(t) {
+ const q = Anim.progress(t, 0, 2, Anim.ease.inOutCubic);
+ const h = height * 0.3;
+ translate(width * (0.2 + 0.6 * q), height * (0.5 - 0.15 * Math.sin(Math.PI * q)));
+ rotate(0.4 * Math.sin(Math.PI * q));
+ imageMode(CENTER);
+ image(this.sprite, 0, 0, h * this.sprite.width / this.sprite.height, h);
+ }
+});
diff --git a/skills/make-an-anime/scripts/tools/p5/lib/court.js b/skills/make-an-anime/scripts/tools/p5/lib/court.js
deleted file mode 100644
index 87915b4..0000000
--- a/skills/make-an-anime/scripts/tools/p5/lib/court.js
+++ /dev/null
@@ -1,244 +0,0 @@
-// Basketball courts as Orbital Command maps: a half court (the drills) and a full court (the match), with glowing
-// lines on steel deck plates, a dribbled ball, a pass, the sprite-to-face-icon swap, and the "fill the spaces" drill.
-// Needs mission.js (frame, floor, units, icons, fog), rts.js and particles.js.
-//
-// const C = Anim.court;
-// const geo = C.half(box); // 15 m across, 14 m deep, the basket at the top: geo.px(u), geo.py(v), geo.m
-// const geo = C.full(box); // 28 m long, 15 m across, baskets left and right: geo.px(x), geo.py(y)
-// C.lines(geo); // the painted lines, glowing
-// C.fromHalf([u, v]) // a half-court spot (attacking the right basket) on the full court
-// C.ball(t, x, y, { dribble }) // the ball at a hand, bouncing when dribbled
-// C.drill(R, f, local, cfg) // the whole "fill the spaces" view (see below)
-//
-// Everything is a pure function of t, as in particles.js: the drill's crawler is re-simulated from 0 each frame.
-window.Anim = window.Anim || {};
-
-(() => {
- const C = {};
- const M = () => Anim.mission;
- const clamp01 = (x) => Math.max(0, Math.min(1, x));
- const TAU = Math.PI * 2;
- const LINE = "rgba(90,190,255,0.9)";
-
- C.half = (box) => { const m = box.h / 14; return { kind: "half", box, m, px: (u) => box.x + u * m, py: (v) => box.y + v * m }; };
- C.full = (box) => { const m = box.w / 28; return { kind: "full", box, m, px: (x) => box.x + x * m, py: (y) => box.y + y * m }; };
- // A spot of the half court (u across, v out from the baseline) on the full court, attacking the right-hand basket.
- C.fromHalf = ([u, v]) => [28 - v, u];
-
- C.lines = (geo, { color = LINE, width: lw = 4 } = {}) => {
- const { px, py, m } = geo, G = (d) => M().glowStroke(d, { color, width: lw, blur: 12, core: "rgba(230,248,255,0.9)" });
- if (geo.kind === "half") {
- // the same lines the drills always had: side lines, the key, the arc, the basket
- G((c) => c.rect(px(0), py(0), 15 * m, 14 * m));
- G((c) => c.rect(px(5.05), py(0), 4.9 * m, 5.8 * m));
- G((c) => c.arc(px(7.5), py(1.575), 6.25 * m, 0, Math.PI));
- G((c) => { c.moveTo(px(7.5) + 0.225 * m, py(1.575)); c.arc(px(7.5), py(1.575), 0.225 * m, 0, TAU); });
- G((c) => { c.moveTo(px(6.6), py(1.2)); c.lineTo(px(8.4), py(1.2)); });
- return;
- }
- G((c) => c.rect(px(0), py(0), 28 * m, 15 * m));
- G((c) => { c.moveTo(px(14), py(0)); c.lineTo(px(14), py(15)); });
- G((c) => { c.moveTo(px(14) + 1.8 * m, py(7.5)); c.arc(px(14), py(7.5), 1.8 * m, 0, TAU); });
- for (const side of [0, 1]) {
- const X = (x) => px(side ? 28 - x : x), dir = side ? -1 : 1;
- G((c) => c.rect(Math.min(X(0), X(5.8)), py(5.05), 5.8 * m, 4.9 * m));
- G((c) => { c.moveTo(X(5.8) + dir * 1.8 * m, py(7.5)); c.arc(X(5.8), py(7.5), 1.8 * m, side ? Math.PI : 0, side ? 3 * Math.PI : TAU); });
- // the three-point line: straight in the corners, then the arc (6.75 m from the basket); a is the arc's half-angle
- const a = Math.asin(6.6 / 6.75), hx = X(1.575);
- G((c) => {
- c.moveTo(X(0), py(0.9)); c.lineTo(X(2.99), py(0.9));
- if (side) c.arc(hx, py(7.5), 6.75 * m, -Math.PI + a, Math.PI - a, true);
- else c.arc(hx, py(7.5), 6.75 * m, -a, a, false);
- c.lineTo(X(0), py(14.1));
- });
- G((c) => { c.moveTo(hx + 0.225 * m, py(7.5)); c.arc(hx, py(7.5), 0.225 * m, 0, TAU); });
- G((c) => { c.moveTo(X(1.2), py(6.6)); c.lineTo(X(1.2), py(8.4)); });
- }
- };
-
- // The ball: orange, with seams, a shadow, and a hot rim light. dribble: bounces from the hand (h px above the floor)
- // to the floor, `hz` bounces a second.
- C.ball = (t, x, y, { r = 13, dribble = false, hz = 2.6, h = 46, glow = true } = {}) => {
- const g = drawingContext;
- const lift = dribble ? h * (1 - Math.abs(Math.cos(Math.PI * hz * t))) ** 0.8 : 0;
- const squash = dribble && lift < 4 ? 0.82 : 1;
- g.save();
- g.fillStyle = `rgba(0,0,0,${0.45 - 0.25 * lift / Math.max(1, h)})`;
- g.beginPath(); g.ellipse(x, y + r * 0.6, r * (1.05 - 0.3 * lift / Math.max(1, h)), r * 0.35, 0, 0, TAU); g.fill();
- g.translate(x, y - lift); g.scale(1 / squash ** 0.5, squash);
- if (glow) { g.shadowColor = "rgba(255,140,40,0.9)"; g.shadowBlur = 14; }
- const gr = g.createRadialGradient(-r * 0.35, -r * 0.4, r * 0.1, 0, 0, r);
- gr.addColorStop(0, "#ffb15a"); gr.addColorStop(1, "#d0561a");
- g.fillStyle = gr; g.beginPath(); g.arc(0, 0, r, 0, TAU); g.fill();
- g.shadowBlur = 0; g.strokeStyle = "rgba(40,14,0,0.75)"; g.lineWidth = 1.6;
- g.beginPath(); g.moveTo(-r, 0); g.lineTo(r, 0); g.moveTo(0, -r); g.lineTo(0, r); g.stroke();
- g.restore();
- };
-
- // A pass from a to b over `dur` s from `at`: the ball's position, with a little loft, or null outside it.
- C.pass = (t, at, dur, a, b, loft = 30) => {
- const q = (t - at) / dur;
- if (q < 0 || q > 1) return null;
- const e = q * q * (3 - 2 * q);
- return [a[0] + (b[0] - a[0]) * e, a[1] + (b[1] - a[1]) * e - loft * Math.sin(Math.PI * q)];
- };
-
- // Formation steps: dots run from one formation to the next at k * step, taking `move` s, then hold.
- C.steps = (forms, t, { step, move, lag = 0 }) => {
- const tt = Math.max(0, t - lag);
- const k = Math.min(Math.floor(tt / step), forms.length - 1);
- const p = k === 0 ? 0 : Anim.ease.inOutCubic(clamp01((tt - k * step) / move));
- const prev = forms[Math.max(k - 1, 0)], next = forms[k];
- return { k, p, dots: next.map((d, i) => [prev[i][0] + (d[0] - prev[i][0]) * p, prev[i][1] + (d[1] - prev[i][1]) * p]),
- moving: next.map((d, i) => p > 0 && p < 1 && Math.hypot(d[0] - prev[i][0], d[1] - prev[i][1]) > 0.05),
- dir: next.map((d, i) => Math.sign(d[0] - prev[i][0]) || 1) };
- };
-
- // A side panel of face icons: the squad, a lost one greyed and crossed. faces: [{img, name, lost}].
- C.squadPanel = (R, f, x, y, w, h, faces, { title = "SQUAD", s = 1.2, t = 0, extra } = {}) => {
- const g = drawingContext;
- g.save(); g.fillStyle = "#05080c"; g.fillRect(x, y, w, h); g.restore();
- const alive = faces.filter((q) => !q.lost).length;
- Anim.rts.ui.styledText(`${title} ${alive}/${faces.length}`, x + w / 2, y + 34, { font: f.logo, size: 24, style: "#cfe8ff", glow: "rgba(60,160,255,0.8)", blur: 8 });
- const cols = 2, cw = w / cols, sz = Math.min(cw - 40, 104), rh = sz + 26;
- faces.forEach((q, i) => {
- const cx = x + cw * (i % cols) + cw / 2, cy = y + 76 + sz / 2 + Math.floor(i / cols) * rh;
- g.save(); g.globalAlpha = q.lost ? 0.35 : 1; g.filter = q.lost ? "grayscale(1)" : "none";
- g.drawImage(q.img.canvas || q.img.elt || q.img, cx - sz / 2, cy - sz / 2, sz, sz);
- g.restore();
- if (q.lost) {
- g.save(); g.strokeStyle = "rgba(255,60,40,0.95)"; g.lineWidth = 6; g.shadowColor = "rgba(255,40,20,1)"; g.shadowBlur = 10;
- const d = sz * 0.3; g.beginPath(); g.moveTo(cx - d, cy - d); g.lineTo(cx + d, cy + d); g.moveTo(cx + d, cy - d); g.lineTo(cx - d, cy + d); g.stroke(); g.restore();
- }
- Anim.rts.ui.hpBar(cx, cy + sz / 2 + 8, sz * 0.8, q.lost ? 0 : 1, [60, 230, 80]);
- });
- if (extra) extra(x, y + h - 70, w);
- M().bezel(R, { x, y, w, h }, { s });
- };
-
- // ---- the drill: "fill the spaces" ------------------------------------------------------------------------------
- // cfg: { forms (4 formations of 8 [u, v]), step, move, faces (8 names, the squad), crawlerFrom [u, v], speed (m/s),
- // chalk (v of the chalk line, optional), ball ([u, v], optional), line (the mission line), title }
- // One red crawler hunts the nearest trooper. Bunched, they are easy; spread, it has to run and the one it chases steps
- // away, so it runs further and cannot get them all. Its metres run are counted on the panel.
- const simCache = {};
- C.drillSim = (cfg, t) => {
- const key = JSON.stringify([cfg.forms, cfg.step, cfg.move, cfg.crawlerFrom, cfg.speed]);
- let sim = simCache[key];
- if (!sim) {
- const dt = 1 / 96, T = 8;
- const n = cfg.forms[0].length, off = Array.from({ length: n }, () => [0, 0]);
- let c = [...cfg.crawlerFrom], run = 0, pause = 0, target = -1;
- const lost = [], frames = [];
- for (let s = 0, tt = 0; tt <= T; s++, tt = s * dt) {
- const base = C.steps(cfg.forms, tt, cfg).dots, spread = tt >= cfg.step;
- const pos = base.map((b, i) => [b[0] + off[i][0], b[1] + off[i][1]]);
- const aliveIdx = pos.map((_, i) => i).filter((i) => !lost.some((q) => q.i === i));
- // the nearest one is the target
- let best = -1, bd = Infinity;
- for (const i of aliveIdx) { const d = Math.hypot(pos[i][0] - c[0], pos[i][1] - c[1]); if (d < bd) { bd = d; best = i; } }
- target = best;
- if (pause > 0) pause -= dt;
- else if (best >= 0) {
- const [dx, dy] = [pos[best][0] - c[0], pos[best][1] - c[1]], d = Math.hypot(dx, dy);
- if (d < 0.55) { lost.push({ i: best, at: tt, x: pos[best][0], y: pos[best][1] }); pause = 0.45; }
- else { const v = Math.min(cfg.speed * dt, d); c = [c[0] + dx / d * v, c[1] + dy / d * v]; run += v; }
- }
- // spread out, the one it closes on steps away from it (inside the half); the others drift back to their space
- for (const i of aliveIdx) {
- const [dx, dy] = [pos[i][0] - c[0], pos[i][1] - c[1]], d = Math.hypot(dx, dy) || 1;
- if (spread && i === target && d < 2.2) {
- const v = cfg.speed * 0.92 * dt;
- off[i][0] += dx / d * v; off[i][1] += dy / d * v;
- off[i][0] = Math.max(0.6 - base[i][0], Math.min(14.4 - base[i][0], off[i][0]));
- off[i][1] = Math.max(0.6 - base[i][1], Math.min(13.4 - base[i][1], off[i][1]));
- } else { off[i][0] *= 0.985; off[i][1] *= 0.985; }
- }
- frames.push({ c: [...c], run, target, off: off.map((o) => [...o]), lost: lost.length });
- }
- sim = simCache[key] = { dt, frames, lost };
- }
- const fr = sim.frames[Math.min(sim.frames.length - 1, Math.max(0, Math.round(t / sim.dt)))];
- return { ...fr, lostList: sim.lost.slice(0, fr.lost) };
- };
-
- C.drill = (R, f, local, cfg) => {
- const box = cfg.box || { x: 300, y: 170, w: 750, h: 700 };
- const s = 1.4;
- M().begin(R, box, { s });
- const geo = C.half(box), { px, py, m } = geo;
- M().floor(box, { seed: "court", tile: 50, tint: [36, 44, 54], light: 1.2 });
- // the half's paint, a shade lighter in the key
- drawingContext.save(); drawingContext.fillStyle = "rgba(70,150,255,0.10)"; drawingContext.fillRect(px(5.05), py(0), 4.9 * m, 5.8 * m); drawingContext.restore();
- C.lines(geo);
- if (cfg.chalk != null) M().glowStroke((c) => { c.moveTo(px(0), py(cfg.chalk)); c.lineTo(px(15), py(cfg.chalk)); }, { color: "rgba(255,255,255,0.85)", width: 6, blur: 6 });
-
- const st = C.steps(cfg.forms, local, cfg), sim = C.drillSim(cfg, local);
- const dots = st.dots.map((d, i) => [d[0] + sim.off[i][0], d[1] + sim.off[i][1]]);
- const lostAt = (i) => sim.lostList.find((q) => q.i === i);
- // fog: the floor near a trooper is lit, the rest stays dim, so the empty spaces show
- // a ring on each space as a trooper arrives in it
- if (st.k > 0 && local - st.k * cfg.step > cfg.move) {
- const r = clamp01((local - st.k * cfg.step - cfg.move) / 0.35);
- for (const [i, [a, b]] of cfg.forms[st.k].entries()) if (!lostAt(i)) M().glowStroke((c) => c.arc(px(a), py(b), 14 + 34 * r, 0, TAU), { color: `rgba(255,255,255,${0.85 * (1 - r)})`, width: 3, blur: 8 });
- }
- if (cfg.ball) {
- C.ball(local, px(cfg.ball[0]), py(cfg.ball[1]), { r: 12 });
- const settle = clamp01((local - 2.2) / 0.3);
- if (settle > 0) { const r = (local * 1.1) % 1; M().glowStroke((c) => c.arc(px(cfg.ball[0]), py(cfg.ball[1]), 16 + 40 * r, 0, TAU), { color: `rgba(255,140,40,${0.9 * (1 - r) * settle})`, width: 3, blur: 8 }); }
- }
- // the crawler's chase line to its target
- const tgt = sim.target;
- if (tgt >= 0 && !lostAt(tgt)) M().orderPath(local, [[px(sim.c[0]), py(sim.c[1])], [px(dots[tgt][0]), py(dots[tgt][1])]], { color: "rgba(255,70,50,0.75)", a: 0.8 });
- // units, back to front
- const list = dots.map((d, i) => ({ i, v: d[1] })).concat([{ i: -1, v: sim.c[1] }]).sort((a, b) => a.v - b.v);
- for (const o of list) {
- if (o.i === -1) {
- const dir = tgt >= 0 ? Math.sign(dots[tgt][0] - sim.c[0]) || -1 : -1;
- M().unit(R, "crawler", px(sim.c[0]), py(sim.c[1]) + 26, 98, { dir, hp: 1, hpColour: [230, 60, 50], bob: Math.abs(Math.sin(local * 12)) * 3 });
- continue;
- }
- const L = lostAt(o.i);
- if (L && local - L.at > 0.5) continue;
- const [a, b] = dots[o.i];
- M().unit(R, "trooper", px(a), py(b) + 24, 60, { dir: st.dir[o.i], sel: !L, alpha: L ? 1 - clamp01((local - L.at) / 0.5) : 1,
- hp: L ? 0 : 1, bob: st.moving[o.i] ? Math.abs(Math.sin(local * 14 + o.i)) * 3 : 0 });
- }
- // each loss: a small blast where it happened
- const ev = sim.lostList.flatMap((q, j) => [
- { type: "explosion", id: `drill-boom-${j}`, at: q.at, x: px(q.x), y: py(q.y), size: 0.6, smokeCount: 3 },
- { type: "sparks", id: `drill-sparks-${j}`, at: q.at, x: px(q.x), y: py(q.y) - 10, count: 18, speed: [160, 520], life: [0.2, 0.5], color: "#ffcf70" },
- ]);
- Anim.particles.draw(ev, local);
- M().end(R, box, { t: local, s, fonts: f, title: cfg.title || "TRAINING", headerY: 4, line: cfg.line });
- // the squad panel, right of the court
- const B = { x: box.x + box.w + 150, y: box.y - 10, w: 380, h: box.h + 20 };
- C.squadPanel(R, f, B.x, B.y, B.w, B.h, cfg.faces.map((n, i) => ({ img: R.faces[n], lost: !!lostAt(i) })), {
- t: local, extra: (x, y, w) => {
- Anim.rts.ui.styledText(`CRAWLER RAN ${sim.run.toFixed(0)} m`, x + w / 2, y + 26, { font: f.logo, size: 22, style: "#ff8a6a", glow: "rgba(255,60,40,0.8)", blur: 8 });
- },
- });
- return { sim, st };
- };
-
- // ---- the match: players as units, then as face icons -----------------------------------------------------------
- // One player at its spot (canvas px): the team's sprite (blue troopers; the other team as tinted crawlers) or, once
- // `icons` is on, its face icon on a team ring. o: { team: "blue"|"yellow"|"red", face (image), dir, moving, t, i, pop }
- C.player = (R, x, y, { team = "blue", face = null, icons = false, dir = 1, moving = false, t = 0, i = 0, size = 1, pop = 1 } = {}) => {
- const bob = moving ? Math.abs(Math.sin(t * 13 + i * 1.7)) * 3 : 0;
- if (icons && face) {
- const ring = team === "blue" ? "rgba(70,170,255,0.95)" : team === "yellow" ? "rgba(255,200,40,0.95)" : "rgba(255,70,50,0.95)";
- const glow = team === "blue" ? "rgba(60,150,255,0.8)" : "rgba(255,180,30,0.85)";
- M().icon(face, x, y - 30 * size - bob, 74 * size, { ring, glow, pop });
- return { x, y, top: y - 70 * size, hand: [x + 26 * size, y - 4] };
- }
- if (team === "blue") {
- const u = M().unit(R, "trooper", x, y, 62 * size, { dir, sel: true, ring: "rgba(70,170,255,0.95)", bob });
- return { ...u, hand: [x + dir * 22 * size, y - 4] };
- }
- const u = M().unit(R, "crawler", x, y, 96 * size, { dir, sel: true, ring: team === "yellow" ? "rgba(255,200,40,0.9)" : "rgba(255,70,50,0.9)", tint: team === "yellow" ? "yellow" : null, bob });
- return { ...u, hand: [x, y] };
- };
-
- Anim.court = C;
-})();
diff --git a/skills/make-an-anime/scripts/tools/p5/lib/mission.js b/skills/make-an-anime/scripts/tools/p5/lib/mission.js
deleted file mode 100644
index a90f243..0000000
--- a/skills/make-an-anime/scripts/tools/p5/lib/mission.js
+++ /dev/null
@@ -1,306 +0,0 @@
-// Mission maps: the small top-down maps of a 2004 RTS (a campaign briefing, a zoomed minimap, a micro drill), drawn in
-// the Orbital Command look. The frame is the HUD console's own minimap bezel (9-sliced from console.png, so it stays
-// sharp at any size), the floor is steel deck plating, lines glow, units are the game's sprites with selection rings,
-// and there is fog of war, objective beacons, face-icon badges, a flash, and a typed mission line.
-// Needs rts.js (Anim.rts.load gives R; Anim.rts.ui gives the shared text, plate and cursor helpers) and particles.js.
-//
-// const R = await Anim.rts.load({ dir: "/output/ui-rts-assets", units: ["trooper", "crawler"] });
-// R.faces = await Anim.mission.loadFaces("/output/ui-rts-assets/faces", ["pilot", "rival"]); // optional
-// const box = { x: 250, y: 60, w: 1420, h: 820 }; // the map's screen rectangle (inside the bezel)
-// Anim.mission.begin(R, box, { t }); // background and console plate, clip to the map
-// Anim.mission.floor(box, { seed: "school", tile: 64 }); // deck plates
-// ...lines, walls, units, fog, beacons, in screen pixels...
-// Anim.mission.end(R, box, { t, fonts, title: "MISSION 3", line: { text: "Reach the stairs", at: 0.2 } });
-//
-// Everything is a pure function of t (see particles.js, the determinism rule): no state between frames.
-window.Anim = window.Anim || {};
-
-(() => {
- const TAU = Math.PI * 2;
- const M = {};
- const UI = () => Anim.rts.ui;
- const P = () => Anim.particles;
- const clamp01 = (x) => Math.max(0, Math.min(1, x));
-
- // The minimap bezel in console.png (its own pixels): the outer edge of the steel frame, and the frame's widths
- // (left, top, right, bottom) up to the black screen. Corners are cut `corner` px deep so the rivets stay whole.
- M.BEZEL = null; // Set from the measured console art, or pass R.bezel. No project-specific geometry.
-
- // Which way each sprite faces as drawn on its sheet: the blue faction faces right, the red one left.
- M.FACING = { trooper: 1, walker: 1, tank: 1, gunship: 1, spider: -1, crawler: -1, skiff: -1, stilt: -1 };
-
- // Tints for a unit drawn in another team's colour (canvas filters on the red sprites).
- M.TINT = {
- yellow: "sepia(0.9) saturate(3.2) hue-rotate(8deg) brightness(1.12)",
- red: "none",
- };
-
- M.loadFaces = async (dir, names) => {
- const out = {};
- for (const n of names) out[n] = await loadImage(`${dir}/${n}.png`);
- return out;
- };
-
- // ---- frame ------------------------------------------------------------------------------------------------------
-
- // The bezel round a screen rectangle, 9-sliced from the console: s scales the frame's thickness (2 ≈ 70 px).
- M.bezel = (R, r, { s = 2 } = {}) => {
- const bezel = R.bezel || M.BEZEL;
- if (!bezel) throw new Error("Anim.mission: set R.bezel {box, inset, corner} from your console image");
- const [bx, by, bw, bh] = bezel.box, [il, it, ir, ib] = bezel.inset, c = bezel.corner;
- const g = drawingContext, img = R.console.canvas || R.console.elt || R.console;
- const ox = r.x - il * s, oy = r.y - it * s, ow = r.w + (il + ir) * s, oh = r.h + (it + ib) * s;
- const cs = c * s;
- const sx = [bx, bx + c, bx + bw - c, bx + bw], dx = [ox, ox + cs, ox + ow - cs, ox + ow];
- const sy = [by, by + c, by + bh - c, by + bh], dy = [oy, oy + cs, oy + oh - cs, oy + oh];
- g.save();
- g.imageSmoothingQuality = "high";
- for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) {
- if (i === 1 && j === 1) continue; // the screen itself
- const w = sx[i + 1] - sx[i], h = sy[j + 1] - sy[j];
- g.drawImage(img, sx[i], sy[j], w, h, dx[i], dy[j], dx[i + 1] - dx[i], dy[j + 1] - dy[j]);
- }
- g.restore();
- return { x: ox, y: oy, w: ow, h: oh };
- };
-
- // The background behind the map: dark gunmetal with a soft top light, and a recessed plate round the bezel.
- M.begin = (R, r, { t = 0, s = 2, plate = true } = {}) => {
- const g = drawingContext;
- background(0);
- const bg = g.createRadialGradient(width / 2, height * 0.42, 80, width / 2, height / 2, width * 0.75);
- bg.addColorStop(0, "#1d242d"); bg.addColorStop(1, "#05070a");
- g.save(); g.fillStyle = bg; g.fillRect(0, 0, width, height);
- // faint panel seams across the background
- g.strokeStyle = "rgba(255,255,255,0.035)"; g.lineWidth = 2;
- for (let x = 0; x < width; x += 160) { g.beginPath(); g.moveTo(x, 0); g.lineTo(x, height); g.stroke(); }
- g.restore();
- if (plate) {
- const bezel = R.bezel || M.BEZEL;
- if (!bezel) throw new Error("Anim.mission: set R.bezel {box, inset, corner} from your console image");
- const [il, it, ir, ib] = bezel.inset, pad = 26;
- UI().bevelRect(r.x - il * s - pad, r.y - it * s - pad, r.w + (il + ir) * s + 2 * pad, r.h + (it + ib) * s + 2 * pad,
- { face: "#222932", light: "#5d6978", dark: "#07090c", cut: 18 });
- }
- g.save(); g.fillStyle = "#000"; g.fillRect(r.x, r.y, r.w, r.h);
- g.beginPath(); g.rect(r.x, r.y, r.w, r.h); g.clip();
- };
-
- // Close the map: the clip ends, then the bezel, an optional header (the logo plate and a title) and the mission line.
- M.end = (R, r, { t = 0, s = 2, fonts, title, line, logo = true, logoText = "ORBITAL", headerY } = {}) => {
- drawingContext.restore();
- // inner shadow on the screen, under the bezel
- const g = drawingContext;
- g.save();
- const sh = 26;
- for (const [x, y, w, h, x0, y0, x1, y1] of [[r.x, r.y, r.w, sh, 0, r.y, 0, r.y + sh], [r.x, r.y, sh, r.h, r.x, 0, r.x + sh, 0]]) {
- const gr = g.createLinearGradient(x0, y0, x1, y1); gr.addColorStop(0, "rgba(0,0,0,0.65)"); gr.addColorStop(1, "rgba(0,0,0,0)");
- g.fillStyle = gr; g.fillRect(x, y, w, h);
- }
- g.restore();
- const B = M.bezel(R, r, { s });
- if (fonts && logo) {
- const hy = headerY ?? Math.max(0, B.y - 74);
- UI().logoPlate(t, { fonts, logo: { text: logoText, sub: title || "BATTLE" } }, width / 2, hy);
- }
- if (fonts && line) M.missionLine(t, line.text, { fonts, x: B.x + 40, y: line.y ?? Math.min(height - 46, B.y + B.h + 34), at: line.at ?? 0, label: line.label });
- return B;
- };
-
- // ---- ground -----------------------------------------------------------------------------------------------------
-
- const floorCache = {};
- // Steel deck plates over a rectangle, the same every frame for a seed.
- M.floor = (r, { seed = "deck", tile = 64, tint = [27, 32, 39], light = 1 } = {}) => {
- const key = `${seed}|${r.w | 0}|${r.h | 0}|${tile}|${tint}|${light}`;
- let c = floorCache[key];
- if (!c) {
- c = document.createElement("canvas"); c.width = Math.ceil(r.w); c.height = Math.ceil(r.h);
- const g = c.getContext("2d");
- const R = (k, s) => P().rand(seed, k, s);
- for (let y = 0, j = 0; y < c.height; y += tile, j++) for (let x = 0, i = 0; x < c.width; x += tile, i++) {
- const k = j * 997 + i, v = (R(k, 1) - 0.5) * 14 * light;
- const [cr, cg, cb] = tint;
- g.fillStyle = `rgb(${cr + v},${cg + v},${cb + v * 1.1})`; g.fillRect(x, y, tile, tile);
- // bevel: light top and left, dark bottom and right
- g.fillStyle = "rgba(255,255,255,0.06)"; g.fillRect(x, y, tile, 2); g.fillRect(x, y, 2, tile);
- g.fillStyle = "rgba(0,0,0,0.55)"; g.fillRect(x, y + tile - 2, tile, 2); g.fillRect(x + tile - 2, y, 2, tile);
- // rivets, some plates with a tread pattern, a rare grate
- g.fillStyle = "rgba(160,175,190,0.22)";
- for (const [a, b] of [[6, 6], [tile - 8, 6], [6, tile - 8], [tile - 8, tile - 8]]) g.fillRect(x + a, y + b, 2, 2);
- const kind = R(k, 2);
- if (kind < 0.18) {
- g.strokeStyle = "rgba(255,255,255,0.05)"; g.lineWidth = 2;
- for (let d = 10; d < tile - 6; d += 9) { g.beginPath(); g.moveTo(x + d, y + 10); g.lineTo(x + d - 5, y + tile - 10); g.stroke(); }
- } else if (kind > 0.96) {
- g.fillStyle = "rgba(0,0,0,0.45)";
- for (let d = 12; d < tile - 10; d += 7) g.fillRect(x + 12, y + d, tile - 24, 3);
- }
- // grime
- g.fillStyle = `rgba(0,0,0,${0.12 * R(k, 3)})`; g.fillRect(x, y, tile, tile);
- }
- floorCache[key] = c;
- }
- drawingContext.drawImage(c, r.x, r.y, r.w, r.h);
- };
-
- // Stroke a path with a glow: draw(path) builds it on the context. Two passes: a wide soft glow, then the crisp line.
- M.glowStroke = (draw, { color = "rgba(70,170,255,0.95)", width: lw = 4, blur = 14, core = null } = {}) => {
- const g = drawingContext;
- g.save();
- g.lineCap = "round"; g.lineJoin = "round";
- g.shadowColor = color; g.shadowBlur = blur; g.strokeStyle = color; g.lineWidth = lw;
- g.beginPath(); draw(g); g.stroke();
- g.shadowBlur = 0;
- if (core) { g.strokeStyle = core; g.lineWidth = Math.max(1, lw * 0.35); g.beginPath(); draw(g); g.stroke(); }
- g.restore();
- };
-
- // A wall: a thick steel strip with a lit top edge and a cobalt trim line, between two points.
- M.wall = (x0, y0, x1, y1, { w = 14, trim = "rgba(60,150,255,0.85)" } = {}) => {
- const g = drawingContext;
- g.save(); g.lineCap = "square";
- g.strokeStyle = "#0a0d11"; g.lineWidth = w + 6; g.beginPath(); g.moveTo(x0, y0); g.lineTo(x1, y1); g.stroke();
- g.strokeStyle = "#4a5562"; g.lineWidth = w; g.beginPath(); g.moveTo(x0, y0); g.lineTo(x1, y1); g.stroke();
- g.strokeStyle = "#8e9bab"; g.lineWidth = 2; g.beginPath(); g.moveTo(x0, y0 - w / 2 + 2); g.lineTo(x1, y1 - w / 2 + 2); g.stroke();
- g.shadowColor = trim; g.shadowBlur = 10; g.strokeStyle = trim; g.lineWidth = 2;
- g.beginPath(); g.moveTo(x0, y0); g.lineTo(x1, y1); g.stroke();
- g.restore();
- };
-
- // A rectangle of walls with optional gaps: gaps [{ side: "top"|"bottom"|"left"|"right", at: px from the side's start, w }].
- M.room = (x, y, w, h, { gaps = [], ...o } = {}) => {
- const side = (name, ax, ay, bx, by) => {
- const len = Math.hypot(bx - ax, by - ay), ux = (bx - ax) / len, uy = (by - ay) / len;
- const cuts = gaps.filter((q) => q.side === name).sort((a, b) => a.at - b.at);
- let s = 0;
- for (const q of cuts) { if (q.at > s) M.wall(ax + ux * s, ay + uy * s, ax + ux * q.at, ay + uy * q.at, o); s = q.at + q.w; }
- if (s < len) M.wall(ax + ux * s, ay + uy * s, bx, by, o);
- };
- side("top", x, y, x + w, y); side("bottom", x, y + h, x + w, y + h);
- side("left", x, y, x, y + h); side("right", x + w, y, x + w, y + h);
- };
-
- // Fog of war over a rectangle: black (alpha `dark`) except soft round holes round each source [x, y, r].
- const fogCanvas = document.createElement("canvas");
- M.fog = (r, sources, { dark = 1, soft = 0.38, color = "0,0,0" } = {}) => {
- const c = fogCanvas;
- if (c.width !== width || c.height !== height) { c.width = width; c.height = height; }
- const g = c.getContext("2d");
- g.globalCompositeOperation = "source-over"; g.clearRect(0, 0, c.width, c.height);
- g.fillStyle = `rgba(${color},${dark})`; g.fillRect(r.x, r.y, r.w, r.h);
- g.globalCompositeOperation = "destination-out";
- for (const [x, y, rad] of sources) {
- const gr = g.createRadialGradient(x, y, 0, x, y, rad);
- gr.addColorStop(0, "rgba(0,0,0,1)"); gr.addColorStop(1 - soft, "rgba(0,0,0,1)"); gr.addColorStop(1, "rgba(0,0,0,0)");
- g.fillStyle = gr; g.fillRect(x - rad, y - rad, 2 * rad, 2 * rad);
- }
- drawingContext.drawImage(c, 0, 0);
- };
-
- // ---- units and markers ------------------------------------------------------------------------------------------
-
- // A unit sprite at its foot point (x, y), w px wide. dir 1 faces right, -1 left. sel: a ring in `ring` colour.
- M.unit = (R, kind, x, y, w, { dir = 1, sel = false, ring = "rgba(70,255,100,0.95)", tint = null, alpha = 1, hp = null, hpColour = [60, 230, 80], bob = 0 } = {}) => {
- const img = R.units[kind];
- const h = (w * img.height) / img.width, g = drawingContext;
- g.save(); g.globalAlpha = alpha;
- g.fillStyle = "rgba(0,0,0,0.5)"; g.beginPath(); g.ellipse(x, y + 2, w * 0.42, w * 0.16, 0, 0, TAU); g.fill();
- if (sel) { g.strokeStyle = ring; g.lineWidth = 2.5; g.beginPath(); g.ellipse(x, y + 2, w * 0.52, w * 0.21, 0, 0, TAU); g.stroke(); }
- const flip = dir !== (M.FACING[kind] ?? 1);
- g.translate(x, y - bob);
- if (flip) g.scale(-1, 1);
- if (tint && M.TINT[tint]) g.filter = M.TINT[tint];
- g.drawImage(img.canvas || img.elt || img, -w / 2, -h, w, h);
- g.filter = "none";
- g.restore();
- if (hp != null) UI().hpBar(x, y - h - bob - 10, Math.min(w * 0.8, 56), hp, hpColour);
- return { x, y, w, h, top: y - h - bob };
- };
-
- // A face icon badge (the SD unit icons) centred at (x, y), s px square, with a team ring under it.
- M.icon = (img, x, y, s, { ring = "rgba(70,255,100,0.95)", glow = "rgba(60,150,255,0.8)", alpha = 1, pop = 1 } = {}) => {
- const g = drawingContext, k = s * pop;
- g.save(); g.globalAlpha = alpha;
- g.fillStyle = "rgba(0,0,0,0.5)"; g.beginPath(); g.ellipse(x, y + k * 0.56, k * 0.46, k * 0.14, 0, 0, TAU); g.fill();
- if (ring) { g.strokeStyle = ring; g.lineWidth = 3; g.beginPath(); g.ellipse(x, y + k * 0.56, k * 0.55, k * 0.18, 0, 0, TAU); g.stroke(); }
- g.shadowColor = glow; g.shadowBlur = 16;
- g.drawImage(img.canvas || img.elt || img, x - k / 2, y - k / 2, k, k);
- g.restore();
- };
-
- // A pop for something appearing at `at`: 0 before, overshoots to about 1.15, settles at 1 by at + dur.
- M.pop = (t, at, dur = 0.28) => {
- const q = (t - at) / dur;
- if (q <= 0) return 0;
- if (q >= 1) return 1;
- return 1 + 0.15 * Math.sin(q * Math.PI) - (1 - q) * (1 - q) * (1 - q);
- };
-
- // A full-screen flash at `at`: white, peaking in 2 frames, gone by at + dur. Returns its strength (0..1).
- M.flash = (t, at, { dur = 0.4, color = "255,255,255", max = 1 } = {}) => {
- const age = t - at;
- if (age < -0.08 || age > dur) return 0;
- const a = max * (age < 0 ? clamp01((age + 0.08) / 0.08) : Math.exp(-age / (dur * 0.32)));
- const g = drawingContext;
- g.save(); g.globalCompositeOperation = "lighter"; g.fillStyle = `rgba(${color},${a})`; g.fillRect(0, 0, width, height); g.restore();
- return a;
- };
-
- // An objective beacon: a turning diamond, rings rising out of it, a soft column of light.
- M.beacon = (t, x, y, { color = [255, 200, 60], size = 1 } = {}) => {
- const g = drawingContext, [r, gg, b] = color;
- g.save();
- const col = g.createLinearGradient(0, y - 160 * size, 0, y);
- col.addColorStop(0, `rgba(${r},${gg},${b},0)`); col.addColorStop(1, `rgba(${r},${gg},${b},0.28)`);
- g.fillStyle = col; g.fillRect(x - 16 * size, y - 160 * size, 32 * size, 160 * size);
- for (let i = 0; i < 2; i++) {
- const q = ((t * 0.9 + i * 0.5) % 1);
- g.strokeStyle = `rgba(${r},${gg},${b},${0.9 * (1 - q)})`; g.lineWidth = 3;
- g.beginPath(); g.ellipse(x, y, (14 + 46 * q) * size, (6 + 18 * q) * size, 0, 0, TAU); g.stroke();
- }
- g.translate(x, y - 26 * size - 4 * Math.sin(t * 3)); g.scale(Math.cos(t * 2.4) * size, size);
- g.shadowColor = `rgba(${r},${gg},${b},1)`; g.shadowBlur = 14;
- g.fillStyle = `rgba(${r},${gg},${b},0.95)`;
- g.beginPath(); g.moveTo(0, -16); g.lineTo(11, 0); g.lineTo(0, 16); g.lineTo(-11, 0); g.closePath(); g.fill();
- g.restore();
- };
-
- // A path the player ordered: dashes moving along a polyline towards its end, with a chevron at the end.
- M.orderPath = (t, pts, { color = "rgba(80,255,110,0.9)", a = 1 } = {}) => {
- const g = drawingContext;
- g.save(); g.globalAlpha = a; g.strokeStyle = color; g.lineWidth = 3; g.setLineDash([14, 12]); g.lineDashOffset = -t * 60;
- g.beginPath(); pts.forEach(([x, y], i) => (i ? g.lineTo(x, y) : g.moveTo(x, y))); g.stroke();
- g.setLineDash([]);
- const [ax, ay] = pts[pts.length - 2], [bx, by] = pts[pts.length - 1], an = Math.atan2(by - ay, bx - ax);
- g.lineWidth = 4; g.beginPath();
- g.moveTo(bx - 18 * Math.cos(an - 0.5), by - 18 * Math.sin(an - 0.5)); g.lineTo(bx, by); g.lineTo(bx - 18 * Math.cos(an + 0.5), by - 18 * Math.sin(an + 0.5));
- g.stroke(); g.restore();
- };
-
- // ---- text -------------------------------------------------------------------------------------------------------
-
- // The mission line: a steel plate with a small label and the objective typed out from `at`, 38 characters a second.
- M.missionLine = (t, str, { fonts, x, y, at = 0, label = "OBJECTIVE", cps = 38 } = {}) => {
- const n = Math.max(0, Math.floor((t - at) * cps));
- if (t < at) return;
- const shown = str.slice(0, n), f = fonts.logo, g = drawingContext;
- textFont(f); textSize(26);
- const w = textWidth(str) + 250, h = 56;
- UI().bevelRect(x, y - h / 2, w, h, { face: "#141a21", light: "#56616e", dark: "#05070a", cut: 10 });
- g.save(); g.fillStyle = "rgba(255,190,60,0.95)"; g.fillRect(x + 12, y - 16, 6, 32); g.restore();
- UI().styledText(label, x + 30, y + 1, { font: f, size: 16, style: "#ffc45a", align: [LEFT, CENTER], spacing: 3, glow: "rgba(255,170,40,0.8)", blur: 8, outline: "#140c00", weight: 2 });
- UI().styledText(shown + (n < str.length && Math.floor(t * 6) % 2 ? "_" : ""), x + 190, y + 1, { font: f, size: 26, style: "#e8f2ff", align: [LEFT, CENTER], glow: "rgba(60,160,255,0.7)", blur: 8 });
- };
-
- // A small tag over a unit or icon, e.g. a name or "#14": dark plate, team colour edge.
- M.tag = (str, x, y, { fonts, colour = "#3aa0ff", size = 18 } = {}) => {
- const f = fonts.logo;
- textFont(f); textSize(size);
- const w = textWidth(str) + 18, h = size + 10, g = drawingContext;
- g.save(); g.fillStyle = "rgba(4,8,14,0.82)"; g.fillRect(x - w / 2, y - h / 2, w, h); g.fillStyle = colour; g.fillRect(x - w / 2, y + h / 2 - 3, w, 3); g.restore();
- UI().styledText(str, x, y, { font: f, size, style: "#eef6ff" });
- };
-
- Anim.mission = M;
-})();
diff --git a/skills/make-an-anime/scripts/tools/p5/lib/rts.js b/skills/make-an-anime/scripts/tools/p5/lib/rts.js
deleted file mode 100644
index 20b1a27..0000000
--- a/skills/make-an-anime/scripts/tools/p5/lib/rts.js
+++ /dev/null
@@ -1,533 +0,0 @@
-// RTS game screen: a 2004-style real-time strategy game on a PC monitor, composed from generated art sheets (terrain,
-// HUD console frame, unit sprites, command icons, a unit portrait) with every readable word and number drawn here.
-// Needs particles.js (Anim.particles) for the shooting and the explosions.
-//
-// const R = await Anim.rts.load({ dir: "/output/ui-rts-assets", units: ["trooper", ...], icons: ["move", ...] });
-// const game = { ...the scene's battle: units, events, cursor, selection... (see "The game object" below) };
-// Anim.rts.screen(t, R, game); // the picture
-// Anim.rts.screen(t, R, game, { mode: "light" }); // only the light (lasers, flashes, eyes), for the mvfx halo pass
-//
-// Assets (tools/python/cut_sheets.py makes them from the five sheets): map.jpg (terrain), console.png (the HUD frame with
-// its screens cut transparent) + console_slots.json (their rectangles), units/<name>.png, icons/<name>.png, portrait.png.
-//
-// Layout: the console is drawn full width along the bottom at its own aspect. Its screens are classified from the slot
-// list: the large ones, left to right, are game.hud.screens (default ["portrait", "minimap", "info", "gauge"]), and the
-// small equal ones are the command-card sockets, row by row. Everything under a screen is drawn first, then the frame.
-//
-// The game object (all times in the same seconds as t; world coordinates are terrain pixels after map.scale):
-// title "Orbital Command" window title bar text top 44 (title bar height)
-// fonts { ui, uiBold, logo } p5 fonts logo { text: "ORBITAL", sub: "BATTLE" }
-// map { scale 0.9, cam(t) -> [x, y] } camera = world point at the viewport's top-left
-// kinds { name: { w, muzzle: [fx, fy], air } } draw width (px) and gun position as fractions of w from the foot point
-// units [{ id, kind, team, at(t) -> [x, y] foot point, dies (s) }] team "blue" (the player) or "red"; facing is the sprite's
-// selected(t, u) -> bool the player's selection target(t) -> unit id | null (red ring + hp bar)
-// events [particle events] world coordinates (see particles.js)
-// markers [{ at, x, y, kind: "attack" | "move" }] click markers on the ground
-// drag(t) -> null | { a: [x, y], b: [x, y] } selection box, screen coordinates
-// cursor(t) -> { x, y, down, mode: "arrow" | "target" } screen coordinates
-// resources(t) -> [{ icon: "crystal" | "gas" | "supply", text }] timer(t) -> "23:41"
-// commands [12 icon names] pressed [{ name, at }] gauge(t) -> 0..1
-// pings [{ at, x, y, color }] minimap alerts (world) portrait { eyes: [[x, y], ...] in portrait.png px,
-// eye "#ffa040", talk: [[from, to], ...] }
-// vision { radius 360 } fog of war around the player's units
-// alert(t) -> null | { text, sub, a } a warning across the battlefield ("Your base is under attack"), a = 0..1
-// iconOf(u) -> image | null a unit's tile in the info screen (e.g. a player's face icon) instead of its sprite
-window.Anim = window.Anim || {};
-
-(() => {
- const TAU = Math.PI * 2;
- const P = () => Anim.particles;
- const TEAM = { blue: [60, 150, 255], red: [255, 70, 60] };
- const clamp01 = (x) => Math.max(0, Math.min(1, x));
-
- const loadJSON = async (url) => {
- const r = await fetch(url);
- if (!r.ok) throw new Error(`Anim.rts: ${url} ${r.status}`);
- return r.json();
- };
-
- Anim.rts = {};
-
- Anim.rts.load = async ({ dir, units = [], icons = [] }) => {
- const R = { dir, units: {}, icons: {} };
- R.map = await loadImage(`${dir}/map.jpg`);
- R.console = await loadImage(`${dir}/console.png`);
- R.slots = await loadJSON(`${dir}/console_slots.json`);
- R.portrait = await loadImage(`${dir}/portrait.png`);
- for (const n of units) R.units[n] = await loadImage(`${dir}/units/${n}.png`);
- for (const n of icons) R.icons[n] = await loadImage(`${dir}/icons/${n}.png`);
- R.fog = document.createElement("canvas");
- return R;
- };
-
- // Screen rectangles of the console and its screens, for a canvas width W and height H.
- Anim.rts.layout = (R, game, W = width, H = height) => {
- const s = R.slots, k = W / s.w, y0 = H - s.h * k;
- const rect = ([x, y, w, h]) => ({ x: x * k, y: y0 + y * k, w: w * k, h: h * k });
- const areas = s.slots.map((r) => r[2] * r[3]).sort((a, b) => a - b);
- const small = areas[Math.floor(areas.length / 4)];
- const big = s.slots.filter((r) => r[2] * r[3] > small * 3).sort((a, b) => a[0] - b[0]);
- const sockets = s.slots.filter((r) => r[2] * r[3] <= small * 3)
- .sort((a, b) => (Math.abs(a[1] - b[1]) > a[3] / 2 ? a[1] - b[1] : a[0] - b[0]));
- const names = game.hud?.screens || ["portrait", "minimap", "info", "gauge"];
- const screens = Object.fromEntries(big.map((r, i) => [names[i] || `screen${i}`, rect(r)]));
- return { k, y0, top: y0 + s.top * k, screens, sockets: sockets.map(rect), W, H };
- };
-
- // A unit's geometry at t: foot point, sprite box, gun and body centre, in world coordinates.
- Anim.rts.geom = (R, game, u, t) => {
- const kind = game.kinds[u.kind], img = R.units[u.kind];
- const [x, y] = u.at(t);
- const w = kind.w, h = (w * img.height) / img.width;
- const lift = kind.air ? 46 + 4 * Math.sin(t * 3 + u.id.length) : 0;
- const dir = u.team === "blue" ? 1 : -1;
- const m = kind.muzzle || [0.45, -0.55];
- return { x, y, w, h, lift, img, dir, air: !!kind.air,
- muzzle: [x + dir * m[0] * w, y - lift + m[1] * h], center: [x, y - lift - h * 0.42] };
- };
-
- Anim.rts.alive = (u, t) => u.dies == null || t < u.dies;
-
- // ---- drawing helpers -------------------------------------------------------------------------------------------
-
- const bevelRect = (x, y, w, h, { face = "#2a3038", light = "#8b97a6", dark = "#0b0e12", cut = 6 } = {}) => {
- const g = drawingContext;
- g.save();
- g.beginPath();
- g.moveTo(x + cut, y); g.lineTo(x + w - cut, y); g.lineTo(x + w, y + cut); g.lineTo(x + w, y + h - cut);
- g.lineTo(x + w - cut, y + h); g.lineTo(x + cut, y + h); g.lineTo(x, y + h - cut); g.lineTo(x, y + cut); g.closePath();
- const grad = g.createLinearGradient(0, y, 0, y + h);
- grad.addColorStop(0, light); grad.addColorStop(0.08, face); grad.addColorStop(0.92, face); grad.addColorStop(1, dark);
- g.fillStyle = grad; g.fill();
- g.strokeStyle = "rgba(0,0,0,0.85)"; g.lineWidth = 2; g.stroke();
- g.restore();
- };
-
- // Text with a canvas fill style (gradient) or a colour, optional glow and outline. p5 caches its fill, so the
- // context's fillStyle is set after fill() and right before text().
- const styledText = (str, x, y, { font, size, style = "#fff", glow = null, blur = 0, outline = null, weight = 0, align = [CENTER, CENTER], spacing = 0 }) => {
- textFont(font); textSize(size); textAlign(...align);
- const g = drawingContext;
- g.save();
- g.letterSpacing = `${spacing}px`;
- if (outline) {
- noFill(); stroke(outline); strokeWeight(weight);
- if (glow) { g.shadowColor = glow; g.shadowBlur = blur; }
- text(str, x, y);
- g.shadowBlur = 0;
- }
- noStroke(); fill(255);
- g.fillStyle = style;
- text(str, x, y);
- g.restore();
- };
-
- // The game logo plate: a chamfered steel plate hanging from the top edge, the title in a heavy chiselled face with a
- // steel bevel and an electric-blue glow.
- const logoPlate = (t, game, cx, y) => {
- const { text: main = "ORBITAL", sub = "BATTLE" } = game.logo || {};
- const f = game.fonts.logo;
- textFont(f); textSize(46);
- drawingContext.letterSpacing = "3px";
- const tw = textWidth(main);
- drawingContext.letterSpacing = "0px";
- const w = tw + 230, h = 78, x = cx - w / 2;
- const g = drawingContext;
- // plate
- g.save();
- g.beginPath();
- g.moveTo(x, y); g.lineTo(x + w, y); g.lineTo(x + w - 34, y + h); g.lineTo(x + 34, y + h); g.closePath();
- const pg = g.createLinearGradient(0, y, 0, y + h);
- pg.addColorStop(0, "#1a2029"); pg.addColorStop(0.5, "#2b333e"); pg.addColorStop(1, "#11151b");
- g.fillStyle = pg; g.fill();
- g.strokeStyle = "#6d7b8c"; g.lineWidth = 2; g.stroke();
- g.beginPath(); g.moveTo(x + 40, y + h - 7); g.lineTo(x + w - 40, y + h - 7);
- g.strokeStyle = `rgba(70,160,255,${0.55 + 0.25 * Math.sin(t * 4)})`; g.lineWidth = 2; g.stroke();
- g.restore();
- // title: blue glow behind a dark outline, then a chrome gradient face, then a thin top highlight
- const ty = y + 32;
- const chrome = g.createLinearGradient(0, ty - 24, 0, ty + 22);
- chrome.addColorStop(0, "#ffffff"); chrome.addColorStop(0.32, "#c9d3df"); chrome.addColorStop(0.5, "#5d6876");
- chrome.addColorStop(0.56, "#3a4350"); chrome.addColorStop(0.78, "#aab6c4"); chrome.addColorStop(1, "#e9f1fb");
- const pulse = 0.75 + 0.25 * Math.sin(t * 2.6);
- styledText(main, cx, ty, { font: f, size: 46, style: chrome, outline: "#041226", weight: 7, glow: `rgba(40,150,255,${pulse})`, blur: 26, spacing: 3 });
- // the sub line between two blue rules
- const sy = y + 63;
- styledText(sub, cx, sy, { font: f, size: 19, style: "#8fd0ff", glow: "rgba(40,150,255,0.9)", blur: 10, outline: "#03101e", weight: 3, spacing: 9 });
- textFont(f); textSize(19); g.letterSpacing = "9px";
- const sw = textWidth(sub); g.letterSpacing = "0px";
- g.save();
- g.strokeStyle = "rgba(80,170,255,0.85)"; g.lineWidth = 2;
- g.beginPath(); g.moveTo(cx - sw / 2 - 90, sy); g.lineTo(cx - sw / 2 - 16, sy); g.moveTo(cx + sw / 2 + 10, sy); g.lineTo(cx + sw / 2 + 84, sy); g.stroke();
- g.restore();
- };
-
- const resourceIcon = (kind, x, y) => {
- const g = drawingContext;
- g.save();
- if (kind === "crystal") {
- g.beginPath(); g.moveTo(x, y - 13); g.lineTo(x + 8, y - 2); g.lineTo(x + 3, y + 12); g.lineTo(x - 5, y + 10); g.lineTo(x - 8, y - 3); g.closePath();
- const gr = g.createLinearGradient(x - 8, y - 13, x + 8, y + 12); gr.addColorStop(0, "#d8f4ff"); gr.addColorStop(0.5, "#3aa4ff"); gr.addColorStop(1, "#0b3d9a");
- g.fillStyle = gr; g.shadowColor = "rgba(60,170,255,0.9)"; g.shadowBlur = 10; g.fill();
- } else if (kind === "gas") {
- g.beginPath(); g.arc(x, y + 3, 9, 0, TAU); g.moveTo(x - 6, y - 4); g.lineTo(x, y - 14); g.lineTo(x + 6, y - 4);
- g.fillStyle = "#3fe07a"; g.shadowColor = "rgba(60,240,120,0.9)"; g.shadowBlur = 10; g.fill();
- g.fillStyle = "rgba(255,255,255,0.7)"; g.beginPath(); g.arc(x - 3, y + 1, 2.5, 0, TAU); g.fill();
- } else {
- g.beginPath(); g.moveTo(x - 10, y + 10); g.lineTo(x - 10, y - 2); g.lineTo(x, y - 12); g.lineTo(x + 10, y - 2); g.lineTo(x + 10, y + 10); g.closePath();
- g.fillStyle = "#c8d2de"; g.shadowColor = "rgba(120,180,255,0.8)"; g.shadowBlur = 8; g.fill();
- g.fillStyle = "#1a3a6a"; g.fillRect(x - 4, y + 1, 8, 9);
- }
- g.restore();
- };
-
- const topHud = (t, game, L) => {
- const top = game.top ?? 44, f = game.fonts;
- // left: menu buttons and the game clock
- ["MENU", "ALLIES"].forEach((label, i) => {
- const x = 14 + i * 118, y = top + 8;
- bevelRect(x, y, 108, 34, { face: "#262d36", light: "#7d8a99", cut: 5 });
- styledText(label, x + 54, y + 18, { font: f.logo, size: 16, style: "#b9c7d6", spacing: 2 });
- });
- bevelRect(254, top + 8, 104, 34, { face: "#11161c", light: "#4c5866", cut: 5 });
- styledText(game.timer(t), 306, top + 25, { font: f.logo, size: 20, style: "#e6f0ff", glow: "rgba(60,160,255,0.7)", blur: 6 });
- logoPlate(t, game, L.W / 2, top);
- // right: resources
- const res = game.resources(t);
- let x = L.W - 22;
- textFont(f.logo); textSize(22);
- for (let i = res.length - 1; i >= 0; i--) {
- const r = res[i], tw = Math.max(textWidth(r.text), 52);
- const bx = x - tw - 44;
- drawingContext.save(); drawingContext.fillStyle = "rgba(4,8,14,0.55)"; drawingContext.fillRect(bx - 6, top + 8, tw + 54, 34); drawingContext.restore();
- resourceIcon(r.icon, bx + 12, top + 25);
- styledText(r.text, bx + 32, top + 26, { font: f.logo, size: 22, style: "#e8f2ff", align: [LEFT, CENTER], glow: null });
- x = bx - 16;
- }
- };
-
- // ---- the battlefield --------------------------------------------------------------------------------------------
-
- const groundMarker = (t, m) => {
- const age = t - m.at;
- if (age < 0 || age > 0.45) return;
- const q = age / 0.45, g = drawingContext;
- g.save();
- g.translate(m.x, m.y); g.scale(1, 0.55);
- if (m.kind === "attack") {
- const r = 34 * (1 - q) + 8;
- g.strokeStyle = `rgba(255,60,50,${1 - q})`; g.lineWidth = 4;
- g.beginPath(); g.arc(0, 0, r, 0, TAU); g.stroke();
- g.beginPath(); g.moveTo(-r * 0.5, -r * 0.5); g.lineTo(r * 0.5, r * 0.5); g.moveTo(r * 0.5, -r * 0.5); g.lineTo(-r * 0.5, r * 0.5); g.stroke();
- } else {
- const r = 10 + 30 * q;
- g.strokeStyle = `rgba(80,255,110,${1 - q})`; g.lineWidth = 4;
- g.beginPath(); g.arc(0, 0, r, 0, TAU); g.stroke();
- }
- g.restore();
- };
-
- const hpBar = (x, y, w, hp, colour) => {
- const n = Math.max(4, Math.round(w / 9)), sw = w / n;
- noStroke(); fill(0, 0, 0, 200); rect(x - w / 2 - 2, y - 2, w + 4, 9);
- for (let i = 0; i < n; i++) {
- const on = (i + 0.5) / n <= hp;
- fill(...(on ? colour : [50, 20, 20])); rect(x - w / 2 + i * sw + 0.5, y, sw - 1.5, 5);
- }
- };
-
- const drawUnits = (t, R, game) => {
- const live = game.units.filter((u) => Anim.rts.alive(u, t)).map((u) => ({ u, G: Anim.rts.geom(R, game, u, t) }))
- .sort((a, b) => a.G.y - b.G.y);
- const target = game.target?.(t);
- const g = drawingContext;
- for (const { u, G } of live) {
- // shadow
- g.save(); g.fillStyle = "rgba(0,0,0,0.45)"; g.beginPath();
- g.ellipse(G.x + (G.air ? 22 : 0), G.y + (G.air ? 10 : 2), G.w * (G.air ? 0.32 : 0.42), G.w * (G.air ? 0.12 : 0.16), 0, 0, TAU); g.fill(); g.restore();
- // selection ring
- const sel = u.team === "blue" && game.selected(t, u), tgt = u.id === target;
- if (sel || tgt) {
- g.save(); g.strokeStyle = sel ? "rgba(70,255,100,0.95)" : "rgba(255,60,50,0.95)"; g.lineWidth = 2.5;
- g.beginPath(); g.ellipse(G.x, G.y + 2, G.w * 0.5, G.w * 0.2, 0, 0, TAU); g.stroke(); g.restore();
- }
- imageMode(CORNER);
- image(G.img, G.x - G.w / 2, G.y - G.lift - G.h, G.w, G.h);
- if (sel || tgt) hpBar(G.x, G.y - G.lift - G.h - 10, Math.min(G.w * 0.8, 60), u.hp ? u.hp(t) : 1, sel ? [60, 230, 80] : [235, 60, 50]);
- }
- };
-
- const drawFog = (t, R, game, L, cam, top) => {
- const c = R.fog, W = L.W, H = L.H;
- if (c.width !== W || c.height !== H) { c.width = W; c.height = H; }
- const g = c.getContext("2d");
- g.globalCompositeOperation = "source-over";
- g.clearRect(0, 0, W, H);
- g.fillStyle = `rgba(0,0,0,${game.vision?.dark ?? 0.55})`; g.fillRect(0, top, W, H - top);
- g.globalCompositeOperation = "destination-out";
- const r = game.vision?.radius ?? 360;
- for (const u of game.units) {
- if (u.team !== "blue" || !Anim.rts.alive(u, t)) continue;
- const [x, y] = u.at(t), sx = x - cam[0], sy = y - cam[1] + top;
- const grad = g.createRadialGradient(sx, sy, 0, sx, sy, r);
- grad.addColorStop(0, "rgba(0,0,0,1)"); grad.addColorStop(0.62, "rgba(0,0,0,1)"); grad.addColorStop(1, "rgba(0,0,0,0)");
- g.fillStyle = grad; g.fillRect(sx - r, sy - r, 2 * r, 2 * r);
- }
- drawingContext.drawImage(c, 0, 0);
- };
-
- const dragBox = (t, game) => {
- const d = game.drag?.(t);
- if (!d) return;
- const [x0, y0] = d.a, [x1, y1] = d.b, g = drawingContext;
- g.save();
- g.fillStyle = "rgba(80,255,110,0.07)"; g.fillRect(Math.min(x0, x1), Math.min(y0, y1), Math.abs(x1 - x0), Math.abs(y1 - y0));
- g.strokeStyle = "rgba(90,255,120,0.95)"; g.lineWidth = 2; g.strokeRect(Math.min(x0, x1), Math.min(y0, y1), Math.abs(x1 - x0), Math.abs(y1 - y0));
- g.restore();
- };
-
- // ---- console screens --------------------------------------------------------------------------------------------
-
- const minimap = (t, R, game, r, cam, L) => {
- const g = drawingContext, ms = game.map.scale ?? 0.9;
- const mw = R.map.width * ms, mh = R.map.height * ms;
- const k = Math.min(r.w / mw, r.h / mh), ox = r.x + (r.w - mw * k) / 2, oy = r.y + (r.h - mh * k) / 2;
- g.save();
- g.fillStyle = "#000"; g.fillRect(r.x, r.y, r.w, r.h);
- g.globalAlpha = 0.85; imageMode(CORNER); image(R.map, ox, oy, mw * k, mh * k); g.globalAlpha = 1;
- // darkened unexplored edges
- g.fillStyle = "rgba(0,0,0,0.35)"; g.fillRect(ox, oy, mw * k * 0.18, mh * k); g.fillRect(ox + mw * k * 0.86, oy, mw * k * 0.14, mh * k);
- for (const u of game.units) {
- if (!Anim.rts.alive(u, t)) continue;
- const [x, y] = u.at(t);
- g.fillStyle = u.team === "blue" ? "#4aa0ff" : "#ff4a3a";
- g.fillRect(ox + x * k - 2, oy + y * k - 2, 4.5, 4.5);
- }
- // alerts: a ring that blinks where the fighting is
- for (const p of game.pings || []) {
- const age = t - p.at;
- if (age < 0 || age > 1.2) continue;
- const q = (age % 0.6) / 0.6;
- g.strokeStyle = `rgba(${p.color || "255,60,50"},${1 - q})`; g.lineWidth = 2;
- g.beginPath(); g.arc(ox + p.x * k, oy + p.y * k, 4 + 14 * q, 0, TAU); g.stroke();
- }
- // the camera box
- const vh = (L.top - (game.top ?? 44));
- g.strokeStyle = "rgba(255,255,255,0.95)"; g.lineWidth = 1.5;
- g.strokeRect(ox + cam[0] * k, oy + cam[1] * k, L.W * k, vh * k);
- g.restore();
- };
-
- const portraitScreen = (t, R, game, r, frame, mode) => {
- const g = drawingContext, img = R.portrait, pc = game.portrait || {};
- const cover = Math.max(r.w / img.width, r.h / img.height) * (1.04 + 0.012 * Math.sin(t * 0.9));
- const dw = img.width * cover, dh = img.height * cover;
- const ox = r.x + (r.w - dw) / 2 + 1.5 * Math.sin(t * 0.7), oy = r.y + (r.h - dh) / 2 + 2.2 * Math.sin(t * 1.6);
- const talking = (pc.talk || []).some(([a, b]) => t >= a && t < b);
- g.save();
- g.beginPath(); g.rect(r.x, r.y, r.w, r.h); g.clip();
- if (mode !== "light") {
- g.fillStyle = "#000"; g.fillRect(r.x, r.y, r.w, r.h);
- imageMode(CORNER); image(img, ox, oy, dw, dh);
- // monitor tint and scanlines inside the little screen
- g.fillStyle = "rgba(20,60,70,0.16)"; g.fillRect(r.x, r.y, r.w, r.h);
- g.fillStyle = "rgba(0,0,0,0.22)";
- for (let y = r.y + ((frame * 1.5) % 3); y < r.y + r.h; y += 3) g.fillRect(r.x, y, r.w, 1);
- if (talking) {
- for (let i = 0; i < 4; i++) {
- const v = P().rand("portrait-static", frame * 7 + i, 1);
- if (v < 0.45) continue;
- g.fillStyle = `rgba(200,255,240,${0.08 + 0.12 * P().rand("portrait-static", frame * 7 + i, 2)})`;
- g.fillRect(r.x, r.y + P().rand("portrait-static", frame * 7 + i, 3) * r.h, r.w, 2 + 6 * v);
- }
- }
- }
- // eyes: glow that pulses, brighter while it talks (in both layers, so the halo pass blooms them)
- const pulse = 0.55 + 0.25 * Math.sin(t * 5.2) + (talking ? 0.3 : 0);
- g.globalCompositeOperation = "lighter";
- for (const [ex, ey] of pc.eyes || []) P().glow(g, ox + ex * cover, oy + ey * cover, 16 * cover * 2.2, pc.eye || "#ffa040", pulse * (mode === "light" ? 0.8 : 0.5));
- g.restore();
- };
-
- const infoScreen = (t, R, game, r) => {
- const g = drawingContext;
- g.save();
- g.fillStyle = "#03070c"; g.fillRect(r.x, r.y, r.w, r.h);
- const sel = game.units.filter((u) => u.team === "blue" && Anim.rts.alive(u, t) && game.selected(t, u));
- const cols = 8, pad = 10, tw = (r.w - pad * 2) / cols - 6, th = Math.min(tw, (r.h - pad * 2) / 2 - 6);
- sel.slice(0, 16).forEach((u, i) => {
- const x = r.x + pad + (i % cols) * (tw + 6), y = r.y + pad + Math.floor(i / cols) * (th + 6);
- g.fillStyle = "#0b1622"; g.fillRect(x, y, tw, th);
- g.strokeStyle = "rgba(70,160,255,0.75)"; g.lineWidth = 1.5; g.strokeRect(x + 0.5, y + 0.5, tw - 1, th - 1);
- const face = game.iconOf?.(u);
- imageMode(CORNER);
- if (face) image(face, x + 2, y + 2, tw - 4, th - 14);
- else {
- const img = R.units[u.kind], k = Math.min((tw - 10) / img.width, (th - 18) / img.height);
- g.globalAlpha = 0.95; image(img, x + (tw - img.width * k) / 2, y + 4 + (th - 18 - img.height * k) / 2, img.width * k, img.height * k); g.globalAlpha = 1;
- }
- const hp = u.hp ? u.hp(t) : 1;
- g.fillStyle = hp > 0.6 ? "#3ee05a" : hp > 0.3 ? "#e8d040" : "#e84a3a";
- g.fillRect(x + 4, y + th - 10, (tw - 8) * hp, 5);
- });
- g.restore();
- };
-
- const gaugeScreen = (t, game, r) => {
- const g = drawingContext, v = clamp01(game.gauge ? game.gauge(t) : 0.7), n = 12;
- g.save();
- g.fillStyle = "#02060a"; g.fillRect(r.x, r.y, r.w, r.h);
- const sh = (r.h - 16) / n;
- for (let i = 0; i < n; i++) {
- const on = (i + 0.5) / n <= v, y = r.y + r.h - 8 - (i + 1) * sh;
- g.fillStyle = on ? `rgba(70,${170 + i * 6},255,${0.75 + 0.25 * Math.sin(t * 6 - i)})` : "rgba(30,50,70,0.6)";
- g.fillRect(r.x + 10, y + 2, r.w - 20, sh - 4);
- }
- g.restore();
- };
-
- const commandCard = (t, R, game, L, cur) => {
- const g = drawingContext;
- (game.commands || []).forEach((name, i) => {
- const r = L.sockets[i];
- if (!r || !R.icons[name]) return;
- const press = (game.pressed || []).find((p) => p.name === name && t >= p.at && t < p.at + 0.18);
- const hover = cur && cur.x >= r.x && cur.x < r.x + r.w && cur.y >= r.y && cur.y < r.y + r.h;
- const d = press ? 2 : 0;
- g.save();
- g.fillStyle = "#000"; g.fillRect(r.x, r.y, r.w, r.h);
- imageMode(CORNER); image(R.icons[name], r.x + 1 + d, r.y + 1 + d, r.w - 2 - d, r.h - 2 - d);
- if (hover) { g.globalCompositeOperation = "lighter"; g.fillStyle = "rgba(90,160,255,0.16)"; g.fillRect(r.x, r.y, r.w, r.h); }
- if (press) { g.globalCompositeOperation = "source-over"; g.fillStyle = "rgba(0,0,0,0.3)"; g.fillRect(r.x, r.y, r.w, r.h);
- g.strokeStyle = "rgba(255,255,255,0.9)"; g.lineWidth = 2; g.strokeRect(r.x + 1, r.y + 1, r.w - 2, r.h - 2); }
- g.restore();
- });
- };
-
- // An original cursor: an angular green gauntlet-arrow, or a red reticle while an attack order waits for its target.
- const cursor = (c) => {
- if (!c) return;
- const g = drawingContext;
- g.save();
- g.translate(c.x, c.y);
- if (c.mode === "target") {
- g.strokeStyle = "rgba(255,70,50,0.95)"; g.lineWidth = 2.5; g.shadowColor = "rgba(255,40,30,0.9)"; g.shadowBlur = 8;
- g.beginPath(); g.arc(0, 0, 15, 0, TAU); g.stroke();
- g.beginPath();
- for (const [dx, dy] of [[1, 0], [-1, 0], [0, 1], [0, -1]]) { g.moveTo(dx * 9, dy * 9); g.lineTo(dx * 23, dy * 23); }
- g.stroke();
- g.fillStyle = "#ffd0c0"; g.beginPath(); g.arc(0, 0, 2.2, 0, TAU); g.fill();
- } else {
- const s = c.down ? 0.92 : 1;
- g.scale(s, s);
- g.beginPath();
- g.moveTo(0, 0); g.lineTo(5, 33); g.lineTo(12, 25); g.lineTo(20, 38); g.lineTo(26, 35); g.lineTo(18, 22); g.lineTo(29, 19); g.closePath();
- const gr = g.createLinearGradient(0, 0, 24, 36); gr.addColorStop(0, "#d6ffcf"); gr.addColorStop(0.35, "#5ef25a"); gr.addColorStop(1, "#167a24");
- g.shadowColor = "rgba(80,255,90,0.75)"; g.shadowBlur = 10;
- g.fillStyle = gr; g.fill();
- g.shadowBlur = 0; g.strokeStyle = "#03200a"; g.lineWidth = 2; g.stroke();
- g.strokeStyle = "rgba(255,255,255,0.7)"; g.lineWidth = 1; g.beginPath(); g.moveTo(3, 5); g.lineTo(6, 26); g.stroke();
- }
- g.restore();
- };
-
- // Windows-classic title bar, like the other PC screens in the film.
- const titleBar = (game, W) => {
- const g = drawingContext, top = game.top ?? 44;
- const grad = g.createLinearGradient(0, 0, W, 0);
- grad.addColorStop(0, "#0a246a"); grad.addColorStop(1, "#a6caf0");
- g.save(); g.fillStyle = grad; g.fillRect(0, 0, W, top); g.restore();
- styledText(game.title, 28, 21, { font: game.fonts.uiBold, size: 28, style: "#ffffff", align: [LEFT, CENTER] });
- ["_", "o", "x"].forEach((c, i) => {
- const x = W - 118 + i * 36;
- noStroke(); fill("#d4d0c8"); rect(x, 8, 30, 28);
- stroke("#ffffff"); line(x, 8, x + 30, 8); line(x, 8, x, 36);
- stroke("#404040"); line(x, 36, x + 30, 36); line(x + 30, 8, x + 30, 36); noStroke();
- styledText(c, x + 15, 19, { font: game.fonts.uiBold, size: 20, style: "#000000" });
- });
- };
-
- // A warning across the battlefield, blinking, in the logo face: red letters on a dark band.
- const alertBanner = (t, game, L) => {
- const al = game.alert?.(t);
- if (!al || !(al.a > 0)) return;
- const f = game.fonts, g = drawingContext, y = (game.alertY ?? (L.top * 0.52));
- const blink = 0.72 + 0.28 * (Math.floor(t * 4) % 2 ? 1 : 0.35);
- g.save(); g.globalAlpha = al.a;
- const band = g.createLinearGradient(0, 0, L.W, 0);
- band.addColorStop(0, "rgba(40,0,0,0)"); band.addColorStop(0.25, "rgba(40,0,0,0.62)"); band.addColorStop(0.75, "rgba(40,0,0,0.62)"); band.addColorStop(1, "rgba(40,0,0,0)");
- g.fillStyle = band; g.fillRect(0, y - 44, L.W, al.sub ? 110 : 84);
- g.globalAlpha = al.a * blink;
- styledText(al.text, L.W / 2, y, { font: f.logo, size: 44, style: "#ff4a36", outline: "#1a0000", weight: 6, glow: "rgba(255,40,20,0.95)", blur: 22, spacing: 3 });
- if (al.sub) styledText(al.sub, L.W / 2, y + 44, { font: f.logo, size: 22, style: "#ffc8b8", glow: "rgba(255,60,40,0.7)", blur: 8, spacing: 4 });
- g.restore();
- };
-
- Anim.rts.ui = { bevelRect, styledText, logoPlate, cursor, hpBar, groundMarker, titleBar, resourceIcon };
-
- // ---- the whole screen -------------------------------------------------------------------------------------------
-
- Anim.rts.screen = (t, R, game, { mode = "color", frame = ANIM.frame } = {}) => {
- const L = Anim.rts.layout(R, game);
- const top = game.top ?? 44, cam = game.map.cam(t), ms = game.map.scale ?? 0.9;
- const ground = (game.events || []).filter((e) => e.type === "scorch");
- const air = (game.events || []).filter((e) => e.type !== "scorch");
- const g = drawingContext;
- const cur = game.cursor?.(t);
-
- if (mode === "light") {
- g.save(); g.beginPath(); g.rect(0, top, L.W, L.top - top + 200); g.clip();
- push(); translate(-cam[0], -cam[1] + top);
- P().draw(air, t, { mode: "light" });
- pop();
- g.restore();
- // Nothing shines through the console: cut its frame and its screens out of the light layer.
- g.save(); g.globalCompositeOperation = "destination-out";
- imageMode(CORNER); image(R.console, 0, L.y0, L.W, R.slots.h * L.k);
- g.fillStyle = "#000";
- for (const r of [...Object.values(L.screens), ...L.sockets]) g.fillRect(r.x, r.y, r.w, r.h);
- g.fillRect(0, 0, L.W, top + 80);
- g.restore();
- if (L.screens.portrait) portraitScreen(t, R, game, L.screens.portrait, frame, "light");
- return L;
- }
-
- background(0);
- g.save(); g.beginPath(); g.rect(0, top, L.W, L.H - top); g.clip();
- push(); translate(-cam[0], -cam[1] + top);
- g.filter = game.map.filter || "brightness(1.22) contrast(1.06) saturate(1.08)";
- imageMode(CORNER); image(R.map, 0, 0, R.map.width * ms, R.map.height * ms);
- g.filter = "none";
- P().draw(ground, t);
- for (const m of game.markers || []) groundMarker(t, m);
- drawUnits(t, R, game);
- pop();
- drawFog(t, R, game, L, cam, top);
- push(); translate(-cam[0], -cam[1] + top);
- P().draw(air, t);
- pop();
- g.restore();
-
- dragBox(t, game);
- alertBanner(t, game, L);
- topHud(t, game, L);
-
- const S = L.screens;
- if (S.minimap) minimap(t, R, game, S.minimap, cam, L);
- if (S.portrait) portraitScreen(t, R, game, S.portrait, frame, "color");
- if (S.info) infoScreen(t, R, game, S.info);
- if (S.gauge) gaugeScreen(t, game, S.gauge);
- commandCard(t, R, game, L, cur);
- imageMode(CORNER); image(R.console, 0, L.y0, L.W, R.slots.h * L.k);
-
- cursor(cur);
- titleBar(game, L.W);
- return L;
- };
-
- // World point -> screen point for the current camera (to aim the cursor at a unit).
- Anim.rts.toScreen = (game, t, [x, y]) => {
- const cam = game.map.cam(t);
- return [x - cam[0], y - cam[1] + (game.top ?? 44)];
- };
-})();
diff --git a/skills/make-an-anime/scripts/tools/p5/render.mjs b/skills/make-an-anime/scripts/tools/p5/render.mjs
index b7d118d..9dabc58 100644
--- a/skills/make-an-anime/scripts/tools/p5/render.mjs
+++ b/skills/make-an-anime/scripts/tools/p5/render.mjs
@@ -15,7 +15,7 @@ import { fileURLToPath } from "node:url";
import puppeteer from "puppeteer-core";
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
-const LIB = ["core", "time", "fx", "type", "paper", "riso", "screens", "battle", "particles", "rts", "mission", "court"];
+const LIB = ["core", "time", "fx", "type", "paper", "riso", "screens", "battle", "particles"];
const CHROME = [
process.env.CHROME_PATH,
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
diff --git a/skills/make-an-anime/scripts/tools/python/cut_sheets.py b/skills/make-an-anime/scripts/tools/python/cut_sheets.py
index 895401b..6a0bd12 100644
--- a/skills/make-an-anime/scripts/tools/python/cut_sheets.py
+++ b/skills/make-an-anime/scripts/tools/python/cut_sheets.py
@@ -1,19 +1,19 @@
#!/usr/bin/env python3
-"""Cut generated game-art sheets into transparent PNGs a p5 overlay loads, and measure a HUD frame's empty screens.
+"""Prepare animation artwork: separate sprites, crop icon grids, open frame apertures, and fit images.
Run with the project's venv and -I (the sheets are generated files, treat them as data):
.venv/bin/python -I tools/python/cut_sheets.py sprites <sheet.png> <out_dir> --names a,b,c,... [--key alpha|magenta|black]
- Sprites laid out in rows with clear gaps (a unit sheet). Rows are found from the alpha (or keyed) coverage along y,
+ Sprites laid out in rows with clear gaps (props, poses or decorative elements). Rows are found from the alpha (or keyed) coverage along y,
then sprites inside each row along x, so the order is row by row, left to right. Each sprite is trimmed with a
small margin and saved as <out_dir>/<name>.png. Specks smaller than --min-px pixels per row/column are ignored.
.venv/bin/python -I tools/python/cut_sheets.py grid <sheet.png> <out_dir> --names a,b,... [--key black] [--inset 0]
Icons on a flat background in a grid: the same row/column search, each tile saved square, at --size px (128).
- .venv/bin/python -I tools/python/cut_sheets.py frame <console.png> <out.png> <slots.json> [--key alpha|magenta]
- A HUD frame with a keyed-out top: writes the transparent frame (its flat-black screens made transparent too,
- so whatever p5 draws under the frame shows through them) and slots.json, the screens' rectangles in the frame's
+ .venv/bin/python -I tools/python/cut_sheets.py frame <frame.png> <out.png> <slots.json> [--key alpha|magenta]
+ A decorative frame with a keyed-out background: writes the transparent frame (its flat-black apertures made transparent too,
+ so whatever p5 draws under the frame shows through them) and slots.json, the apertures' rectangles in the frame's
own pixels, largest first, as {"w", "h", "slots": [[x, y, w, h], ...]}.
.venv/bin/python -I tools/python/cut_sheets.py fit <image.png> <out.png> --width W [--crop x,y,w,h]
@@ -166,7 +166,7 @@ def label(mask):
def cmd_frame(args):
- a = load_rgba(args.console)
+ a = load_rgba(args.frame)
rgba = key_alpha(a, args.key) if args.key != "alpha" else np.clip(a, 0, 255).astype(np.uint8)
solid = rgba[..., 3] > 200
dark = solid & (a[..., :3].max(axis=2) < args.dark)
@@ -175,7 +175,7 @@ def cmd_frame(args):
comps = [c for c in label(small) if c[4] >= args.min_area and c[4] >= 0.8 * c[2] * c[3]] # filled, box-like
comps.sort(key=lambda c: -c[4])
slots = [[int(x * f), int(y * f), int(w * f), int(h * f)] for x, y, w, h, _ in comps]
- # Clear the screens so the layer under the frame shows through them.
+ # Clear the apertures so the layer under the frame shows through them.
hole = np.zeros(dark.shape, dtype=bool)
for x, y, w, h in slots:
hole[y:y + h, x:x + w] = True
@@ -213,7 +213,7 @@ def main():
s.add_argument("--size", type=int, default=128)
s.add_argument("--inset", type=int, default=0)
s = sub.add_parser("frame")
- s.add_argument("console"); s.add_argument("out"); s.add_argument("slots")
+ s.add_argument("frame"); s.add_argument("out"); s.add_argument("slots")
s.add_argument("--key", default="alpha")
s.add_argument("--dark", type=int, default=22)
s.add_argument("--scale", type=int, default=4)
@@ -232,7 +232,7 @@ def main():
outputs = [os.path.join(args.out, f"{n}.png") for n in names]
source = args.sheet
else:
- source = args.console if args.cmd == "frame" else args.image
+ source = args.frame if args.cmd == "frame" else args.image
outputs = [args.out] + ([args.slots] if args.cmd == "frame" else [])
if args.cmd == "frame" and min(args.scale, args.min_area) <= 0:
p.error("scale and min-area must be positive")
diff --git a/skills/make-an-anime/scripts/tools/python/face_collage.py b/skills/make-an-anime/scripts/tools/python/face_collage.py
index 24b06b2..0ddf3f7 100644
--- a/skills/make-an-anime/scripts/tools/python/face_collage.py
+++ b/skills/make-an-anime/scripts/tools/python/face_collage.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
-"""Game unit icons of real characters, in one image edit: crop each face from its character sheet, lay the faces out in
-a clean grid collage (no text), send the collage to the image-edit model with a prompt that redraws every cell as a
-super-deformed (chibi) unit icon of the same person in the same cell, then cut the cells back out.
+"""Prepare character portraits for an animation: crop faces from accepted sheets into a reference collage,
+then split an edited portrait sheet into named transparent images. Styling is chosen in the image-edit prompt;
+the tool does not impose a genre, costume, icon frame or character proportions.
.venv/bin/python -I tools/python/face_collage.py build <spec.json> <out.png> [--preview faces.jpg]
.venv/bin/python -I tools/python/face_collage.py cut <edited.png> <spec.json> <out_dir> [--size 256]
@@ -10,10 +10,10 @@ spec.json:
{"cols": 4, "rows": 2, "cell": [460, 520], "gap": 40, "margin": 60, "background": "#d8d8d8", "aspect": 1.7778,
"faces": [{"name": "pilot", "sheet": "output/char-pilot-v1/01_ref_base.png", "box": [cx, cy, w], "scale": 4}, ...]}
box is the face's centre and width in the sheet's pixels divided by `scale` (measure on a downscaled copy and give
- the copy's factor); the crop is w wide and 1.2 w tall, so hair and chin fit. Cells are filled row by row.
+ the copy's factor); the crop is w wide with the configured cell aspect ratio. Cells are filled row by row.
`cut` does not trust the model to keep the exact pixel grid: it finds the icons by projection (anything that differs
-from the background colour), expects cols x rows of them in reading order, and saves each one square (centred, padded with
+from the background colour), expects one per named face in reading order, and saves each one square (centred, padded with
transparency), at --size. If the count is off, it stops; --grid-fallback explicitly enables a measured content-grid fallback for review.
Needs Pillow and numpy only. Prints a JSON summary.
"""