Skip to main content

Crate oxframe

Crate oxframe 

Source
Expand description

§oxframe

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 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§

prelude
Everything a scene usually needs: use oxframe::prelude::*;.
presets
Named Bézier presets (values follow easings.net / CSS).

Macros§

color
color!("#e13238") — a Color checked at compile time. Accepts #rgb, #rgba, #rrggbb and #rrggbbaa.
ease
ease!("slide") or ease!("slide", presets::OUT_BACK) — a named Bézier easing editable in the curve editor; the value lives in meta.json.
tune
tune!("speed", 1.4) — a number editable with a slider in the inspector; the value lives in meta.json.

Structs§

Affine
A 2D affine transform.
BezPath
A Bézier path.
Circle
Handle to a Circle node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
Code
Handle to a Code node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
CodeTheme
Colors of a code theme.
Color
sRGB color with straight (non-premultiplied) alpha, components in 0..=1.
CubicBezier
CSS-style cubic Bézier easing with control points (x1, y1), (x2, y2); the end points are fixed at (0, 0) and (1, 1).
Engine
Runs a Project: knows the length of every scene and produces the state of any global frame.
Executor
Deterministic single-threaded executor: one step is 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.
Gradient
A gradient in the node’s local coordinates (origin at the node center).
Grid
Handle to a Grid node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
Group
Handle to a Group node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
Img
Handle to a Img node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
JoinHandle
Awaiting it waits for the spawned task to finish.
Layout
Handle to a Layout node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
Line
Handle to a Line node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
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 Path node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
Point
A 2D point.
Polygon
Handle to a Polygon node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
PreviewAdapter
An Engine plus a renderer, as seen by the preview session.
Project
A sequence of scenes plus output settings. Call main() from your binary’s main to get the render/info commands.
Rect
Handle to a Rect node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
RichSpan
A run of text with its own look; unset fields use the node’s style.
SceneDef
A scene produced by #[oxframe::scene].
SceneGraph
Arena of nodes for one scene run. Node 0 is the view (root).
Signal
A reactive value.
SourceLocation
Where a scene was defined; used to find its <name>.meta.json.
Star
Handle to a Star node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
Transform
Decomposed 2D transform. Interpolates component-wise, so rotations turn instead of shearing through the matrix midpoint.
Tween
Animates a Signal towards a target. Created by Signal::to.
Txt
Handle to a Txt node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
Vec2
A 2D vector.
View
Root of a scene. Origin is the center of the frame, y points down.

Enums§

BlendMode
How a node’s layer is composited onto what is below it.
Direction
Main axis of a Layout.
EngineError
Why a project could not be loaded.
Justify
Main-axis distribution of children; only matters with a fixed size.
LayoutAlign
Cross-axis alignment of children in a Layout.
LineCap
Shape of the ends of open outlines.
LineJoin
Shape of outline corners.
MetaSection
A section of meta.json, for Engine::edit_meta.
TextAlign
Horizontal alignment of lines.

Constants§

MONO
Built-in monospace family (JetBrains Mono).
SANS
Built-in sans-serif family (Inter).

Traits§

Ease
Maps linear progress t ∈ [0, 1] to eased progress.
Lerp
Linear interpolation; t is already eased and may leave [0, 1] (e.g. with back easings).
NodeBuilder
Describes a node before it is added to the scene.

Functions§

all
Runs futures concurrently and completes when all of them have. Takes a tuple of up to 12 futures and returns a tuple of their outputs.
all_vec
all for a dynamic number of futures.
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; default is recorded there on first use. Use through the ease! 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.
next_frame
Yields until the next frame.
now
Time of the current frame, frame / fps seconds.
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.
sequence
Starts the futures one after another with delay seconds between their starts; they then run concurrently. Completes when all have.
span
Shorthand for RichSpan::new.
spawn
Runs fut in the background, starting this frame. Background tasks stop when the scene ends.
time
Virtual time of the current task — where the next animation starts.
tunable
Value of tunable name from meta.json; default is recorded there on first use. Use through the tune! macro.
wait_for
Waits seconds of scene time.
wait_until
Waits until marker name from meta.json. On first encounter the current time becomes the marker’s default, so it does not wait at all.
with_rng
Runs f with the scene’s random generator. It is seeded from the project seed and the scene name, so results are reproducible; never use rand::rng() or other entropy sources in scenes.

Type Aliases§

BoxFuture
A boxed scene future, e.g. for sequence.

Attribute Macros§

scene
Turns async fn intro(view: View) { .. } into fn intro() -> SceneDef.