Struct Size

Source
#[repr(C)]
pub struct Size<N, Kind> { pub w: N, pub h: N, /* private fields */ }
Expand description

A size as defined by its width and height

Constructors of this type ensure that the values are always positive via debug_assert!(), however manually changing the values of the fields can break this invariant.

Operations on sizes are saturating.

Fields§

§w: N

horizontal coordinate

§h: N

vertical coordinate

Implementations§

Source§

impl<N: Coordinate, Kind> Size<N, Kind>

Source

pub fn new(w: N, h: N) -> Size<N, Kind>

Create a new Size

Source§

impl<N: Coordinate, Kind> Size<N, Kind>

Source

pub fn to_point(self) -> Point<N, Kind>

Convert this Size to a Point with the same coordinates

Source§

impl<N: Coordinate, Kind> Size<N, Kind>

Source

pub fn clamp( self, min: impl Into<Size<N, Kind>>, max: impl Into<Size<N, Kind>>, ) -> Size<N, Kind>

Restrict this Size to min and max Size with the same coordinates

Source§

impl<N: Coordinate, Kind> Size<N, Kind>

Source

pub fn to_f64(self) -> Size<f64, Kind>

Convert the underlying numerical type to f64 for floating point manipulations

Source§

impl<N: Coordinate, Kind> Size<N, Kind>

Source

pub fn upscale(self, scale: impl Into<Scale<N>>) -> Size<N, Kind>

Upscale this Size by a specified Scale

Source

pub fn downscale(self, scale: impl Into<Scale<N>>) -> Size<N, Kind>

Downscale this Size by a specified Scale

Source

pub fn is_empty(&self) -> bool

Check if this Size is empty

Returns true if either the width or the height is zero

Source§

impl<Kind> Size<f64, Kind>

Source

pub fn to_i32_round<N: Coordinate>(self) -> Size<N, Kind>

Convert to i32 for integer-space manipulations by rounding float values

Source

pub fn to_i32_floor<N: Coordinate>(self) -> Size<N, Kind>

Convert to i32 for integer-space manipulations by flooring float values

Source

pub fn to_i32_ceil<N: Coordinate>(self) -> Size<N, Kind>

Convert to i32 for integer-space manipulations by ceiling float values

Source§

impl<N: Coordinate> Size<N, Logical>

Source

pub fn to_physical(self, scale: impl Into<Scale<N>>) -> Size<N, Physical>

Convert this logical size to physical coordinate space according to given scale factor

Source

pub fn to_physical_precise_round<S: Coordinate, R: Coordinate>( self, scale: impl Into<Scale<S>>, ) -> Size<R, Physical>

Convert this logical size to physical coordinate space according to given scale factor and round the result

Source

pub fn to_physical_precise_ceil<S: Coordinate, R: Coordinate>( &self, scale: impl Into<Scale<S>>, ) -> Size<R, Physical>

Convert this logical size to physical coordinate space according to given scale factor and ceil the result

Source

pub fn to_physical_precise_floor<S: Coordinate, R: Coordinate>( &self, scale: impl Into<Scale<S>>, ) -> Size<R, Physical>

Convert this logical size to physical coordinate space according to given scale factor and floor the result

Source

pub fn to_buffer( self, scale: impl Into<Scale<N>>, transformation: Transform, ) -> Size<N, Buffer>

Convert this logical size to buffer coordinate space according to given scale factor

Source§

impl<N: Coordinate> Size<N, Physical>

Source

pub fn to_logical(self, scale: impl Into<Scale<N>>) -> Size<N, Logical>

Convert this physical point to logical coordinate space according to given scale factor

Source§

impl<N: Coordinate> Size<N, Buffer>

Source

pub fn to_logical( self, scale: impl Into<Scale<N>>, transformation: Transform, ) -> Size<N, Logical>

Convert this physical point to logical coordinate space according to given scale factor

Trait Implementations§

Source§

impl<N: Coordinate, Kind> Add<Size<N, Kind>> for Point<N, Kind>

Source§

type Output = Point<N, Kind>

The resulting type after applying the + operator.
Source§

fn add(self, other: Size<N, Kind>) -> Point<N, Kind>

Performs the + operation. Read more
Source§

impl<N: Coordinate, Kind> Add for Size<N, Kind>

Source§

type Output = Size<N, Kind>

The resulting type after applying the + operator.
Source§

fn add(self, other: Size<N, Kind>) -> Size<N, Kind>

Performs the + operation. Read more
Source§

impl<N: Coordinate, Kind> AddAssign for Size<N, Kind>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<N: Clone, Kind> Clone for Size<N, Kind>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<N: Debug, S> Debug for Size<N, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<N: Default, Kind> Default for Size<N, Kind>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<N: Coordinate + Div, Kind> Div<N> for Size<N, Kind>

Source§

type Output = Size<<N as Div>::Output, Kind>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: N) -> Self::Output

Performs the / operation. Read more
Source§

impl<N: Coordinate + Div<Output = N>, KindLhs, KindRhs> Div<Size<N, KindRhs>> for Size<N, KindLhs>

Source§

type Output = Scale<N>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Size<N, KindRhs>) -> Self::Output

Performs the / operation. Read more
Source§

impl<N: Coordinate, Kind> From<(N, N)> for Size<N, Kind>

Source§

fn from((w, h): (N, N)) -> Size<N, Kind>

Converts to this type from the input type.
Source§

impl<N, Kind> From<Size<N, Kind>> for (N, N)

Source§

fn from(point: Size<N, Kind>) -> (N, N)

Converts to this type from the input type.
Source§

impl<N: Coordinate + Mul, Kind> Mul<N> for Size<N, Kind>

Source§

type Output = Size<<N as Mul>::Output, Kind>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: N) -> Self::Output

Performs the * operation. Read more
Source§

impl<N: PartialEq, Kind> PartialEq for Size<N, Kind>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<N: Coordinate, Kind> Sub<Size<N, Kind>> for Point<N, Kind>

Source§

type Output = Point<N, Kind>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Size<N, Kind>) -> Point<N, Kind>

Performs the - operation. Read more
Source§

impl<N: Coordinate, Kind> Sub for Size<N, Kind>

Source§

type Output = Size<N, Kind>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<N: Coordinate, Kind> SubAssign for Size<N, Kind>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<N: Copy, Kind> Copy for Size<N, Kind>

Source§

impl<N: Eq, Kind> Eq for Size<N, Kind>

Auto Trait Implementations§

§

impl<N, Kind> Freeze for Size<N, Kind>
where N: Freeze,

§

impl<N, Kind> RefUnwindSafe for Size<N, Kind>
where N: RefUnwindSafe, Kind: RefUnwindSafe,

§

impl<N, Kind> Send for Size<N, Kind>
where N: Send, Kind: Send,

§

impl<N, Kind> Sync for Size<N, Kind>
where N: Sync, Kind: Sync,

§

impl<N, Kind> Unpin for Size<N, Kind>
where N: Unpin, Kind: Unpin,

§

impl<N, Kind> UnwindSafe for Size<N, Kind>
where N: UnwindSafe, Kind: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more