Skip to main content

WriteOptions

Struct WriteOptions 

Source
pub struct WriteOptions {
    pub trim_hex_colors: bool,
    pub remove_leading_zero: bool,
    pub use_compact_path_notation: bool,
    pub join_arc_to_flags: bool,
    pub remove_duplicated_path_commands: bool,
    pub use_implicit_lineto_commands: bool,
    pub simplify_transform_matrices: bool,
    pub list_separator: ListSeparator,
}
Expand description

Options for SVG types writing.

Fields§

§trim_hex_colors: bool

Use #RGB color notation when possible.

By default all colors written using #RRGGBB notation.

§Examples

#ff0000 -> #f00, #000000 -> #000, #00aa00 -> #0a0

Default: disabled

§remove_leading_zero: bool

Remove leading zero from numbers.

§Examples

  • 0.1 -> .1
  • -0.1 -> -.1

Default: disabled

§use_compact_path_notation: bool

Use compact path notation.

SVG allow us to remove some symbols from path notation without breaking parsing.

§Examples

M 10 -20 A 5.5 0.3 -4 1 1 0 -0.1 -> M10-20A5.5.3-4 1 1 0-.1

Default: disabled

§join_arc_to_flags: bool

Join ArcTo flags.

Elliptical arc curve segment has flags parameters, which can have values of 0 or 1. Since we have fixed-width values, we can skip spaces between them.

Note: Sadly, but most of the viewers doesn’t support such notation, even though it’s valid according to the SVG spec.

§Examples

A 5 5 30 1 1 10 10 -> A 5 5 30 1110 10

Default: disabled

§remove_duplicated_path_commands: bool

Remove duplicated commands.

If a segment has the same type as a previous then we can skip command specifier.

§Examples

M 10 10 L 20 20 L 30 30 L 40 40 -> M 10 10 L 20 20 30 30 40 40

Default: disabled

§use_implicit_lineto_commands: bool

Use implicit LineTo commands.

‘If a MoveTo is followed by multiple pairs of coordinates, the subsequent pairs are treated as implicit LineTo commands.’

§Examples

M 10 10 L 20 20 L 30 30 -> M 10 10 20 20 30 30

Default: disabled

§simplify_transform_matrices: bool

Simplify transform matrices into short equivalent when possible.

If not set - all transform will be saved as ‘matrix’.

§Examples

matrix(1 0 0 1 10 20) -> translate(10 20)
matrix(1 0 0 1 10 0)  -> translate(10)
matrix(2 0 0 3 0 0)   -> scale(2 3)
matrix(2 0 0 2 0 0)   -> scale(2)
matrix(0 1 -1 0 0 0)  -> rotate(-90)

Default: disabled

§list_separator: ListSeparator

Set the separator type for list types.

Affects Points, LengthList, NumberList and Transform.

Default: ListSeparator::Space

Implementations§

Source§

impl WriteOptions

Source

pub fn write_separator(&self, out: &mut Vec<u8>)

Writes a selected separator to the output buffer.

Uses WriteOptions::list_separator option.

Trait Implementations§

Source§

impl Clone for WriteOptions

Source§

fn clone(&self) -> WriteOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WriteOptions

Source§

impl Debug for WriteOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WriteOptions

Source§

fn default() -> WriteOptions

Returns the “default value” for a type. Read more
Source§

impl PartialEq for WriteOptions

Source§

fn eq(&self, other: &WriteOptions) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for WriteOptions

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Construction<T> for T
where T: Default + Clone,

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<Fr, To> IntoColor<To> for Fr
where To: FromColor<Fr>,

Source§

fn into_color(self) -> To

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V