pub struct Svg<'a, Theme = Theme>where
Theme: Catalog,{ /* private fields */ }Available on crate feature
svg only.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,
impl<'a, Theme> Svg<'a, Theme>where
Theme: Catalog,
Sourcepub fn from_path(path: impl Into<PathBuf>) -> Self
pub fn from_path(path: impl Into<PathBuf>) -> Self
Creates a new Svg that will display the contents of the file at the
provided path.
Sourcepub fn content_fit(self, content_fit: ContentFit) -> Self
pub fn content_fit(self, content_fit: ContentFit) -> Self
Sets the ContentFit of the Svg.
Defaults to ContentFit::Contain
Sourcepub fn style(self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self
pub fn style(self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self
Sets the style of the Svg.
Sourcepub fn class(self, class: impl Into<Theme::Class<'a>>) -> Self
Available on crate feature advanced only.
pub fn class(self, class: impl Into<Theme::Class<'a>>) -> Self
advanced only.Sets the style class of the Svg.
Trait Implementations§
Source§impl<'a, Message, Theme, Renderer> From<Svg<'a, Theme>> for Element<'a, Message, Theme, Renderer>
impl<'a, Message, Theme, Renderer> From<Svg<'a, Theme>> for Element<'a, Message, Theme, Renderer>
Source§impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Svg<'_, Theme>
impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Svg<'_, Theme>
Source§fn update(
&mut self,
_state: &mut Tree,
event: &Event,
layout: Layout<'_>,
cursor: Cursor,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
_viewport: &Rectangle,
)
fn update( &mut self, _state: &mut Tree, event: &Event, layout: Layout<'_>, cursor: Cursor, _renderer: &Renderer, _clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, _viewport: &Rectangle, )
Source§fn draw(
&self,
_state: &Tree,
renderer: &mut Renderer,
theme: &Theme,
_style: &Style,
layout: Layout<'_>,
_cursor: Cursor,
_viewport: &Rectangle,
)
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,
)
fn operate( &mut self, _tree: &mut Tree, _layout: Layout<'_>, _renderer: &Renderer, _operation: &mut dyn Operation, )
Source§fn mouse_interaction(
&self,
_tree: &Tree,
_layout: Layout<'_>,
_cursor: Cursor,
_viewport: &Rectangle,
_renderer: &Renderer,
) -> Interaction
fn mouse_interaction( &self, _tree: &Tree, _layout: Layout<'_>, _cursor: Cursor, _viewport: &Rectangle, _renderer: &Renderer, ) -> Interaction
Auto Trait Implementations§
impl<'a, Theme> Freeze for Svg<'a, Theme>
impl<'a, Theme> RefUnwindSafe for Svg<'a, Theme>
impl<'a, Theme> Send for Svg<'a, Theme>
impl<'a, Theme> Sync for Svg<'a, Theme>
impl<'a, Theme> Unpin for Svg<'a, Theme>
impl<'a, Theme> UnwindSafe for Svg<'a, Theme>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more