Expand description
2D scene graph of 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.
Scene code creates nodes with builders (Rect::new().width(100.0)) and
adds them with Node::add (view.add(..)), which returns a Copy
handle whose zero-argument methods of the same names return
Signals:
ⓘ
let r = view.add(Rect::new().size(200.0).x(-300.0));
r.x().to(300.0, 1.0).await;Renderers consume a flat DrawItem list produced by
SceneGraph::draw_list, so every backend draws exactly the same thing.
Re-exports§
pub use builder::CameraBuilder;pub use builder::CircleBuilder;pub use builder::CodeBuilder;pub use builder::CustomBuilder;pub use builder::EffectBuilder;pub use builder::GridBuilder;pub use builder::GroupBuilder;pub use builder::ImgBuilder;pub use builder::LayoutBuilder;pub use builder::LineBuilder;pub use builder::NodeBuilder;pub use builder::ParticlesBuilder;pub use builder::PathBuilder;pub use builder::PolygonBuilder;pub use builder::RectBuilder;pub use builder::ShaderBuilder;pub use builder::StarBuilder;pub use builder::TxtBuilder;pub use graph::Direction;pub use graph::InspectNode;pub use graph::Justify;pub use graph::LayoutAlign;pub use graph::NodeId;pub use graph::SceneGraph;pub use graph::add_site;pub use post::Input;pub use post::Shade;pub use post::ShadeOp;pub use post::apply as apply_shade;pub use theme::Corner;pub use theme::Ink;pub use theme::Ink::Accent;pub use theme::Ink::Background;pub use theme::Ink::Danger;pub use theme::Ink::Muted;pub use theme::Ink::OnAccent;pub use theme::Ink::Success;pub use theme::Ink::Surface;pub use theme::Ink::Text;pub use theme::Ink::Warning;pub use theme::IntoPaint;pub use theme::Len;pub use theme::Motion;pub use theme::Pace;pub use theme::Pace::Fast;pub use theme::Pace::Normal;pub use theme::Pace::Slow;pub use theme::Scale;pub use theme::ShadowSpec;pub use theme::Step;pub use theme::Step::Lg;pub use theme::Step::Md;pub use theme::Step::Sm;pub use theme::Step::Xl;pub use theme::Step::Xs;pub use theme::Theme;pub use theme::TypeRole;pub use theme::TypeScale;pub use theme::TypeStyle;
Modules§
- post
- Pixel shaders that read what was drawn: the frame before a node, or the node’s own layer.
Structs§
- Camera
- Handle to a
Cameranode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Camera
Builder - A camera: everything added to it is seen through it, so animating its
x/y(the point it looks at),zoomandrotationpans, zooms and turns the view. Nodes added to the view itself stay on screen (titles, captions, a HUD). - Circle
- Handle to a
Circlenode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Circle
Builder - Builder for a
Circlenode: set the initial values, then pass it toadd. - Code
- Handle to a
Codenode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Code
Builder - Builder for a
Codenode: set the initial values, then pass it toadd. - Code
Text - The source of a
Codenode. - Code
Theme - Colors of a code theme.
- Code
Tween - Diff tween returned by
CodeText::to,Code::insert,Code::removeandCode::replace. - Color
- sRGB color with straight (non-premultiplied) alpha, components in
0..=1. - Custom
- Handle to geometry drawn by a closure. Derefs to
Node. - Custom
Builder - Builder for a
Customnode. - DrawCtx
- What a
crate::Customnode draws into. Coordinates are the node’s own: the origin is the node center, positive x is right, positive y is down. - Draw
Item - One thing to paint, in local coordinates of
transform. Paints already include the node’s opacity (unless the node draws into a layer). - DrawRng
- A generator from
DrawCtx::rng. - Effect
- Handle to a node’s shader effect, from
Node::effect. - Effect
Builder - A shader effect for
Node::effect. - 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. - Grid
Builder - Builder for a
Gridnode: set the initial values, then pass it toadd. - Group
- Handle to a
Groupnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Group
Builder - Builder for a
Groupnode: set the initial values, then pass it toadd. - Img
- Handle to a
Imgnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - ImgBuilder
- Builder for a
Imgnode: set the initial values, then pass it toadd. - Inspect
Node - A node as
oxframe inspectand the visual linter see it. - Layer
- Everything drawn until the matching
Primitive::PopLayeris rendered into its own buffer, filtered, clipped and composited as a whole. - Layout
- Handle to a
Layoutnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Layout
Builder - Places children in a row or column. Children’s
x/ybecome offsets from their layout position. - Line
- Handle to a
Linenode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Line
Builder - Builder for a
Linenode: set the initial values, then pass it toadd. - 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. - Particles
- Handle to a
Particlesnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Particles
Builder - Builder for a
Particlesnode. - Pass
- One pass in topological order: contents before the composite that uses them.
- Path
- Handle to a
Pathnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Path
Builder - Builder for a
Pathnode: set the initial values, then pass it toadd. - Pen
- A shape just added to a
DrawCtx, waiting for a fill or a stroke. - Polygon
- Handle to a
Polygonnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Polygon
Builder - Builder for a
Polygonnode: set the initial values, then pass it toadd. - Raster
Image - Decoded raster image: sRGB RGBA8, straight alpha.
- Rect
- Handle to a
Rectnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Rect
Builder - Builder for a
Rectnode: set the initial values, then pass it toadd. - 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). - Scale
- Five pixel sizes, smallest to largest.
- Scene
Graph - Arena of nodes for one scene run. Node 0 is the view (root).
- Shader
- Handle to a WGSL shader. Derefs to
Node. - Shader
Builder - Builder for a
Shadernode. - Shader
Diag - A WGSL problem found while painting.
- Shadow
- Drop shadow of a layer.
- Shadow
Spec - A drop shadow.
- Signal
- A reactive value.
- Star
- Handle to a
Starnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - Star
Builder - Builder for a
Starnode: set the initial values, then pass it toadd. - Stroke
Style - How an outline is drawn.
- Svg
- Handle to a
Svgnode 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.
- Txt
- Handle to a
Txtnode in the scene: cheap to copy, its methods return the node’s properties asSignals. Derefs toNode. - TxtBuilder
- Builder for a
Txtnode: set the initial values, then pass it toadd. - Type
Scale - Display, headings, body, caption and code.
- Type
Style - One text role: size in pixels, weight 100..=900, line height as a multiple.
- Vector
Image - SVG converted to filled/stroked paths (gradients become their first stop color in v1).
- Vector
Shape - One painted path of a
VectorImage. - View
- Root of a scene. Origin is the center of the frame, y points down.
Enums§
- 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.
- Gradient
Kind - Shape of a
Gradient. - Image
Source - Decoded image data for an
Imgnode. - Ink
- A color role. Use it wherever a
Coloris accepted:.fill(Accent). - Justify
- Main-axis distribution of children; only matters with a fixed size.
- Lang
- Language for syntax highlighting.
- Layout
Align - Cross-axis alignment of children in a
Layout. - LineCap
- Shape of the ends of open outlines.
- Line
Join - Shape of outline corners.
- Pace
- How long a motion token lasts:
.to(1.0, Normal). - Paint
- What a shape is filled or stroked with.
- Pass
Kind - What a pass draws.
- Place
- How a node is placed. Resolved every frame; not set by scene code directly.
- Primitive
- A drawing operation in a
DrawItem. - 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.
- Type
Role - Which type role
.display(),.h1()and the others select.
Constants§
- MONO
- Built-in monospace family (JetBrains Mono).
- SANS
- Built-in sans-serif family (Inter).
- SLIDE_
DISTANCE - How far
Node::slide_instarts from the node’s place, in pixels.
Traits§
- Corner
- A corner radius: pixels, or a
Stepon the radius scale. - Into
Paint - Something that can be used as a color: a
Coloror anInk. - Len
- A padding, gap or margin: pixels, or a
Stepon the space scale. - 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§
- add_
site - Runs
fso that the nodes it adds report the caller’s file and line incheckandinspect. - current_
theme - Theme of the scene that is running, or the dark theme outside one.
The theme of the scene that is running, or
Theme::darkoutside one. - draft_
shaders - Paints shader nodes at half resolution until dropped.
- enter_
theme - Installs
themefor the duration off. - layer_
fingerprint - Identity of a layer slice, including its
PushLayeratstartthrough the matchingPopLayer. Used to reuse a layer whose vectors did not change. - lens_
drops - The lens_drops preset: water drops on the lens that magnify and flip what was drawn before this node, inside its box.
- pass_
graph - Passes for
items, in the order they must run. - pct
80percent of the frame, or of the parent when it has a fixed size.- ripple
- Rings that push a node’s colors out from its center, like a drop on
water. The node’s outline stays, so a flat fill shows no rings: use it
on text, a gradient, an image or water. Put it on a node with
Node::effect. - set_
shader_ budget_ ms - Milliseconds a shader raster may take before
shader_slow. - span
- Shorthand for
RichSpan::new. - trim
- The part of
pathbetween fractionsstartandendof its total length (0 ≤ start ≤ end ≤ 1), as used by thestart/endsignals. - waves
- The waves preset: a crest of
foamoverdeepwater.