Struct kas::geom::Offset

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

A (x, y) offset, also known as a vector

This is a relative position. It can be added to or subtracted from a Coord, and it can be added to or subtracted from itself. It can be negative. It can be multiplied by a scalar.

This may be converted to Size with from / into.

Tuple Fields§

§0: i32§1: i32

Implementations§

source§

impl Offset

source

pub const ZERO: Offset = _

The constant (0, 0)

source

pub const MIN: Offset = _

The minimum value

source

pub const MAX: Offset = _

The maximum value

source

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

True when for all components, lhs < rhs

source

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

True when for all components, lhs ≤ rhs

source

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

True when for all components, lhs ≥ rhs

source

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

True when for all components, lhs > rhs

source

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

Return the minimum, componentwise

source

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

Return the maximum, componentwise

source

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

Restrict a value to the specified interval, componentwise

source

pub fn transpose(self) -> Offset

Return the transpose (swap x and y values)

source

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

Return the result of component-wise multiplication

source

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

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 Offset

source

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

Construct

source

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

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<Offset> for Event

§

type Output = Event

The resulting type after applying the + operator.
source§

fn add(self, offset: Offset) -> Event

Performs the + operation. Read more
source§

impl Add<Offset> for Rect

§

type Output = Rect

The resulting type after applying the + operator.
source§

fn add(self, offset: Offset) -> Rect

Performs the + operation. Read more
source§

impl Add for Offset

§

type Output = Offset

The resulting type after applying the + operator.
source§

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

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<Offset> for Event

source§

fn add_assign(&mut self, offset: Offset)

Performs the += operation. Read more
source§

impl AddAssign<Offset> for Rect

source§

fn add_assign(&mut self, offset: Offset)

Performs the += operation. Read more
source§

impl AddAssign for Offset

source§

fn add_assign(&mut self, rhs: Offset)

Performs the += operation. Read more
source§

impl Clone for Offset

source§

fn clone(&self) -> Offset

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 Offset

source§

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

Convert from T to Self Read more
source§

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

Try converting 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<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 Conv<Offset> for DVec2

source§

fn try_conv(arg: Offset) -> 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<Offset> for Size

Convert an Offset into a Size

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

source§

fn try_conv(v: Offset) -> Result<Size, 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 Vec2

source§

fn try_conv(arg: Offset) -> 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 Vec2

source§

fn try_conv(v: Offset) -> 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<Size> for Offset

source§

fn try_conv(v: Size) -> 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 ConvApprox<DVec2> for Offset

source§

fn try_conv_approx(arg: DVec2) -> Result<Offset, 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 Offset

source§

fn try_conv_approx(arg: Vec2) -> Result<Offset, 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 Offset

source§

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

Try converting to integer with truncation Read more
source§

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

Try converting to the nearest integer Read more
source§

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

Try converting the floor to an integer Read more
source§

fn try_conv_ceil(x: DVec2) -> Result<Offset, 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 Offset

source§

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

Try converting to integer with truncation Read more
source§

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

Try converting to the nearest integer Read more
source§

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

Try converting the floor to an integer Read more
source§

fn try_conv_ceil(x: Vec2) -> Result<Offset, 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 Offset

source§

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

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

impl Default for Offset

source§

fn default() -> Offset

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

impl Div<i32> for Offset

§

type Output = Offset

The resulting type after applying the / operator.
source§

fn div(self, x: i32) -> Offset

Performs the / operation. Read more
source§

impl From<(i32, i32)> for Offset

source§

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

Converts to this type from the input type.
source§

impl Hash for Offset

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 Mul<i32> for Offset

§

type Output = Offset

The resulting type after applying the * operator.
source§

fn mul(self, x: i32) -> Offset

Performs the * operation. Read more
source§

impl PartialEq for Offset

source§

fn eq(&self, other: &Offset) -> 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<Offset> for Rect

§

type Output = Rect

The resulting type after applying the - operator.
source§

fn sub(self, offset: Offset) -> Rect

Performs the - operation. Read more
source§

impl Sub for Offset

§

type Output = Offset

The resulting type after applying the - operator.
source§

fn sub(self, other: Offset) -> 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<Offset> for Rect

source§

fn sub_assign(&mut self, offset: Offset)

Performs the -= operation. Read more
source§

impl SubAssign for Offset

source§

fn sub_assign(&mut self, rhs: Offset)

Performs the -= operation. Read more
source§

impl Copy for Offset

source§

impl Eq for Offset

source§

impl StructuralEq for Offset

source§

impl StructuralPartialEq for Offset

Auto Trait Implementations§

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<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: 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.
§

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

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

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

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

§

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

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> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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,