pub struct Transform2D {
pub a: f64,
pub b: f64,
pub c: f64,
pub d: f64,
pub e: f64,
pub f: f64,
}Expand description
A two-dimensional affine transform stored as the six meaningful entries of a 3×3 matrix.
The matrix is applied to a point (x, y) as:
x' = a·x + c·y + e
y' = b·x + d·y + fThis is the same layout SVG and Canvas2D use, so a transform built here can be handed to a Canvas2D context verbatim.
Fields§
§a: f64The horizontal scale / shear term applied to x.
b: f64The vertical shear term applied to x.
c: f64The horizontal shear term applied to y.
d: f64The vertical scale / shear term applied to y.
e: f64The horizontal translation.
f: f64The vertical translation.
Implementations§
Source§impl Transform2D
Inherent implementation of Transform2D.
impl Transform2D
Inherent implementation of Transform2D.
Sourcepub fn from_rect_to_rect(from: BBox, to: BBox) -> Self
pub fn from_rect_to_rect(from: BBox, to: BBox) -> Self
Returns the transform that maps the from rectangle onto the to
rectangle, scaling uniformly on both axes and centering the result.
§Arguments
BBox- ABBoxparameter.
Sourcepub fn then(&self, other: &Self) -> Self
pub fn then(&self, other: &Self) -> Self
Returns the composition of this transform with other, where
other is applied first.
§Arguments
&Self- Shared reference to aSelf.
Sourcepub fn determinant(&self) -> f64
pub fn determinant(&self) -> f64
Returns the transform’s determinant.
A determinant of zero means the transform collapses the plane onto a line or a point; such a transform has no inverse.
§Returns
f64- A 64-bit float.