summaryrefslogtreecommitdiffstats
path: root/tiny_skia/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tiny_skia/src/lib.rs')
-rw-r--r--tiny_skia/src/lib.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/tiny_skia/src/lib.rs b/tiny_skia/src/lib.rs
index 758921d4..a42f1de4 100644
--- a/tiny_skia/src/lib.rs
+++ b/tiny_skia/src/lib.rs
@@ -29,7 +29,7 @@ pub use geometry::Geometry;
use crate::core::renderer;
use crate::core::{
- Background, Color, Font, Pixels, Point, Rectangle, Transformation,
+ Background, Color, Font, Pixels, Point, Rectangle, Size, Transformation,
};
use crate::engine::Engine;
use crate::graphics::compositor;
@@ -405,3 +405,26 @@ impl core::svg::Renderer for Renderer {
impl compositor::Default for Renderer {
type Compositor = window::Compositor;
}
+
+impl renderer::Headless for Renderer {
+ fn new(default_font: Font, default_text_size: Pixels) -> Self {
+ Self::new(default_font, default_text_size)
+ }
+
+ fn screenshot(
+ &mut self,
+ size: Size<u32>,
+ scale_factor: f32,
+ background_color: Color,
+ ) -> Vec<u8> {
+ let viewport =
+ Viewport::with_physical_size(size, f64::from(scale_factor));
+
+ window::compositor::screenshot::<&str>(
+ self,
+ &viewport,
+ background_color,
+ &[],
+ )
+ }
+}