Skip to main content

Renderer

Trait Renderer 

Source
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-skia
  • plotine-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§

Source

fn clear(&mut self, color: Color) -> Result<()>

Source

fn fill_rect(&mut self, rect: Rect, style: &FillStyle) -> Result<()>

Source

fn stroke_rect(&mut self, rect: Rect, style: &StrokeStyle) -> Result<()>

Source

fn fill_path(&mut self, path: &BezPath, style: &FillStyle) -> Result<()>

Source

fn stroke_path(&mut self, path: &BezPath, style: &StrokeStyle) -> Result<()>

Source

fn draw_text( &mut self, text: &str, position: Point, style: &TextStyle, ) -> Result<()>

Source

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.

Source

fn measure_text_styled( &self, text: &str, size_px: f32, italic: bool, ) -> Result<(f64, f64)>

Measure text with optional italic/oblique face (mathtext variables).

Source

fn push_clip_rect(&mut self, rect: Rect) -> Result<()>

Restrict subsequent drawing to rect until pop_clip.

Source

fn pop_clip(&mut self) -> Result<()>

Source

fn width(&self) -> u32

Source

fn height(&self) -> u32

Provided Methods§

Source

fn draw_line(&mut self, p0: Point, p1: Point, style: &StrokeStyle) -> Result<()>

Source

fn measure_text(&self, text: &str, size_px: f32) -> Result<(f64, f64)>

Measure text width/height in pixels for layout (upright face).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§