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
.
angle
in degrees.
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.
angle
in degrees.
sourcepub fn from_bbox(bbox: NonZeroRect) -> Transform
pub fn from_bbox(bbox: NonZeroRect) -> Transform
Converts Rect
into a bounding box Transform
.
sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Checks that transform is identity.
sourcepub fn is_translate(&self) -> bool
pub fn is_translate(&self) -> bool
Checks that transform is translate-only.
sourcepub fn is_scale_translate(&self) -> bool
pub fn is_scale_translate(&self) -> bool
Checks that transform contains only scale and translate.
sourcepub fn has_translate(&self) -> bool
pub fn has_translate(&self) -> bool
Checks that transform contains a translate part.
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_rotate(&self, angle: f32) -> Transform
pub fn pre_rotate(&self, angle: f32) -> Transform
Pre-rotates the current transform.
angle
in degrees.
sourcepub fn post_rotate(&self, angle: f32) -> Transform
pub fn post_rotate(&self, angle: f32) -> Transform
Post-rotates the current transform.
angle
in degrees.
sourcepub fn pre_rotate_at(&self, angle: f32, tx: f32, ty: f32) -> Transform
pub fn pre_rotate_at(&self, angle: f32, tx: f32, ty: f32) -> Transform
Pre-rotates the current transform by the specified position.
angle
in degrees.
sourcepub fn post_rotate_at(&self, angle: f32, tx: f32, ty: f32) -> Transform
pub fn post_rotate_at(&self, angle: f32, tx: f32, ty: f32) -> Transform
Post-rotates the current transform by the specified position.
angle
in degrees.
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.