Skip to main content

Crate oxframe_2d

Crate oxframe_2d 

Source
Expand description

2D scene graph of oxframe.

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::CircleBuilder;
pub use builder::CodeBuilder;
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::PathBuilder;
pub use builder::PolygonBuilder;
pub use builder::RectBuilder;
pub use builder::StarBuilder;
pub use builder::TxtBuilder;
pub use graph::Direction;
pub use graph::Justify;
pub use graph::LayoutAlign;
pub use graph::NodeId;
pub use graph::SceneGraph;

Structs§

Circle
Handle to a Circle node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
CircleBuilder
Builder for a Circle node: set the initial values, then pass it to add.
Code
Handle to a Code node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
CodeBuilder
Builder for a Code node: set the initial values, then pass it to add.
CodeTheme
Colors of a code theme.
Color
sRGB color with straight (non-premultiplied) alpha, components in 0..=1.
DrawItem
One thing to paint, in local coordinates of transform. Paints already include the node’s opacity (unless the node draws into a layer).
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.
GridBuilder
Builder for a Grid node: set the initial values, then pass it to add.
Group
Handle to a Group node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
GroupBuilder
Builder for a Group node: set the initial values, then pass it to add.
Img
Handle to a Img node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
ImgBuilder
Builder for a Img node: set the initial values, then pass it to add.
Layer
Everything drawn until the matching Primitive::PopLayer is rendered into its own buffer, filtered, clipped and composited as a whole.
Layout
Handle to a Layout node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
LayoutBuilder
Places children in a row or column. Children’s x/y become offsets from their layout position.
Line
Handle to a Line node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
LineBuilder
Builder for a Line node: set the initial values, then pass it to add.
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.
PathBuilder
Builder for a Path node: set the initial values, then pass it to add.
Polygon
Handle to a Polygon node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
PolygonBuilder
Builder for a Polygon node: set the initial values, then pass it to add.
RasterImage
Decoded raster image: sRGB RGBA8, straight alpha.
Rect
Handle to a Rect node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
RectBuilder
Builder for a Rect node: set the initial values, then pass it to add.
RichSpan
A run of text with its own look; unset fields use the node’s style.
SceneGraph
Arena of nodes for one scene run. Node 0 is the view (root).
Shadow
Drop shadow of a layer.
Signal
A reactive value.
Star
Handle to a Star node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
StarBuilder
Builder for a Star node: set the initial values, then pass it to add.
StrokeStyle
How an outline is drawn.
Txt
Handle to a Txt node in the scene: cheap to copy, its methods return the node’s properties as Signals. Derefs to Node.
TxtBuilder
Builder for a Txt node: set the initial values, then pass it to add.
VectorImage
SVG converted to filled/stroked paths (gradients become their first stop color in v1).
VectorShape
One painted path of a VectorImage.
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.
GradientKind
Shape of a Gradient.
ImageSource
Decoded image data for an Img node.
Justify
Main-axis distribution of children; only matters with a fixed size.
Lang
Language for syntax highlighting.
LayoutAlign
Cross-axis alignment of children in a Layout.
LineCap
Shape of the ends of open outlines.
LineJoin
Shape of outline corners.
Paint
What a shape is filled or stroked with.
Primitive
A drawing operation in a DrawItem.
TextAlign
Horizontal alignment of lines.

Constants§

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

Traits§

NodeBuilder
Describes a node before it is added to the scene.

Functions§

span
Shorthand for RichSpan::new.
trim
The part of path between fractions start and end of its total length (0 ≤ start ≤ end ≤ 1), as used by the start/end signals.