claude-exode-mcp 7.5.7 → 7.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MCP_DOCUMENTATION.md +1 -0
- package/SKILL.md +10 -0
- package/examples/aurum-product-page.exode +3208 -0
- package/examples/bell-ring-icon.exode +1 -0
- package/examples/drift-kinetic-type.exode +770 -0
- package/examples/earbuds-product.exode +214 -0
- package/examples/energy-flow.exode +1736 -0
- package/examples/flux-hero.exode +223 -0
- package/examples/gooey-toggle.exode +214 -0
- package/examples/gravity-well.exode +3113 -0
- package/examples/heart-icon.exode +1 -0
- package/examples/hologram-temple.exode +8100 -0
- package/examples/jarful-app.exode +1 -0
- package/examples/kip-character-rig.exode +1 -0
- package/examples/low-tide-tilt.exode +2216 -0
- package/examples/manifest.json +352 -0
- package/examples/swipe-stack-carousel.exode +4048 -0
- package/examples/tokyo-neon-weather.exode +470 -0
- package/examples/typographic-collapse.exode +1578 -0
- package/examples/void-product-ad.exode +1269 -0
- package/examples/wire-globe-card.exode +580 -0
- package/index.d.ts +41 -1
- package/index.js +2553 -2407
- package/package.json +4 -2
- package/render-runtime/exode-runtime.js +20 -20
- package/skills/creative-motion/SKILL.md +10 -0
- package/skills/creative-motion/recipes/character-rig.js +104 -0
- package/skills/creative-motion/recipes/dashboard.js +120 -0
- package/skills/creative-motion/recipes/game-arcade.js +203 -0
- package/skills/creative-motion/recipes/hero-physics.js +65 -0
- package/skills/creative-motion/recipes/pricing.js +88 -0
- package/skills/creative-motion/recipes/title-sequence.js +62 -0
- package/skills/creative-motion/references/apps.md +37 -0
- package/skills/creative-motion/references/gotchas.md +80 -0
- package/skills/creative-motion/references/native-layers.md +60 -0
- package/skills/creative-motion/references/quality.md +54 -0
- package/src/__tests__/buildKit.test.ts +127 -0
- package/src/__tests__/effectKnobs.test.ts +162 -0
- package/src/__tests__/nativeLayers.test.ts +178 -0
- package/src/buildKit.d.ts +301 -0
- package/src/buildKit.d.ts.map +1 -0
- package/src/buildKit.js +559 -0
- package/src/buildKit.js.map +1 -0
- package/src/buildKit.ts +520 -0
- package/src/compiler.d.ts +4 -0
- package/src/compiler.d.ts.map +1 -1
- package/src/compiler.js +21 -45
- package/src/compiler.js.map +1 -1
- package/src/compiler.ts +22 -51
- package/src/critique.d.ts +8 -0
- package/src/critique.d.ts.map +1 -0
- package/src/critique.js +348 -0
- package/src/critique.js.map +1 -0
- package/src/critique.ts +239 -0
- package/src/effectKnobs.d.ts +72 -0
- package/src/effectKnobs.d.ts.map +1 -0
- package/src/effectKnobs.js +541 -0
- package/src/effectKnobs.js.map +1 -0
- package/src/effectKnobs.ts +445 -0
- package/src/effectOptimizer.d.ts +18 -0
- package/src/effectOptimizer.d.ts.map +1 -0
- package/src/effectOptimizer.js +125 -0
- package/src/effectOptimizer.js.map +1 -0
- package/src/effectOptimizer.ts +104 -0
- package/src/engine/layout.js +1 -1
- package/src/engine/layout.js.map +1 -1
- package/src/engine/layout.ts +1 -1
- package/src/examples.d.ts +30 -0
- package/src/examples.d.ts.map +1 -0
- package/src/examples.js +168 -0
- package/src/examples.js.map +1 -0
- package/src/examples.ts +151 -0
- package/src/handlers/artboardHandlers.d.ts.map +1 -1
- package/src/handlers/artboardHandlers.js +45 -10
- package/src/handlers/artboardHandlers.js.map +1 -1
- package/src/handlers/artboardHandlers.ts +43 -12
- package/src/handlers/buildHandlers.d.ts +2 -0
- package/src/handlers/buildHandlers.d.ts.map +1 -0
- package/src/handlers/buildHandlers.js +86 -0
- package/src/handlers/buildHandlers.js.map +1 -0
- package/src/handlers/buildHandlers.ts +76 -0
- package/src/handlers/compilerHandlers.d.ts.map +1 -1
- package/src/handlers/compilerHandlers.js +32 -2
- package/src/handlers/compilerHandlers.js.map +1 -1
- package/src/handlers/compilerHandlers.ts +31 -2
- package/src/handlers/exampleHandlers.d.ts +2 -0
- package/src/handlers/exampleHandlers.d.ts.map +1 -0
- package/src/handlers/exampleHandlers.js +81 -0
- package/src/handlers/exampleHandlers.js.map +1 -0
- package/src/handlers/exampleHandlers.ts +76 -0
- package/src/handlers/renderHandlers.d.ts.map +1 -1
- package/src/handlers/renderHandlers.js +100 -2
- package/src/handlers/renderHandlers.js.map +1 -1
- package/src/handlers/renderHandlers.ts +90 -2
- package/src/handlers/scaffoldHandlers.d.ts.map +1 -1
- package/src/handlers/scaffoldHandlers.js +3 -0
- package/src/handlers/scaffoldHandlers.js.map +1 -1
- package/src/handlers/scaffoldHandlers.ts +2 -0
- package/src/handlers/widgetHandlers.js +1 -1
- package/src/handlers/widgetHandlers.js.map +1 -1
- package/src/handlers/widgetHandlers.ts +1 -1
- package/src/lottie/convert.d.ts +16 -0
- package/src/lottie/convert.d.ts.map +1 -0
- package/src/lottie/convert.js +1225 -0
- package/src/lottie/convert.js.map +1 -0
- package/src/lottie/convert.ts +1134 -0
- package/src/lottie/evaluate.d.ts +48 -0
- package/src/lottie/evaluate.d.ts.map +1 -0
- package/src/lottie/evaluate.js +174 -0
- package/src/lottie/evaluate.js.map +1 -0
- package/src/lottie/evaluate.ts +184 -0
- package/src/nativeLayers.d.ts +76 -0
- package/src/nativeLayers.d.ts.map +1 -0
- package/src/nativeLayers.js +404 -0
- package/src/nativeLayers.js.map +1 -0
- package/src/nativeLayers.ts +339 -0
- package/src/render/motionBrief.d.ts.map +1 -1
- package/src/render/motionBrief.js +4 -0
- package/src/render/motionBrief.js.map +1 -1
- package/src/render/motionBrief.ts +4 -0
- package/src/render/videoRenderer.d.ts.map +1 -1
- package/src/render/videoRenderer.js +5 -2
- package/src/render/videoRenderer.js.map +1 -1
- package/src/render/videoRenderer.ts +5 -2
- package/src/rive/convert.d.ts +17 -0
- package/src/rive/convert.d.ts.map +1 -0
- package/src/rive/convert.js +1779 -0
- package/src/rive/convert.js.map +1 -0
- package/src/rive/convert.ts +1492 -0
- package/src/rive/font.d.ts +13 -0
- package/src/rive/font.d.ts.map +1 -0
- package/src/rive/font.js +154 -0
- package/src/rive/font.js.map +1 -0
- package/src/rive/font.ts +132 -0
- package/src/rive/layout.d.ts +20 -0
- package/src/rive/layout.d.ts.map +1 -0
- package/src/rive/layout.js +145 -0
- package/src/rive/layout.js.map +1 -0
- package/src/rive/layout.ts +140 -0
- package/src/rive/reader.d.ts +32 -0
- package/src/rive/reader.d.ts.map +1 -0
- package/src/rive/reader.js +172 -0
- package/src/rive/reader.js.map +1 -0
- package/src/rive/reader.ts +160 -0
- package/src/rive/schema.generated.d.ts +9 -0
- package/src/rive/schema.generated.d.ts.map +1 -0
- package/src/rive/schema.generated.js +13 -0
- package/src/rive/schema.generated.js.map +1 -0
- package/src/rive/schema.generated.ts +13 -0
- package/src/schema.d.ts +5 -0
- package/src/schema.d.ts.map +1 -1
- package/src/schema.js +5 -0
- package/src/schema.js.map +1 -1
- package/src/schema.ts +6 -0
- package/src/serverInstructions.d.ts +2 -0
- package/src/serverInstructions.d.ts.map +1 -0
- package/src/serverInstructions.js +22 -0
- package/src/serverInstructions.js.map +1 -0
- package/src/serverInstructions.ts +21 -0
- package/src/sseServer.d.ts +2 -0
- package/src/sseServer.d.ts.map +1 -0
- package/src/sseServer.js +165 -0
- package/src/sseServer.js.map +1 -0
- package/src/sseServer.ts +189 -0
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +23 -1
- package/src/utils.js.map +1 -1
- package/src/utils.ts +13 -1
- package/src/widgets.d.ts +26 -0
- package/src/widgets.d.ts.map +1 -1
- package/src/widgets.js +89 -45
- package/src/widgets.js.map +1 -1
- package/src/widgets.ts +88 -45
|
@@ -12,6 +12,8 @@ metadata:
|
|
|
12
12
|
|
|
13
13
|
Every Exode animation runs live on the Exode engine, and the same engine renders it to video headlessly. This skill covers how to decide what to make, how to make it move well, and how to check it the way a director would: by looking at frames, not by trusting the JSON.
|
|
14
14
|
|
|
15
|
+
**Before you build:** read `get_motion_skill { topic: "quality" }` (the quality bar: user intent first, premium defaults, native-first, explorable files) and `{ topic: "gotchas" }` (runtime rules the schema doesn't show), then study the closest one or two pieces from `list_examples` / `get_example`.
|
|
16
|
+
|
|
15
17
|
**Three rules come before everything else:**
|
|
16
18
|
|
|
17
19
|
1. **No house style.** Two different briefs must not come out looking alike. Derive the look from the subject, then use `roll_motion_brief` for any axis the subject leaves open. Never reuse the previous piece's family, palette or rhythm by default.
|
|
@@ -86,6 +88,8 @@ Derive first, roll second. A typhoon explainer is wind and water, so the family
|
|
|
86
88
|
| Generative: particles, noise, flow fields, metaballs, procedural type, thousands of marks | A `CustomEffect` (`render(ctx, env)` drawn every frame) on a full-bleed object | `add_custom_effect`; read `references/effect-code.md` |
|
|
87
89
|
| Text | Native Text objects. Animate the object, or decorate it with an effect that draws around the glyphs | `edit_typography` |
|
|
88
90
|
| Travel along a curve | Draw a Path, then bake it into constant-speed x/y (+ rotation) keyframes | `add_motion_path` |
|
|
91
|
+
| Structured scenes drawn in code: 3D models, buildings, machines, maps, holograms, exploded diagrams | One native Path layer per meaningful part (named groups, tight frames) driven by a Logic group: a shared library effect plus one small effect per job, and a group effect mirroring all of them. One glow effect. Keeps all motion and interaction at display rate | Read `references/native-layers.md` (`get_motion_skill { topic: 'native-layers' }`), then `bake_native_layers` |
|
|
92
|
+
| Games, simulations, dashboards, HUD-heavy apps | Hybrid native file: named effect layers for the world plus one `Game logic` layer; HUD, menus and buttons as native objects bound to inputs; a state machine with keyframed animations for every visual change | Read `references/apps.md` (`get_motion_skill { topic: 'apps' }`) before building |
|
|
89
93
|
| Charts and data UI that animate | Native widgets bound to data inputs; animate the inputs | `add_widget`, `add_input` |
|
|
90
94
|
|
|
91
95
|
Use keyframes when the motion is designed beat by beat and should stay editable in the editor timeline. Use effect code when the motion comes from a rule (noise, physics, data, many marks). Most good pieces use both: a coded field or texture behind keyframed hero elements.
|
|
@@ -101,6 +105,8 @@ Frames are stepped on a virtual clock, so renders are deterministic and smooth h
|
|
|
101
105
|
|
|
102
106
|
## Exode gotchas that cost a round each
|
|
103
107
|
|
|
108
|
+
The short list. The full list (text keyframes, opacity > 1, applyState names, triggers, images, bones, performance) is `get_motion_skill { topic: "gotchas" }`.
|
|
109
|
+
|
|
104
110
|
- An animation plays only when a state machine state points at it. `add_animation` and `add_motion_path` wire new animations to play on load (a second one gets its own layer). Files you write by hand need the wiring; the renderer auto-wires files that have no state machine.
|
|
105
111
|
- Paths re-centre on their bounding box every frame, so a morphing path drifts. Prepend two `moveTo` pin points at fixed corners and set width, height, baseWidth and baseHeight to the pinned box.
|
|
106
112
|
- Blend states only mix numbers and colours. Morph with one track per coordinate, and give every pose in a blend the same tracks.
|
|
@@ -115,8 +121,12 @@ Frames are stepped on a virtual clock, so renders are deterministic and smooth h
|
|
|
115
121
|
|
|
116
122
|
## Reference files
|
|
117
123
|
|
|
124
|
+
- `references/quality.md`: the quality bar: user intent first, premium defaults when style is open, motion that feels expensive, native-first and explorable files, learning from examples
|
|
125
|
+
- `references/gotchas.md`: every runtime rule the file format doesn't show (layout, text, paths, keyframes, state machine, bones, images, effect code, performance)
|
|
118
126
|
- `references/families.md`: ~30 motion families with Exode recipes, numbers and a twist each
|
|
119
127
|
- `references/craft.md`: timing, easing, choreography, the 12 principles, emotion → motion, troubleshooting
|
|
120
128
|
- `references/sequencing.md`: timeline maths (position parameter, stagger distributions, labels, repeat/yoyo) applied to Exode tracks, plus utility functions for effect code
|
|
129
|
+
- `references/native-layers.md`: code-drawn scenes as native, editable layers (native kit, nativeBake, bake_native_layers, per-engine state, logic split, glow-only effect)
|
|
130
|
+
- `references/apps.md`: games, simulations and dashboards as hybrid native files (effect layers + native HUD + state machine), and the `EXODE_KEEP_LIVE` marker
|
|
121
131
|
- `references/effect-code.md`: the `CustomEffect` contract, determinism, seamless loops, noise/flow/particle/metaball patterns, colour interpolation
|
|
122
132
|
- `references/qc.md`: the contact-sheet critique checklist with severity tiers
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/* RECIPE: character-rig
|
|
2
|
+
A bone-rigged mascot with personality: native shapes parented rigidly to FK bones, a Breath
|
|
3
|
+
layer (squash bone) and a Blink layer (eye bones) that run forever, and an Action layer
|
|
4
|
+
(Wave, Jump, Nod, Dance) built with d.actions() so every action covers the same tracks,
|
|
5
|
+
one-shots land back on the rest pose, and each replays on every tap of its button.
|
|
6
|
+
ADAPT: change NAME, COLORS, the body proportions in SHAPE, and the poses in ACTIONS
|
|
7
|
+
(rotation in degrees: negative = counter-clockwise). Keep the bone tree and layer split.
|
|
8
|
+
Run with build_from_script. */
|
|
9
|
+
|
|
10
|
+
const NAME = 'Pip';
|
|
11
|
+
const COLORS = { bg: '#F4EFE7', body: '#2F5BFF', belly: '#5B7DFF', limb: '#2448D8', ink: '#141210', eye: '#FFFFFF', cheek: '#FF8FA3', accent: '#FFC53D', muted: '#6E675C' };
|
|
12
|
+
const SHAPE = { bodyW: 240, bodyH: 280, armL: 112, legL: 60 };
|
|
13
|
+
|
|
14
|
+
const W = 1200, H = 900, GROUND = 650, C = COLORS;
|
|
15
|
+
const d = exode.artboard({ name: `${NAME} character`, width: W, height: H, background: C.bg, ease: exode.ease.out });
|
|
16
|
+
|
|
17
|
+
/* stage */
|
|
18
|
+
d.text(NAME, { name: 'Title', left: 80, y: 92, size: 44, weight: 700, color: C.ink, w: 300 });
|
|
19
|
+
d.text('A bone-rigged companion · tap an action', { name: 'Subtitle', left: 80, y: 136, size: 16, color: C.muted, w: 500 });
|
|
20
|
+
const shadow = d.ellipse({ name: 'Ground shadow', x: W / 2, y: GROUND + 14, w: 280, h: 30, fill: C.ink, fillOpacity: 0.12 });
|
|
21
|
+
|
|
22
|
+
/* bone tree: Root → Legs, Squash → Spine → (Antenna, Face → Eyes, Arms) */
|
|
23
|
+
const root = d.bone({ name: 'Root', x: W / 2, y: GROUND - 40, length: 30 });
|
|
24
|
+
const legL = d.bone({ name: 'Leg L', parent: root, x: -52, y: 0, length: 40 });
|
|
25
|
+
const legR = d.bone({ name: 'Leg R', parent: root, x: 52, y: 0, length: 40 });
|
|
26
|
+
d.rect({ name: 'Leg L / shape', parent: legL, x: 0, y: 22, w: 46, h: SHAPE.legL, r: 23, fill: C.limb });
|
|
27
|
+
d.ellipse({ name: 'Leg L / foot', parent: legL, x: -6, y: 52, w: 72, h: 32, fill: C.limb });
|
|
28
|
+
d.rect({ name: 'Leg R / shape', parent: legR, x: 0, y: 22, w: 46, h: SHAPE.legL, r: 23, fill: C.limb });
|
|
29
|
+
d.ellipse({ name: 'Leg R / foot', parent: legR, x: 6, y: 52, w: 72, h: 32, fill: C.limb });
|
|
30
|
+
|
|
31
|
+
const squash = d.bone({ name: 'Squash', parent: root, x: 0, y: 0, length: 20 });
|
|
32
|
+
const spine = d.bone({ name: 'Spine', parent: squash, x: 0, y: -SHAPE.bodyH / 2 + 10, length: 120 });
|
|
33
|
+
const antenna = d.bone({ name: 'Antenna', parent: spine, x: 0, y: -SHAPE.bodyH / 2 + 6, length: 50 });
|
|
34
|
+
d.path('M0 26 L0 -26', { name: 'Antenna / stem', parent: antenna, x: 0, y: -26, w: 4, h: 52, stroke: C.limb, strokeWidth: 5 });
|
|
35
|
+
d.ellipse({ name: 'Antenna / bulb', parent: antenna, x: 0, y: -58, size: 26, fill: C.accent });
|
|
36
|
+
|
|
37
|
+
d.rect({ name: 'Body', parent: spine, x: 0, y: 0, w: SHAPE.bodyW, h: SHAPE.bodyH, r: SHAPE.bodyW / 2, fill: C.body });
|
|
38
|
+
d.ellipse({ name: 'Belly', parent: spine, x: 0, y: 46, w: 150, h: 140, fill: C.belly });
|
|
39
|
+
|
|
40
|
+
const armL = d.bone({ name: 'Arm L', parent: spine, x: -SHAPE.bodyW / 2 + 8, y: -18, length: SHAPE.armL });
|
|
41
|
+
const armR = d.bone({ name: 'Arm R', parent: spine, x: SHAPE.bodyW / 2 - 8, y: -18, length: SHAPE.armL });
|
|
42
|
+
d.rect({ name: 'Arm L / shape', parent: armL, x: 0, y: SHAPE.armL / 2 - 6, w: 42, h: SHAPE.armL, r: 21, fill: C.limb });
|
|
43
|
+
d.rect({ name: 'Arm R / shape', parent: armR, x: 0, y: SHAPE.armL / 2 - 6, w: 42, h: SHAPE.armL, r: 21, fill: C.limb });
|
|
44
|
+
|
|
45
|
+
const face = d.bone({ name: 'Face', parent: spine, x: 0, y: -46, length: 30 });
|
|
46
|
+
const eyeL = d.bone({ name: 'Eye L', parent: face, x: -44, y: 0, length: 10 });
|
|
47
|
+
const eyeR = d.bone({ name: 'Eye R', parent: face, x: 44, y: 0, length: 10 });
|
|
48
|
+
for (const [eye, side] of [[eyeL, 'L'], [eyeR, 'R']]) {
|
|
49
|
+
d.ellipse({ name: `Eye ${side} / white`, parent: eye, x: 0, y: 0, w: 42, h: 48, fill: C.eye });
|
|
50
|
+
d.ellipse({ name: `Eye ${side} / pupil`, parent: eye, x: 4, y: 5, w: 20, h: 24, fill: C.ink });
|
|
51
|
+
d.ellipse({ name: `Eye ${side} / glint`, parent: eye, x: 9, y: -2, size: 7, fill: C.eye });
|
|
52
|
+
}
|
|
53
|
+
d.ellipse({ name: 'Cheek L', parent: face, x: -74, y: 38, w: 30, h: 16, fill: C.cheek, fillOpacity: 0.75 });
|
|
54
|
+
d.ellipse({ name: 'Cheek R', parent: face, x: 74, y: 38, w: 30, h: 16, fill: C.cheek, fillOpacity: 0.75 });
|
|
55
|
+
d.path('M-16 -4 Q0 12 16 -4', { name: 'Mouth', parent: face, x: 0, y: 42, w: 32, h: 12, stroke: C.ink, strokeWidth: 4 });
|
|
56
|
+
|
|
57
|
+
/* life that never stops: breathing on the squash bone, blinking on the eye bones */
|
|
58
|
+
d.ambient([
|
|
59
|
+
d.track(squash, 'scale_y', [[0, 1, exode.ease.sine], [1.6, 1.03, exode.ease.sine], [3.2, 1]]),
|
|
60
|
+
d.track(squash, 'scale_x', [[0, 1, exode.ease.sine], [1.6, 0.985, exode.ease.sine], [3.2, 1]]),
|
|
61
|
+
], 'Breath', 3.2);
|
|
62
|
+
d.ambient([
|
|
63
|
+
...[eyeL, eyeR].map((e) => d.track(e, 'scale_y', [[0, 1, 'linear'], [3.55, 1, exode.ease.in], [3.65, 0.08, exode.ease.out], [3.78, 1], [4.2, 1]])),
|
|
64
|
+
], 'Blink', 4.2);
|
|
65
|
+
|
|
66
|
+
/* actions: poses only; d.actions() fills the gaps and wires triggers */
|
|
67
|
+
const Y = root.transform.y;
|
|
68
|
+
const ACTIONS = {
|
|
69
|
+
Wave: { duration: 2.2, tracks: [
|
|
70
|
+
[armR, 'rotation', [[0, 0], [0.35, -150, exode.ease.outBack], [0.6, -118, exode.ease.sine], [0.85, -152, exode.ease.sine], [1.1, -118, exode.ease.sine], [1.35, -150], [1.8, -150], [2.2, 0]]],
|
|
71
|
+
[face, 'rotation', [[0, 0], [0.4, 8], [1.8, 8], [2.2, 0]]],
|
|
72
|
+
[spine, 'rotation', [[0, 0], [0.4, -4], [1.8, -4], [2.2, 0]]],
|
|
73
|
+
] },
|
|
74
|
+
Jump: { duration: 1.4, tracks: [
|
|
75
|
+
[root, 'y', [[0, Y, exode.ease.out], [0.18, Y + 16, exode.ease.out], [0.56, Y - 180, exode.ease.in], [0.96, Y, exode.ease.out], [1.12, Y + 8], [1.4, Y]]],
|
|
76
|
+
[armL, 'rotation', [[0, 0], [0.18, 20], [0.5, 140, exode.ease.out], [0.96, 30], [1.4, 0]]],
|
|
77
|
+
[armR, 'rotation', [[0, 0], [0.18, -20], [0.5, -140, exode.ease.out], [0.96, -30], [1.4, 0]]],
|
|
78
|
+
[legL, 'rotation', [[0, 0], [0.5, 14], [0.96, 0]]],
|
|
79
|
+
[legR, 'rotation', [[0, 0], [0.5, -14], [0.96, 0]]],
|
|
80
|
+
[shadow, 'scale', [[0, 1], [0.56, 0.55, exode.ease.in], [0.96, 1]]],
|
|
81
|
+
] },
|
|
82
|
+
Nod: { duration: 1.3, tracks: [
|
|
83
|
+
[face, 'y', [[0, face.transform.y], [0.2, face.transform.y + 12, exode.ease.sine], [0.45, face.transform.y, exode.ease.sine], [0.7, face.transform.y + 12, exode.ease.sine], [0.95, face.transform.y], [1.3, face.transform.y]]],
|
|
84
|
+
[spine, 'rotation', [[0, 0], [0.2, 3], [0.45, 0], [0.7, 3], [0.95, 0]]],
|
|
85
|
+
] },
|
|
86
|
+
Dance: { duration: 1.6, loop: true, tracks: [
|
|
87
|
+
[root, 'rotation', [[0, -6, exode.ease.sine], [0.8, 6, exode.ease.sine], [1.6, -6]]],
|
|
88
|
+
[root, 'x', [[0, W / 2 - 14, exode.ease.sine], [0.8, W / 2 + 14, exode.ease.sine], [1.6, W / 2 - 14]]],
|
|
89
|
+
[armL, 'rotation', [[0, 150, exode.ease.sine], [0.8, 40, exode.ease.sine], [1.6, 150]]],
|
|
90
|
+
[armR, 'rotation', [[0, -40, exode.ease.sine], [0.8, -150, exode.ease.sine], [1.6, -40]]],
|
|
91
|
+
[face, 'rotation', [[0, 6, exode.ease.sine], [0.8, -6, exode.ease.sine], [1.6, 6]]],
|
|
92
|
+
[antenna, 'rotation', [[0, -12, exode.ease.sine], [0.4, 12, exode.ease.sine], [0.8, -12, exode.ease.sine], [1.2, 12, exode.ease.sine], [1.6, -12]]],
|
|
93
|
+
] },
|
|
94
|
+
};
|
|
95
|
+
const triggers = d.actions('Action', ACTIONS);
|
|
96
|
+
|
|
97
|
+
/* controls: one button per action, firing its trigger */
|
|
98
|
+
const bar = d.group({ name: 'Controls', x: W / 2, y: H - 86, w: 600, h: 52 });
|
|
99
|
+
Object.keys(ACTIONS).forEach((n, i) => d.button(n, { name: `Controls / ${n} button`, parent: bar, x: -225 + i * 150, y: 0, w: 132, h: 48, size: 15,
|
|
100
|
+
variant: i === 0 ? 'primary' : 'secondary', fill: i === 0 ? C.ink : C.ink, color: i === 0 ? C.bg : C.ink, line: 'rgba(20,18,16,0.18)', onTap: triggers[n] }));
|
|
101
|
+
|
|
102
|
+
/* entrance for the page chrome (the character's bones belong to the Action layer, so leave them alone) */
|
|
103
|
+
d.intro(d.reveal(['title', 'subtitle', bar], { dy: 16, step: 0.08 }));
|
|
104
|
+
return d;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/* RECIPE: dashboard
|
|
2
|
+
Analytics dashboard, desktop: header with range selector and export, four KPI cards whose
|
|
3
|
+
numbers count up (formatted) with delta chips, a revenue line that draws itself in over a
|
|
4
|
+
gradient area with a pulsing live point, and channel bars that grow in a stagger. Every card
|
|
5
|
+
lifts on hover. Light by default (switch PALETTE for dark).
|
|
6
|
+
ADAPT: change TITLE, KPIS, SERIES, CHANNELS and PALETTE. Keep the grid, spacing and motion.
|
|
7
|
+
Run with build_from_script. */
|
|
8
|
+
|
|
9
|
+
const TITLE = { name: 'Overview', sub: 'Acme Cloud · all workspaces', range: ['7D', '30D', '90D'], activeRange: 1 };
|
|
10
|
+
const KPIS = [
|
|
11
|
+
{ label: 'Revenue', value: 48.2, prefix: '$', suffix: 'k', decimals: 1, delta: '+12.4%', good: true },
|
|
12
|
+
{ label: 'Active users', value: 12480, delta: '+8.1%', good: true },
|
|
13
|
+
{ label: 'Conversion', value: 3.42, suffix: '%', decimals: 2, delta: '−0.3%', good: false },
|
|
14
|
+
{ label: 'Churn', value: 1.9, suffix: '%', decimals: 1, delta: '−0.4%', good: true },
|
|
15
|
+
];
|
|
16
|
+
const SERIES = { title: 'Revenue', note: 'Last 30 days', labels: ['Jun 1', 'Jun 8', 'Jun 15', 'Jun 22', 'Jun 29'], values: [18, 22, 21, 27, 25, 31, 34, 32, 38, 41, 39, 46, 48] };
|
|
17
|
+
const CHANNELS = { title: 'Signups by channel', items: [['Organic', 4210], ['Referral', 2870], ['Paid social', 2140], ['Email', 1630], ['Partners', 920]] };
|
|
18
|
+
const PALETTE = 'porcelain'; /* light: porcelain · paper · bone dark: graphite · midnight · obsidian */
|
|
19
|
+
|
|
20
|
+
const W = 1440, H = 900, M = 56, GAP = 20;
|
|
21
|
+
const P = exode.palette(PALETTE);
|
|
22
|
+
const good = '#1F9D55', bad = '#D64545';
|
|
23
|
+
const d = exode.artboard({ name: `${TITLE.name} dashboard`, width: W, height: H, palette: PALETTE, ease: exode.ease.outQuart });
|
|
24
|
+
d.rect({ name: 'Backdrop', x: W / 2, y: H / 2, w: W, h: H, fill: P.bg });
|
|
25
|
+
|
|
26
|
+
/* header */
|
|
27
|
+
const head = d.group({ name: 'Header', x: W / 2, y: 70, w: W - 2 * M, h: 60 });
|
|
28
|
+
d.text(TITLE.name, { name: 'Header / title', parent: head, left: -(W - 2 * M) / 2, y: -10, size: 30, weight: 600, color: P.ink });
|
|
29
|
+
d.text(TITLE.sub, { name: 'Header / subtitle', parent: head, left: -(W - 2 * M) / 2, y: 20, size: 14, color: P.muted });
|
|
30
|
+
const seg = d.rect({ name: 'Header / range', parent: head, x: (W - 2 * M) / 2 - 290, y: 0, w: 180, h: 38, r: 10, fill: P.surface, stroke: P.line, strokeWidth: 1 });
|
|
31
|
+
TITLE.range.forEach((r, i) => {
|
|
32
|
+
const on = i === TITLE.activeRange, x = -60 + i * 60;
|
|
33
|
+
if (on) d.rect({ name: `Header / range ${r} active`, parent: seg, x, y: 0, w: 54, h: 30, r: 7, fill: P.raised, shadow: { blur: 6, offsetY: 1, opacity: 14 } });
|
|
34
|
+
d.text(r, { name: `Header / range ${r}`, parent: seg, x, y: 0, size: 13, weight: on ? 600 : 500, color: on ? P.ink : P.muted, align: 'center', w: 54 });
|
|
35
|
+
});
|
|
36
|
+
d.button('Export', { name: 'Header / Export button', parent: head, x: (W - 2 * M) / 2 - 70, y: 0, h: 38, size: 13, radius: 10, fill: P.ink, color: P.bg });
|
|
37
|
+
|
|
38
|
+
/* KPI cards */
|
|
39
|
+
const top = 130, kw = (W - 2 * M - 3 * GAP) / 4, kh = 132;
|
|
40
|
+
const wrappers = [], intro = [];
|
|
41
|
+
KPIS.forEach((k, i) => {
|
|
42
|
+
const wrap = d.group({ name: `KPI ${k.label}`, x: M + kw / 2 + i * (kw + GAP), y: top + kh / 2, w: kw, h: kh });
|
|
43
|
+
wrappers.push(wrap);
|
|
44
|
+
const card = d.rect({ name: `KPI ${k.label} / card`, parent: wrap, x: 0, y: 0, w: kw, h: kh, r: 16, fill: P.surface, stroke: P.line, strokeWidth: 1, shadow: { blur: 18, offsetY: 6, opacity: 10 } });
|
|
45
|
+
const L = -kw / 2 + 24;
|
|
46
|
+
d.text(k.label, { name: `KPI ${k.label} / label`, parent: card, left: L, y: -36, size: 13, weight: 500, color: P.muted, w: kw - 48 });
|
|
47
|
+
const v = d.text('0', { name: `KPI ${k.label} / value`, parent: card, left: L, y: 6, size: 34, weight: 600, color: P.ink, w: kw - 140 });
|
|
48
|
+
intro.push(d.countUp(v, k.value, { prefix: k.prefix, suffix: k.suffix, decimals: k.decimals, delay: 0.35 + i * 0.08, duration: 1.4 }));
|
|
49
|
+
const col = k.good ? good : bad;
|
|
50
|
+
const chip = d.rect({ name: `KPI ${k.label} / delta`, parent: card, x: kw / 2 - 24 - 36, y: 6, w: 72, h: 26, r: 13, fill: col, fillOpacity: 0.12 });
|
|
51
|
+
d.text(k.delta, { name: `KPI ${k.label} / delta label`, parent: chip, x: 0, y: 0, size: 12, weight: 600, color: col, align: 'center', w: 72 });
|
|
52
|
+
d.text('vs previous period', { name: `KPI ${k.label} / note`, parent: card, left: L, y: 42, size: 12, color: P.muted, w: kw - 48 });
|
|
53
|
+
d.interactive(card, { lift: 3, scale: 1.01, press: 0.99, shadowBlur: [18, 30] });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/* revenue chart */
|
|
57
|
+
const cy = top + kh + GAP, ch = H - cy - 48, lw = (W - 2 * M - GAP) * 0.64, rw = W - 2 * M - GAP - lw;
|
|
58
|
+
const lwrap = d.group({ name: 'Revenue chart', x: M + lw / 2, y: cy + ch / 2, w: lw, h: ch });
|
|
59
|
+
wrappers.push(lwrap);
|
|
60
|
+
const lcard = d.rect({ name: 'Revenue chart / card', parent: lwrap, x: 0, y: 0, w: lw, h: ch, r: 18, fill: P.surface, stroke: P.line, strokeWidth: 1, shadow: { blur: 18, offsetY: 6, opacity: 10 } });
|
|
61
|
+
d.text(SERIES.title, { name: 'Revenue chart / title', parent: lcard, left: -lw / 2 + 28, y: -ch / 2 + 38, size: 17, weight: 600, color: P.ink, w: 300 });
|
|
62
|
+
d.text(SERIES.note, { name: 'Revenue chart / note', parent: lcard, right: lw / 2 - 28, y: -ch / 2 + 38, size: 13, color: P.muted, align: 'right', w: 200 });
|
|
63
|
+
const px0 = -lw / 2 + 64, px1 = lw / 2 - 32, py0 = -ch / 2 + 86, py1 = ch / 2 - 52;
|
|
64
|
+
const vmax = Math.ceil(Math.max(...SERIES.values) / 10) * 10;
|
|
65
|
+
for (let g = 0; g <= 4; g++) {
|
|
66
|
+
const y = py1 - (py1 - py0) * (g / 4);
|
|
67
|
+
d.rect({ name: `Revenue chart / grid ${g}`, parent: lcard, x: (px0 + px1) / 2, y, w: px1 - px0, h: 1, fill: P.line });
|
|
68
|
+
d.text(`${Math.round((vmax * g) / 4)}k`, { name: `Revenue chart / axis ${g}`, parent: lcard, right: px0 - 14, y, size: 11, color: P.muted, align: 'right', w: 40 });
|
|
69
|
+
}
|
|
70
|
+
SERIES.labels.forEach((l, i) => d.text(l, { name: `Revenue chart / month ${i + 1}`, parent: lcard, x: px0 + (px1 - px0) * (i / (SERIES.labels.length - 1)), y: py1 + 24, size: 11, color: P.muted, align: 'center', w: 60 }));
|
|
71
|
+
const pts = SERIES.values.map((v, i) => [px0 + (px1 - px0) * (i / (SERIES.values.length - 1)), py1 - (py1 - py0) * (v / vmax)]);
|
|
72
|
+
/* smooth curve (Catmull-Rom → cubic Bézier), path data centred on the chart box */
|
|
73
|
+
const ox = (px0 + px1) / 2, oy = (py0 + py1) / 2, f = (n) => Math.round(n * 10) / 10;
|
|
74
|
+
let line = `M${f(pts[0][0] - ox)} ${f(pts[0][1] - oy)}`;
|
|
75
|
+
for (let i = 0; i < pts.length - 1; i++) {
|
|
76
|
+
const p0 = pts[Math.max(0, i - 1)], p1 = pts[i], p2 = pts[i + 1], p3 = pts[Math.min(pts.length - 1, i + 2)];
|
|
77
|
+
line += ` C${f(p1[0] + (p2[0] - p0[0]) / 6 - ox)} ${f(p1[1] + (p2[1] - p0[1]) / 6 - oy)} ${f(p2[0] - (p3[0] - p1[0]) / 6 - ox)} ${f(p2[1] - (p3[1] - p1[1]) / 6 - oy)} ${f(p2[0] - ox)} ${f(p2[1] - oy)}`;
|
|
78
|
+
}
|
|
79
|
+
/* pin the path box to the plot area (two moveTo pins) so it never re-centres */
|
|
80
|
+
const pin = `M${f(px0 - ox)} ${f(py0 - oy)} M${f(px1 - ox)} ${f(py1 - oy)} `;
|
|
81
|
+
const area = d.path(pin + line + ` L${f(px1 - ox)} ${f(py1 - oy)} L${f(px0 - ox)} ${f(py1 - oy)} Z`, { name: 'Revenue chart / area', parent: lcard, x: ox, y: oy, w: px1 - px0, h: py1 - py0,
|
|
82
|
+
fill: exode.linear([exode.alpha(P.accent, 0.16), exode.alpha(P.accent, 0)], 180) });
|
|
83
|
+
const stroke = d.path(pin + line, { name: 'Revenue chart / line', parent: lcard, x: ox, y: oy, w: px1 - px0, h: py1 - py0, stroke: P.accent, strokeWidth: 3 });
|
|
84
|
+
const last = pts[pts.length - 1];
|
|
85
|
+
/* live point: the group fades in when the line arrives; the halo pulses inside it (separate owners) */
|
|
86
|
+
const live = d.group({ name: 'Revenue chart / live', parent: lcard, x: last[0], y: last[1], w: 40, h: 40 });
|
|
87
|
+
const halo = d.ellipse({ name: 'Revenue chart / live halo', parent: live, x: 0, y: 0, size: 26, fill: P.accent, fillOpacity: 0.18 });
|
|
88
|
+
const dot = d.ellipse({ name: 'Revenue chart / live point', parent: live, x: 0, y: 0, size: 10, fill: P.accent, stroke: P.surface, strokeWidth: 2 });
|
|
89
|
+
intro.push(
|
|
90
|
+
d.track(stroke, 'style.stroke.trimEnd', [[0, 0.002, 'linear'], [0.6, 0.002, exode.ease.inOut], [2.0, 1]]),
|
|
91
|
+
/* a near-zero trim still draws a round-cap dot: keep the line hidden until it starts drawing */
|
|
92
|
+
d.track(stroke, 'opacity', [[0, 0, 'linear'], [0.62, 0, 'linear'], [0.66, 1]]),
|
|
93
|
+
d.track(area, 'opacity', [[0, 0, 'linear'], [1.2, 0], [2.2, 1]]),
|
|
94
|
+
d.track(live, 'opacity', [[0, 0, 'linear'], [1.9, 0], [2.1, 1]]),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
/* channel bars */
|
|
98
|
+
const bwrap = d.group({ name: 'Channels', x: M + lw + GAP + rw / 2, y: cy + ch / 2, w: rw, h: ch });
|
|
99
|
+
wrappers.push(bwrap);
|
|
100
|
+
const bcard = d.rect({ name: 'Channels / card', parent: bwrap, x: 0, y: 0, w: rw, h: ch, r: 18, fill: P.surface, stroke: P.line, strokeWidth: 1, shadow: { blur: 18, offsetY: 6, opacity: 10 } });
|
|
101
|
+
d.text(CHANNELS.title, { name: 'Channels / title', parent: bcard, left: -rw / 2 + 28, y: -ch / 2 + 38, size: 17, weight: 600, color: P.ink, w: rw - 56 });
|
|
102
|
+
const bmax = Math.max(...CHANNELS.items.map((c) => c[1])), bx0 = -rw / 2 + 28, bwid = rw - 56, rowH = (ch - 120) / CHANNELS.items.length;
|
|
103
|
+
CHANNELS.items.forEach(([label, v], i) => {
|
|
104
|
+
const y = -ch / 2 + 100 + i * rowH;
|
|
105
|
+
d.text(label, { name: `Channels / ${label}`, parent: bcard, left: bx0, y, size: 13, color: P.ink, w: 160 });
|
|
106
|
+
const val = d.text('0', { name: `Channels / ${label} value`, parent: bcard, right: bx0 + bwid, y, size: 13, weight: 600, color: P.ink, align: 'right', w: 80 });
|
|
107
|
+
intro.push(d.countUp(val, v, { delay: 0.7 + i * 0.09, duration: 1.1 }));
|
|
108
|
+
d.rect({ name: `Channels / ${label} track`, parent: bcard, left: bx0, y: y + 22, w: bwid, h: 8, r: 4, fill: P.line });
|
|
109
|
+
const bw = bwid * (v / bmax);
|
|
110
|
+
const bar = d.rect({ name: `Channels / ${label} bar`, parent: bcard, left: bx0, y: y + 22, w: bw, h: 8, r: 4, fill: i === 0 ? P.accent : exode.mix(P.accent, P.surface, 0.25 + i * 0.12) });
|
|
111
|
+
const t0 = 0.7 + i * 0.09;
|
|
112
|
+
/* grow from the left edge: scale_x and x move together so the left end stays put */
|
|
113
|
+
intro.push(d.track(bar, 'scale_x', [[0, 0.001, 'linear'], [t0, 0.001], [t0 + 1.0, 1]]), d.track(bar, 'x', [[0, bx0, 'linear'], [t0, bx0], [t0 + 1.0, bx0 + bw / 2]]));
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
/* motion */
|
|
117
|
+
intro.push(...d.reveal([head, ...wrappers], { dy: 18, step: 0.06, duration: 0.8 }));
|
|
118
|
+
d.intro(intro.flat());
|
|
119
|
+
d.ambient([d.loopTrack(halo, 'scale_x', (u) => 1 + 0.6 * Math.sin(u * Math.PI), 2.4), d.loopTrack(halo, 'scale_y', (u) => 1 + 0.6 * Math.sin(u * Math.PI), 2.4), d.loopTrack(halo, 'opacity', (u) => 0.9 * (1 - u), 2.4)], 'Live pulse', 2.4);
|
|
120
|
+
return d;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/* RECIPE: game-arcade
|
|
2
|
+
One-button arcade game as a hybrid native file (the `apps` topic method): tap or press Space
|
|
3
|
+
to rise, thread the gates, score. Ready → playing → game over → retry.
|
|
4
|
+
- World: one shared script in three named effect layers (Sky, Gates, Game logic), picked by
|
|
5
|
+
GAME.part; only the logic layer runs update(); state is kept per engine (NK_*), never global.
|
|
6
|
+
- Native: the player (moved by the logic with env.scene.set), the HUD bound to Text inputs,
|
|
7
|
+
start / game-over overlays parked below the artboard, a hit flash parked above it.
|
|
8
|
+
- State machine: `started` / `lost` triggers drive the Phase layer (a Number `phase` input mirrors
|
|
9
|
+
it for hosts); a `hit` trigger plays the flash. A full-screen hit area sets `tap`, which the logic reads and clears.
|
|
10
|
+
ADAPT: change TITLE, COLORS and TUNE (feel: gravity, flap, speed, gap). Keep the structure.
|
|
11
|
+
Run with build_from_script. */
|
|
12
|
+
|
|
13
|
+
const TITLE = { name: 'Drift', hint: 'Tap or press Space to rise', over: 'Signal lost', retry: 'Tap to fly again' };
|
|
14
|
+
const COLORS = { bg: '#05070D', sky: '#0B1730', ink: '#EAF1FA', muted: '#7F93B0', accent: '#5CE1E6', gate: '#16243B', edge: '#5CE1E6', flash: '#FFFFFF' };
|
|
15
|
+
const TUNE = { gravity: 1500, flap: 520, speed: 260, gap: 210, spacing: 360 };
|
|
16
|
+
|
|
17
|
+
const W = 1280, H = 720, C = COLORS;
|
|
18
|
+
const d = exode.artboard({ name: `${TITLE.name} game`, width: W, height: H, background: C.bg, ease: exode.ease.outQuart });
|
|
19
|
+
const phase = d.input('phase', 'Number', 0);
|
|
20
|
+
const tap = d.input('tap', 'Number', 0);
|
|
21
|
+
d.input('engineKey', 'Text', '');
|
|
22
|
+
const scoreIn = d.input('scoreText', 'Text', '0');
|
|
23
|
+
const bestIn = d.input('bestText', 'Text', 'Best 0');
|
|
24
|
+
d.input('hit', 'Trigger');
|
|
25
|
+
d.input('started', 'Trigger');
|
|
26
|
+
d.input('lost', 'Trigger');
|
|
27
|
+
|
|
28
|
+
/* ── shared world script (one copy per layer, prefixed with its part) ───────────────────── */
|
|
29
|
+
const SHARED = `/* EXODE_KEEP_LIVE ${TITLE.name}: one script, three layers picked by GAME.part. Only 'logic' runs update(). */
|
|
30
|
+
var CFG = { W: ${W}, H: ${H}, ground: ${H - 64}, gravity: ${TUNE.gravity}, flap: ${TUNE.flap}, speed: ${TUNE.speed}, gap: ${TUNE.gap}, spacing: ${TUNE.spacing}, gateW: 70, px: 360, r: 16 };
|
|
31
|
+
var COL = { sky: '${C.sky}', gate: '${C.gate}', edge: '${C.edge}', ink: '${C.ink}' };
|
|
32
|
+
function NK_root() { var G = typeof globalThis !== 'undefined' ? globalThis : window; return G.__exodeGameV1 || (G.__exodeGameV1 = {}); }
|
|
33
|
+
function NK_engine(env) {
|
|
34
|
+
if (!env || !env.input || !env.setInput) return 'still';
|
|
35
|
+
var k = env.input('engineKey');
|
|
36
|
+
if (typeof k === 'string' && k) return k;
|
|
37
|
+
k = 'e' + Math.floor(Math.random() * 1e9).toString(36);
|
|
38
|
+
env.setInput('engineKey', k);
|
|
39
|
+
return k;
|
|
40
|
+
}
|
|
41
|
+
function NK_key(env) { var k = env && env.input ? env.input('engineKey') : ''; return typeof k === 'string' && k ? k : 'still'; }
|
|
42
|
+
function NK_state(key) { var R = NK_root(); return R[key] || (R[key] = {}); }
|
|
43
|
+
function rnd(s) { s.seed = (s.seed * 16807) % 2147483647; return (s.seed - 1) / 2147483646; }
|
|
44
|
+
function reset(s) { s.y = CFG.H / 2; s.vy = 0; s.gates = []; s.score = 0; s.shown = -1; }
|
|
45
|
+
function spawn(s, x) { s.gates.push({ x: x, c: 200 + rnd(s) * (CFG.ground - 400), passed: false }); }
|
|
46
|
+
var PREVIEW = null;
|
|
47
|
+
function preview() { var s = { seed: 11, t: 0 }; reset(s); for (var i = 0; i < 4; i++) spawn(s, 620 + i * CFG.spacing); return s; }
|
|
48
|
+
|
|
49
|
+
function update(env, dt) {
|
|
50
|
+
if (GAME.part !== 'logic') return;
|
|
51
|
+
var s = NK_state(NK_engine(env));
|
|
52
|
+
if (!s.init) { s.init = true; s.seed = 11; s.t = 0; s.phase = 0; s.best = 0; reset(s); }
|
|
53
|
+
dt = Math.min(dt || 0, 1 / 30);
|
|
54
|
+
s.t += dt;
|
|
55
|
+
var tapped = (env.input('tap') || 0) > 0;
|
|
56
|
+
if (tapped) env.setInput('tap', 0);
|
|
57
|
+
if (env.scene.pressed(' ') || env.scene.pressed('Space') || env.scene.pressed('ArrowUp')) tapped = true;
|
|
58
|
+
|
|
59
|
+
if (s.phase === 0) {
|
|
60
|
+
s.y = CFG.H / 2 + Math.sin(s.t * 2.4) * 14;
|
|
61
|
+
if (tapped) start(env, s);
|
|
62
|
+
} else if (s.phase === 1) {
|
|
63
|
+
if (tapped) s.vy = 0 - CFG.flap;
|
|
64
|
+
s.vy += CFG.gravity * dt;
|
|
65
|
+
s.y += s.vy * dt;
|
|
66
|
+
var last = s.gates.length ? s.gates[s.gates.length - 1].x : 0;
|
|
67
|
+
if (!s.gates.length || last < CFG.W + 100 - CFG.spacing) spawn(s, s.gates.length ? last + CFG.spacing : CFG.W + 160);
|
|
68
|
+
for (var i = s.gates.length - 1; i >= 0; i--) {
|
|
69
|
+
var g = s.gates[i];
|
|
70
|
+
g.x -= CFG.speed * dt;
|
|
71
|
+
if (g.x < 0 - 120) { s.gates.splice(i, 1); continue; }
|
|
72
|
+
var near = Math.abs(g.x - CFG.px) < CFG.gateW / 2 + CFG.r;
|
|
73
|
+
if (near && (s.y - CFG.r < g.c - CFG.gap / 2 || s.y + CFG.r > g.c + CFG.gap / 2)) lose(env, s);
|
|
74
|
+
if (!g.passed && g.x + CFG.gateW / 2 < CFG.px - CFG.r) { g.passed = true; s.score += 1; }
|
|
75
|
+
}
|
|
76
|
+
if (s.y < CFG.r) { s.y = CFG.r; s.vy = Math.max(0, s.vy); } /* the ceiling is soft: only the ground and gates end a run */
|
|
77
|
+
if (s.y + CFG.r > CFG.ground) lose(env, s);
|
|
78
|
+
} else if (s.phase === 3) {
|
|
79
|
+
if (s.y + CFG.r < CFG.ground) { s.vy += CFG.gravity * dt; s.y = Math.min(CFG.ground - CFG.r, s.y + s.vy * dt); }
|
|
80
|
+
if (tapped && s.t - s.lostAt > 0.6) start(env, s);
|
|
81
|
+
}
|
|
82
|
+
if (s.score !== s.shown) { s.shown = s.score; env.setInput('scoreText', String(s.score)); }
|
|
83
|
+
env.scene.set('player', 'y', s.y);
|
|
84
|
+
env.scene.set('player', 'rotation', Math.max(0 - 25, Math.min(70, s.vy * 0.06)));
|
|
85
|
+
}
|
|
86
|
+
function start(env, s) { reset(s); s.phase = 1; s.vy = 0 - CFG.flap; env.setInput('phase', 1); env.scene.fire('started'); }
|
|
87
|
+
function lose(env, s) {
|
|
88
|
+
if (s.phase !== 1) return;
|
|
89
|
+
s.phase = 3; s.lostAt = s.t;
|
|
90
|
+
if (s.score > s.best) { s.best = s.score; env.setInput('bestText', 'Best ' + s.best); }
|
|
91
|
+
env.setInput('phase', 3);
|
|
92
|
+
env.scene.fire('lost');
|
|
93
|
+
env.scene.fire('hit');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function render(ctx, env) {
|
|
97
|
+
var s = NK_state(NK_key(env));
|
|
98
|
+
if (!s.init) s = PREVIEW || (PREVIEW = preview());
|
|
99
|
+
var t = s.init ? s.t : (env.time || 0);
|
|
100
|
+
ctx.save();
|
|
101
|
+
ctx.translate(0 - env.width / 2, 0 - env.height / 2);
|
|
102
|
+
if (GAME.part === 'sky') drawSky(ctx, t);
|
|
103
|
+
if (GAME.part === 'gates') drawGates(ctx, s);
|
|
104
|
+
ctx.restore();
|
|
105
|
+
}
|
|
106
|
+
function drawSky(ctx, t) {
|
|
107
|
+
var g = ctx.createLinearGradient(0, 0, 0, CFG.H);
|
|
108
|
+
g.addColorStop(0, 'rgba(0,0,0,0)'); g.addColorStop(1, COL.sky);
|
|
109
|
+
ctx.fillStyle = g; ctx.fillRect(0, 0, CFG.W, CFG.H);
|
|
110
|
+
for (var i = 0; i < 90; i++) {
|
|
111
|
+
var depth = 0.2 + ((i * 37) % 10) / 12;
|
|
112
|
+
var x = ((i * 173.3) % CFG.W - t * CFG.speed * 0.12 * depth) % CFG.W;
|
|
113
|
+
if (x < 0) x += CFG.W;
|
|
114
|
+
var y = (i * 97.7) % (CFG.ground - 40);
|
|
115
|
+
ctx.globalAlpha = 0.25 + depth * 0.5;
|
|
116
|
+
ctx.fillStyle = COL.ink;
|
|
117
|
+
ctx.fillRect(x, y, 1.2 + depth, 1.2 + depth);
|
|
118
|
+
}
|
|
119
|
+
ctx.globalAlpha = 1;
|
|
120
|
+
ctx.fillStyle = COL.edge; ctx.globalAlpha = 0.5; ctx.fillRect(0, CFG.ground, CFG.W, 1); ctx.globalAlpha = 1;
|
|
121
|
+
}
|
|
122
|
+
function drawGates(ctx, s) {
|
|
123
|
+
for (var i = 0; i < s.gates.length; i++) {
|
|
124
|
+
var g = s.gates[i], x = g.x - CFG.gateW / 2, top = g.c - CFG.gap / 2, bot = g.c + CFG.gap / 2;
|
|
125
|
+
ctx.fillStyle = COL.gate;
|
|
126
|
+
ctx.fillRect(x, 0 - 10, CFG.gateW, top + 10);
|
|
127
|
+
ctx.fillRect(x, bot, CFG.gateW, CFG.ground - bot);
|
|
128
|
+
ctx.shadowColor = COL.edge; ctx.shadowBlur = 18;
|
|
129
|
+
ctx.fillStyle = COL.edge;
|
|
130
|
+
ctx.fillRect(x - 6, top - 6, CFG.gateW + 12, 6);
|
|
131
|
+
ctx.fillRect(x - 6, bot, CFG.gateW + 12, 6);
|
|
132
|
+
ctx.shadowBlur = 0;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
const layer = (name, part) => {
|
|
137
|
+
const r = d.rect({ name, x: W / 2, y: H / 2, w: W, h: H });
|
|
138
|
+
d.effect(r, `var GAME = { part: '${part}' };\n` + SHARED, { name: `${name} effect` });
|
|
139
|
+
return r;
|
|
140
|
+
};
|
|
141
|
+
layer('Sky', 'sky');
|
|
142
|
+
layer('Gates', 'gates');
|
|
143
|
+
layer('Game logic', 'logic');
|
|
144
|
+
|
|
145
|
+
/* ── native player ─────────────────────────────────────────────────────────────────────── */
|
|
146
|
+
const player = d.group({ id: 'player', name: 'Player', x: 360, y: H / 2, w: 60, h: 60 });
|
|
147
|
+
d.glow({ name: 'Player / glow', parent: player, x: 0, y: 0, size: 96, color: C.accent, strength: 0.45 });
|
|
148
|
+
d.ellipse({ name: 'Player / core', parent: player, x: 0, y: 0, size: 32, fill: C.accent, stroke: C.ink, strokeWidth: 2 });
|
|
149
|
+
d.ellipse({ name: 'Player / eye', parent: player, x: 6, y: -4, size: 8, fill: C.bg });
|
|
150
|
+
|
|
151
|
+
/* ── native HUD ────────────────────────────────────────────────────────────────────────── */
|
|
152
|
+
const hud = d.group({ name: 'HUD', x: W / 2, y: 64, w: W - 96, h: 60 });
|
|
153
|
+
const score = d.text('0', { name: 'HUD / score', parent: hud, x: 0, y: 0, size: 48, weight: 700, color: C.ink, align: 'center', w: 200 });
|
|
154
|
+
score.geometry.textInputId = scoreIn;
|
|
155
|
+
const best = d.text('Best 0', { name: 'HUD / best', parent: hud, right: (W - 96) / 2, y: 0, size: 14, weight: 600, color: C.muted, align: 'right', w: 200 });
|
|
156
|
+
best.geometry.textInputId = bestIn;
|
|
157
|
+
d.text(TITLE.name.toUpperCase(), { name: 'HUD / title', parent: hud, left: -(W - 96) / 2, y: 0, size: 14, weight: 700, letterSpacing: 4, color: C.muted, w: 200 });
|
|
158
|
+
|
|
159
|
+
/* ── overlays: parked below the artboard, brought home by the Phase layer ────────────────── */
|
|
160
|
+
/* parked apart (not stacked) so the design view shows both panels side by side below the artboard */
|
|
161
|
+
const PARK = H + 260, HOME = H / 2;
|
|
162
|
+
const startO = d.group({ name: 'Overlay · start', x: W / 2 - 320, y: PARK, w: 560, h: 220 });
|
|
163
|
+
d.rect({ name: 'Overlay · start / panel', parent: startO, x: 0, y: 0, w: 560, h: 220, r: 28, fill: C.sky, fillOpacity: 0.92, stroke: C.edge, strokeWidth: 1 });
|
|
164
|
+
d.text(TITLE.name, { name: 'Overlay · start / title', parent: startO, x: 0, y: -36, size: 64, weight: 700, color: C.ink, align: 'center', w: 500 });
|
|
165
|
+
d.text(TITLE.hint, { name: 'Overlay · start / hint', parent: startO, x: 0, y: 40, size: 18, color: C.accent, align: 'center', w: 500 });
|
|
166
|
+
const overO = d.group({ name: 'Overlay · game over', x: W / 2 + 320, y: PARK, w: 560, h: 240 });
|
|
167
|
+
d.rect({ name: 'Overlay · game over / panel', parent: overO, x: 0, y: 0, w: 560, h: 240, r: 28, fill: C.sky, fillOpacity: 0.94, stroke: C.edge, strokeWidth: 1 });
|
|
168
|
+
d.text(TITLE.over, { name: 'Overlay · game over / title', parent: overO, x: 0, y: -52, size: 44, weight: 700, color: C.ink, align: 'center', w: 500 });
|
|
169
|
+
const finalScore = d.text('0', { name: 'Overlay · game over / score', parent: overO, x: 0, y: 12, size: 40, weight: 700, color: C.accent, align: 'center', w: 300 });
|
|
170
|
+
finalScore.geometry.textInputId = scoreIn;
|
|
171
|
+
d.text(TITLE.retry, { name: 'Overlay · game over / retry', parent: overO, x: 0, y: 72, size: 17, color: C.muted, align: 'center', w: 500 });
|
|
172
|
+
|
|
173
|
+
const show = (g, t0 = 0) => [d.track(g, 'x', [[0, W / 2]]), d.track(g, 'y', [[0, PARK, 'linear'], [t0, PARK, exode.ease.outBack], [t0 + 0.55, HOME]]), d.track(g, 'opacity', [[0, 0, 'linear'], [t0, 0], [t0 + 0.3, 1]])];
|
|
174
|
+
const hide = (g) => [d.track(g, 'x', [[0, W / 2]]), d.track(g, 'y', [[0, HOME, exode.ease.in], [0.35, PARK]]), d.track(g, 'opacity', [[0, 1], [0.25, 0]])];
|
|
175
|
+
const parked = (g) => [d.track(g, 'x', [[0, g.transform.x]]), d.track(g, 'y', [[0, PARK]]), d.track(g, 'opacity', [[0, 0]])];
|
|
176
|
+
const aReady = d.anim('Phase · ready', [...show(startO, 0.2), ...parked(overO)]);
|
|
177
|
+
const aPlay = d.anim('Phase · playing', [...hide(startO), ...hide(overO)]);
|
|
178
|
+
const aLost = d.anim('Phase · lost', [...show(overO, 0.35), ...parked(startO)]);
|
|
179
|
+
/* Phase changes ride one-shot triggers: transitions are evaluated from ANY state, so a held
|
|
180
|
+
condition like phase == 1 aimed at two different states would flip between them every frame. */
|
|
181
|
+
d.layer('Phase', [
|
|
182
|
+
{ name: 'Ready', anim: aReady, on: { started: 'Playing' } },
|
|
183
|
+
{ name: 'Playing', anim: aPlay, on: { lost: 'Lost' } },
|
|
184
|
+
{ name: 'Lost', anim: aLost, on: { started: 'Playing' } },
|
|
185
|
+
]);
|
|
186
|
+
|
|
187
|
+
/* hit flash: parked above the artboard, swept in and faded by the `hit` trigger */
|
|
188
|
+
const flash = d.rect({ name: 'Hit flash', x: W / 2, y: -H / 2 - 20, w: W, h: H, fill: C.flash, fillOpacity: 1, opacity: 0 });
|
|
189
|
+
const aFlash = d.anim('Hit flash', [d.track(flash, 'y', [[0, H / 2, 'linear'], [0.3, H / 2, 'linear'], [0.31, -H / 2 - 20]]), d.track(flash, 'opacity', [[0, 0.55, exode.ease.out], [0.3, 0]])]);
|
|
190
|
+
const aFlashRest = d.anim('Hit flash rest', [d.track(flash, 'y', [[0, -H / 2 - 20]]), d.track(flash, 'opacity', [[0, 0]])]);
|
|
191
|
+
d.layer('Hit flash', [
|
|
192
|
+
{ name: 'Rest', anim: aFlashRest, on: { hit: 'Flash A' } },
|
|
193
|
+
{ name: 'Flash A', anim: aFlash, on: { hit: 'Flash B' } },
|
|
194
|
+
{ name: 'Flash B', anim: aFlash, on: { hit: 'Flash A' } },
|
|
195
|
+
]);
|
|
196
|
+
|
|
197
|
+
/* idle life: the player's glow breathes (the logic owns the player group's y/rotation) */
|
|
198
|
+
d.ambient([d.loopTrack('player_glow', 'scale_x', (u) => 1 + 0.12 * Math.sin(u * Math.PI * 2), 2.2), d.loopTrack('player_glow', 'scale_y', (u) => 1 + 0.12 * Math.sin(u * Math.PI * 2), 2.2)], 'Player glow', 2.2);
|
|
199
|
+
|
|
200
|
+
/* full-screen tap area, on top: every tap sets `tap`, which the logic reads and clears */
|
|
201
|
+
const hit = d.hit({ name: 'Tap area', x: W / 2, y: H / 2, w: W, h: H });
|
|
202
|
+
hit.interactions.push({ id: 'int_tap', event: 'onPointerDown', trigger: 'onPointerDown', triggers: ['onPointerDown'], action: 'Set Input', targetInputId: tap, value: 1, inputValue: 1 });
|
|
203
|
+
return d;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* RECIPE: hero-physics
|
|
2
|
+
Premium desktop website hero: nav, eyebrow, two-tone headline, subhead, two CTAs,
|
|
3
|
+
proof line, and a physics visual (labelled tiles that drop in, land with weight and
|
|
4
|
+
can be dragged) on a soft accent glow.
|
|
5
|
+
ADAPT: change BRAND, COPY, TILES and PALETTE. Keep the structure, spacing and motion.
|
|
6
|
+
Run with build_from_script. */
|
|
7
|
+
|
|
8
|
+
const BRAND = 'Northwind';
|
|
9
|
+
const COPY = {
|
|
10
|
+
eyebrow: 'AI LOGISTICS PLATFORM',
|
|
11
|
+
line1: 'Freight that',
|
|
12
|
+
line2: 'routes itself.', /* second line renders in the muted tone */
|
|
13
|
+
sub: 'Northwind plans, books and reroutes every shipment in real time, so delays are solved before anyone notices.',
|
|
14
|
+
primary: 'Book a demo',
|
|
15
|
+
secondary: 'See how it works',
|
|
16
|
+
proof: 'Trusted by 1,200 shippers · 40M parcels routed',
|
|
17
|
+
nav: ['Platform', 'Network', 'Pricing', 'Company'],
|
|
18
|
+
};
|
|
19
|
+
const TILES = ['Rotterdam', 'Shenzhen', 'Chicago', 'Santos', 'Dubai', 'Lagos', 'Busan', 'Antwerp'];
|
|
20
|
+
const PALETTE = 'midnight'; /* obsidian · midnight · graphite · aurora · (light: paper · bone · porcelain) */
|
|
21
|
+
|
|
22
|
+
const W = 1440, H = 900;
|
|
23
|
+
const P = exode.palette(PALETTE);
|
|
24
|
+
const d = exode.artboard({ name: `${BRAND} hero`, width: W, height: H, palette: PALETTE, ease: exode.ease.outQuart });
|
|
25
|
+
d.physics({ gravity: [0, 9.8], effects: { squash: { amount: 0.25 } } });
|
|
26
|
+
|
|
27
|
+
/* light and depth */
|
|
28
|
+
d.rect({ name: 'Backdrop', x: W / 2, y: H / 2, w: W, h: H, fill: exode.radial([P.surface, P.bg], [0.75, 0.2], 0.9) });
|
|
29
|
+
const glow = d.glow({ name: 'Accent glow', x: 1050, y: 560, size: 900, color: P.accent, strength: 0.22, scaleY: 0.7 });
|
|
30
|
+
d.rect({ name: 'Horizon line', x: W / 2, y: 820, w: W - 160, h: 1, fill: P.line });
|
|
31
|
+
|
|
32
|
+
/* nav */
|
|
33
|
+
const nav = d.group({ name: 'Nav', x: W / 2, y: 52, w: W - 160, h: 44 });
|
|
34
|
+
d.text(BRAND, { name: 'Logo', parent: nav, left: -(W - 160) / 2, y: 0, size: 19, weight: 700, color: P.ink });
|
|
35
|
+
COPY.nav.forEach((s, i) => d.text(s, { name: `Nav / ${s}`, parent: nav, x: 120 + i * 104, y: 0, size: 14, color: P.muted, align: 'center', w: 96 }));
|
|
36
|
+
d.button('Sign in', { name: 'Nav / Sign in button', parent: nav, x: (W - 160) / 2 - 52, y: 0, variant: 'secondary', size: 14, h: 40, color: P.ink });
|
|
37
|
+
|
|
38
|
+
/* copy column */
|
|
39
|
+
const L = 120;
|
|
40
|
+
const eyebrow = d.text(COPY.eyebrow, { name: 'Eyebrow', left: L, y: 268, size: 12, weight: 600, letterSpacing: 2.4, color: P.accent });
|
|
41
|
+
const h1 = d.text(COPY.line1, { name: 'Headline / line 1', left: L, y: 340, size: 76, weight: 600, color: P.ink, w: 640 });
|
|
42
|
+
const h2 = d.text(COPY.line2, { name: 'Headline / line 2', left: L, y: 420, size: 76, weight: 600, color: P.muted, w: 640 });
|
|
43
|
+
const sub = d.text(COPY.sub, { name: 'Subhead', left: L, y: 510, size: 18, color: P.muted, w: 520, lineHeight: 1.55 });
|
|
44
|
+
const ctas = d.group({ name: 'CTAs', x: L + 190, y: 604, w: 380, h: 52 });
|
|
45
|
+
d.button(COPY.primary, { name: 'Primary CTA', parent: ctas, x: -95, y: 0, fill: P.accent, color: P.onAccent, glow: true, onTap: 'primaryTap' });
|
|
46
|
+
d.button(COPY.secondary, { name: 'Secondary CTA', parent: ctas, x: 100, y: 0, variant: 'ghost', color: P.ink, onTap: 'secondaryTap' });
|
|
47
|
+
const proof = d.text(COPY.proof, { name: 'Proof line', left: L, y: 690, size: 13, color: P.muted });
|
|
48
|
+
|
|
49
|
+
/* physics visual: tiles fall in from above, land on the horizon and can be dragged */
|
|
50
|
+
d.walls({ inset: 80 });
|
|
51
|
+
const r = exode.rng(11);
|
|
52
|
+
TILES.forEach((label, i) => {
|
|
53
|
+
const w = 132 + label.length * 7, col = i % 4, row = Math.floor(i / 4);
|
|
54
|
+
const tile = d.rect({ name: `Tile / ${label}`, x: 840 + col * 140 + r.range(-20, 20), y: -90 - row * 170 - col * 60, w, h: 56, r: 14,
|
|
55
|
+
fill: i === 2 ? P.accent : P.raised, stroke: i === 2 ? undefined : P.line, strokeWidth: 1, rotation: r.range(-14, 14), shadow: { blur: 20, offsetY: 10, opacity: 35 } });
|
|
56
|
+
d.ellipse({ name: `Tile / ${label} dot`, parent: tile, x: -w / 2 + 22, y: 0, size: 8, fill: i === 2 ? P.onAccent : P.accent });
|
|
57
|
+
d.text(label, { name: `Tile / ${label} label`, parent: tile, x: 10, y: 0, size: 15, weight: 600, color: i === 2 ? P.onAccent : P.ink, align: 'center', w: w - 30 });
|
|
58
|
+
d.body(tile, { restitution: 0.15, density: 0.002, air: 0.02, friction: 0.7, draggable: true });
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/* motion: staggered entrance, then a slow breathing light */
|
|
62
|
+
d.intro(d.reveal([eyebrow, h1, h2, sub, ctas, proof], { dy: 26, step: 0.07, duration: 0.9 }));
|
|
63
|
+
d.ambient([d.loopTrack(glow, 'opacity', (u) => 0.75 + 0.25 * Math.sin(u * Math.PI * 2), 8)], 'Glow breathe', 8);
|
|
64
|
+
d.input('headline', 'Text', COPY.line1);
|
|
65
|
+
return d;
|