Skip to main content

SvgGraphics

Struct SvgGraphics 

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

SVG graphics builder for a single page

Implementations§

Source§

impl SvgGraphics

Source

pub fn new(width: Length, height: Length) -> Self

Create a new SVG graphics builder

Source

pub fn add_rect( &mut self, x: Length, y: Length, width: Length, height: Length, fill: Option<Color>, stroke: Option<Color>, stroke_width: Option<Length>, opacity: Option<f64>, rx: Option<Length>, )

Add a rectangle (for backgrounds, borders)

Source

pub fn add_text( &mut self, text: &str, x: Length, y: Length, font_size: Length, color: Option<Color>, )

Add text with full font styling

Source

pub fn add_text_styled( &mut self, text: &str, x: Length, y: Length, font_size: Length, color: Option<Color>, font_family: Option<&str>, font_weight: Option<u16>, font_style_italic: Option<bool>, text_decoration: Option<(bool, bool, bool)>, )

Add text with full styling (font-family, font-weight, font-style, text-decoration)

Source

pub fn add_linear_gradient( &mut self, id: &str, x1: f64, y1: f64, x2: f64, y2: f64, stops: &[(f64, Color)], )

Add a linear gradient to the defs section

Source

pub fn add_gradient_rect( &mut self, x: Length, y: Length, width: Length, height: Length, gradient_id: &str, )

Add a rect filled with a gradient (reference gradient by id)

Source

pub fn add_image( &mut self, data_uri: &str, x: Length, y: Length, width: Length, height: Length, )

Add an image

Source

pub fn add_line( &mut self, x1: Length, y1: Length, x2: Length, y2: Length, color: Color, width: Length, style: &str, )

Add a line (for rules, borders)

Source

pub fn start_clip( &mut self, x: Length, y: Length, width: Length, height: Length, )

Start a clipping path

Source

pub fn end_clip(&mut self)

End a clipping path

Trait Implementations§

Source§

impl Display for SvgGraphics

Source§

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

Formats the value using the given formatter. Read more

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.