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<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_points(width: f32, height: f32) -> Self
pub const fn from_points(width: f32, height: f32) -> Self
Generates a Size<Dimension>
using Dimension::Points
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 both the width and height values are the constant fit_content value of the contained type (e.g. 2.1, Some(2.1), or Dimension::Points(2.1))