Skip to main content

Svg

Struct Svg 

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

A vector graphics image.

An Svg image resizes smoothly without losing any quality.

Svg images can have a considerable rendering cost when resized, specially when they are complex.

Implementations§

Source§

impl Svg

Source

pub fn new(handle: impl Into<Handle>) -> Svg

Creates a new Svg from the given Handle.

Source

pub fn from_path(path: impl Into<PathBuf>) -> Svg

Creates a new Svg that will display the contents of the file at the provided path.

Source

pub fn width(self, width: Length) -> Svg

Sets the width of the Svg.

Source

pub fn height(self, height: Length) -> Svg

Sets the height of the Svg.

Source

pub fn content_fit(self, content_fit: ContentFit) -> Svg

Sets the ContentFit of the Svg.

Defaults to ContentFit::Contain

Trait Implementations§

Source§

impl Clone for Svg

Source§

fn clone(&self) -> Svg

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 Svg

Source§

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

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

impl<'a, Message, Renderer> Into<Element<'a, Message, Renderer>> for Svg
where Message: Clone + 'a, Renderer: Renderer + 'a,

Source§

fn into(self) -> Element<'a, Message, Renderer>

Converts this type into the (usually inferred) input type.
Source§

impl<Message, Renderer> Widget<Message, Renderer> for Svg
where Renderer: Renderer,

Source§

fn width(&self) -> Length

Returns the width of the Widget.
Source§

fn height(&self) -> Length

Returns the height of the Widget.
Source§

fn layout(&self, renderer: &Renderer, limits: &Limits) -> Node

Returns the Node of the Widget. Read more
Source§

fn draw( &self, renderer: &mut Renderer, _style: &Style, layout: Layout<'_>, _cursor_position: Point, _viewport: &Rectangle, )

Draws the Widget using the associated Renderer.
Source§

fn on_event( &mut self, _event: Event, _layout: Layout<'_>, _cursor_position: Point, _renderer: &Renderer, _clipboard: &mut dyn Clipboard, _shell: &mut Shell<'_, Message>, ) -> Status

Processes a runtime Event. Read more
Source§

fn mouse_interaction( &self, _layout: Layout<'_>, _cursor_position: Point, _viewport: &Rectangle, _renderer: &Renderer, ) -> Interaction

Returns the current mouse::Interaction of the Widget. Read more
Source§

fn overlay( &mut self, _layout: Layout<'_>, _renderer: &Renderer, ) -> Option<Element<'_, Message, Renderer>>

Returns the overlay of the Widget, if there is any.
Source§

impl<Message, Renderer> Widget<Message, Renderer> for Svg
where Renderer: Renderer,

Source§

fn width(&self) -> Length

Returns the width of the Widget.
Source§

fn height(&self) -> Length

Returns the height of the Widget.
Source§

fn layout(&self, renderer: &Renderer, limits: &Limits) -> Node

Returns the layout::Node of the Widget. Read more
Source§

fn draw( &self, _tree: &Tree, renderer: &mut Renderer, style: &Style, layout: Layout<'_>, cursor_position: Point, viewport: &Rectangle, )

Draws the Widget using the associated Renderer.
Source§

fn tag(&self) -> Tag

Returns the Tag of the Widget.
Source§

fn state(&self) -> State

Returns the State of the Widget.
Source§

fn children(&self) -> Vec<Tree>

Returns the state Tree of the children of the Widget.
Source§

fn diff(&self, _tree: &mut Tree)

Reconciliates the Widget with the provided Tree.
Source§

fn on_event( &mut self, _state: &mut Tree, _event: Event, _layout: Layout<'_>, _cursor_position: Point, _renderer: &Renderer, _clipboard: &mut dyn Clipboard, _shell: &mut Shell<'_, Message>, ) -> Status

Processes a runtime Event. Read more
Source§

fn mouse_interaction( &self, _state: &Tree, _layout: Layout<'_>, _cursor_position: Point, _viewport: &Rectangle, _renderer: &Renderer, ) -> Interaction

Returns the current mouse::Interaction of the Widget. Read more
Source§

fn overlay<'a>( &'a self, _state: &'a mut Tree, _layout: Layout<'_>, _renderer: &Renderer, ) -> Option<Element<'a, Message, Renderer>>

Returns the overlay of the Widget, if there is any.

Auto Trait Implementations§

§

impl Freeze for Svg

§

impl RefUnwindSafe for Svg

§

impl Send for Svg

§

impl Sync for Svg

§

impl Unpin for Svg

§

impl UnsafeUnpin for Svg

§

impl UnwindSafe for Svg

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> MaybeSend for T
where T: Send,

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.