gioser

tawasuyu/llimphi

Sovereign retained-mode GPU UI framework in Rust (wgpu+vello+taffy+parley), Elm loop, 40+ widgets.

Rust 484Markdown 258TOML 131RON 38118 Sutichaykuna

⎇ main llimphi-motion/README.md Markdown · 47 siq'ikuna · 1.3 KB Ñawpa willay ch'uya

chore: refresco desde el monorepo — 27 crates nuevos (anim, lottie, svg, mesh, image, layer, test, wire-view, widgets rag-sidebar/router/lazy-list/rive-button) y sync de los 95 existentes 93253cc22 · Sergio ·

1# llimphi-motion
2
3Simple animation over Llimphi's Elm loop.
4
5Llimphi is pure Elm: `update(msg) -> model`. To animate a value over time (an
6alpha rising from 0 to 1, a position sliding) the app keeps a `Tween` in its
7model and asks the `Handle` to dispatch a `Msg::Tick` periodically (every ~16 ms)
8until the animation ends. Each `update` reads `tween.value()` and the `view`
9paints it.
10
11This crate is deliberately tiny:
12
13- `Lerp` — generic linear interpolation (impls for `f32`, `(f32, f32)` and
14  `Color`).
15- `Tween` — timed interpolation with easing between two values.
16- `animate` — a helper that starts a self-sufficient tick loop over a `Handle`.
17
18The canonical durations and easings live in `llimphi_theme::motion`.
19
20## Typical pattern
21
22```ignore
23use llimphi_motion::{Tween, animate};
24use llimphi_theme::motion;
25
26enum Msg { ToastShow, Tick, ToastHidden }
27struct Model { toast_alpha: Tween<f32> }
28
29// update:
30Msg::ToastShow => {
31    model.toast_alpha = Tween::new(0.0, 1.0, motion::NORMAL, motion::ease_out_cubic);
32    animate(handle, motion::NORMAL, || Msg::Tick);
33    model
34}
35Msg::Tick => {
36    // The internal loop ends by itself once the tween is done;
37    // the `view` already reads the current alpha.
38    model
39}
40
41// view:
42toast_view().alpha(model.toast_alpha.value())
43```
44
45---
46
47Part of **llimphi** — see [llimphi](../README.md).

README.md

llimphi-motion

Simple animation over Llimphi's Elm loop.

Llimphi is pure Elm: update(msg) -> model. To animate a value over time (an alpha rising from 0 to 1, a position sliding) the app keeps a Tween in its model and asks the Handle to dispatch a Msg::Tick periodically (every ~16 ms) until the animation ends. Each update reads tween.value() and the view paints it.

This crate is deliberately tiny:

The canonical durations and easings live in llimphi_theme::motion.

Typical pattern

use llimphi_motion::{Tween, animate};
use llimphi_theme::motion;

enum Msg { ToastShow, Tick, ToastHidden }
struct Model { toast_alpha: Tween<f32> }

// update:
Msg::ToastShow => {
    model.toast_alpha = Tween::new(0.0, 1.0, motion::NORMAL, motion::ease_out_cubic);
    animate(handle, motion::NORMAL, || Msg::Tick);
    model
}
Msg::Tick => {
    // The internal loop ends by itself once the tween is done;
    // the `view` already reads the current alpha.
    model
}

// view:
toast_view().alpha(model.toast_alpha.value())

Part of llimphi — see llimphi.