pub struct Image { /* private fields */ }Expand description
Shows an image. Without a size it takes the image’s own size in logical
pixels; with only a width (or height) it keeps the aspect ratio. With
crossfade, a new image dissolves over the one before it.
use ravenrs_core::ImageData;
use ravenrs_widgets::{Image, Ui};
let pixel = ImageData::from_rgba8(1, 1, vec![200, 80, 40, 255]).expect("one pixel");
let photo = Image::new(pixel).size(160.0, 90.0).crossfade(0.2).alt("A photo");
let mut ui = Ui::new(photo, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl Image
impl Image
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Image, DecodeError>
pub fn from_bytes(bytes: &[u8]) -> Result<Image, DecodeError>
Decodes PNG or JPEG bytes (e.g. from include_bytes!).
Sourcepub fn content_mode(self, mode: ContentMode) -> Image
pub fn content_mode(self, mode: ContentMode) -> Image
How the image fills its frame (Cover by default).
Sourcepub fn corner_radius(self, radius: f32) -> Image
pub fn corner_radius(self, radius: f32) -> Image
Corner radius in logical pixels (default 0).
Sourcepub fn stretch(self) -> Image
pub fn stretch(self) -> Image
Stretches across the parent stack (height follows the aspect ratio unless set).
Sourcepub fn alt(self, text: impl Into<String>) -> Image
pub fn alt(self, text: impl Into<String>) -> Image
Describes the image for screen readers. Images without it are treated as decoration and hidden from them.
Sourcepub fn opacity(self, opacity: f32) -> Image
pub fn opacity(self, opacity: f32) -> Image
Opacity, 0.0 (invisible) to 1.0 (opaque, the default).
Sourcepub fn crossfade(self, seconds: f64) -> Image
pub fn crossfade(self, seconds: f64) -> Image
When the image changes, dissolves from the old one to the new one over this many
seconds. It asks for frames only while that lasts, and with reduced motion the new
one simply appears. Pass a clone of the same ImageData while the picture is the
same: new data counts as a new image, even with the same pixels.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnsafeUnpin for Image
impl UnwindSafe for Image
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.