Struct PointDelta

Source
pub struct PointDelta<T: Coordinate> {
    pub dx: T,
    pub dy: T,
}
Expand description

A difference between two 2D points.

Fields§

§dx: T§dy: T

Implementations§

Source§

impl<T: Coordinate> PointDelta<T>

Source

pub const ZERO: Self

The PointDelta object with a value of (0, 0).

§Examples
assert_eq!(swf::PointDelta::<swf::Twips>::ZERO.dx, swf::Twips::ZERO);
assert_eq!(swf::PointDelta::<swf::Twips>::ZERO.dy, swf::Twips::ZERO);
Source

pub const fn new(dx: T, dy: T) -> Self

Source§

impl PointDelta<Twips>

Source

pub fn from_pixels(dx: f64, dy: 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::PointDelta::from_pixels(40.0, 20.0);
assert_eq!(point.dx.get(), 800);
assert_eq!(point.dy.get(), 400);

// Output is truncated if more precise than a twip (1/20 pixels).
let point = swf::PointDelta::from_pixels(40.018, 20.0);
assert_eq!(point.dx.get(), 800);
assert_eq!(point.dy.get(), 400);

Trait Implementations§

Source§

impl<T: Coordinate> Add<PointDelta<T>> for Point<T>

Source§

type Output = Point<T>

The resulting type after applying the + operator.
Source§

fn add(self, other: PointDelta<T>) -> Self

Performs the + operation. Read more
Source§

impl<T: Coordinate> AddAssign<PointDelta<T>> for Point<T>

Source§

fn add_assign(&mut self, other: PointDelta<T>)

Performs the += operation. Read more
Source§

impl<T: Clone + Coordinate> Clone for PointDelta<T>

Source§

fn clone(&self) -> PointDelta<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Coordinate> Debug for PointDelta<T>

Source§

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

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

impl<T: Default + Coordinate> Default for PointDelta<T>

Source§

fn default() -> PointDelta<T>

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

impl<T: Coordinate> Div<i32> for PointDelta<T>

Source§

type Output = PointDelta<T>

The resulting type after applying the / operator.
Source§

fn div(self, other: i32) -> Self

Performs the / operation. Read more
Source§

impl<T: Coordinate> DivAssign<i32> for PointDelta<T>

Source§

fn div_assign(&mut self, other: i32)

Performs the /= operation. Read more
Source§

impl<T: Coordinate> Mul<i32> for PointDelta<T>

Source§

type Output = PointDelta<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: i32) -> Self

Performs the * operation. Read more
Source§

impl<T: Coordinate> MulAssign<i32> for PointDelta<T>

Source§

fn mul_assign(&mut self, other: i32)

Performs the *= operation. Read more
Source§

impl<T: Coordinate> Neg for PointDelta<T>

Source§

type Output = PointDelta<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T: PartialEq + Coordinate> PartialEq for PointDelta<T>

Source§

fn eq(&self, other: &PointDelta<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Coordinate> Sub<PointDelta<T>> for Point<T>

Source§

type Output = Point<T>

The resulting type after applying the - operator.
Source§

fn sub(self, other: PointDelta<T>) -> Self

Performs the - operation. Read more
Source§

impl<T: Coordinate> SubAssign<PointDelta<T>> for Point<T>

Source§

fn sub_assign(&mut self, other: PointDelta<T>)

Performs the -= operation. Read more
Source§

impl<T: Copy + Coordinate> Copy for PointDelta<T>

Source§

impl<T: Eq + Coordinate> Eq for PointDelta<T>

Source§

impl<T: Coordinate> StructuralPartialEq for PointDelta<T>

Auto Trait Implementations§

§

impl<T> Freeze for PointDelta<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for PointDelta<T>
where T: RefUnwindSafe,

§

impl<T> Send for PointDelta<T>
where T: Send,

§

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

§

impl<T> Unpin for PointDelta<T>
where T: Unpin,

§

impl<T> UnwindSafe for PointDelta<T>
where T: UnwindSafe,

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

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.