pub struct Affine(/* private fields */);Expand description
A 2D affine transform.
Implementations§
Source§impl Affine
impl Affine
Sourcepub const FLIP_Y: Affine
pub const FLIP_Y: Affine
A transform that is flipped on the y-axis. Useful for converting between y-up and y-down spaces.
Sourcepub const fn new(c: [f64; 6]) -> Affine
pub const fn new(c: [f64; 6]) -> Affine
Construct an affine transform from coefficients.
If the coefficients are (a, b, c, d, e, f), then the resulting
transformation represents this augmented matrix:
| a c e |
| b d f |
| 0 0 1 |Note that this convention is transposed from PostScript and
Direct2D, but is consistent with the
Wikipedia
formulation of affine transformation as augmented matrix. The
idea is that (A * B) * v == A * (B * v), where * is the
Mul trait.
Sourcepub const fn scale_non_uniform(s_x: f64, s_y: f64) -> Affine
pub const fn scale_non_uniform(s_x: f64, s_y: f64) -> Affine
An affine transform representing non-uniform scaling with different scale values for x and y
Sourcepub fn rotate(th: f64) -> Affine
pub fn rotate(th: f64) -> Affine
An affine transform representing rotation.
The convention for rotation is that a positive angle rotates a positive X direction into positive Y. Thus, in a Y-down coordinate system (as is common for graphics), it is a clockwise rotation, and in Y-up (traditional for math), it is anti-clockwise.
The angle, th, is expressed in radians.
Sourcepub fn determinant(self) -> f64
pub fn determinant(self) -> f64
Compute the determinant of this transform.
Sourcepub fn inverse(self) -> Affine
pub fn inverse(self) -> Affine
Compute the inverse transform.
Produces NaN values when the determinant is zero.
Sourcepub fn transform_rect_bbox(self, rect: Rect) -> Rect
pub fn transform_rect_bbox(self, rect: Rect) -> Rect
Compute the bounding box of a transformed rectangle.
Returns the minimal Rect that encloses the given Rect after affine transformation.
If the transform is axis-aligned, then this bounding box is “tight”, in other words the
returned Rect is the transformed rectangle.
The returned rectangle always has non-negative width and height.
Trait Implementations§
Source§impl From<TranslateScale> for Affine
impl From<TranslateScale> for Affine
Source§fn from(ts: TranslateScale) -> Affine
fn from(ts: TranslateScale) -> Affine
Source§impl MulAssign for Affine
impl MulAssign for Affine
Source§fn mul_assign(&mut self, other: Affine)
fn mul_assign(&mut self, other: Affine)
*= operation. Read more