#[repr(C)]pub struct TransformationMatrix {
pub rotation_scale: [[f32; 2]; 2],
pub translation: [f32; 2],
}Expand description
A data type representing a 2 dimensional transformation that can be applied to an element.
Fields§
§rotation_scale: [[f32; 2]; 2]2x2 matrix containing rotation and scale, stored row-major
translation: [f32; 2]translation vector
Implementations§
Source§impl TransformationMatrix
impl TransformationMatrix
Sourcepub fn translate(self, point: Point<ScaledPixels>) -> Self
pub fn translate(self, point: Point<ScaledPixels>) -> Self
Move the origin by a given point
Sourcepub fn compose(self, other: TransformationMatrix) -> TransformationMatrix
pub fn compose(self, other: TransformationMatrix) -> TransformationMatrix
Perform matrix multiplication with another transformation
to produce a new transformation that is the result of
applying both transformations: first, other, then self.
Sourcepub fn apply(&self, point: Point<Pixels>) -> Point<Pixels>
pub fn apply(&self, point: Point<Pixels>) -> Point<Pixels>
Apply transformation to a point, mainly useful for debugging
Sourcepub fn inverse(&self) -> Option<TransformationMatrix>
pub fn inverse(&self) -> Option<TransformationMatrix>
The inverse transformation, or None when the matrix is singular
(scale(0) collapses the element to nothing, and nothing has no
interior to map a point back into).
This is what hit-testing needs: a hitbox stores its untransformed
bounds, so testing a pointer against a transformed element means
mapping the pointer back into the element’s own frame rather than
mapping four corners forward and testing a polygon.
Trait Implementations§
Source§impl Clone for TransformationMatrix
impl Clone for TransformationMatrix
impl Copy for TransformationMatrix
Source§impl Debug for TransformationMatrix
impl Debug for TransformationMatrix
Source§impl Default for TransformationMatrix
impl Default for TransformationMatrix
impl Eq for TransformationMatrix
Source§impl PartialEq for TransformationMatrix
impl PartialEq for TransformationMatrix
impl StructuralPartialEq for TransformationMatrix
Auto Trait Implementations§
impl Forget for TransformationMatrix
impl Freeze for TransformationMatrix
impl Move for TransformationMatrix
impl RefUnwindSafe for TransformationMatrix
impl Send for TransformationMatrix
impl Sync for TransformationMatrix
impl Unpin for TransformationMatrix
impl UnsafeUnpin for TransformationMatrix
impl UnwindSafe for TransformationMatrix
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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> ⓘ
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