pub enum ScalingMode {
Exact,
Fit,
Cover,
Contain,
}Variants§
Exact
Scale to an exact size.
If both dimensions are given, aspect ratio is ignored. If at most a single dimension is given, aspect ratio is kept.
§Example
use aspect_ratio::{Size, Bounds};
assert_eq!(
Size::new(200, 200).scale(Bounds::exact().w(300).h(600)).unwrap(),
Size::new(300, 600)
);
assert_eq!(
Size::new(200, 100).scale(Bounds::exact().h(150)).unwrap(),
Size::new(200, 150)
);Fit
Fit to wxh while keeping aspect ratio, scaling up or down as required.
If at most one dimension is given, the larger image dimension is scaled to
fit into min(w, h).
§Example
use aspect_ratio::{Size, Bounds};
assert_eq!(
Size::new(200, 200).scale(Bounds::fit().w(400).h(100)).unwrap(),
Size::new(100, 100)
);Cover
Fit to cover (w, h) while keeping aspect ratio.
If at most one dimension is given, the smallest dimension is scaled up to
cover min(w, h).
§Example
use aspect_ratio::{Size, Bounds};
assert_eq!(
Size::new(200, 200).scale(Bounds::cover().w(400).h(100)).unwrap(),
Size::new(400, 400)
);Contain
Scale to be contained while keeping aspect ratio, only scaling down.
§Example
use aspect_ratio::{Size, Bounds};
assert_eq!(
Size::new(200, 200).scale(Bounds::contain().w(400).h(400)).unwrap(),
Size::new(200, 200)
);Implementations§
Source§impl ScalingMode
impl ScalingMode
pub fn iter() -> <Self as IntoEnumIterator>::Iterator
Trait Implementations§
Source§impl Clone for ScalingMode
impl Clone for ScalingMode
Source§fn clone(&self) -> ScalingMode
fn clone(&self) -> ScalingMode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ScalingMode
impl Debug for ScalingMode
Source§impl Default for ScalingMode
impl Default for ScalingMode
Source§impl Hash for ScalingMode
impl Hash for ScalingMode
Source§impl IntoEnumIterator for ScalingMode
impl IntoEnumIterator for ScalingMode
type Iterator = ScalingModeIter
fn iter() -> ScalingModeIter ⓘ
Source§impl Ord for ScalingMode
impl Ord for ScalingMode
Source§fn cmp(&self, other: &ScalingMode) -> Ordering
fn cmp(&self, other: &ScalingMode) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ScalingMode
impl PartialEq for ScalingMode
Source§impl PartialOrd for ScalingMode
impl PartialOrd for ScalingMode
impl Copy for ScalingMode
impl Eq for ScalingMode
impl StructuralPartialEq for ScalingMode
Auto Trait Implementations§
impl Freeze for ScalingMode
impl RefUnwindSafe for ScalingMode
impl Send for ScalingMode
impl Sync for ScalingMode
impl Unpin for ScalingMode
impl UnwindSafe for ScalingMode
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