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: u32Output width in pixels.
height: u32Output 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: FitHow 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
impl Output
Sourcepub fn new(width: u32, height: u32) -> Self
pub fn new(width: u32, height: u32) -> Self
Create a new output with the given dimensions and a default black background.
Sourcepub fn with_background_color(self, color: [f32; 4]) -> Self
pub fn with_background_color(self, color: [f32; 4]) -> Self
Set the background color as RGBA (each component 0.0-1.0).
Sourcepub fn with_background_image(self, path: impl Into<String>) -> Self
pub fn with_background_image(self, path: impl Into<String>) -> Self
Set the background image path. If set, the image is rendered after color.
Sourcepub fn with_background_fit(self, fit: Fit) -> Self
pub fn with_background_fit(self, fit: Fit) -> Self
Set how the background image fills the output.
Sourcepub fn add_layer(&mut self, layer: OutputLayer)
pub fn add_layer(&mut self, layer: OutputLayer)
Add a layer to this output.
Sourcepub fn add_layers(&mut self, layers: impl IntoIterator<Item = OutputLayer>)
pub fn add_layers(&mut self, layers: impl IntoIterator<Item = OutputLayer>)
Add multiple layers at once.
Sourcepub fn remove_layer(&mut self, video_source_id: &str) -> bool
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.
Sourcepub fn get_layer_mut(
&mut self,
video_source_id: &str,
) -> Option<&mut OutputLayer>
pub fn get_layer_mut( &mut self, video_source_id: &str, ) -> Option<&mut OutputLayer>
Get a mutable reference to a layer by source ID.
Sourcepub fn visible_layers(&self) -> impl Iterator<Item = &OutputLayer>
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.
Sourcepub fn get_layer(&self, video_source_id: &str) -> Option<&OutputLayer>
pub fn get_layer(&self, video_source_id: &str) -> Option<&OutputLayer>
Get a layer by video source ID.
Sourcepub fn visible_layer_count(&self) -> usize
pub fn visible_layer_count(&self) -> usize
Get the number of visible layers.
Sourcepub fn layer_count(&self) -> usize
pub fn layer_count(&self) -> usize
Get the number of total layers.
Sourcepub fn clear_layers(&mut self)
pub fn clear_layers(&mut self)
Clear all layers from this output.
Sourcepub fn with_background_rgb(self, r: f32, g: f32, b: f32) -> Self
pub fn with_background_rgb(self, r: f32, g: f32, b: f32) -> Self
Set the background color as RGB (alpha defaults to 1.0).
Sourcepub fn with_transparent_background(self) -> Self
pub fn with_transparent_background(self) -> Self
Set the background to transparent (alpha = 0.0).