Skip to main content

PxPosition

Struct PxPosition 

Source
pub struct PxPosition {
    pub x: f32,
    pub y: f32,
}
Expand description

A fractional physical-pixel position; x increases rightward and y downward.

Fields§

§x: f32

The x-coordinate in physical pixels. May be fractional.

§y: f32

The y-coordinate in physical pixels. May be fractional.

Implementations§

Source§

impl PxPosition

Source

pub const ZERO: Self

A constant representing the zero position (0, 0).

Source

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

Creates a new position from whole-pixel coordinates.

Source

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

Creates a position from fractional pixel coordinates.

Source

pub fn x_px(self) -> Px

Returns the x-coordinate rounded to the nearest whole pixel.

Source

pub fn y_px(self) -> Px

Returns the y-coordinate rounded to the nearest whole pixel.

Source

pub fn offset(self, dx: Px, dy: Px) -> Self

Offsets the position by the given whole-pixel deltas.

Source

pub fn offset_f32(self, dx: f32, dy: f32) -> Self

Offsets the position by fractional pixel deltas.

Source

pub fn saturating_offset(self, dx: Px, dy: Px) -> Self

Offsets the position with saturating arithmetic.

Source

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

Calculates the Euclidean distance to another position.

Source

pub fn to_f32_arr2(self) -> [f32; 2]

Converts the position to a 2D f32 array.

Source

pub fn to_f32_arr3(self) -> [f32; 3]

Converts the position to a 3D f32 array with z=0.

Source

pub fn from_f32_arr2(arr: [f32; 2]) -> Self

Creates a position from a 2D f32 array.

Source

pub fn from_f32_arr3(arr: [f32; 3]) -> Self

Creates a position from a 3D f32 array, ignoring z.

Source

pub fn to_f64_arr2(self) -> [f64; 2]

Converts the position to a 2D f64 array.

Source

pub fn to_f64_arr3(self) -> [f64; 3]

Converts the position to a 3D f64 array with z=0.

Source

pub fn from_f64_arr2(arr: [f64; 2]) -> Self

Creates a position from a 2D f64 array.

Source

pub fn from_f64_arr3(arr: [f64; 3]) -> Self

Creates a position from a 3D f64 array, ignoring the z component.

Trait Implementations§

Source§

impl Add for PxPosition

Source§

type Output = PxPosition

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Clone for PxPosition

Source§

fn clone(&self) -> PxPosition

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for PxPosition

Source§

impl Debug for PxPosition

Source§

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

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

impl Default for PxPosition

Source§

fn default() -> PxPosition

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

impl From<PxPosition> for PhysicalPosition<i32>

Source§

fn from(pos: PxPosition) -> Self

Converts to this type from the input type.
Source§

impl From<PxPosition> for Position

Source§

fn from(pos: PxPosition) -> Self

Converts to this type from the input type.
Source§

impl From<PxPosition> for [i32; 2]

Source§

fn from(pos: PxPosition) -> Self

Converts to this type from the input type.
Source§

impl From<PxPosition> for [u32; 2]

Source§

fn from(pos: PxPosition) -> Self

Converts to this type from the input type.
Source§

impl From<PxPosition> for [Px; 2]

Source§

fn from(pos: PxPosition) -> Self

Converts to this type from the input type.
Source§

impl From<[Px; 2]> for PxPosition

Source§

fn from(pos: [Px; 2]) -> Self

Converts to this type from the input type.
Source§

impl From<[i32; 2]> for PxPosition

Source§

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

Converts to this type from the input type.
Source§

impl From<[u32; 2]> for PxPosition

Source§

fn from(pos: [u32; 2]) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for PxPosition

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PxPosition

Source§

impl Sub for PxPosition

Source§

type Output = PxPosition

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

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> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &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)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

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<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SendSync for T
where T: Send + Sync + 'static,

Source§

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

Source§

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

Source§

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

Source§

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> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

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

§

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