pub struct Matrix {
pub a: f32,
pub b: f32,
pub c: f32,
pub d: f32,
pub e: f32,
pub f: f32,
}Expand description
An affine transform [a b c d e f], applied to row vectors: (x, y, 1) · M.
This is the convention the PDF specification uses for the CTM and text matrices, so
composition reads the same way here as in the spec: transforming by A then B is
A.concat(B).
Fields§
§a: f32§b: f32§c: f32§d: f32§e: f32§f: f32Implementations§
Source§impl Matrix
impl Matrix
pub const IDENTITY: Matrix
pub const fn new(a: f32, b: f32, c: f32, d: f32, e: f32, f: f32) -> Self
pub fn translate(tx: f32, ty: f32) -> Self
pub fn scale(sx: f32, sy: f32) -> Self
Sourcepub fn concat(&self, other: &Matrix) -> Matrix
pub fn concat(&self, other: &Matrix) -> Matrix
self then other: the matrix that applies self first.
pub fn apply(&self, p: Point) -> Point
Sourcepub fn apply_vector(&self, x: f32, y: f32) -> (f32, f32)
pub fn apply_vector(&self, x: f32, y: f32) -> (f32, f32)
Transforms only the vector part (no translation).
Sourcepub fn apply_rect(&self, r: &Rect) -> Rect
pub fn apply_rect(&self, r: &Rect) -> Rect
The axis-aligned bounding box of the four transformed corners.
Sourcepub fn y_scale(&self) -> f32
pub fn y_scale(&self) -> f32
Length of the transformed unit y vector: the factor a font size is scaled by.
pub fn x_scale(&self) -> f32
pub fn invert(&self) -> Option<Matrix>
Trait Implementations§
impl Copy for Matrix
impl StructuralPartialEq for Matrix
Auto Trait Implementations§
impl Forget for Matrix
impl Freeze for Matrix
impl Move for Matrix
impl RefUnwindSafe for Matrix
impl Send for Matrix
impl Sync for Matrix
impl Unpin for Matrix
impl UnsafeUnpin for Matrix
impl UnwindSafe for Matrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more