pub struct Point<T: Coordinate> {
pub x: T,
pub y: T,
}Expand description
A 2D position defined by x and y coordinates.
Fields§
§x: T§y: TImplementations§
Source§impl Point<Twips>
impl Point<Twips>
Sourcepub fn from_pixels(x: f64, y: f64) -> Self
pub fn from_pixels(x: f64, y: f64) -> Self
Converts the given number of pixels into twips.
This may be a lossy conversion; any precision more than a twip (1/20 pixels) is truncated.
§Examples
// 40 pixels is equivalent to 800 twips.
let point = swf::Point::from_pixels(40.0, 20.0);
assert_eq!(point.x.get(), 800);
assert_eq!(point.y.get(), 400);
// Output is truncated if more precise than a twip (1/20 pixels).
let point = swf::Point::from_pixels(40.018, 20.0);
assert_eq!(point.x.get(), 800);
assert_eq!(point.y.get(), 400);Trait Implementations§
Source§impl<T: Coordinate> Add<PointDelta<T>> for Point<T>
impl<T: Coordinate> Add<PointDelta<T>> for Point<T>
Source§impl<T: Coordinate> AddAssign<PointDelta<T>> for Point<T>
impl<T: Coordinate> AddAssign<PointDelta<T>> for Point<T>
Source§fn add_assign(&mut self, other: PointDelta<T>)
fn add_assign(&mut self, other: PointDelta<T>)
Performs the
+= operation. Read moreSource§impl<T: Coordinate> Sub<PointDelta<T>> for Point<T>
impl<T: Coordinate> Sub<PointDelta<T>> for Point<T>
Source§impl<T: Coordinate> Sub for Point<T>
impl<T: Coordinate> Sub for Point<T>
Source§type Output = PointDelta<T>
type Output = PointDelta<T>
The resulting type after applying the
- operator.Source§fn sub(self, other: Self) -> PointDelta<T>
fn sub(self, other: Self) -> PointDelta<T>
Performs the
- operation. Read moreSource§impl<T: Coordinate> SubAssign<PointDelta<T>> for Point<T>
impl<T: Coordinate> SubAssign<PointDelta<T>> for Point<T>
Source§fn sub_assign(&mut self, other: PointDelta<T>)
fn sub_assign(&mut self, other: PointDelta<T>)
Performs the
-= operation. Read moreimpl<T: Copy + Coordinate> Copy for Point<T>
impl<T: Eq + Coordinate> Eq for Point<T>
impl<T: Coordinate> StructuralPartialEq for Point<T>
Auto Trait Implementations§
impl<T> Freeze for Point<T>where
T: Freeze,
impl<T> RefUnwindSafe for Point<T>where
T: RefUnwindSafe,
impl<T> Send for Point<T>where
T: Send,
impl<T> Sync for Point<T>where
T: Sync,
impl<T> Unpin for Point<T>where
T: Unpin,
impl<T> UnwindSafe for Point<T>where
T: 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