Support custom renderers in iced_test through renderer::Headless trait
This commit is contained in:
parent
6572909ab5
commit
2cf4abf25b
12 changed files with 191 additions and 80 deletions
|
|
@ -3,7 +3,8 @@
|
|||
mod null;
|
||||
|
||||
use crate::{
|
||||
Background, Border, Color, Rectangle, Shadow, Size, Transformation, Vector,
|
||||
Background, Border, Color, Font, Pixels, Rectangle, Shadow, Size,
|
||||
Transformation, Vector,
|
||||
};
|
||||
|
||||
/// A component that can be used by widgets to draw themselves on a screen.
|
||||
|
|
@ -100,3 +101,19 @@ impl Default for Style {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A headless renderer is a renderer that can render offscreen without
|
||||
/// a window nor a compositor.
|
||||
pub trait Headless {
|
||||
/// Creates a new [`Headless`] renderer;
|
||||
fn new(default_font: Font, default_text_size: Pixels) -> Self;
|
||||
|
||||
/// Draws offscreen into a screenshot, returning a collection of
|
||||
/// bytes representing the rendered pixels in RGBA order.
|
||||
fn screenshot(
|
||||
&mut self,
|
||||
size: Size<u32>,
|
||||
scale_factor: f32,
|
||||
background_color: Color,
|
||||
) -> Vec<u8>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue