Skip to main content

Scene

Struct Scene 

Source
pub struct Scene { /* private fields */ }
Expand description

A builder of vector draw primitives in logical-pixel space.

Implementations§

Source§

impl Scene

Source

pub fn new(logical_size: Size) -> Self

Create an empty scene covering logical_size.

Source

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.

Source

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.

Source

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).

Source

pub fn logical_size(&self) -> Size

The scene’s extent in logical pixels.

Source

pub fn len(&self) -> usize

Number of top-level primitives queued (at the root clip level).

Source

pub fn is_empty(&self) -> bool

Source

pub fn fill_rect(&mut self, rect: Rect, color: Color)

Fill an axis-aligned rectangle with a solid color.

Source

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).

Source

pub fn stroke_rect(&mut self, rect: Rect, color: Color, width: f64)

Stroke the outline of a rectangle with the given line width.

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Trait Implementations§

Source§

impl Clone for Scene

Source§

fn clone(&self) -> Scene

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Scene

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Scene

§

impl RefUnwindSafe for Scene

§

impl Send for Scene

§

impl Sync for Scene

§

impl Unpin for Scene

§

impl UnsafeUnpin for Scene

§

impl UnwindSafe for Scene

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.