Skip to main content

Tree

Struct Tree 

Source
pub struct Tree {
    pub(crate) size: Size,
    pub(crate) root: Group,
    pub(crate) linear_gradients: Vec<Arc<LinearGradient>>,
    pub(crate) radial_gradients: Vec<Arc<RadialGradient>>,
    pub(crate) patterns: Vec<Arc<Pattern>>,
    pub(crate) clip_paths: Vec<Arc<ClipPath>>,
    pub(crate) masks: Vec<Arc<Mask>>,
    pub(crate) filters: Vec<Arc<Filter>>,
    pub(crate) fontdb: Arc<Database>,
}
Expand description

A nodes tree container.

Fields§

§size: Size§root: Group§linear_gradients: Vec<Arc<LinearGradient>>§radial_gradients: Vec<Arc<RadialGradient>>§patterns: Vec<Arc<Pattern>>§clip_paths: Vec<Arc<ClipPath>>§masks: Vec<Arc<Mask>>§filters: Vec<Arc<Filter>>§fontdb: Arc<Database>

Implementations§

Source§

impl Tree

Source

pub fn from_data(data: &[u8], opt: &Options<'_>) -> Result<Self, Error>

Parses Tree from an SVG data.

Can contain an SVG string or a gzip compressed data.

Source

pub fn from_data_nested(data: &[u8], opt: &Options<'_>) -> Result<Self, Error>

Similar to the from_data method, except that it ignores all image elements linking to external files, as required by the SVG specification when SVG files are loaded for <image href="..." /> tags.

Source

pub fn from_str(text: &str, opt: &Options<'_>) -> Result<Self, Error>

Parses Tree from an SVG string.

Source

pub fn from_xmltree( doc: &Document<'_>, opt: &Options<'_>, ) -> Result<Self, Error>

Parses Tree from roxmltree::Document.

Source§

impl Tree

Source

pub fn size(&self) -> Size

Image size.

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

width and height in SVG.

Note that this does not necessarily represent the bounding box of the rendered contents. Use self.root().abs_layer_bounding_box() to retrieve it instead.

Source

pub fn root(&self) -> &Group

The root element of the SVG tree.

Source

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

Returns a renderable node by ID.

If an empty ID is provided, than this method will always return None.

Source

pub fn has_text_nodes(&self) -> bool

Checks if the current tree has any text nodes.

Source

pub fn has_defs_nodes(&self) -> bool

Checks if the current tree has any defs nodes.

Source

pub fn linear_gradients(&self) -> &[Arc<LinearGradient>]

Returns a list of all unique LinearGradients in the tree.

Source

pub fn radial_gradients(&self) -> &[Arc<RadialGradient>]

Returns a list of all unique RadialGradients in the tree.

Source

pub fn patterns(&self) -> &[Arc<Pattern>]

Returns a list of all unique Patterns in the tree.

Source

pub fn clip_paths(&self) -> &[Arc<ClipPath>]

Returns a list of all unique ClipPaths in the tree.

Source

pub fn masks(&self) -> &[Arc<Mask>]

Returns a list of all unique Masks in the tree.

Source

pub fn filters(&self) -> &[Arc<Filter>]

Returns a list of all unique Filters in the tree.

Source

pub fn fontdb(&self) -> &Arc<Database>

Returns the font database that applies to all text nodes in the tree.

Source

pub(crate) fn collect_paint_servers(&mut self)

Source§

impl Tree

Source

pub fn to_string(&self, opt: &WriteOptions) -> String

Writes usvg::Tree back to SVG.

Trait Implementations§

Source§

impl Clone for Tree

Source§

fn clone(&self) -> Tree

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 Debug for Tree

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl !RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

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

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.