Struct glam::i32::IVec2[][src]

#[repr(transparent)]
pub struct IVec2(_);
Expand description

A 2-dimensional vector.

Implementations

impl IVec2[src]

pub const ZERO: Self[src]

All zeroes.

pub const ONE: Self[src]

All ones.

pub const X: Self[src]

[1, 0]: a unit-length vector pointing along the positive X axis.

pub const Y: Self[src]

[0, 1]: a unit-length vector pointing along the positive Y axis.

pub const AXES: [Self; 2][src]

The unit axes.

pub fn new(x: i32, y: i32) -> IVec2[src]

Creates a new vector.

pub fn extend(self, z: i32) -> IVec3[src]

Creates a 3D vector from self and the given z value.

pub fn to_array(&self) -> [i32; 2][src]

[x, y]

pub fn splat(v: i32) -> Self[src]

Creates a vector with all elements set to v.

pub fn select(mask: BVec2, if_true: IVec2, if_false: IVec2) -> IVec2[src]

Creates a vector from the elements in if_true and if_false, selecting which to use for each element of self.

A true element in the mask uses the corresponding element from if_true, and false uses the element from if_false.

pub fn dot(self, other: Self) -> i32[src]

Computes the dot product of self and other.

pub fn min(self, other: Self) -> Self[src]

Returns a vector containing the mininum values for each element of self and other.

In other words this computes [self.x.max(other.x), self.y.max(other.y), ..].

pub fn max(self, other: Self) -> Self[src]

Returns a vector containing the maximum values for each element of self and other.

In other words this computes [self.x.max(other.x), self.y.max(other.y), ..].

pub fn clamp(self, min: Self, max: Self) -> Self[src]

Component-wise clamping of values, similar to f32::clamp.

Each element in min must be less-or-equal to the corresponing element in max.

If the glam-assert feature is enabled, the function will panic if the contract is not met, otherwise the behavior is undefined.

pub fn min_element(self) -> i32[src]

Returns the horizontal minimum of self.

In other words this computes min(x, y, ..).

pub fn max_element(self) -> i32[src]

Returns the horizontal maximum of self.

In other words this computes max(x, y, ..).

pub fn cmpeq(self, other: Self) -> BVec2[src]

Returns a vector mask containing the result of a == comparison for each element of self and other.

In other words, this computes [self.x == other.x, self.y == other.y, ..] for all elements.

pub fn cmpne(self, other: Self) -> BVec2[src]

Returns a vector mask containing the result of a != comparison for each element of self and other.

In other words this computes [self.x != other.x, self.y != other.y, ..] for all elements.

pub fn cmpge(self, other: Self) -> BVec2[src]

Returns a vector mask containing the result of a >= comparison for each element of self and other.

In other words this computes [self.x >= other.x, self.y >= other.y, ..] for all elements.

pub fn cmpgt(self, other: Self) -> BVec2[src]

Returns a vector mask containing the result of a > comparison for each element of self and other.

In other words this computes [self.x > other.x, self.y > other.y, ..] for all elements.

pub fn cmple(self, other: Self) -> BVec2[src]

Returns a vector mask containing the result of a <= comparison for each element of self and other.

In other words this computes [self.x <= other.x, self.y <= other.y, ..] for all elements.

pub fn cmplt(self, other: Self) -> BVec2[src]

Returns a vector mask containing the result of a < comparison for each element of self and other.

In other words this computes [self.x < other.x, self.y < other.y, ..] for all elements.

pub fn from_slice_unaligned(slice: &[i32]) -> Self[src]

👎 Deprecated since 0.15.2:

Please use from_slice() instead

pub fn from_slice(slice: &[i32]) -> Self[src]

Creates a vector from the first N values in slice.

Panics

Panics if slice is less than N elements long.

pub fn write_to_slice_unaligned(self, slice: &mut [i32])[src]

👎 Deprecated since 0.15.2:

Please use write_to_slice() instead

pub fn write_to_slice(self, slice: &mut [i32])[src]

Writes the elements of self to the first N elements in slice.

Panics

Panics if slice is less than N elements long.

pub fn abs(self) -> Self[src]

Returns a vector containing the absolute value of each element of self.

pub fn signum(self) -> Self[src]

Returns a vector with elements representing the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NAN if the number is NAN

pub fn perp(self) -> Self[src]

Returns a vector that is equal to self rotated by 90 degrees.

pub fn perp_dot(self, other: IVec2) -> i32[src]

The perpendicular dot product of self and other.

pub fn as_f32(&self) -> Vec2[src]

Casts all elements of self to f32.

pub fn as_f64(&self) -> DVec2[src]

Casts all elements of self to f64.

pub fn as_u32(&self) -> UVec2[src]

Casts all elements of self to u32.

Trait Implementations

impl Add<IVec2> for IVec2[src]

type Output = Self

The resulting type after applying the + operator.

fn add(self, other: Self) -> Self[src]

Performs the + operation. Read more

impl AddAssign<IVec2> for IVec2[src]

fn add_assign(&mut self, other: Self)[src]

Performs the += operation. Read more

impl AsMut<[i32; 2]> for IVec2[src]

fn as_mut(&mut self) -> &mut [i32; 2][src]

Performs the conversion.

impl AsRef<[i32; 2]> for IVec2[src]

fn as_ref(&self) -> &[i32; 2][src]

Performs the conversion.

impl Clone for IVec2[src]

fn clone(&self) -> IVec2[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for IVec2[src]

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

Formats the value using the given formatter. Read more

impl Default for IVec2[src]

fn default() -> Self[src]

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

impl Deref for IVec2[src]

type Target = XY<i32>

The resulting type after dereferencing.

fn deref(&self) -> &Self::Target[src]

Dereferences the value.

impl DerefMut for IVec2[src]

fn deref_mut(&mut self) -> &mut Self::Target[src]

Mutably dereferences the value.

impl Display for IVec2[src]

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

Formats the value using the given formatter. Read more

impl Div<IVec2> for IVec2[src]

type Output = Self

The resulting type after applying the / operator.

fn div(self, other: IVec2) -> Self[src]

Performs the / operation. Read more

impl Div<i32> for IVec2[src]

type Output = Self

The resulting type after applying the / operator.

fn div(self, other: i32) -> Self[src]

Performs the / operation. Read more

impl DivAssign<IVec2> for IVec2[src]

fn div_assign(&mut self, other: IVec2)[src]

Performs the /= operation. Read more

impl DivAssign<i32> for IVec2[src]

fn div_assign(&mut self, other: i32)[src]

Performs the /= operation. Read more

impl From<[i32; 2]> for IVec2[src]

fn from(a: [i32; 2]) -> Self[src]

Performs the conversion.

impl From<(i32, i32)> for IVec2[src]

fn from(t: (i32, i32)) -> Self[src]

Performs the conversion.

impl From<IVec3> for IVec2[src]

fn from(v: IVec3) -> Self[src]

Creates a Vec2 from the x and y elements of self, discarding z.

impl From<IVec4> for IVec2[src]

fn from(v: IVec4) -> Self[src]

Creates a 2D vector from the x and y elements of self, discarding z and w.

impl Hash for IVec2[src]

fn hash<H: Hasher>(&self, state: &mut H)[src]

Feeds this value into the given Hasher. Read more

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

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

impl Index<usize> for IVec2[src]

type Output = i32

The returned type after indexing.

fn index(&self, index: usize) -> &Self::Output[src]

Performs the indexing (container[index]) operation. Read more

impl IndexMut<usize> for IVec2[src]

fn index_mut(&mut self, index: usize) -> &mut Self::Output[src]

Performs the mutable indexing (container[index]) operation. Read more

impl Mul<IVec2> for IVec2[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, other: IVec2) -> Self[src]

Performs the * operation. Read more

impl Mul<i32> for IVec2[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, other: i32) -> Self[src]

Performs the * operation. Read more

impl MulAssign<IVec2> for IVec2[src]

fn mul_assign(&mut self, other: IVec2)[src]

Performs the *= operation. Read more

impl MulAssign<i32> for IVec2[src]

fn mul_assign(&mut self, other: i32)[src]

Performs the *= operation. Read more

impl Neg for IVec2[src]

type Output = Self

The resulting type after applying the - operator.

fn neg(self) -> Self[src]

Performs the unary - operation. Read more

impl PartialEq<IVec2> for IVec2[src]

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

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<'a> Product<&'a IVec2> for IVec2[src]

fn product<I>(iter: I) -> Self where
    I: Iterator<Item = &'a Self>, 
[src]

Method which takes an iterator and generates Self from the elements by multiplying the items. Read more

impl Sub<IVec2> for IVec2[src]

type Output = Self

The resulting type after applying the - operator.

fn sub(self, other: IVec2) -> Self[src]

Performs the - operation. Read more

impl SubAssign<IVec2> for IVec2[src]

fn sub_assign(&mut self, other: IVec2)[src]

Performs the -= operation. Read more

impl<'a> Sum<&'a IVec2> for IVec2[src]

fn sum<I>(iter: I) -> Self where
    I: Iterator<Item = &'a Self>, 
[src]

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

impl Vec2Swizzles for IVec2[src]

type Vec3 = IVec3

type Vec4 = IVec4

fn xxxx(self) -> IVec4[src]

fn xxxy(self) -> IVec4[src]

fn xxyx(self) -> IVec4[src]

fn xxyy(self) -> IVec4[src]

fn xyxx(self) -> IVec4[src]

fn xyxy(self) -> IVec4[src]

fn xyyx(self) -> IVec4[src]

fn xyyy(self) -> IVec4[src]

fn yxxx(self) -> IVec4[src]

fn yxxy(self) -> IVec4[src]

fn yxyx(self) -> IVec4[src]

fn yxyy(self) -> IVec4[src]

fn yyxx(self) -> IVec4[src]

fn yyxy(self) -> IVec4[src]

fn yyyx(self) -> IVec4[src]

fn yyyy(self) -> IVec4[src]

fn xxx(self) -> IVec3[src]

fn xxy(self) -> IVec3[src]

fn xyx(self) -> IVec3[src]

fn xyy(self) -> IVec3[src]

fn yxx(self) -> IVec3[src]

fn yxy(self) -> IVec3[src]

fn yyx(self) -> IVec3[src]

fn yyy(self) -> IVec3[src]

fn xx(self) -> Self[src]

fn yx(self) -> Self[src]

fn yy(self) -> Self[src]

fn xy(self) -> Self[src]

impl Copy for IVec2[src]

impl Eq for IVec2[src]

Auto Trait Implementations

impl RefUnwindSafe for IVec2

impl Send for IVec2

impl Sync for IVec2

impl Unpin for IVec2

impl UnwindSafe for IVec2

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.