Struct usvg_tree::Tree

source ·
pub struct Tree {
    pub size: Size,
    pub view_box: ViewBox,
    pub root: Node,
}
Expand description

A nodes tree container.

Fields§

§size: Size

Image size.

Size of an image that should be created to fit the SVG.

width and height in SVG.

§view_box: ViewBox

SVG viewbox.

Specifies which part of the SVG image should be rendered.

viewBox and preserveAspectRatio in SVG.

§root: Node

The root element of the SVG tree.

The root node is always Group.

Implementations§

source§

impl Tree

source

pub fn node_by_id(&self, id: &str) -> Option<Node>

Returns renderable node by ID.

If an empty ID is provided, than this method will always return None. Even if tree has nodes with empty ID.

source

pub fn has_text_nodes(&self) -> bool

Checks if the current tree has any text nodes.

source

pub fn paint_servers<F: FnMut(&Paint)>(&self, f: F)

Calls a closure for each Paint in the tree.

Doesn’t guarantee to have unique paint servers. A caller must deduplicate them manually.

source

pub fn clip_paths<F: FnMut(Rc<ClipPath>)>(&self, f: F)

Calls a closure for each ClipPath in the tree.

Doesn’t guarantee to have unique clip paths. A caller must deduplicate them manually.

source

pub fn masks<F: FnMut(Rc<Mask>)>(&self, f: F)

Calls a closure for each Mask in the tree.

Doesn’t guarantee to have unique masks. A caller must deduplicate them manually.

source

pub fn filters<F: FnMut(Rc<Filter>)>(&self, f: F)

Calls a closure for each Filter in the tree.

Doesn’t guarantee to have unique filters. A caller must deduplicate them manually.

source

pub fn calculate_abs_transforms(&mut self)

Calculates absolute transforms for all nodes in the tree.

As of now, sets Group::abs_transform.

Automatically called by the parser and ideally should be called manually after each tree modification.

Trait Implementations§

source§

impl Clone for Tree

source§

fn clone(&self) -> Tree

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Tree

§

impl !Send for Tree

§

impl !Sync for Tree

§

impl Unpin for Tree

§

impl !UnwindSafe for Tree

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

§

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>,

§

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>,

§

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.