pub trait OutputDevice {
Show 18 methods
// Required methods
fn fill_path(&mut self, path: &PsPath, params: &FillParams);
fn stroke_path(&mut self, path: &PsPath, params: &StrokeParams);
fn clip_path(&mut self, path: &PsPath, params: &ClipParams);
fn init_clip(&mut self);
fn erase_page(&mut self);
fn show_page(&mut self, output_path: &str) -> Result<(), String>;
fn draw_image(&mut self, sample_data: &[u8], params: &ImageParams);
fn page_size(&self) -> (u32, u32);
// Provided methods
fn paint_axial_shading(&mut self, _params: &AxialShadingParams) { ... }
fn paint_radial_shading(&mut self, _params: &RadialShadingParams) { ... }
fn paint_mesh_shading(&mut self, _params: &MeshShadingParams) { ... }
fn paint_patch_shading(&mut self, _params: &PatchShadingParams) { ... }
fn paint_pattern_fill(&mut self, _params: &PatternFillParams) { ... }
fn set_trim_box(&mut self, _llx: f64, _lly: f64, _urx: f64, _ury: f64) { ... }
fn replay_and_show(
&mut self,
list: DisplayList,
output_path: &str,
) -> Result<(), String> { ... }
fn finish(&mut self) -> Result<(), String> { ... }
fn finish_with_context(&mut self, _ctx: &Context) -> Result<(), String> { ... }
fn as_any(&self) -> &dyn Any { ... }
}Expand description
Trait for raster rendering devices.
Operators never see the concrete implementation — they call trait methods. This enables backend swaps (tiny-skia, cairo, etc.) without changing operator code.
Required Methods§
Sourcefn fill_path(&mut self, path: &PsPath, params: &FillParams)
fn fill_path(&mut self, path: &PsPath, params: &FillParams)
Fill a path with the given color.
Sourcefn stroke_path(&mut self, path: &PsPath, params: &StrokeParams)
fn stroke_path(&mut self, path: &PsPath, params: &StrokeParams)
Stroke a path with the given parameters.
Sourcefn clip_path(&mut self, path: &PsPath, params: &ClipParams)
fn clip_path(&mut self, path: &PsPath, params: &ClipParams)
Intersect the current clip region with the given path.
Sourcefn erase_page(&mut self)
fn erase_page(&mut self)
Erase the page (fill with white).
Sourcefn show_page(&mut self, output_path: &str) -> Result<(), String>
fn show_page(&mut self, output_path: &str) -> Result<(), String>
Output the current page (e.g., save PNG) and return Ok/Err.
Sourcefn draw_image(&mut self, sample_data: &[u8], params: &ImageParams)
fn draw_image(&mut self, sample_data: &[u8], params: &ImageParams)
Draw an image from raw sample data.
Provided Methods§
Sourcefn paint_axial_shading(&mut self, _params: &AxialShadingParams)
fn paint_axial_shading(&mut self, _params: &AxialShadingParams)
Paint an axial (linear) gradient shading.
Sourcefn paint_radial_shading(&mut self, _params: &RadialShadingParams)
fn paint_radial_shading(&mut self, _params: &RadialShadingParams)
Paint a radial gradient shading.
Sourcefn paint_mesh_shading(&mut self, _params: &MeshShadingParams)
fn paint_mesh_shading(&mut self, _params: &MeshShadingParams)
Paint a Gouraud-shaded triangle mesh.
Sourcefn paint_patch_shading(&mut self, _params: &PatchShadingParams)
fn paint_patch_shading(&mut self, _params: &PatchShadingParams)
Paint a Coons/tensor-product patch mesh.
Sourcefn paint_pattern_fill(&mut self, _params: &PatternFillParams)
fn paint_pattern_fill(&mut self, _params: &PatternFillParams)
Paint a tiled pattern fill.
Sourcefn set_trim_box(&mut self, _llx: f64, _lly: f64, _urx: f64, _ury: f64)
fn set_trim_box(&mut self, _llx: f64, _lly: f64, _urx: f64, _ury: f64)
Set the trim box for the next page (PDF points, lower-left origin). Only meaningful for PDF output; other devices ignore this.
Sourcefn replay_and_show(
&mut self,
list: DisplayList,
output_path: &str,
) -> Result<(), String>
fn replay_and_show( &mut self, list: DisplayList, output_path: &str, ) -> Result<(), String>
Replay a display list and write output in one step.