Struct Image
pub struct Image<'a, Handle = Handle> { /* private fields */ }Expand description
A frame that displays an image while keeping aspect ratio.
§Example
use iced::widget::image;
enum Message {
// ...
}
fn view(state: &State) -> Element<'_, Message> {
image("ferris.png").into()
}
Implementations§
§impl<'a, Handle> Image<'a, Handle>
impl<'a, Handle> Image<'a, Handle>
pub fn width(self, width: impl Into<Length>) -> Image<'a, Handle>
pub fn width(self, width: impl Into<Length>) -> Image<'a, Handle>
Sets the width of the Image boundaries.
pub fn height(self, height: impl Into<Length>) -> Image<'a, Handle>
pub fn height(self, height: impl Into<Length>) -> Image<'a, Handle>
Sets the height of the Image boundaries.
pub fn expand(self, expand: bool) -> Image<'a, Handle>
pub fn expand(self, expand: bool) -> Image<'a, Handle>
Sets whether the Image should try to fill as much space
available as possible while keeping aspect ratio and without
allocating extra space in any axis with a Length::Shrink
sizing strategy.
This is similar to using Length::Fill for both the
width and the height,
but without the downside of blank space.
pub fn content_fit(self, content_fit: ContentFit) -> Image<'a, Handle>
pub fn content_fit(self, content_fit: ContentFit) -> Image<'a, Handle>
Sets the ContentFit of the Image.
Defaults to ContentFit::Contain
pub fn filter_method(self, filter_method: FilterMethod) -> Image<'a, Handle>
pub fn filter_method(self, filter_method: FilterMethod) -> Image<'a, Handle>
Sets the FilterMethod of the Image.
pub fn opacity(self, opacity: impl Into<f32>) -> Image<'a, Handle>
pub fn opacity(self, opacity: impl Into<f32>) -> Image<'a, Handle>
Sets the opacity of the Image.
It should be in the [0.0, 1.0] range—0.0 meaning completely transparent,
and 1.0 meaning completely opaque.
pub fn crop(self, region: Rectangle<u32>) -> Image<'a, Handle>
pub fn crop(self, region: Rectangle<u32>) -> Image<'a, Handle>
Crops the Image to the given region described by the Rectangle in absolute
coordinates.
Cropping is done before applying any transformation or ContentFit. In practice,
this means that cropping an Image with this method should produce the same result
as cropping it externally (e.g. with an image editor) and creating a new Handle
for the cropped version.
However, this method is much more efficient; since it just leverages scissoring during rendering and no image cropping actually takes place. Instead, it reuses the existing image allocations and should be as efficient as not cropping at all!
The region coordinates will be clamped to the image dimensions, if necessary.
pub fn border_radius(
self,
border_radius: impl Into<Radius>,
) -> Image<'a, Handle>
pub fn border_radius( self, border_radius: impl Into<Radius>, ) -> Image<'a, Handle>
Sets the border::Radius of the Image.
Currently, it will only be applied around the rectangular bounding box
of the Image.
pub fn description_widget<T>(self, description: &T) -> Image<'a, Handle>where
T: Describes,
pub fn description_widget<T>(self, description: &T) -> Image<'a, Handle>where
T: Describes,
Sets the description of the Image.
Trait Implementations§
§impl<'a, Message, Theme, Renderer, Handle> From<Image<'a, Handle>> for Element<'a, Message, Theme, Renderer>
impl<'a, Message, Theme, Renderer, Handle> From<Image<'a, Handle>> for Element<'a, Message, Theme, Renderer>
§impl<'a, Message, Theme, Renderer, Handle> Widget<Message, Theme, Renderer> for Image<'a, Handle>
impl<'a, Message, Theme, Renderer, Handle> Widget<Message, Theme, Renderer> for Image<'a, Handle>
§fn draw(
&self,
_tree: &Tree,
renderer: &mut Renderer,
_theme: &Theme,
_style: &Style,
layout: Layout<'_>,
_cursor: Cursor,
_viewport: &Rectangle,
)
fn draw( &self, _tree: &Tree, renderer: &mut Renderer, _theme: &Theme, _style: &Style, layout: Layout<'_>, _cursor: Cursor, _viewport: &Rectangle, )
Widget using the associated Renderer.§fn a11y_nodes(
&self,
layout: Layout<'_>,
_state: &Tree,
_cursor: Cursor,
) -> A11yTree
fn a11y_nodes( &self, layout: Layout<'_>, _state: &Tree, _cursor: Cursor, ) -> A11yTree
§fn set_id(&mut self, id: Id)
fn set_id(&mut self, id: Id)
§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, )
§fn update(
&mut self,
_tree: &mut Tree,
_event: &Event,
_layout: Layout<'_>,
_cursor: Cursor,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
_shell: &mut Shell<'_, Message>,
_viewport: &Rectangle,
)
fn update( &mut self, _tree: &mut Tree, _event: &Event, _layout: Layout<'_>, _cursor: Cursor, _renderer: &Renderer, _clipboard: &mut dyn Clipboard, _shell: &mut Shell<'_, Message>, _viewport: &Rectangle, )
§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
§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>>
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>>
Widget, if there is any.§fn drag_destinations(
&self,
_state: &Tree,
_layout: Layout<'_>,
_renderer: &Renderer,
_dnd_rectangles: &mut DndDestinationRectangles,
)
fn drag_destinations( &self, _state: &Tree, _layout: Layout<'_>, _renderer: &Renderer, _dnd_rectangles: &mut DndDestinationRectangles, )
Auto Trait Implementations§
impl<'a, Handle> Freeze for Image<'a, Handle>where
Handle: Freeze,
impl<'a, Handle> RefUnwindSafe for Image<'a, Handle>where
Handle: RefUnwindSafe,
impl<'a, Handle> Send for Image<'a, Handle>where
Handle: Send,
impl<'a, Handle> Sync for Image<'a, Handle>where
Handle: Sync,
impl<'a, Handle> Unpin for Image<'a, Handle>where
Handle: Unpin,
impl<'a, Handle> UnwindSafe for Image<'a, Handle>where
Handle: UnwindSafe,
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
§impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<'a, Message, T> IntoListItem<'a, Message> for T
impl<'a, Message, T> IntoListItem<'a, Message> for T
fn into_list_item(self) -> ListItem<'a, Message>
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more