pub struct Transform2D { /* private fields */ }Expand description
A 2D affine transformation matrix.
Internally uses a 3x3 matrix for affine transforms. The last row is always [0, 0, 1].
Implementations§
Source§impl Transform2D
impl Transform2D
Sourcepub fn skew(skew_x: f32, skew_y: f32) -> Self
pub fn skew(skew_x: f32, skew_y: f32) -> Self
Create a skew transform.
skew_x is the horizontal skew angle in radians.
skew_y is the vertical skew angle in radians.
Sourcepub fn then(&self, other: &Transform2D) -> Self
pub fn then(&self, other: &Transform2D) -> Self
Combine two transforms (self then other).
Sourcepub fn then_translate(&self, offset: Vec2) -> Self
pub fn then_translate(&self, offset: Vec2) -> Self
Add a translation after this transform.
Sourcepub fn then_rotate(&self, angle: f32) -> Self
pub fn then_rotate(&self, angle: f32) -> Self
Add a rotation after this transform.
Sourcepub fn then_scale(&self, factor: f32) -> Self
pub fn then_scale(&self, factor: f32) -> Self
Add a scale after this transform.
Sourcepub fn then_scale_xy(&self, scale: Vec2) -> Self
pub fn then_scale_xy(&self, scale: Vec2) -> Self
Add a non-uniform scale after this transform.
Sourcepub fn transform_point(&self, point: Vec2) -> Vec2
pub fn transform_point(&self, point: Vec2) -> Vec2
Transform a point.
Sourcepub fn transform_vector(&self, vector: Vec2) -> Vec2
pub fn transform_vector(&self, vector: Vec2) -> Vec2
Transform a vector (ignores translation).
Sourcepub fn translation(&self) -> Vec2
pub fn translation(&self) -> Vec2
Get the translation component.
Sourcepub fn scale_factor(&self) -> Vec2
pub fn scale_factor(&self) -> Vec2
Get the scale component (approximate for non-uniform transforms).
Trait Implementations§
Source§impl Clone for Transform2D
impl Clone for Transform2D
Source§fn clone(&self) -> Transform2D
fn clone(&self) -> Transform2D
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 Debug for Transform2D
impl Debug for Transform2D
Source§impl Default for Transform2D
impl Default for Transform2D
Source§impl Mul<Vec2> for Transform2D
impl Mul<Vec2> for Transform2D
Source§impl Mul for Transform2D
impl Mul for Transform2D
Source§type Output = Transform2D
type Output = Transform2D
The resulting type after applying the
* operator.Source§fn mul(self, rhs: Transform2D) -> Transform2D
fn mul(self, rhs: Transform2D) -> Transform2D
Performs the
* operation. Read moreSource§impl PartialEq for Transform2D
impl PartialEq for Transform2D
impl Copy for Transform2D
impl StructuralPartialEq for Transform2D
Auto Trait Implementations§
impl Freeze for Transform2D
impl RefUnwindSafe for Transform2D
impl Send for Transform2D
impl Sync for Transform2D
impl Unpin for Transform2D
impl UnwindSafe for Transform2D
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