Expand description
§oxframe
Status: oxframe is under very active development. The API is not stable yet and may change from version to version. Pin the exact version in your Cargo.toml and check the changelog before upgrading.
Procedural animation modelled after Motion Canvas: a scene is an
async fn, and every .await on an animation is a frame boundary.
use oxframe::prelude::*;
#[oxframe::scene]
async fn intro(view: View) {
let r = view.add(Rect::new().size(200.0).x(-300.0).fill(color!("#e13238")));
all((r.x().to(300.0, 1.0), r.radius().to(100.0, 1.0))).await;
}
fn main() {
Project::new("intro").scene(intro()).main();
}Re-exports§
pub use Accent;pub use Background;pub use Danger;pub use Fast;pub use Lg;pub use Md;pub use Muted;pub use Normal;pub use OnAccent;pub use Slow;pub use Sm;pub use Success;pub use Surface;pub use Text;pub use Warning;pub use Xl;pub use Xs;pub use oxframe_2d as nodes;pub use oxframe_core as core;pub use oxframe_protocol as protocol;pub use oxframe_render as render;pub use oxframe_text as text;
Modules§
- feedback
checkandinspect: a storyboard, a visual-lint report, and a scene dump.- lint
- Visual lint over sampled scene graphs. Pure: no rendering, no files.
- prelude
- Everything a scene usually needs:
use oxframe::prelude::*;. - presets
- Named Bézier presets (values follow easings.net / CSS).
Macros§
- color
color!("#e13238")— aColorchecked at compile time. Accepts#rgb,#rgba,#rrggbband#rrggbbaa.- ease
ease!("slide")orease!("slide", presets::OUT_BACK)— a named Bézier easing editable in the curve editor; the value lives inmeta.json.- tune
tune!("speed", 1.4)— a number editable with a slider in the inspector; the value lives inmeta.json.
Structs§
- Affine
- A 2D affine transform.
- BezPath
- A Bézier path.
- Bullet
List - Items appear one per
next, afterentershows the stack. - Callout
- A caption above
target, with an arrow pointing down at it.nextreveals the caption; the arrow comes in withenter. - Camera
- Handle to a
Cameranode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Chapter
Marker - A short label pinned to the top safe area.
- Circle
- Handle to a
Circlenode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Code
- Handle to a
Codenode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Code
Explainer - Code with a caption.
entershows the code. Eachnextfocuses one step and sets the caption. - Code
Theme - Colors of a code theme.
- Color
- sRGB color with straight (non-premultiplied) alpha, components in
0..=1. - Cubic
Bezier - CSS-style cubic Bézier easing with control points
(x1, y1),(x2, y2); the end points are fixed at(0, 0)and(1, 1). - EndCard
- Closing card.
nextreveals the note. - Engine
- Runs a
Project: knows the length of every scene and produces the state of any global frame. - Executor
- Deterministic single-threaded executor: one
stepis one frame. The root future and every spawned task are polled once per step, in a fixed order (root, then tasks in spawn order). No wakers, no clocks, no threads — the same input always produces the same frames. - Flow
Diagram - Nodes and arrows. The diagram places itself: left to right, or top to
bottom after
down.nexthighlights the next node. - Gradient
- A gradient in the node’s local coordinates (origin at the node center).
- Grid
- Handle to a
Gridnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Group
- Handle to a
Groupnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Img
- Handle to a
Imgnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Join
Handle - Awaiting it waits for the spawned task to finish.
- Layout
- Handle to a
Layoutnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Line
- Handle to a
Linenode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Lower
Third - Name and role pinned to the bottom safe area.
nextreveals the role. - Motion
- Durations in seconds and the eases for entering, leaving and emphasis.
- Node
- Untyped node handle with the properties every node has.
- NodeId
- Index of a node in its
SceneGraph. Assigned in creation order, so it is deterministic too. - Path
- Handle to a
Pathnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Point
- A 2D point.
- Polygon
- Handle to a
Polygonnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Preview
Adapter - An
Engineplus a renderer, as seen by the preview session. - Project
- A sequence of scenes plus output settings. Call
main()from your binary’smainto get therender/infocommands. - Rect
- Handle to a
Rectnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Rich
Span - A run of text with its own look; unset fields use the node’s style.
- Safe
Area - The rectangle
to_edgekeeps inside, in scene coordinates (origin at the center, y down). - Scene
Def - A scene produced by
#[oxframe::scene]. - Scene
Graph - Arena of nodes for one scene run. Node 0 is the view (root).
- Signal
- A reactive value.
- Source
Location - Where a scene was defined; used to find its
<name>.meta.json. - Star
- Handle to a
Starnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Theme
- Colors, type, space, radii, shadows and motion for one look.
- Title
Card - A centered title.
entershows the card and the title,nextshows the subtitle. - Transform
- Decomposed 2D transform. Interpolates component-wise, so rotations turn instead of shearing through the matrix midpoint.
- Tween
- Animates a
Signaltowards a target. Created bySignal::to. - Txt
- Handle to a
Txtnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Vec2
- A 2D vector.
- View
- Root of a scene. Origin is the center of the frame, y points down.
Enums§
- Aspect
- A frame shape. The project’s longer side stays the long side.
- Blend
Mode - How a node’s layer is composited onto what is below it.
- Direction
- Main axis of a
Layout. - Edge
- An edge of a node or of the safe area.
- Engine
Error - Why a project could not be loaded.
- Ink
- A color role. Use it wherever a
Coloris accepted:.fill(Accent). - Justify
- Main-axis distribution of children; only matters with a fixed size.
- Layout
Align - Cross-axis alignment of children in a
Layout. - LineCap
- Shape of the ends of open outlines.
- Line
Join - Shape of outline corners.
- Meta
Section - A section of
meta.json, forEngine::edit_meta. - Pace
- How long a motion token lasts:
.to(1.0, Normal). - Side
- Which side of a neighbor
Node::next_touses. - Span
- A length in pixels, or a percentage of the frame (or of a sized parent).
- Step
- A step on the space, radius and shadow scales:
.padding(Md),.radius(Lg). - Text
Align - Horizontal alignment of lines.
Constants§
Traits§
- Ease
- Maps linear progress
t ∈ [0, 1]to eased progress. - Lerp
- Linear interpolation;
tis already eased and may leave[0, 1](e.g. with back easings). - Node
Builder - Describes a node before it is added to the scene.
- Percent
- A number that can be a percentage.
pct(80)andpct(80.0)are the same.
Functions§
- all
- Runs animations at the same time and completes when all of them have.
- all_vec
Deprecated allfor boxed futures.- any
- Runs animations at the same time and completes as soon as the first one
does; the others stop where they are. Returns the index of the one that
finished. Takes the same arguments as
all. - bounce_
in - Bounces before leaving.
- bounce_
in_ out - Bounces at both ends.
- bounce_
out - Bounces into place, like a dropped ball.
- dt
- Duration of one frame in seconds,
1 / fps. - ease_
named - Named easing from
meta.json;defaultis recorded there on first use. Use through theease!macro. - elastic_
in - Oscillates before leaving, like a spring being wound.
- elastic_
in_ out - Spring at both ends.
- elastic_
out - Overshoots and oscillates into place, like a spring.
- fps
- Frames per second of the running project.
- frame
- Index of the frame being computed.
- loop_
while - Runs the animation
make()returns again and again whilekeep_going()is true (checked before each run). Usuallyspawned for a background loop:spawn(loop_while(|| true, || pulse.scale().to(1.1, 0.5))). - next_
frame - Yields until the next frame.
- now
- Time of the current frame,
frame / fpsseconds. - pct
80percent of the frame, or of the parent when it has a fixed size.- random
- Uniform random number in
[0, 1)from the scene’s seeded generator. - random_
range - Uniform random number in
[min, max)from the scene’s seeded generator. - register_
font - Registers a font (TTF/OTF/TTC bytes, e.g. from
include_bytes!). Returns the family names it provides. - repeat
- Runs the animation
make()returnstimestimes in a row. - sequence
- Starts animations one after another,
delayseconds apart; they then run concurrently. Completes when all have. Takes aVec, an array or an iterator of animations of one type. For “the same animation on many nodes”,staggerreads better. - span
- Shorthand for
RichSpan::new. - spawn
- Runs
futin the background, starting this frame. Background tasks stop when the scene ends. - stagger
- Runs
animateon every item, starting eachdelayseconds after the previous one; completes when all have finished: - time
- Virtual time of the current task — where the next animation starts.
- tunable
- Value of tunable
namefrommeta.json;defaultis recorded there on first use. Use through thetune!macro. - wait_
for - Waits
secondsof scene time. - wait_
until - Waits until marker
namefrommeta.json. On first encounter the current time becomes the marker’s default, so it does not wait at all. - with_
rng - Runs
fwith the scene’s random generator. It is seeded from the project seed and the scene name, so results are reproducible; never userand::rng()or other entropy sources in scenes.
Type Aliases§
Attribute Macros§
- scene
- Turns
async fn intro(view: View) { .. }intofn intro() -> SceneDef.