pub struct Scene { /* private fields */ }Expand description
A builder of vector draw primitives in logical-pixel space.
Implementations§
Source§impl Scene
impl Scene
Sourcepub fn push_clip(&mut self, rect: Rect)
pub fn push_clip(&mut self, rect: Rect)
Begin clipping subsequently-emitted primitives to rect; nests until the
matching pop_clip. Used by scroll containers to mask
overflowing content to the viewport.
Sourcepub fn pop_clip(&mut self)
pub fn pop_clip(&mut self)
End the innermost clip region opened by push_clip,
folding its primitives into a clipped group. A no-op if none is open.
Sourcepub fn commands(&self) -> &[DrawCmd]
pub fn commands(&self) -> &[DrawCmd]
The structured draw commands recorded by the typed helpers (for a GPU backend; the CPU rasterizer uses the lowered nodes instead).
Sourcepub fn logical_size(&self) -> Size
pub fn logical_size(&self) -> Size
The scene’s extent in logical pixels.
pub fn is_empty(&self) -> bool
Sourcepub fn fill_rect(&mut self, rect: Rect, color: Color)
pub fn fill_rect(&mut self, rect: Rect, color: Color)
Fill an axis-aligned rectangle with a solid color.
Sourcepub fn fill_round_rect(&mut self, rect: Rect, radius: f64, color: Color)
pub fn fill_round_rect(&mut self, rect: Rect, radius: f64, color: Color)
Fill a rectangle with rounded corners (corner radius in logical
pixels, clamped to half the shorter side).
Sourcepub fn stroke_rect(&mut self, rect: Rect, color: Color, width: f64)
pub fn stroke_rect(&mut self, rect: Rect, color: Color, width: f64)
Stroke the outline of a rectangle with the given line width.
Sourcepub fn fill_viewport(&mut self, rect: Rect, id: u64, placeholder: Color)
pub fn fill_viewport(&mut self, rect: Rect, id: u64, placeholder: Color)
Reserve an embedded-content area rect for the viewport id, painting a
solid placeholder so the region is visible before any content is
composited in. Records a DrawCmd::Viewport so a GPU backend can
texture the rect from an imported content surface instead, and so the app
can locate the rect to blit registered CPU content over the placeholder.
Sourcepub fn push_node(&mut self, node: Node)
pub fn push_node(&mut self, node: Node)
Escape hatch: push a pre-built oxideav scene-graph node. Lets callers emit text runs, images, gradients, or clips that the typed helpers don’t yet cover.
Sourcepub fn into_vector_frame(self) -> VectorFrame
pub fn into_vector_frame(self) -> VectorFrame
Lower the scene to an oxideav-core VectorFrame.
The frame carries a view box equal to the logical size, so the rasterizer maps logical pixels onto whatever physical canvas size the renderer was constructed with — that mapping is the DPI scale.
Sourcepub fn into_vector_frame_region(self, view: Rect) -> VectorFrame
pub fn into_vector_frame_region(self, view: Rect) -> VectorFrame
Lower to a frame whose view box is view — a logical-pixel sub-rect of
the scene. A renderer sized to that region’s physical pixels then
rasterizes only the region; content outside it is clipped by the canvas
bounds. Used for area-limited repaints (see SoftwareRenderer::render_region).
Source§impl Scene
impl Scene
Sourcepub fn fill_text(
&mut self,
font: &Font,
text: &str,
origin: Point,
size_px: f64,
color: Color,
)
pub fn fill_text( &mut self, font: &Font, text: &str, origin: Point, size_px: f64, color: Color, )
Shape and paint text with font at origin (the top-left of the text
box, logical pixels), size_px, and color. Newlines (\n) start a new
line, each dropped by one line_height from the last.
Glyphs are emitted as scene-graph nodes under a group translated to the baseline, so they rasterize and composite like any other primitive.