pub struct PxPosition {
pub x: f32,
pub y: f32,
}Expand description
A fractional physical-pixel position; x increases rightward and y downward.
Fields§
§x: f32The x-coordinate in physical pixels. May be fractional.
y: f32The y-coordinate in physical pixels. May be fractional.
Implementations§
Source§impl PxPosition
impl PxPosition
Sourcepub const fn from_f32_xy(x: f32, y: f32) -> Self
pub const fn from_f32_xy(x: f32, y: f32) -> Self
Creates a position from fractional pixel coordinates.
Sourcepub fn offset(self, dx: Px, dy: Px) -> Self
pub fn offset(self, dx: Px, dy: Px) -> Self
Offsets the position by the given whole-pixel deltas.
Sourcepub fn offset_f32(self, dx: f32, dy: f32) -> Self
pub fn offset_f32(self, dx: f32, dy: f32) -> Self
Offsets the position by fractional pixel deltas.
Sourcepub fn saturating_offset(self, dx: Px, dy: Px) -> Self
pub fn saturating_offset(self, dx: Px, dy: Px) -> Self
Offsets the position with saturating arithmetic.
Sourcepub fn distance_to(self, other: Self) -> f32
pub fn distance_to(self, other: Self) -> f32
Calculates the Euclidean distance to another position.
Sourcepub fn to_f32_arr2(self) -> [f32; 2]
pub fn to_f32_arr2(self) -> [f32; 2]
Converts the position to a 2D f32 array.
Sourcepub fn to_f32_arr3(self) -> [f32; 3]
pub fn to_f32_arr3(self) -> [f32; 3]
Converts the position to a 3D f32 array with z=0.
Sourcepub fn from_f32_arr2(arr: [f32; 2]) -> Self
pub fn from_f32_arr2(arr: [f32; 2]) -> Self
Creates a position from a 2D f32 array.
Sourcepub fn from_f32_arr3(arr: [f32; 3]) -> Self
pub fn from_f32_arr3(arr: [f32; 3]) -> Self
Creates a position from a 3D f32 array, ignoring z.
Sourcepub fn to_f64_arr2(self) -> [f64; 2]
pub fn to_f64_arr2(self) -> [f64; 2]
Converts the position to a 2D f64 array.
Sourcepub fn to_f64_arr3(self) -> [f64; 3]
pub fn to_f64_arr3(self) -> [f64; 3]
Converts the position to a 3D f64 array with z=0.
Sourcepub fn from_f64_arr2(arr: [f64; 2]) -> Self
pub fn from_f64_arr2(arr: [f64; 2]) -> Self
Creates a position from a 2D f64 array.
Sourcepub fn from_f64_arr3(arr: [f64; 3]) -> Self
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
impl Add for PxPosition
Source§impl Clone for PxPosition
impl Clone for PxPosition
Source§fn clone(&self) -> PxPosition
fn clone(&self) -> PxPosition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PxPosition
Source§impl Debug for PxPosition
impl Debug for PxPosition
Source§impl Default for PxPosition
impl Default for PxPosition
Source§fn default() -> PxPosition
fn default() -> PxPosition
Source§impl From<PxPosition> for PhysicalPosition<i32>
impl From<PxPosition> for PhysicalPosition<i32>
Source§fn from(pos: PxPosition) -> Self
fn from(pos: PxPosition) -> Self
Source§impl From<PxPosition> for Position
impl From<PxPosition> for Position
Source§fn from(pos: PxPosition) -> Self
fn from(pos: PxPosition) -> Self
Source§impl From<PxPosition> for [i32; 2]
impl From<PxPosition> for [i32; 2]
Source§fn from(pos: PxPosition) -> Self
fn from(pos: PxPosition) -> Self
Source§impl From<PxPosition> for [u32; 2]
impl From<PxPosition> for [u32; 2]
Source§fn from(pos: PxPosition) -> Self
fn from(pos: PxPosition) -> Self
Source§impl From<PxPosition> for [Px; 2]
impl From<PxPosition> for [Px; 2]
Source§fn from(pos: PxPosition) -> Self
fn from(pos: PxPosition) -> Self
Source§impl PartialEq for PxPosition
impl PartialEq for PxPosition
impl StructuralPartialEq for PxPosition
Auto Trait Implementations§
impl Freeze for PxPosition
impl RefUnwindSafe for PxPosition
impl Send for PxPosition
impl Sync for PxPosition
impl Unpin for PxPosition
impl UnsafeUnpin for PxPosition
impl UnwindSafe for PxPosition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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 Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.