Struct kas::geom::Coord

source ·
pub struct Coord(pub i32, pub i32);
Expand description

A 2D coordinate, also known as a point

A coordinate (or point) is an absolute position. One cannot add a point to a point. The difference between two points is an Offset.

Tuple Fields§

§0: i32§1: i32

Implementations§

source§

impl Coord

source

pub const ZERO: Coord = _

The constant (0, 0)

source

pub const MIN: Coord = _

The minimum value

source

pub const MAX: Coord = _

The maximum value

source

pub fn lt(self, rhs: Coord) -> bool

True when for all components, lhs < rhs

source

pub fn le(self, rhs: Coord) -> bool

True when for all components, lhs ≤ rhs

source

pub fn ge(self, rhs: Coord) -> bool

True when for all components, lhs ≥ rhs

source

pub fn gt(self, rhs: Coord) -> bool

True when for all components, lhs > rhs

source

pub fn min(self, other: Coord) -> Coord

Return the minimum, componentwise

source

pub fn max(self, other: Coord) -> Coord

Return the maximum, componentwise

source

pub fn clamp(self, min: Coord, max: Coord) -> Coord

Restrict a value to the specified interval, componentwise

source

pub fn transpose(self) -> Coord

Return the transpose (swap x and y values)

source

pub fn cwise_mul(self, rhs: Coord) -> Coord

Return the result of component-wise multiplication

source

pub fn cwise_div(self, rhs: Coord) -> Coord

Return the result of component-wise division

source

pub fn distance_l1(self) -> i32

Return the L1 (rectilinear / taxicab) distance

source

pub fn distance_l_inf(self) -> i32

Return the L-inf (max) distance

source

pub fn extract<D>(self, dir: D) -> i32
where D: Directional,

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.

source

pub fn set_component<D>(&mut self, dir: D, value: i32)
where D: Directional,

Set one component of self, based on a direction

This does not negate components when the direction is reversed.

source§

impl Coord

source

pub fn new(x: i32, y: i32) -> Coord

Construct

source

pub const fn splat(n: i32) -> Coord

Construct, using the same value on all axes

Trait Implementations§

source§

impl Add<Offset> for Coord

§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, other: Offset) -> Coord

Performs the + operation. Read more
source§

impl Add<Size> for Coord

§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, other: Size) -> Coord

Performs the + operation. Read more
source§

impl AddAssign<Offset> for Coord

source§

fn add_assign(&mut self, rhs: Offset)

Performs the += operation. Read more
source§

impl AddAssign<Size> for Coord

source§

fn add_assign(&mut self, rhs: Size)

Performs the += operation. Read more
source§

impl Clone for Coord

source§

fn clone(&self) -> Coord

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Conv<(i32, i32)> for Coord

source§

fn conv(v: (i32, i32)) -> Coord

Convert from T to Self Read more
source§

fn try_conv(v: (i32, i32)) -> Result<Coord, Error>

Try converting from T to Self Read more
source§

impl Conv<Coord> for DVec2

source§

fn try_conv(arg: Coord) -> Result<DVec2, Error>

Try converting from T to Self Read more
§

fn conv(v: T) -> Self

Convert from T to Self Read more
source§

impl Conv<Coord> for Offset

source§

fn try_conv(v: Coord) -> Result<Offset, Error>

Try converting from T to Self Read more
§

fn conv(v: T) -> Self

Convert from T to Self Read more
source§

impl Conv<Coord> for Vec2

source§

fn try_conv(pos: Coord) -> Result<Vec2, Error>

Try converting from T to Self Read more
§

fn conv(v: T) -> Self

Convert from T to Self Read more
source§

impl Conv<Coord> for Vec2

source§

fn try_conv(arg: Coord) -> Result<Vec2, Error>

Try converting from T to Self Read more
§

fn conv(v: T) -> Self

Convert from T to Self Read more
source§

impl Conv<Offset> for Coord

Convert an Offset into a Coord

In debug mode this asserts that the result is non-negative.

source§

fn try_conv(v: Offset) -> Result<Coord, Error>

Try converting from T to Self Read more
§

fn conv(v: T) -> Self

Convert from T to Self Read more
source§

impl ConvApprox<DVec2> for Coord

source§

fn try_conv_approx(arg: DVec2) -> Result<Coord, Error>

Try converting from T to Self, allowing approximation of value Read more
§

fn conv_approx(x: T) -> Self

Converting from T to Self, allowing approximation of value Read more
source§

impl<X> ConvApprox<PhysicalPosition<X>> for Coord
where X: CastApprox<i32>,

source§

fn try_conv_approx(pos: PhysicalPosition<X>) -> Result<Coord, Error>

Try converting from T to Self, allowing approximation of value Read more
§

fn conv_approx(x: T) -> Self

Converting from T to Self, allowing approximation of value Read more
source§

impl ConvApprox<Vec2> for Coord

source§

fn try_conv_approx(arg: Vec2) -> Result<Coord, Error>

Try converting from T to Self, allowing approximation of value Read more
§

fn conv_approx(x: T) -> Self

Converting from T to Self, allowing approximation of value Read more
source§

impl ConvFloat<DVec2> for Coord

source§

fn try_conv_trunc(x: DVec2) -> Result<Coord, Error>

Try converting to integer with truncation Read more
source§

fn try_conv_nearest(x: DVec2) -> Result<Coord, Error>

Try converting to the nearest integer Read more
source§

fn try_conv_floor(x: DVec2) -> Result<Coord, Error>

Try converting the floor to an integer Read more
source§

fn try_conv_ceil(x: DVec2) -> Result<Coord, Error>

Try convert the ceiling to an integer Read more
§

fn conv_trunc(x: T) -> Self

Convert to integer with truncatation Read more
§

fn conv_nearest(x: T) -> Self

Convert to the nearest integer Read more
§

fn conv_floor(x: T) -> Self

Convert the floor to an integer Read more
§

fn conv_ceil(x: T) -> Self

Convert the ceiling to an integer Read more
source§

impl ConvFloat<Vec2> for Coord

source§

fn try_conv_trunc(x: Vec2) -> Result<Coord, Error>

Try converting to integer with truncation Read more
source§

fn try_conv_nearest(x: Vec2) -> Result<Coord, Error>

Try converting to the nearest integer Read more
source§

fn try_conv_floor(x: Vec2) -> Result<Coord, Error>

Try converting the floor to an integer Read more
source§

fn try_conv_ceil(x: Vec2) -> Result<Coord, Error>

Try convert the ceiling to an integer Read more
§

fn conv_trunc(x: T) -> Self

Convert to integer with truncatation Read more
§

fn conv_nearest(x: T) -> Self

Convert to the nearest integer Read more
§

fn conv_floor(x: T) -> Self

Convert the floor to an integer Read more
§

fn conv_ceil(x: T) -> Self

Convert the ceiling to an integer Read more
source§

impl Debug for Coord

source§

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

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

impl Default for Coord

source§

fn default() -> Coord

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

impl From<(i32, i32)> for Coord

source§

fn from(v: (i32, i32)) -> Coord

Converts to this type from the input type.
source§

impl Hash for Coord

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Coord

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Sub<Offset> for Coord

§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, other: Offset) -> Coord

Performs the - operation. Read more
source§

impl Sub<Size> for Coord

§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, other: Size) -> Coord

Performs the - operation. Read more
source§

impl Sub for Coord

§

type Output = Offset

The resulting type after applying the - operator.
source§

fn sub(self, other: Coord) -> Offset

Performs the - operation. Read more
source§

impl SubAssign<Offset> for Coord

source§

fn sub_assign(&mut self, rhs: Offset)

Performs the -= operation. Read more
source§

impl SubAssign<Size> for Coord

source§

fn sub_assign(&mut self, rhs: Size)

Performs the -= operation. Read more
source§

impl Copy for Coord

source§

impl Eq for Coord

source§

impl StructuralEq for Coord

source§

impl StructuralPartialEq for Coord

Auto Trait Implementations§

§

impl RefUnwindSafe for Coord

§

impl Send for Coord

§

impl Sync for Coord

§

impl Unpin for Coord

§

impl UnwindSafe for Coord

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
§

impl<S, T> Cast<T> for S
where T: Conv<S>,

§

fn cast(self) -> T

Cast from Self to T Read more
§

fn try_cast(self) -> Result<T, Error>

Try converting from Self to T Read more
§

impl<S, T> CastApprox<T> for S
where T: ConvApprox<S>,

§

fn try_cast_approx(self) -> Result<T, Error>

Try approximate conversion from Self to T Read more
§

fn cast_approx(self) -> T

Cast approximately from Self to T Read more
§

impl<S, T> CastFloat<T> for S
where T: ConvFloat<S>,

§

fn cast_trunc(self) -> T

Cast to integer, truncating Read more
§

fn cast_nearest(self) -> T

Cast to the nearest integer Read more
§

fn cast_floor(self) -> T

Cast the floor to an integer Read more
§

fn cast_ceil(self) -> T

Cast the ceiling to an integer Read more
§

fn try_cast_trunc(self) -> Result<T, Error>

Try converting to integer with truncation Read more
§

fn try_cast_nearest(self) -> Result<T, Error>

Try converting to the nearest integer Read more
§

fn try_cast_floor(self) -> Result<T, Error>

Try converting the floor to an integer Read more
§

fn try_cast_ceil(self) -> Result<T, Error>

Try convert the ceiling to an integer Read more
§

impl<S, T> ConvApprox<S> for T
where T: Conv<S>,

§

fn try_conv_approx(x: S) -> Result<T, Error>

Try converting from T to Self, allowing approximation of value Read more
§

fn conv_approx(x: S) -> T

Converting from T to Self, allowing approximation of value Read more
§

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

§

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

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

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

§

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.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
source§

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

§

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>,

§

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>,

§

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSync for T
where T: Sync,