Struct kas::geom::Size [−][src]
Expand description
A 2D size, also known as an extent
This is both a size and a relative position. One can add or subtract a size
from a Coord
. One can multiply a size by a scalar.
A Size
is expected to be non-negative; some methods such as Size::new
and implementations of subtraction will check this, but only in debug mode
(similar to overflow checks on integers).
This may be converted to Offset
with from
/ into
.
Tuple Fields
0: i32
1: i32
Implementations
Construct
In debug mode, this asserts that components are non-negative.
Subtraction, clamping the result to 0 or greater
Scale to fit within the target size, keeping aspect ratio
If either dimension of self is 0, this returns None.
Return the value clamped to the given min
and max
In the case that min > max
, the min
value is returned.
Return the L1 (rectilinear / taxicab) distance
Return the L-inf (max) distance
Extract one component, based on a direction
This merely extracts the horizontal or vertical component. It never negates it, even if the axis is reversed.
Set one component of self, based on a direction
This does not negate components when the direction is reversed.
Trait Implementations
Performs the +=
operation. Read more
Performs the +=
operation. Read more
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Size, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Size, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Performs the -=
operation. Read more
Performs the -=
operation. Read more
Auto Trait Implementations
impl RefUnwindSafe for Size
impl UnwindSafe for Size
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn cast_trunc(self) -> T
pub fn cast_trunc(self) -> T
Cast to integer, truncating Read more
pub fn cast_nearest(self) -> T
pub fn cast_nearest(self) -> T
Cast to the nearest integer Read more
pub fn cast_floor(self) -> T
pub fn cast_floor(self) -> T
Cast the floor to an integer Read more
pub fn try_cast_trunc(self) -> Result<T, Error>
pub fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
pub fn try_cast_nearest(self) -> Result<T, Error>
pub fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
pub fn try_cast_floor(self) -> Result<T, Error>
pub fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
pub fn try_cast_ceil(self) -> Result<T, Error>
pub fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more
Compare self to key
and return true
if they are equal.
Checks that type has a default value.