pub struct Position2D<T, S: CoordinateSpace> {
pub x: T,
pub y: T,
/* private fields */
}Expand description
A 2D position with a coordinate space marker.
Use the type aliases LogicalPosition and PhysicalPosition for convenience.
Fields§
§x: T§y: TImplementations§
Source§impl<T, S: CoordinateSpace> Position2D<T, S>
impl<T, S: CoordinateSpace> Position2D<T, S>
Source§impl<T: Copy, S: CoordinateSpace> Position2D<T, S>
impl<T: Copy, S: CoordinateSpace> Position2D<T, S>
Source§impl<T, S: CoordinateSpace> Position2D<T, S>
impl<T, S: CoordinateSpace> Position2D<T, S>
Sourcepub fn to_f32(self) -> Position2D<f32, S>
pub fn to_f32(self) -> Position2D<f32, S>
Cast to f32 type within the same coordinate space.
Sourcepub fn to_f64(self) -> Position2D<f64, S>
pub fn to_f64(self) -> Position2D<f64, S>
Cast to f64 type within the same coordinate space.
Source§impl<T> Position2D<T, Logical>
impl<T> Position2D<T, Logical>
Sourcepub fn to_physical(self, scale: ScaleFactor) -> PhysicalPosition<i32>
pub fn to_physical(self, scale: ScaleFactor) -> PhysicalPosition<i32>
Convert to physical coordinates.
Sourcepub fn to_physical_f32(self, scale: ScaleFactor) -> PhysicalPosition<f32>
pub fn to_physical_f32(self, scale: ScaleFactor) -> PhysicalPosition<f32>
Convert to physical coordinates as f32.
Sourcepub fn to_physical_f64(self, scale: ScaleFactor) -> PhysicalPosition<f64>
pub fn to_physical_f64(self, scale: ScaleFactor) -> PhysicalPosition<f64>
Convert to physical coordinates as f64.
Source§impl<T> Position2D<T, Physical>
impl<T> Position2D<T, Physical>
Sourcepub fn to_logical(self, scale: ScaleFactor) -> LogicalPosition<f32>
pub fn to_logical(self, scale: ScaleFactor) -> LogicalPosition<f32>
Convert to logical coordinates.
Sourcepub fn to_logical_f64(self, scale: ScaleFactor) -> LogicalPosition<f64>
pub fn to_logical_f64(self, scale: ScaleFactor) -> LogicalPosition<f64>
Convert to logical coordinates as f64.
Trait Implementations§
Source§impl<T: Add<Output = T>, S: CoordinateSpace> Add for Position2D<T, S>
impl<T: Add<Output = T>, S: CoordinateSpace> Add for Position2D<T, S>
Source§impl<T: Clone, S: Clone + CoordinateSpace> Clone for Position2D<T, S>
impl<T: Clone, S: Clone + CoordinateSpace> Clone for Position2D<T, S>
Source§fn clone(&self) -> Position2D<T, S>
fn clone(&self) -> Position2D<T, S>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug, S: Debug + CoordinateSpace> Debug for Position2D<T, S>
impl<T: Debug, S: Debug + CoordinateSpace> Debug for Position2D<T, S>
Source§impl<T: Default, S: CoordinateSpace> Default for Position2D<T, S>
impl<T: Default, S: CoordinateSpace> Default for Position2D<T, S>
Source§impl<T, S: CoordinateSpace> From<Position2D<T, S>> for Pos<T>
impl<T, S: CoordinateSpace> From<Position2D<T, S>> for Pos<T>
Source§fn from(pos: Position2D<T, S>) -> Self
fn from(pos: Position2D<T, S>) -> Self
Converts to this type from the input type.
Source§impl From<Position2D<f64, Logical>> for LogicalPosition<f64>
impl From<Position2D<f64, Logical>> for LogicalPosition<f64>
Source§fn from(pos: LogicalPosition<f64>) -> Self
fn from(pos: LogicalPosition<f64>) -> Self
Converts to this type from the input type.
Source§impl From<Position2D<f64, Physical>> for PhysicalPosition<f64>
impl From<Position2D<f64, Physical>> for PhysicalPosition<f64>
Source§fn from(pos: PhysicalPosition<f64>) -> Self
fn from(pos: PhysicalPosition<f64>) -> Self
Converts to this type from the input type.
Source§impl From<Position2D<i32, Physical>> for PhysicalPosition<i32>
impl From<Position2D<i32, Physical>> for PhysicalPosition<i32>
Source§fn from(pos: PhysicalPosition<i32>) -> Self
fn from(pos: PhysicalPosition<i32>) -> Self
Converts to this type from the input type.
Source§impl<T: Hash, S: CoordinateSpace> Hash for Position2D<T, S>
impl<T: Hash, S: CoordinateSpace> Hash for Position2D<T, S>
Source§impl<T: Mul<Output = T> + Copy, S: CoordinateSpace> Mul<T> for Position2D<T, S>
impl<T: Mul<Output = T> + Copy, S: CoordinateSpace> Mul<T> for Position2D<T, S>
Source§impl<T: PartialEq, S: CoordinateSpace> PartialEq for Position2D<T, S>
impl<T: PartialEq, S: CoordinateSpace> PartialEq for Position2D<T, S>
Source§impl<T: Sub<Output = T>, S: CoordinateSpace> Sub for Position2D<T, S>
impl<T: Sub<Output = T>, S: CoordinateSpace> Sub for Position2D<T, S>
impl<T: Copy, S: Copy + CoordinateSpace> Copy for Position2D<T, S>
impl<T: Eq, S: CoordinateSpace> Eq for Position2D<T, S>
Auto Trait Implementations§
impl<T, S> Freeze for Position2D<T, S>where
T: Freeze,
impl<T, S> RefUnwindSafe for Position2D<T, S>where
T: RefUnwindSafe,
S: RefUnwindSafe,
impl<T, S> Send for Position2D<T, S>
impl<T, S> Sync for Position2D<T, S>
impl<T, S> Unpin for Position2D<T, S>
impl<T, S> UnsafeUnpin for Position2D<T, S>where
T: UnsafeUnpin,
impl<T, S> UnwindSafe for Position2D<T, S>where
T: UnwindSafe,
S: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn 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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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.Source§fn as_any(&self) -> &(dyn Any + 'static)
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.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more