Struct emath::pos2::Pos2

source ·
#[repr(C)]
pub struct Pos2 { pub x: f32, pub y: f32, }
Expand description

A position on screen.

Normally given in points (logical pixels).

Mathematically this is known as a “point”, but the term position was chosen so not to conflict with the unit (one point = X physical pixels).

Fields§

§x: f32

How far to the right.

§y: f32

How far down.

Implementations§

source§

impl Pos2

source

pub const ZERO: Self = _

The zero position, the origin. The top left corner in a GUI. Same as Pos2::default().

source

pub const fn new(x: f32, y: f32) -> Self

source

pub fn to_vec2(self) -> Vec2

The vector from origin to this position. p.to_vec2() is equivalent to p - Pos2::default().

source

pub fn distance(self, other: Self) -> f32

source

pub fn distance_sq(self, other: Self) -> f32

source

pub fn floor(self) -> Self

source

pub fn round(self) -> Self

source

pub fn ceil(self) -> Self

source

pub fn is_finite(self) -> bool

True if all members are also finite.

source

pub fn any_nan(self) -> bool

True if any member is NaN.

source

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

source

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

source

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

source

pub fn lerp(&self, other: Self, t: f32) -> Self

Linearly interpolate towards another point, so that 0.0 => self, 1.0 => other.

Trait Implementations§

source§

impl Add<Vec2> for Pos2

§

type Output = Pos2

The resulting type after applying the + operator.
source§

fn add(self, rhs: Vec2) -> Self

Performs the + operation. Read more
source§

impl AddAssign<Vec2> for Pos2

source§

fn add_assign(&mut self, rhs: Vec2)

Performs the += operation. Read more
source§

impl Clone for Pos2

source§

fn clone(&self) -> Pos2

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 Debug for Pos2

source§

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

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

impl Default for Pos2

source§

fn default() -> Pos2

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

impl Display for Pos2

source§

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

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

impl Div<f32> for Pos2

§

type Output = Pos2

The resulting type after applying the / operator.
source§

fn div(self, factor: f32) -> Self

Performs the / operation. Read more
source§

impl From<&[f32; 2]> for Pos2

source§

fn from(v: &[f32; 2]) -> Self

Converts to this type from the input type.
source§

impl From<&(f32, f32)> for Pos2

source§

fn from(v: &(f32, f32)) -> Self

Converts to this type from the input type.
source§

impl From<&Pos2> for [f32; 2]

source§

fn from(v: &Pos2) -> Self

Converts to this type from the input type.
source§

impl From<&Pos2> for (f32, f32)

source§

fn from(v: &Pos2) -> Self

Converts to this type from the input type.
source§

impl From<[f32; 2]> for Pos2

source§

fn from(v: [f32; 2]) -> Self

Converts to this type from the input type.
source§

impl From<(f32, f32)> for Pos2

source§

fn from(v: (f32, f32)) -> Self

Converts to this type from the input type.
source§

impl From<Pos2> for [f32; 2]

source§

fn from(v: Pos2) -> Self

Converts to this type from the input type.
source§

impl From<Pos2> for (f32, f32)

source§

fn from(v: Pos2) -> Self

Converts to this type from the input type.
source§

impl Index<usize> for Pos2

§

type Output = f32

The returned type after indexing.
source§

fn index(&self, index: usize) -> &f32

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

impl IndexMut<usize> for Pos2

source§

fn index_mut(&mut self, index: usize) -> &mut f32

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

impl Mul<Pos2> for &RectTransform

Transforms the position.

§

type Output = Pos2

The resulting type after applying the * operator.
source§

fn mul(self, pos: Pos2) -> Pos2

Performs the * operation. Read more
source§

impl Mul<Pos2> for RectTransform

Transforms the position.

§

type Output = Pos2

The resulting type after applying the * operator.
source§

fn mul(self, pos: Pos2) -> Pos2

Performs the * operation. Read more
source§

impl Mul<Pos2> for TSTransform

Transforms the position.

§

type Output = Pos2

The resulting type after applying the * operator.
source§

fn mul(self, pos: Pos2) -> Pos2

Performs the * operation. Read more
source§

impl Mul<Pos2> for f32

§

type Output = Pos2

The resulting type after applying the * operator.
source§

fn mul(self, vec: Pos2) -> Pos2

Performs the * operation. Read more
source§

impl Mul<f32> for Pos2

§

type Output = Pos2

The resulting type after applying the * operator.
source§

fn mul(self, factor: f32) -> Self

Performs the * operation. Read more
source§

impl NumExt for Pos2

source§

fn at_least(self, lower_limit: Self) -> Self

More readable version of self.max(lower_limit)
source§

fn at_most(self, upper_limit: Self) -> Self

More readable version of self.min(upper_limit)
source§

impl PartialEq for Pos2

source§

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

§

type Output = Pos2

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Vec2) -> Self

Performs the - operation. Read more
source§

impl Sub for Pos2

§

type Output = Vec2

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Vec2

Performs the - operation. Read more
source§

impl SubAssign<Vec2> for Pos2

source§

fn sub_assign(&mut self, rhs: Vec2)

Performs the -= operation. Read more
source§

impl Zeroable for Pos2

source§

fn zeroed() -> Self

source§

impl Copy for Pos2

source§

impl Eq for Pos2

source§

impl Pod for Pos2

source§

impl StructuralPartialEq for Pos2

Auto Trait Implementations§

§

impl Freeze for Pos2

§

impl RefUnwindSafe for Pos2

§

impl Send for Pos2

§

impl Sync for Pos2

§

impl Unpin for Pos2

§

impl UnwindSafe for Pos2

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

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.
source§

impl<T> AnyBitPattern for T
where T: Pod,

source§

impl<T> NoUninit for T
where T: Pod,