pub struct Transform2D {
pub a: f32,
pub b: f32,
pub c: f32,
pub d: f32,
pub e: f32,
pub f: f32,
}Expand description
A 2D affine transform stored as the column-major matrix
| a c e | | x |
| b d f | * | y |
| 0 0 1 | | 1 |— i.e. (x', y') = (a*x + c*y + e, b*x + d*y + f). The layout
matches SVG’s matrix(a, b, c, d, e, f) and PDF’s cm operator
argument order, so emitters can serialize fields directly.
Fields§
§a: f32§b: f32§c: f32§d: f32§e: f32§f: f32Implementations§
Source§impl Transform2D
impl Transform2D
Sourcepub const fn scale(sx: f32, sy: f32) -> Self
pub const fn scale(sx: f32, sy: f32) -> Self
Build a non-uniform scale by (sx, sy) about the origin.
Sourcepub fn rotate(angle_radians: f32) -> Self
pub fn rotate(angle_radians: f32) -> Self
Build a rotation by angle_radians about the origin
(counter-clockwise in a Y-up system, clockwise visually under
the SVG / PDF Y-down convention — this matches both formats).
Sourcepub fn skew_x(angle_radians: f32) -> Self
pub fn skew_x(angle_radians: f32) -> Self
Build a horizontal skew (shear along X) by angle_radians.
Sourcepub fn skew_y(angle_radians: f32) -> Self
pub fn skew_y(angle_radians: f32) -> Self
Build a vertical skew (shear along Y) by angle_radians.
Sourcepub fn compose(&self, other: &Self) -> Self
pub fn compose(&self, other: &Self) -> Self
Compose self ∘ other — the resulting transform applies
other first, then self, to a point. Equivalent to
self.matrix() * other.matrix() in column-vector form.
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
true when this transform is bit-identical to the identity.
Useful for emitters that want to skip a no-op matrix(...) /
cm write.
Trait Implementations§
Source§impl Clone for Transform2D
impl Clone for Transform2D
Source§fn clone(&self) -> Transform2D
fn clone(&self) -> Transform2D
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Transform2D
Source§impl Debug for Transform2D
impl Debug for Transform2D
Source§impl Default for Transform2D
impl Default for Transform2D
Source§impl PartialEq for Transform2D
impl PartialEq for Transform2D
Source§fn eq(&self, other: &Transform2D) -> bool
fn eq(&self, other: &Transform2D) -> bool
self and other values to be equal, and is used by ==.