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.
Unlike other types, doesn’t guarantee to be valid. This is Skia quirk. Meaning Transform(0, 0, 0, 0, 0, 0) is ok, while it’s technically not. Non-finite values are also not an error.
Fields§
§sx: f32
§kx: f32
§ky: f32
§sy: f32
§tx: f32
§ty: f32
Implementations§
source§impl Transform
impl Transform
sourcepub fn from_row(
sx: f32,
ky: f32,
kx: f32,
sy: f32,
tx: f32,
ty: f32
) -> Transform
pub fn from_row( sx: f32, ky: f32, kx: f32, sy: f32, tx: f32, ty: f32 ) -> Transform
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) -> Transform
pub fn from_translate(tx: f32, ty: f32) -> Transform
Creates a new translating Transform
.
sourcepub fn from_scale(sx: f32, sy: f32) -> Transform
pub fn from_scale(sx: f32, sy: f32) -> Transform
Creates a new scaling Transform
.
sourcepub fn from_rotate(angle: f32) -> Transform
pub fn from_rotate(angle: f32) -> Transform
Creates a new rotating Transform
.
sourcepub fn from_rotate_at(angle: f32, tx: f32, ty: f32) -> Transform
pub fn from_rotate_at(angle: f32, tx: f32, ty: f32) -> Transform
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) -> Transform
pub fn post_scale(&self, sx: f32, sy: f32) -> Transform
Post-scales the current transform.
sourcepub fn pre_translate(&self, tx: f32, ty: f32) -> Transform
pub fn pre_translate(&self, tx: f32, ty: f32) -> Transform
Pre-translates the current transform.
sourcepub fn post_translate(&self, tx: f32, ty: f32) -> Transform
pub fn post_translate(&self, tx: f32, ty: f32) -> Transform
Post-translates the current transform.
sourcepub fn pre_concat(&self, other: Transform) -> Transform
pub fn pre_concat(&self, other: Transform) -> Transform
Pre-concats the current transform.
sourcepub fn post_concat(&self, other: Transform) -> Transform
pub fn post_concat(&self, other: Transform) -> Transform
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.