pub struct Transform {
pub sx: f32,
pub kx: f32,
pub ky: f32,
pub sy: f32,
pub tx: f32,
pub ty: f32,
}
Expand description
An affine transformation matrix.
Stores scale, skew and transform coordinates and a type of a transform.
Fields
sx: f32
kx: f32
ky: f32
sy: f32
tx: f32
ty: f32
Implementations
sourceimpl Transform
impl Transform
sourcepub fn from_row(sx: f32, ky: f32, kx: f32, sy: f32, tx: f32, ty: f32) -> Self
pub fn from_row(sx: f32, ky: f32, kx: f32, sy: f32, tx: f32, ty: f32) -> Self
Creates a new Transform
.
We are using column-major-column-vector matrix notation, therefore it’s ky-kx, not kx-ky.
sourcepub fn from_translate(tx: f32, ty: f32) -> Self
pub fn from_translate(tx: f32, ty: f32) -> Self
Creates a new translating Transform
.
sourcepub fn from_scale(sx: f32, sy: f32) -> Self
pub fn from_scale(sx: f32, sy: f32) -> Self
Creates a new scaling Transform
.
sourcepub fn from_rotate(angle: f32) -> Self
pub fn from_rotate(angle: f32) -> Self
Creates a new rotating Transform
.
sourcepub fn from_rotate_at(angle: f32, tx: f32, ty: f32) -> Self
pub fn from_rotate_at(angle: f32, tx: f32, ty: f32) -> Self
Creates a new rotating Transform
at the specified position.
sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Checks that transform is identity.
The transform type is detected on creation, so this method is essentially free.
sourcepub fn is_scale(&self) -> bool
pub fn is_scale(&self) -> bool
Checks that transform is scale-only.
The transform type is detected on creation, so this method is essentially free.
sourcepub fn is_skew(&self) -> bool
pub fn is_skew(&self) -> bool
Checks that transform is skew-only.
The transform type is detected on creation, so this method is essentially free.
sourcepub fn is_translate(&self) -> bool
pub fn is_translate(&self) -> bool
Checks that transform is translate-only.
The transform type is detected on creation, so this method is essentially free.
sourcepub fn is_scale_translate(&self) -> bool
pub fn is_scale_translate(&self) -> bool
Checks that transform contains only scale and translate.
The transform type is detected on creation, so this method is essentially free.
sourcepub fn has_scale(&self) -> bool
pub fn has_scale(&self) -> bool
Checks that transform contains a scale part.
The transform type is detected on creation, so this method is essentially free.
sourcepub fn has_skew(&self) -> bool
pub fn has_skew(&self) -> bool
Checks that transform contains a skew part.
The transform type is detected on creation, so this method is essentially free.
sourcepub fn has_translate(&self) -> bool
pub fn has_translate(&self) -> bool
Checks that transform contains a translate part.
The transform type is detected on creation, so this method is essentially free.
sourcepub fn post_scale(&self, sx: f32, sy: f32) -> Self
pub fn post_scale(&self, sx: f32, sy: f32) -> Self
Post-scales the current transform.
sourcepub fn pre_translate(&self, tx: f32, ty: f32) -> Self
pub fn pre_translate(&self, tx: f32, ty: f32) -> Self
Pre-translates the current transform.
sourcepub fn post_translate(&self, tx: f32, ty: f32) -> Self
pub fn post_translate(&self, tx: f32, ty: f32) -> Self
Post-translates the current transform.
sourcepub fn pre_concat(&self, other: Self) -> Self
pub fn pre_concat(&self, other: Self) -> Self
Pre-concats the current transform.
sourcepub fn post_concat(&self, other: Self) -> Self
pub fn post_concat(&self, other: Self) -> Self
Post-concats the current transform.
sourcepub fn map_points(&self, points: &mut [Point])
pub fn map_points(&self, points: &mut [Point])
Transforms a slice of points using the current transform.
Trait Implementations
impl Copy for Transform
impl StructuralPartialEq for Transform
Auto Trait Implementations
impl RefUnwindSafe for Transform
impl Send for Transform
impl Sync for Transform
impl Unpin for Transform
impl UnwindSafe for Transform
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more