Skip to main content

Scene

Struct Scene 

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

An ordered display list. Reused between frames to avoid reallocating.

Implementations§

Source§

impl Scene

Source

pub fn new() -> Self

Creates an empty display list with a transparent clear color.

Source

pub fn clear(&mut self)

Empties the list but keeps its allocation.

Source

pub fn set_clear_color(&mut self, color: Color)

Sets the color the frame is cleared to before drawing.

Source

pub fn clear_color(&self) -> Color

Color the frame is cleared to before drawing.

Source

pub fn push_path(&mut self, path: PathFill)

Appends a shape made of curves.

Source

pub fn push_quad(&mut self, quad: Quad)

Appends a rounded rectangle.

Source

pub fn push_glyphs(&mut self, run: GlyphRun)

Appends a glyph run; empty runs are skipped.

Source

pub fn push_image(&mut self, image: ImageQuad)

Appends an image.

Source

pub fn push_clip(&mut self, rect: Rect)

Clips subsequent primitives to rect (intersected with the current clip) until Scene::pop_clip.

Source

pub fn pop_clip(&mut self)

Ends the clip started by the matching Scene::push_clip.

Source

pub fn apply_effect( &mut self, range: Range<usize>, effect: Effect, pivot: Point, )

Applies effect to a range of primitives, scaling around pivot.

use ravenrs_core::{Color, Effect, Point, Primitive, Quad, Rect, Scene};

let mut scene = Scene::new();
scene.push_quad(Quad::new(Rect::new(0.0, 0.0, 10.0, 10.0), Color::WHITE));
scene.apply_effect(0..1, Effect::moved(5.0, 0.0), Point::ZERO);
let Primitive::Quad(q) = &scene.primitives()[0] else { unreachable!() };
assert_eq!(q.rect.x(), 5.0);
Source

pub fn extend_from_slice(&mut self, primitives: &[Primitive])

Appends primitives recorded earlier.

Source

pub fn primitives(&self) -> &[Primitive]

All primitives in painter’s order.

Source

pub fn len(&self) -> usize

Number of primitives.

Source

pub fn is_empty(&self) -> bool

Returns true when no primitives have been pushed.

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
Source§

impl Default for Scene

Source§

fn default() -> Scene

Returns the “default value” for a type. Read more
Source§

impl Scratch for Scene

Available on crate feature live only.

A closure of the playground draws into a scene of its own, which is then added to the real one, as a &mut Scene cannot leave the paint.

Source§

fn fresh() -> Self

An empty one.
Source§

fn merge_into(self, target: &mut Self)

Adds what was done to it to the real one.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Scene

§

impl !UnwindSafe for Scene

§

impl Freeze for Scene

§

impl Send for Scene

§

impl Sync for Scene

§

impl Unpin for Scene

§

impl UnsafeUnpin 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.