Skip to main content

Svg

Struct Svg 

Source
pub struct Svg<'a, Theme = Theme>
where Theme: Catalog,
{ /* 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.

§Example

use iced::widget::svg;

enum Message {
    // ...
}

fn view(state: &State) -> Element<'_, Message> {
    svg("tiger.svg").into()
}

Implementations§

Source§

impl<'a, Theme> Svg<'a, Theme>
where Theme: Catalog,

Source

pub fn new(handle: impl Into<Handle>) -> Svg<'a, Theme>

Available on crate feature svg only.

Creates a new Svg from the given Handle.

Source

pub fn from_path(path: impl Into<PathBuf>) -> Svg<'a, Theme>

Available on crate feature svg only.

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

Source

pub fn width(self, width: impl Into<Length>) -> Svg<'a, Theme>

Available on crate feature svg only.

Sets the width of the Svg.

Source

pub fn height(self, height: impl Into<Length>) -> Svg<'a, Theme>

Available on crate feature svg only.

Sets the height of the Svg.

Source

pub fn content_fit(self, content_fit: ContentFit) -> Svg<'a, Theme>

Available on crate feature svg only.

Sets the ContentFit of the Svg.

Defaults to ContentFit::Contain

Source

pub fn style( self, style: impl Fn(&Theme, Status) -> Style + 'a, ) -> Svg<'a, Theme>
where <Theme as Catalog>::Class<'a>: From<Box<dyn Fn(&Theme, Status) -> Style + 'a>>,

Available on crate feature svg only.

Sets the style of the Svg.

Source

pub fn class( self, class: impl Into<<Theme as Catalog>::Class<'a>>, ) -> Svg<'a, Theme>

Available on crate features svg and advanced only.

Sets the style class of the Svg.

Source

pub fn rotation(self, rotation: impl Into<Rotation>) -> Svg<'a, Theme>

Available on crate feature svg only.

Applies the given Rotation to the Svg.

Source

pub fn opacity(self, opacity: impl Into<f32>) -> Svg<'a, Theme>

Available on crate feature svg only.

Sets the opacity of the Svg.

It should be in the [0.0, 1.0] range—0.0 meaning completely transparent, and 1.0 meaning completely opaque.

Source

pub fn alt(self, text: impl Into<String>) -> Svg<'a, Theme>

Available on crate feature svg only.

Sets the alt text of the Svg.

This is the accessible name announced by screen readers. It should be a short phrase describing the image content.

Source

pub fn description(self, description: impl Into<String>) -> Svg<'a, Theme>

Available on crate feature svg only.

Sets an extended description of the Svg.

This supplements the alt text with additional context for assistive technology, when the alt text alone is not sufficient.

Trait Implementations§

Source§

impl<'a, Message, Theme, Renderer> From<Svg<'a, Theme>> for Element<'a, Message, Theme, Renderer>
where Theme: Catalog + 'a, Renderer: Renderer + 'a,

Source§

fn from(icon: Svg<'a, Theme>) -> Element<'a, Message, Theme, Renderer>

Converts to this type from the input type.
Source§

impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Svg<'_, Theme>
where Renderer: Renderer, Theme: Catalog,

Source§

fn size(&self) -> Size<Length>

Returns the Size of the Widget in lengths.
Source§

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

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

fn update( &mut self, _state: &mut Tree, event: &Event, layout: Layout<'_>, cursor: Cursor, _renderer: &Renderer, shell: &mut Shell<'_, Message>, _viewport: &Rectangle, )

Processes a runtime Event. Read more
Source§

fn draw( &self, _state: &Tree, renderer: &mut Renderer, theme: &Theme, _style: &Style, layout: Layout<'_>, _cursor: Cursor, _viewport: &Rectangle, )

Draws the Widget using the associated Renderer.
Source§

fn operate( &mut self, _tree: &mut Tree, layout: Layout<'_>, _renderer: &Renderer, operation: &mut dyn Operation, )

Applies an Operation to the Widget.
Source§

fn size_hint(&self) -> Size<Length>

Returns a Size hint for laying out the Widget. Read more
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)

Reconciles the Widget with the provided Tree.
Source§

fn mouse_interaction( &self, _tree: &Tree, _layout: Layout<'_>, _cursor: Cursor, _viewport: &Rectangle, _renderer: &Renderer, ) -> Interaction

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

fn overlay<'a>( &'a mut self, _tree: &'a mut Tree, _layout: Layout<'a>, _renderer: &Renderer, _viewport: &Rectangle, _translation: Vector, ) -> Option<Element<'a, Message, Theme, Renderer>>

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

Auto Trait Implementations§

§

impl<'a, Theme> Freeze for Svg<'a, Theme>
where <Theme as Catalog>::Class<'a>: Freeze,

§

impl<'a, Theme> RefUnwindSafe for Svg<'a, Theme>
where <Theme as Catalog>::Class<'a>: RefUnwindSafe,

§

impl<'a, Theme> Send for Svg<'a, Theme>
where <Theme as Catalog>::Class<'a>: Send,

§

impl<'a, Theme> Sync for Svg<'a, Theme>
where <Theme as Catalog>::Class<'a>: Sync,

§

impl<'a, Theme> Unpin for Svg<'a, Theme>
where <Theme as Catalog>::Class<'a>: Unpin,

§

impl<'a, Theme> UnsafeUnpin for Svg<'a, Theme>
where <Theme as Catalog>::Class<'a>: UnsafeUnpin,

§

impl<'a, Theme> UnwindSafe for Svg<'a, Theme>
where <Theme as Catalog>::Class<'a>: UnwindSafe,

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

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<State, Message> IntoBoot<State, Message> for State

Source§

fn into_boot(self) -> (State, Task<Message>)

Turns some type into the initial state of some Application.
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, 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<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,