pub trait Renderer {
Show 14 methods
// Required methods
fn clear(&mut self, color: Color) -> Result<()>;
fn fill_rect(&mut self, rect: Rect, style: &FillStyle) -> Result<()>;
fn stroke_rect(&mut self, rect: Rect, style: &StrokeStyle) -> Result<()>;
fn fill_path(&mut self, path: &BezPath, style: &FillStyle) -> Result<()>;
fn stroke_path(&mut self, path: &BezPath, style: &StrokeStyle) -> Result<()>;
fn draw_text(
&mut self,
text: &str,
position: Point,
style: &TextStyle,
) -> Result<()>;
fn draw_rgba_image(
&mut self,
rgba: &[u8],
width: u32,
height: u32,
position: Point,
) -> Result<()>;
fn measure_text_styled(
&self,
text: &str,
size_px: f32,
italic: bool,
) -> Result<(f64, f64)>;
fn push_clip_rect(&mut self, rect: Rect) -> Result<()>;
fn pop_clip(&mut self) -> Result<()>;
fn width(&self) -> u32;
fn height(&self) -> u32;
// Provided methods
fn draw_line(
&mut self,
p0: Point,
p1: Point,
style: &StrokeStyle,
) -> Result<()> { ... }
fn measure_text(&self, text: &str, size_px: f32) -> Result<(f64, f64)> { ... }
}Expand description
Backend-agnostic drawing surface.
Implement this trait to add a new output format. The built-in backends are:
plotine-backend-skia::SkiaRenderer— raster PNG via tiny-skiaplotine-backend-svg::SvgRenderer— deterministic SVG
Recipes produce kurbo::BezPath geometry; backends only need to fill/stroke
paths, draw text, and manage a clip stack.
Required Methods§
fn clear(&mut self, color: Color) -> Result<()>
fn fill_rect(&mut self, rect: Rect, style: &FillStyle) -> Result<()>
fn stroke_rect(&mut self, rect: Rect, style: &StrokeStyle) -> Result<()>
fn fill_path(&mut self, path: &BezPath, style: &FillStyle) -> Result<()>
fn stroke_path(&mut self, path: &BezPath, style: &StrokeStyle) -> Result<()>
fn draw_text( &mut self, text: &str, position: Point, style: &TextStyle, ) -> Result<()>
Sourcefn draw_rgba_image(
&mut self,
rgba: &[u8],
width: u32,
height: u32,
position: Point,
) -> Result<()>
fn draw_rgba_image( &mut self, rgba: &[u8], width: u32, height: u32, position: Point, ) -> Result<()>
Blit an RGBA8 image with top-left at position (figure pixels).
rgba.len() must be width * height * 4. Used by optional external LaTeX
(feature = "latex") and any future raster overlays.
Sourcefn measure_text_styled(
&self,
text: &str,
size_px: f32,
italic: bool,
) -> Result<(f64, f64)>
fn measure_text_styled( &self, text: &str, size_px: f32, italic: bool, ) -> Result<(f64, f64)>
Measure text with optional italic/oblique face (mathtext variables).
Sourcefn push_clip_rect(&mut self, rect: Rect) -> Result<()>
fn push_clip_rect(&mut self, rect: Rect) -> Result<()>
Restrict subsequent drawing to rect until pop_clip.
fn pop_clip(&mut self) -> Result<()>
fn width(&self) -> u32
fn height(&self) -> u32
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".