pub enum ImageFit {
Contain,
Cover,
Fill,
None,
}Expand description
How a raster image projects into the rect resolved for its El.
Mirrors CSS object-fit. The El rect (after padding) is the
“viewport”; the image is the “content”.
Variants§
Contain
Scale uniformly so the image fits inside the rect, preserving
aspect ratio. Letterbox bands appear on the side that runs
short. Default — matches the CSS default for <img> in most
frameworks.
Cover
Scale uniformly so the image covers the rect, preserving aspect
ratio. Excess on the longer axis is clipped via the El’s
scissor (the destination rect can extend past the El’s content
area; draw_ops clips it back).
Fill
Stretch the image to the rect, ignoring aspect ratio.
None
No scaling — paint at the image’s natural pixel size, anchored top-left within the rect. Excess clips via the scissor.
Implementations§
Trait Implementations§
impl Copy for ImageFit
impl Eq for ImageFit
impl StructuralPartialEq for ImageFit
Auto Trait Implementations§
impl Freeze for ImageFit
impl RefUnwindSafe for ImageFit
impl Send for ImageFit
impl Sync for ImageFit
impl Unpin for ImageFit
impl UnsafeUnpin for ImageFit
impl UnwindSafe for ImageFit
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.