pub struct Coord2D {
pub x: i32,
pub y: i32,
}
Expand description
A 2-D integer coordinate type.
Fields§
§x: i32
§y: i32
Implementations§
Source§impl Coord2D
impl Coord2D
pub const fn new(x: i32, y: i32) -> Self
Sourcepub fn abs_diff(&self, other: &Coord2D) -> Self
pub fn abs_diff(&self, other: &Coord2D) -> Self
Returns the absolute value of the difference to other, component by component.
Sourcepub fn shortest_dim_dist(&self, other: &Coord2D) -> i32
pub fn shortest_dim_dist(&self, other: &Coord2D) -> i32
Returns the value of the smallest dimension of the absolute value of the difference to other.
Sourcepub fn largest_dim_dist(&self, other: &Coord2D) -> i32
pub fn largest_dim_dist(&self, other: &Coord2D) -> i32
Returns the value of the largest dimension of the absolute value of the difference to other.
Sourcepub fn max_per_comp(&self, other: Coord2D) -> Self
pub fn max_per_comp(&self, other: Coord2D) -> Self
Returns the maximum value of self and other, component by component.
Sourcepub fn min_per_comp(&self, other: Coord2D) -> Self
pub fn min_per_comp(&self, other: Coord2D) -> Self
Returns the minimum value of self and other, component by component.
Sourcepub fn rand_uniform(range: Coord2D) -> Self
pub fn rand_uniform(range: Coord2D) -> Self
Generates a random value between 0 and range.
Sourcepub fn manhattan_dist(&self, other: Coord2D) -> i32
pub fn manhattan_dist(&self, other: Coord2D) -> i32
Manhattan distance between self and other.
Trait Implementations§
Source§impl AddAssign for Coord2D
impl AddAssign for Coord2D
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moreSource§impl DivAssign<i32> for Coord2D
impl DivAssign<i32> for Coord2D
Source§fn div_assign(&mut self, rhs: i32)
fn div_assign(&mut self, rhs: i32)
Performs the
/=
operation. Read moreSource§impl MulAssign<i32> for Coord2D
impl MulAssign<i32> for Coord2D
Source§fn mul_assign(&mut self, rhs: i32)
fn mul_assign(&mut self, rhs: i32)
Performs the
*=
operation. Read moreSource§impl Ord for Coord2D
impl Ord for Coord2D
Source§impl PartialOrd for Coord2D
impl PartialOrd for Coord2D
Source§impl SubAssign for Coord2D
impl SubAssign for Coord2D
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moreimpl Copy for Coord2D
impl Eq for Coord2D
impl StructuralPartialEq for Coord2D
Auto Trait Implementations§
impl Freeze for Coord2D
impl RefUnwindSafe for Coord2D
impl Send for Coord2D
impl Sync for Coord2D
impl Unpin for Coord2D
impl UnwindSafe for Coord2D
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Convert the source color to the destination color using the specified
method
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford
method by default
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
Source§fn convert_into(self) -> U
fn convert_into(self) -> U
Convert into T with values clamped to the color defined bounds Read more
Source§fn convert_unclamped_into(self) -> U
fn convert_unclamped_into(self) -> U
Convert into T. The resulting color might be invalid in its color space Read more
Source§fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
Convert into T, returning ok if the color is inside of its defined range,
otherwise an
OutOfBounds
error is returned which contains the unclamped color. Read moreSource§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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.