pub struct Size<T> {
pub width: T,
pub height: T,
}
Expand description
The width and height of a Rect
Fields§
§width: T
The x extent of the rectangle
height: T
The y extent of the rectangle
Implementations§
Source§impl<T> Size<T>
impl<T> Size<T>
Sourcepub fn get_abs(self, axis: AbsoluteAxis) -> T
pub fn get_abs(self, axis: AbsoluteAxis) -> T
Get either the width or height depending on the AbsoluteAxis passed in
Source§impl<T> Size<T>
impl<T> Size<T>
Sourcepub fn map<R, F>(self, f: F) -> Size<R>where
F: Fn(T) -> R,
pub fn map<R, F>(self, f: F) -> Size<R>where
F: Fn(T) -> R,
Applies the function f
to both the width and height
This is used to transform a Size<T>
into a Size<R>
.
Sourcepub fn map_width<F>(self, f: F) -> Size<T>where
F: Fn(T) -> T,
pub fn map_width<F>(self, f: F) -> Size<T>where
F: Fn(T) -> T,
Applies the function f
to the width
Sourcepub fn map_height<F>(self, f: F) -> Size<T>where
F: Fn(T) -> T,
pub fn map_height<F>(self, f: F) -> Size<T>where
F: Fn(T) -> T,
Applies the function f
to the height
Source§impl Size<f32>
impl Size<f32>
Sourcepub fn has_non_zero_area(self) -> bool
pub fn has_non_zero_area(self) -> bool
Return true if both width and height are greater than 0 else false
Source§impl Size<Option<f32>>
impl Size<Option<f32>>
Sourcepub const fn new(width: f32, height: f32) -> Self
pub const fn new(width: f32, height: f32) -> Self
A Size<Option<f32>>
with Some(width)
and Some(height)
as parameters
Sourcepub fn maybe_apply_aspect_ratio(
self,
aspect_ratio: Option<f32>,
) -> Size<Option<f32>>
pub fn maybe_apply_aspect_ratio( self, aspect_ratio: Option<f32>, ) -> Size<Option<f32>>
Applies aspect_ratio (if one is supplied) to the Size:
- If width is
Some
but height isNone
, then height is computed from width and aspect_ratio - If height is
Some
but width isNone
, then width is computed from height and aspect_ratio
If aspect_ratio is None
then this function simply returns self.
Source§impl<T> Size<Option<T>>
impl<T> Size<Option<T>>
Sourcepub fn unwrap_or(self, alt: Size<T>) -> Size<T>
pub fn unwrap_or(self, alt: Size<T>) -> Size<T>
Performs Option::unwrap_or on each component separately
Sourcepub fn or(self, alt: Size<Option<T>>) -> Size<Option<T>>
pub fn or(self, alt: Size<Option<T>>) -> Size<Option<T>>
Performs Option::or on each component separately
Sourcepub fn both_axis_defined(&self) -> bool
pub fn both_axis_defined(&self) -> bool
Return true if both components are Some, else false.
Source§impl Size<Dimension>
impl Size<Dimension>
Sourcepub const fn from_lengths(width: f32, height: f32) -> Self
pub const fn from_lengths(width: f32, height: f32) -> Self
Generates a Size<Dimension>
using Dimension::Length
values
Sourcepub const fn from_percent(width: f32, height: f32) -> Self
pub const fn from_percent(width: f32, height: f32) -> Self
Generates a Size<Dimension>
using Dimension::Percent
values
Source§impl Size<AvailableSpace>
impl Size<AvailableSpace>
Source§impl<T: TaffyMinContent> Size<T>
impl<T: TaffyMinContent> Size<T>
Sourcepub const fn min_content() -> Self
pub const fn min_content() -> Self
Returns a Size where both the width and height values are the min_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)
Source§impl<T: TaffyMaxContent> Size<T>
impl<T: TaffyMaxContent> Size<T>
Sourcepub const fn max_content() -> Self
pub const fn max_content() -> Self
Returns a Size where both the width and height values are the max_content value of the contained type (e.g. Dimension::Auto or LengthPercentageAuto::Auto)
Source§impl<T: TaffyFitContent> Size<T>
impl<T: TaffyFitContent> Size<T>
Sourcepub fn fit_content(argument: LengthPercentage) -> Self
pub fn fit_content(argument: LengthPercentage) -> Self
Returns a Size where with width and height set to the same fit-content(…)
value
with the given argument.