Skip to main content

Output

Struct Output 

Source
pub struct Output {
    pub width: u32,
    pub height: u32,
    pub background_color: [f32; 4],
    pub background_image: Option<String>,
    pub background_fit: Fit,
    pub layers: Vec<OutputLayer>,
}
Expand description

An output or scene: a render target with multiple layers, background, and dimensions.

An Output is independent of any particular monitor or device. It specifies:

  • Dimensions (width, height)
  • Background (solid color or image path)
  • Layers of video sources, each with position, size, and z-order

Multiple Outputs can render in parallel to different monitors or streams. When embedded in a host application, the output texture is composited by the host.

Fields§

§width: u32

Output width in pixels.

§height: u32

Output height in pixels.

§background_color: [f32; 4]

Background color as RGBA: [red, green, blue, alpha], each 0.0-1.0.

Default is [0.0, 0.0, 0.0, 1.0] (opaque black).

§background_image: Option<String>

Optional background image path. If present, this image is rendered after the background color and before the layers.

Path is relative to the application’s working directory or absolute.

§background_fit: Fit

How the background image fills the output. Fit::Cover by default, the way a desktop wallpaper does: no bars, cropped rather than stretched.

§layers: Vec<OutputLayer>

Layers to render on top of the background, ordered by z-index.

Implementations§

Source§

impl Output

Source

pub fn new(width: u32, height: u32) -> Self

Create a new output with the given dimensions and a default black background.

Source

pub fn with_background_color(self, color: [f32; 4]) -> Self

Set the background color as RGBA (each component 0.0-1.0).

Source

pub fn with_background_image(self, path: impl Into<String>) -> Self

Set the background image path. If set, the image is rendered after color.

Source

pub fn with_background_fit(self, fit: Fit) -> Self

Set how the background image fills the output.

Source

pub fn add_layer(&mut self, layer: OutputLayer)

Add a layer to this output.

Source

pub fn add_layers(&mut self, layers: impl IntoIterator<Item = OutputLayer>)

Add multiple layers at once.

Source

pub fn remove_layer(&mut self, video_source_id: &str) -> bool

Remove a layer by video source ID. Returns true if a layer was removed.

Source

pub fn get_layer_mut( &mut self, video_source_id: &str, ) -> Option<&mut OutputLayer>

Get a mutable reference to a layer by source ID.

Source

pub fn visible_layers(&self) -> impl Iterator<Item = &OutputLayer>

Get visible layers, top first (lowest z-index first). Drawing goes the other way — see OutputLayer.

Source

pub fn get_layer(&self, video_source_id: &str) -> Option<&OutputLayer>

Get a layer by video source ID.

Source

pub fn has_layer(&self, video_source_id: &str) -> bool

Check if a layer exists by source ID.

Source

pub fn visible_layer_count(&self) -> usize

Get the number of visible layers.

Source

pub fn layer_count(&self) -> usize

Get the number of total layers.

Source

pub fn clear_layers(&mut self)

Clear all layers from this output.

Source

pub fn with_background_rgb(self, r: f32, g: f32, b: f32) -> Self

Set the background color as RGB (alpha defaults to 1.0).

Source

pub fn with_transparent_background(self) -> Self

Set the background to transparent (alpha = 0.0).

Trait Implementations§

Source§

impl Clone for Output

Source§

fn clone(&self) -> Self

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 Output

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.