ScaleOffset2D

Struct ScaleOffset2D 

Source
#[repr(C)]
pub struct ScaleOffset2D<T, Src, Dst> { pub sx: T, pub sy: T, pub tx: T, pub ty: T, /* private fields */ }

Fields§

§sx: T§sy: T§tx: T§ty: T

Implementations§

Source§

impl<T, Src, Dst> ScaleOffset2D<T, Src, Dst>

Source

pub fn identity() -> Self
where T: Zero + One,

Create an identity transform.

Source

pub fn new(sx: T, sy: T, tx: T, ty: T) -> Self

Create a transform with provided scale and offset terms.

Source

pub fn scale(sx: T, sy: T) -> Self
where T: Zero,

Create a transform from a scale.

Source

pub fn offset(tx: T, ty: T) -> Self
where T: One,

Create a transform from an offset.

Source

pub fn is_identity(&self) -> bool
where T: One + Zero + ApproxEq<T>,

Returns true if self is an identity transform, using T’s default epsilon value.

Source

pub fn is_identity_eps(&self, epsilon: T) -> bool
where T: One + Zero + ApproxEq<T>,

Returns true if self is an identity transform.

Source§

impl<T: Copy, Src, Dst> ScaleOffset2D<T, Src, Dst>

Source

pub fn transform_point(&self, p: Point2D<T, Src>) -> Point2D<T, Dst>
where T: Add<Output = T> + Mul<Output = T>,

Returns the given point transformed by this transform.

Source

pub fn transform_vector(&self, v: Vector2D<T, Src>) -> Vector2D<T, Dst>
where T: Mul<Output = T>,

Returns the given vector transformed by this transform.

Source

pub fn transform_box(&self, b: &Box2D<T, Src>) -> Box2D<T, Dst>
where T: Zero + Add<Output = T> + Mul<Output = T> + PartialOrd,

Returns the given box transformed by this transform.

Source

pub fn transform_rect(&self, r: &Rect<T, Src>) -> Rect<T, Dst>
where T: Zero + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + PartialOrd,

Returns the given rectangle transformed by this transform.

Source

pub fn then<NewDst>( &self, other: &ScaleOffset2D<T, Dst, NewDst>, ) -> ScaleOffset2D<T, Src, NewDst>
where T: Add<Output = T> + Mul<Output = T>,

Produce a ScaleOffset2D that includes both self and other. The ‘other’ ScaleOffset2D is applied after self.

This is equivalent to Transform2D::then.

Source

pub fn pre_translate(&self, v: Vector2D<T, Src>) -> Self
where T: Add<Output = T> + Mul<Output = T>,

Applies a translation before self’s transformation and returns the resulting transform.

Source

pub fn then_translate(&self, v: Vector2D<T, Dst>) -> Self
where T: Add<Output = T> + Mul<Output = T>,

Applies a translation after self’s transformation and returns the resulting transform.

Source

pub fn pre_scale(&self, sx: T, sy: T) -> Self
where T: Add<Output = T> + Mul<Output = T>,

Applies a scale before self’s transformation and returns the resulting transform.

Source

pub fn then_scale(&self, sx: T, sy: T) -> Self
where T: Add<Output = T> + Mul<Output = T>,

Applies a scale after self’s transformation and returns the resulting transform.

Source

pub fn is_invertible(&self) -> bool
where T: Zero + PartialEq,

Returns whether it is possible to compute the inverse transform.

Source

pub fn inverse(&self) -> Option<ScaleOffset2D<T, Dst, Src>>
where T: Zero + One + PartialEq + Div<Output = T> + Mul<Output = T> + Neg<Output = T>,

Returns the inverse transform if possible.

Source

pub fn to_transform2d(&self) -> Transform2D<T, Src, Dst>
where T: Zero,

Returns the same transform using Transform2D’s matrix representation.

Source

pub fn to_transform3d(&self) -> Transform3D<T, Src, Dst>
where T: Zero + One,

Returns the same transform using Transform3D’s matrix representation.

Source

pub fn to_array(&self) -> [T; 4]

Returns an array containing this transform’s terms.

The terms are laid out in the same order as they are specified in ScaleOffset2D::new.

Source

pub fn with_source<NewSrc>(&self) -> ScaleOffset2D<T, NewSrc, Dst>

Returns the same transform with a different source unit.

Source

pub fn with_destination<NewDst>(&self) -> ScaleOffset2D<T, Src, NewDst>

Returns the same transform with a different destination unit.

Source

pub fn to_untyped(&self) -> ScaleOffset2D<T, UnknownUnit, UnknownUnit>

Drop the units, preserving only the numeric value.

Source

pub fn from_untyped(val: ScaleOffset2D<T, UnknownUnit, UnknownUnit>) -> Self

Tag a unitless value with units.

Trait Implementations§

Source§

impl<T: ApproxEq<T>, Src, Dst> ApproxEq<T> for ScaleOffset2D<T, Src, Dst>

Source§

fn approx_eq_eps(&self, other: &Self, eps: &T) -> bool

Returns true if this transform is approximately equal to the other one, using a provided epsilon value.

Source§

fn approx_epsilon() -> T

Default epsilon value
Source§

fn approx_eq(&self, other: &Self) -> bool

Returns true if this object is approximately equal to the other one, using the approx_epsilon epsilon value.
Source§

impl<T: Clone, Src, Dst> Clone for ScaleOffset2D<T, Src, Dst>

Source§

fn clone(&self) -> Self

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

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

Performs copy-assignment from source. Read more
Source§

impl<T, Src, Dst> Debug for ScaleOffset2D<T, Src, Dst>
where T: Copy + Debug + PartialEq + One + Zero + ApproxEq<T>,

Source§

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

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

impl<T, Src, Dst> Default for ScaleOffset2D<T, Src, Dst>
where T: Copy + Zero + One,

Source§

fn default() -> Self

Returns the identity transform.

Source§

impl<'de, T, Src, Dst> Deserialize<'de> for ScaleOffset2D<T, Src, Dst>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Copy + Zero, Src, Dst> From<Scale<T, Src, Dst>> for ScaleOffset2D<T, Src, Dst>

Source§

fn from(s: Scale<T, Src, Dst>) -> Self

Converts to this type from the input type.
Source§

impl<T: Copy + Zero, Src, Dst> From<ScaleOffset2D<T, Src, Dst>> for Transform2D<T, Src, Dst>

Source§

fn from(t: ScaleOffset2D<T, Src, Dst>) -> Self

Converts to this type from the input type.
Source§

impl<T: Copy + One, Src, Dst> From<Translation2D<T, Src, Dst>> for ScaleOffset2D<T, Src, Dst>

Source§

fn from(t: Translation2D<T, Src, Dst>) -> Self

Converts to this type from the input type.
Source§

impl<T, Src, Dst> Hash for ScaleOffset2D<T, Src, Dst>
where T: Hash,

Source§

fn hash<H: Hasher>(&self, h: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, Src, Dst> PartialEq for ScaleOffset2D<T, Src, Dst>
where T: PartialEq,

Source§

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

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

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, Src, Dst> Serialize for ScaleOffset2D<T, Src, Dst>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: Copy, Src, Dst> Copy for ScaleOffset2D<T, Src, Dst>

Source§

impl<T, Src, Dst> Eq for ScaleOffset2D<T, Src, Dst>
where T: Eq,

Auto Trait Implementations§

§

impl<T, Src, Dst> Freeze for ScaleOffset2D<T, Src, Dst>
where T: Freeze,

§

impl<T, Src, Dst> RefUnwindSafe for ScaleOffset2D<T, Src, Dst>

§

impl<T, Src, Dst> Send for ScaleOffset2D<T, Src, Dst>
where T: Send, Src: Send, Dst: Send,

§

impl<T, Src, Dst> Sync for ScaleOffset2D<T, Src, Dst>
where T: Sync, Src: Sync, Dst: Sync,

§

impl<T, Src, Dst> Unpin for ScaleOffset2D<T, Src, Dst>
where T: Unpin, Src: Unpin, Dst: Unpin,

§

impl<T, Src, Dst> UnwindSafe for ScaleOffset2D<T, Src, Dst>
where T: UnwindSafe, Src: UnwindSafe, Dst: 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,