Skip to main content

SvgWriter

Struct SvgWriter 

Source
pub struct SvgWriter { /* private fields */ }
Expand description

SVG file writer for visualizing clipper paths.

Direct port from C++ SvgWriter class. Add paths and text, then save to an SVG file.

§Examples

use clipper2_rust::utils::svg::SvgWriter;
use clipper2_rust::core::FillRule;

let mut svg = SvgWriter::new(0);
// svg.add_paths_64(&paths, false, FillRule::NonZero, 0x1800009C, 0xFFB3B3DA, 0.8, false);
// svg.save_to_file("output.svg", 800, 600, 20);

Implementations§

Source§

impl SvgWriter

Source

pub fn new(precision: i32) -> Self

Create a new SvgWriter with the given precision (decimal places). Direct port from C++ SvgWriter(int precision).

Source

pub fn clear(&mut self)

Clear all stored paths and text.

Source

pub fn fill_rule(&self) -> FillRule

Get the current fill rule.

Source

pub fn set_coords_style( &mut self, font_name: &str, font_color: u32, font_size: u32, )

Set the coordinate display style. Direct port from C++ SetCoordsStyle().

Source

pub fn add_text( &mut self, text: &str, font_color: u32, font_size: u32, x: f64, y: f64, )

Add a text label at the given position. Direct port from C++ AddText().

Source

pub fn add_path_64( &mut self, path: &Path64, is_open: bool, fillrule: FillRule, brush_color: u32, pen_color: u32, pen_width: f64, show_coords: bool, )

Add a single Path64, scaling by the writer’s precision. Direct port from C++ AddPath(const Path64&, ...).

Source

pub fn add_path_d( &mut self, path: &PathD, is_open: bool, fillrule: FillRule, brush_color: u32, pen_color: u32, pen_width: f64, show_coords: bool, )

Add a single PathD. Direct port from C++ AddPath(const PathD&, ...).

Source

pub fn add_paths_64( &mut self, paths: &Paths64, is_open: bool, fillrule: FillRule, brush_color: u32, pen_color: u32, pen_width: f64, show_coords: bool, )

Add multiple Paths64, scaling by the writer’s precision. Direct port from C++ AddPaths(const Paths64&, ...).

Source

pub fn add_paths_d( &mut self, paths: &PathsD, is_open: bool, fillrule: FillRule, brush_color: u32, pen_color: u32, pen_width: f64, show_coords: bool, )

Add multiple PathsD. Direct port from C++ AddPaths(const PathsD&, ...).

Source

pub fn save_to_file( &self, filename: &str, max_width: i32, max_height: i32, margin: i32, ) -> bool

Save all stored paths and text to an SVG file. Direct port from C++ SaveToFile().

Returns true on success, false on failure.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.