pub struct Transform {
pub position: Vec2,
pub scale: Vec2,
pub rotation: f32,
pub pivot: Vec2,
pub skew: Vec2,
}Expand description
Local 2D affine transform.
Defaults to identity: zero translation, unit scale, zero rotation/skew/pivot.
Fields§
§position: Vec2Translation in parent coordinates. The pivot lands here.
scale: Vec2Per-axis scale around the pivot.
rotation: f32Rotation in radians (around the pivot).
pivot: Vec2Anchor point in local coordinates that stays fixed under rotation/scale.
skew: Vec2Per-axis skew in radians.
Implementations§
Source§impl Transform
impl Transform
Sourcepub const IDENTITY: Self
pub const IDENTITY: Self
Identity transform — to_mat3 returns Mat3::IDENTITY.
Sourcepub const fn from_position(position: Vec2) -> Self
pub const fn from_position(position: Vec2) -> Self
Construct a translation-only transform.
Sourcepub const fn from_scale(scale: Vec2) -> Self
pub const fn from_scale(scale: Vec2) -> Self
Construct a scale-only transform.
Sourcepub const fn from_rotation(rotation: f32) -> Self
pub const fn from_rotation(rotation: f32) -> Self
Construct a rotation-only transform (radians).
Sourcepub fn to_mat3(&self) -> Mat3
pub fn to_mat3(&self) -> Mat3
Compose this transform into a 3×3 affine matrix.
Order: T(position) · S(scale) · R(rotation) · K(skew) · T(-pivot).
Sourcepub fn transform_point(&self, p: Vec2) -> Vec2
pub fn transform_point(&self, p: Vec2) -> Vec2
Transform a 2D point through this transform.
Trait Implementations§
impl Copy for Transform
impl StructuralPartialEq for Transform
Auto Trait Implementations§
impl Freeze for Transform
impl RefUnwindSafe for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnsafeUnpin for Transform
impl UnwindSafe for Transform
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().