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 draw_image_source(
&mut self,
bounds: Rect,
source: &ImageSource,
fit: ImageFit,
)
pub fn draw_image_source( &mut self, bounds: Rect, source: &ImageSource, fit: ImageFit, )
Draw source into bounds, placed per fit. A bitmap is scaled into
the fitted rect (clipped to bounds for ImageFit::Cover); an SVG is
rasterized at bounds’ physical size (see Scene::scale) so it stays
sharp.
Source§impl Scene
impl Scene
Sourcepub fn set_scale(&mut self, scale: f64)
pub fn set_scale(&mut self, scale: f64)
Set the physical-per-logical pixel scale this scene will be shown at.
Sourcepub fn draw_image(&mut self, rect: Rect, image: Arc<Pixmap>)
pub fn draw_image(&mut self, rect: Rect, image: Arc<Pixmap>)
Draw image (straight-alpha RGBA) into rect.
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
(or the innermost open region is a layer).
Sourcepub fn push_layer(&mut self, transform: Affine, opacity: f32)
pub fn push_layer(&mut self, transform: Affine, opacity: f32)
Begin a layer: primitives emitted until the matching
pop_layer are drawn through transform (mapping
logical pixels to logical pixels, inside any enclosing layer’s) and
composited as a group at opacity (0.0..=1.0): the layer’s content
is rendered at full opacity on its own, then blended once, so
overlapping primitives inside it don’t show through each other. Layers
and clips nest freely; a clip opened inside a layer is transformed with
it.
Sourcepub fn pop_layer(&mut self)
pub fn pop_layer(&mut self)
End the innermost layer opened by push_layer. A
no-op if none is open (or the innermost open region is a clip).
Sourcepub fn has_effects(&self) -> bool
pub fn has_effects(&self) -> bool
Whether any layer pushed so far moves things or makes them translucent
(a DrawCmd::PushLayer with a non-identity transform or an opacity
below 1). Backends that can’t draw layers natively fall back on this.
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 stroke_round_rect(
&mut self,
rect: Rect,
radius: f64,
color: Color,
width: f64,
)
pub fn stroke_round_rect( &mut self, rect: Rect, radius: f64, color: Color, width: f64, )
Stroke the outline of a rectangle with rounded corners.
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.
Each line goes through the Unicode Bidirectional Algorithm, with its
direction taken from its first strong character; right-to-left lines
are aligned to the right edge of the widest line. Use
Font::layout and Scene::fill_layout to choose the direction or
the alignment width.
Sourcepub fn fill_layout(
&mut self,
layout: &TextLayout<'_>,
origin: Point,
color: Color,
)
pub fn fill_layout( &mut self, layout: &TextLayout<'_>, origin: Point, color: Color, )
Paint a TextLayout with its top-left at origin, in color.
Glyphs are emitted as scene-graph nodes under a group translated to each line’s baseline, so they rasterize and composite like any other primitive.