Two ECS-native, deterministic namespaces for 2D motion, driven off the fixed
frame clock so replays and lockstep netcode reproduce every frame and every
eased value exactly. Both are pure computed-inline Q16.16 / integer math (no new
runtime, no heap) — the game stores a timer on a component and calls these each
frame, exactly the way Collision.* / Grid.* are used.
Anim.* — spritesheet frame animation:
- Anim.frame(timer,fps,count) -> int looping frame index
- Anim.once(timer,fps,count) -> int one-shot, clamps on the last frame
- Anim.pingpong(timer,fps,count) -> int bounce 0..count-1..0
- Anim.finished(timer,fps,count) -> bool has a one-shot run past its end?
- Anim.duration(fps,count) -> fixed seconds for one cycle
- Anim.cell_x/cell_y(frame,cols,cell) -> int source rect on a grid sheet
Tween.* — value interpolation over a timeline:
- Tween.progress/loop/yoyo(timer,duration) -> fixed normalized amount
- Tween.done(timer,duration) -> bool
- Tween.ease(t, mode) -> fixed shape by a literal curve 0..6,
the same curves as Ease.* (now
factored into a shared ease_eval)
- Tween.number/round/point/tint(from,to,t) blend a fixed / int / Vector / color
The typed blends reuse the existing fixed / Vector / color helpers, and
Tween.ease shares Ease.*'s exact formulas via the new ease_eval(mode,t) — one
source of truth for every easing curve in the engine.
examples/library/anim.ludic asserts 34 cases (frame math, clamping, ping-pong,
cell geometry, timeline clamp/loop/yoyo, rounding, color/vector blends, and
Ease.in == Tween.ease(.,1)); wired into x test (now 62 passed). Docs: Anim +
Tween sections with 16 per-symbol pages, inventory/coverage green. Seed
reseeded; the C-free bootstrap fixpoint holds.
The stateful sugar the proposal sketches (named clips, Anim.play, fluent
Tween.chain/parallel handles, and an auto-injected advance system) is deliberately
left as a follow-up — this lands the deterministic math core both halves stand on.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
29 lines
988 B
Markdown
29 lines
988 B
Markdown
---
|
|
id: tween-tint
|
|
name: Tween.tint
|
|
category: tween
|
|
kind: namespace-method
|
|
tokens: Tween.tint
|
|
sig: Tween.tint(from, to, t) -> int
|
|
tip: Per-channel blend of two colors by amount t.
|
|
order: 9
|
|
ns: Tween
|
|
member: tint
|
|
---
|
|
|
|
Blends two colors (<code>0x00RRGGBB</code> ints) channel by channel by amount <code>t</code> — the color equivalent of <a href="tween-number"><code>Tween.number</code></a>. Fade a sprite to white on hit, cross-fade a sky, or pulse a UI accent. Matches <a href="color-lerp"><code>Color.lerp</code></a>, ready for an eased <code>t</code> from <a href="tween-ease"><code>Tween.ease</code></a>.
|
|
|
|
Parameters:
|
|
- `from` — the color at `t = 0` (an `int`, `0x00RRGGBB`)
|
|
- `to` — the color at `t = 1` (an `int`, `0x00RRGGBB`)
|
|
- `t` — the blend amount (a `fixed`, usually 0..1)
|
|
|
|
```ludic
|
|
program Demo {
|
|
handler Run phase Update {
|
|
let t = Tween.progress(fixed(1), fixed(2))
|
|
let c = Tween.tint(Color.rgb(0, 0, 0), Color.rgb(255, 255, 255), t)
|
|
print(c)
|
|
}
|
|
}
|
|
```
|