Struct tiny_skia_path::Transform
source · 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) -> 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
.
angle
in degrees.
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.
angle
in degrees.
sourcepub fn from_bbox(bbox: NonZeroRect) -> Self
pub fn from_bbox(bbox: NonZeroRect) -> Self
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) -> 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_rotate(&self, angle: f32) -> Self
pub fn pre_rotate(&self, angle: f32) -> Self
Pre-rotates the current transform.
angle
in degrees.
sourcepub fn post_rotate(&self, angle: f32) -> Self
pub fn post_rotate(&self, angle: f32) -> Self
Post-rotates the current transform.
angle
in degrees.
sourcepub fn pre_rotate_at(&self, angle: f32, tx: f32, ty: f32) -> Self
pub fn pre_rotate_at(&self, angle: f32, tx: f32, ty: f32) -> Self
Pre-rotates the current transform by the specified position.
angle
in degrees.
sourcepub fn post_rotate_at(&self, angle: f32, tx: f32, ty: f32) -> Self
pub fn post_rotate_at(&self, angle: f32, tx: f32, ty: f32) -> Self
Post-rotates the current transform by the specified position.
angle
in degrees.
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.