Skip to main content

Crate oxframe_core

Crate oxframe_core 

Source
Expand description

Core of oxframe: signals, tweens, easing and a deterministic, single-threaded coroutine executor.

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.

An animation is an async fn; every .await on a Tween, wait_for or next_frame is a frame boundary. One poll of the root future is exactly one frame, with a fixed dt = 1 / fps.

Re-exports§

pub use rand;
pub use self;

Modules§

presets
Named Bézier presets (values follow easings.net / CSS).

Structs§

Affine
A 2D affine transform.
All
Future returned by all.
Any
Future returned by any.
BezPath
A Bézier path.
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).
Delayed
A future that starts after a wait; see sequence.
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).
Image
8-bit sRGB RGBA, straight alpha, row-major, no padding.
JoinHandle
Awaiting it waits for the spawned task to finish.
Point
A 2D point.
Signal
A reactive value.
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.
Vec2
A 2D vector.
VecBranches
Branches of all or any over many futures of one type.

Enums§

BlendMode
How a node’s layer is composited onto what is below it.
GradientKind
Shape of a Gradient.

Constants§

TIME_EPSILON
Times are compared with this tolerance so that sums of f64 seconds (0.1 + 0.2) land on the frame they were meant for.

Traits§

Animation
Anything that can be awaited in a scene: a tween, wait_for, all(..), an async block… Every future is one; the trait exists for the error message when a closure returns something else.
Branches
Branches run by all and any. Implemented by the crate only.
Ease
Maps linear progress t ∈ [0, 1] to eased progress.
FrameSource
A timeline that can draw any of its frames: “give me frame n”.
IntoAll
What all and any accept: a tuple of futures, or a Vec, array or iterator of futures of one type.
Lerp
Linear interpolation; t is already eased and may leave [0, 1] (e.g. with back easings).
Seconds
A length of time. f64 means seconds; other types (a theme pace) convert.

Functions§

all
Runs animations at the same time and completes when all of them have.
all_vecDeprecated
all for 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; 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.
loop_while
Runs the animation make() returns again and again while keep_going() is true (checked before each run). Usually spawned for a background loop: spawn(loop_while(|| true, || pulse.scale().to(1.1, 0.5))).
meta_snapshot
Copy of the running scene’s markers, eases and tunables.
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.
repeat
Runs the animation make() returns times times in a row.
sequence
Starts animations one after another, delay seconds apart; they then run concurrently. Completes when all have. Takes a Vec, an array or an iterator of animations of one type. For “the same animation on many nodes”, stagger reads better.
spawn
Runs fut in the background, starting this frame. Background tasks stop when the scene ends.
stagger
Runs animate on every item, starting each delay seconds 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 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.