#[repr(C)]pub struct Size2<T: Unit = f32> {
pub width: T::Scalar,
pub height: T::Scalar,
}
Expand description
2D size.
Fields§
§width: T::Scalar
Width
height: T::Scalar
Height
Implementations§
source§impl<T: Unit> Size2<T>
impl<T: Unit> Size2<T>
sourcepub fn from_vector(vec: Vector2<T>) -> Self
pub fn from_vector(vec: Vector2<T>) -> Self
Interpret vec
as size.
sourcepub fn as_vector_mut(&mut self) -> &mut Vector2<T>
pub fn as_vector_mut(&mut self) -> &mut Vector2<T>
Reinterpret as vector.
sourcepub fn with_width(self, width: T::Scalar) -> Self
pub fn with_width(self, width: T::Scalar) -> Self
Replace the width component with a new value.
sourcepub fn with_height(self, height: T::Scalar) -> Self
pub fn with_height(self, height: T::Scalar) -> Self
Replace the width component with a new value.
source§impl<T: Unit> Size2<T>
impl<T: Unit> Size2<T>
sourcepub fn from_array(array: [T::Scalar; 2]) -> Self
pub fn from_array(array: [T::Scalar; 2]) -> Self
Instantiate from array.
See glam::Vec2::from_array()
.
sourcepub fn to_array(self) -> [T::Scalar; 2]
pub fn to_array(self) -> [T::Scalar; 2]
Convert to array.
See glam::Vec2::to_array()
.
sourcepub fn splat(scalar: T::Scalar) -> Self
pub fn splat(scalar: T::Scalar) -> Self
Instance with all components set to scalar
.
See glam::Vec2::splat()
.
sourcepub fn write_to_slice(self, slice: &mut [T::Scalar])
pub fn write_to_slice(self, slice: &mut [T::Scalar])
Write all components to slice.
sourcepub fn cmpeq(self, other: Self) -> BVec2
pub fn cmpeq(self, other: Self) -> BVec2
Return a mask with the result of a component-wise equals comparison.
See glam::Vec2::cmpeq()
.
sourcepub fn cmpne(self, other: Self) -> BVec2
pub fn cmpne(self, other: Self) -> BVec2
Return a mask with the result of a component-wise not-equal comparison.
See glam::Vec2::cmpne()
.
sourcepub fn cmpge(self, other: Self) -> BVec2
pub fn cmpge(self, other: Self) -> BVec2
Return a mask with the result of a component-wise greater-than-or-equal comparison.
See glam::Vec2::cmpge()
.
sourcepub fn cmpgt(self, other: Self) -> BVec2
pub fn cmpgt(self, other: Self) -> BVec2
Return a mask with the result of a component-wise greater-than comparison.
See glam::Vec2::cmpgt()
.
sourcepub fn cmple(self, other: Self) -> BVec2
pub fn cmple(self, other: Self) -> BVec2
Return a mask with the result of a component-wise less-than-or-equal comparison.
See glam::Vec2::cmple()
.
sourcepub fn cmplt(self, other: Self) -> BVec2
pub fn cmplt(self, other: Self) -> BVec2
Return a mask with the result of a component-wise less-than comparison.
See glam::Vec2::cmplt()
.
sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Minimum by component.
See glam::Vec2::min()
.
sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Maximum by component.
See glam::Vec2::max()
.
sourcepub fn min_element(self) -> T::Scalar
pub fn min_element(self) -> T::Scalar
Horizontal minimum (smallest component).
See glam::Vec2::min_element()
.
sourcepub fn max_element(self) -> T::Scalar
pub fn max_element(self) -> T::Scalar
Horizontal maximum (largest component).
See glam::Vec2::max_element()
.
sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Component-wise clamp.
See glam::Vec2::clamp()
.
sourcepub fn select(mask: BVec2, a: Self, b: Self) -> Self
pub fn select(mask: BVec2, a: Self, b: Self) -> Self
Select components from two instances based on a mask.
See glam::Vec2::select()
.
sourcepub fn from_untyped(untyped: Size2<T::Scalar>) -> Size2<T>
pub fn from_untyped(untyped: Size2<T::Scalar>) -> Size2<T>
Bitcast an untyped instance to self.
sourcepub fn to_untyped(self) -> Size2<T::Scalar>
pub fn to_untyped(self) -> Size2<T::Scalar>
Bitcast self to an untyped instance.
sourcepub fn as_untyped(&self) -> &Size2<T::Scalar>
pub fn as_untyped(&self) -> &Size2<T::Scalar>
Reinterpret cast self as the untyped variant.
sourcepub fn as_untyped_mut(&mut self) -> &mut Size2<T::Scalar>
pub fn as_untyped_mut(&mut self) -> &mut Size2<T::Scalar>
Reinterpret cast self as the untyped variant.
sourcepub fn cast<T2>(self) -> Size2<T2>
pub fn cast<T2>(self) -> Size2<T2>
Cast to a different coordinate space with the same underlying scalar type.
sourcepub fn cast_ref<T2>(&self) -> &Size2<T2>
pub fn cast_ref<T2>(&self) -> &Size2<T2>
Cast to a different coordinate space with the same underlying scalar type.
sourcepub fn cast_mut<T2>(&mut self) -> &mut Size2<T2>
pub fn cast_mut<T2>(&mut self) -> &mut Size2<T2>
Cast to a different coordinate space with the same underlying scalar type.
sourcepub fn try_cast<T2>(self) -> Option<Size2<T2>>where
T2: Unit,
pub fn try_cast<T2>(self) -> Option<Size2<T2>>where
T2: Unit,
Cast to a different coordinate space with scalar type conversion. Returns None
if any component could not be converted to the target scalar type.
sourcepub const fn from_tuple((width, height): (T::Scalar, T::Scalar)) -> Self
pub const fn from_tuple((width, height): (T::Scalar, T::Scalar)) -> Self
Instantiate from tuple.
sourcepub fn as_array_mut(&mut self) -> &mut [T::Scalar; 2]
pub fn as_array_mut(&mut self) -> &mut [T::Scalar; 2]
Reinterpret as mutable array.
source§impl<T> Size2<T>
impl<T> Size2<T>
sourcepub const NEG_INFINITY: Self = _
pub const NEG_INFINITY: Self = _
All negative infinity.
sourcepub fn is_finite(&self) -> bool
pub fn is_finite(&self) -> bool
True if all components are non-infinity and non-NaN.
See glam::Vec2::is_finite()
.
sourcepub fn is_nan(&self) -> bool
pub fn is_nan(&self) -> bool
True if any component is NaN.
See glam::Vec2::is_nan()
.
sourcepub fn is_nan_mask(&self) -> BVec2
pub fn is_nan_mask(&self) -> BVec2
Return a mask where each bit is set if the corresponding component is NaN.
See glam::Vec2::is_nan_mask()
.
sourcepub fn ceil(self) -> Self
pub fn ceil(self) -> Self
Round all components up.
See glam::Vec2::ceil()
.
sourcepub fn floor(self) -> Self
pub fn floor(self) -> Self
Round all components down.
See glam::Vec2::floor()
.
sourcepub fn round(self) -> Self
pub fn round(self) -> Self
Round all components.
See glam::Vec2::round()
.
sourcepub fn fract(self) -> Self
pub fn fract(self) -> Self
See (e.g.) glam::Vec2::fract()
See glam::Vec2::fract()
.
sourcepub fn fract_gl(self) -> Self
pub fn fract_gl(self) -> Self
See (e.g.) glam::Vec2::fract_gl()
See glam::Vec2::fract_gl()
.
sourcepub fn lerp(self, other: Self, t: T::Scalar) -> Self
pub fn lerp(self, other: Self, t: T::Scalar) -> Self
Linear interpolation.
See glam::Vec2::lerp()
.
Trait Implementations§
source§impl<T: Unit> AbsDiffEq for Size2<T>
impl<T: Unit> AbsDiffEq for Size2<T>
§type Epsilon = <<T as Unit>::Scalar as AbsDiffEq>::Epsilon
type Epsilon = <<T as Unit>::Scalar as AbsDiffEq>::Epsilon
source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
source§fn abs_diff_ne(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Self, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq
.source§impl<T: Unit> AddAssign for Size2<T>
impl<T: Unit> AddAssign for Size2<T>
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
+=
operation. Read moresource§impl<T> BorrowMut<DVec2> for Size2<T>
impl<T> BorrowMut<DVec2> for Size2<T>
source§fn borrow_mut(&mut self) -> &mut DVec2
fn borrow_mut(&mut self) -> &mut DVec2
source§impl<T> BorrowMut<I64Vec2> for Size2<T>
impl<T> BorrowMut<I64Vec2> for Size2<T>
source§fn borrow_mut(&mut self) -> &mut I64Vec2
fn borrow_mut(&mut self) -> &mut I64Vec2
source§impl<T> BorrowMut<IVec2> for Size2<T>
impl<T> BorrowMut<IVec2> for Size2<T>
source§fn borrow_mut(&mut self) -> &mut IVec2
fn borrow_mut(&mut self) -> &mut IVec2
source§impl<T> BorrowMut<Size2<T>> for DVec2
impl<T> BorrowMut<Size2<T>> for DVec2
source§fn borrow_mut(&mut self) -> &mut Size2<T>
fn borrow_mut(&mut self) -> &mut Size2<T>
source§impl<T> BorrowMut<Size2<T>> for I64Vec2
impl<T> BorrowMut<Size2<T>> for I64Vec2
source§fn borrow_mut(&mut self) -> &mut Size2<T>
fn borrow_mut(&mut self) -> &mut Size2<T>
source§impl<T> BorrowMut<Size2<T>> for IVec2
impl<T> BorrowMut<Size2<T>> for IVec2
source§fn borrow_mut(&mut self) -> &mut Size2<T>
fn borrow_mut(&mut self) -> &mut Size2<T>
source§impl<T> BorrowMut<Size2<T>> for U64Vec2
impl<T> BorrowMut<Size2<T>> for U64Vec2
source§fn borrow_mut(&mut self) -> &mut Size2<T>
fn borrow_mut(&mut self) -> &mut Size2<T>
source§impl<T> BorrowMut<Size2<T>> for UVec2
impl<T> BorrowMut<Size2<T>> for UVec2
source§fn borrow_mut(&mut self) -> &mut Size2<T>
fn borrow_mut(&mut self) -> &mut Size2<T>
source§impl<T> BorrowMut<Size2<T>> for Vec2
impl<T> BorrowMut<Size2<T>> for Vec2
source§fn borrow_mut(&mut self) -> &mut Size2<T>
fn borrow_mut(&mut self) -> &mut Size2<T>
source§impl<T> BorrowMut<U64Vec2> for Size2<T>
impl<T> BorrowMut<U64Vec2> for Size2<T>
source§fn borrow_mut(&mut self) -> &mut U64Vec2
fn borrow_mut(&mut self) -> &mut U64Vec2
source§impl<T> BorrowMut<UVec2> for Size2<T>
impl<T> BorrowMut<UVec2> for Size2<T>
source§fn borrow_mut(&mut self) -> &mut UVec2
fn borrow_mut(&mut self) -> &mut UVec2
source§impl<T> BorrowMut<Vec2> for Size2<T>
impl<T> BorrowMut<Vec2> for Size2<T>
source§fn borrow_mut(&mut self) -> &mut Vec2
fn borrow_mut(&mut self) -> &mut Vec2
source§impl<T: Unit> DivAssign<<T as Unit>::Scalar> for Size2<T>
impl<T: Unit> DivAssign<<T as Unit>::Scalar> for Size2<T>
source§fn div_assign(&mut self, other: T::Scalar)
fn div_assign(&mut self, other: T::Scalar)
/=
operation. Read moresource§impl<T: Unit> IntoIterator for Size2<T>
impl<T: Unit> IntoIterator for Size2<T>
source§impl<T: Unit> MulAssign<<T as Unit>::Scalar> for Size2<T>
impl<T: Unit> MulAssign<<T as Unit>::Scalar> for Size2<T>
source§fn mul_assign(&mut self, other: T::Scalar)
fn mul_assign(&mut self, other: T::Scalar)
*=
operation. Read moresource§impl<T: Unit> PartialEq<[<T as Unit>::Scalar; 2]> for Size2<T>
impl<T: Unit> PartialEq<[<T as Unit>::Scalar; 2]> for Size2<T>
source§impl<T: Unit> PartialEq<(<T as Unit>::Scalar, <T as Unit>::Scalar)> for Size2<T>
impl<T: Unit> PartialEq<(<T as Unit>::Scalar, <T as Unit>::Scalar)> for Size2<T>
source§impl<T: Unit> PartialEq for Size2<T>
impl<T: Unit> PartialEq for Size2<T>
source§impl<T: Unit> RelativeEq for Size2<T>where
T::Scalar: RelativeEq,
impl<T: Unit> RelativeEq for Size2<T>where
T::Scalar: RelativeEq,
source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool
source§fn relative_ne(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_ne( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool
RelativeEq::relative_eq
.source§impl<T: Unit> RemAssign<<T as Unit>::Scalar> for Size2<T>
impl<T: Unit> RemAssign<<T as Unit>::Scalar> for Size2<T>
source§fn rem_assign(&mut self, other: T::Scalar)
fn rem_assign(&mut self, other: T::Scalar)
%=
operation. Read moresource§impl<T: Unit> SubAssign for Size2<T>
impl<T: Unit> SubAssign for Size2<T>
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
-=
operation. Read moresource§impl<T: Unit> TransparentWrapper<<<T as Unit>::Scalar as Scalar>::Vec2> for Size2<T>
impl<T: Unit> TransparentWrapper<<<T as Unit>::Scalar as Scalar>::Vec2> for Size2<T>
source§fn wrap_ref(s: &Inner) -> &Self
fn wrap_ref(s: &Inner) -> &Self
source§fn wrap_mut(s: &mut Inner) -> &mut Self
fn wrap_mut(s: &mut Inner) -> &mut Self
source§fn wrap_slice(s: &[Inner]) -> &[Self]where
Self: Sized,
fn wrap_slice(s: &[Inner]) -> &[Self]where
Self: Sized,
source§fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]where
Self: Sized,
fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]where
Self: Sized,
source§fn peel_ref(s: &Self) -> &Inner
fn peel_ref(s: &Self) -> &Inner
source§fn peel_mut(s: &mut Self) -> &mut Inner
fn peel_mut(s: &mut Self) -> &mut Inner
source§impl<T: Unit> UlpsEq for Size2<T>
impl<T: Unit> UlpsEq for Size2<T>
impl<T: Unit> Copy for Size2<T>
impl<T> Eq for Size2<T>
impl<T: Unit> Pod for Size2<T>
SAFETY: All members are Pod
, and we are #[repr(C)]
.
Auto Trait Implementations§
impl<T> Freeze for Size2<T>
impl<T> RefUnwindSafe for Size2<T>
impl<T> Send for Size2<T>
impl<T> Sync for Size2<T>
impl<T> Unpin for Size2<T>
impl<T> UnwindSafe for Size2<T>
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
source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.