TransformMatrix

Struct TransformMatrix 

Source
pub struct TransformMatrix {
    pub a: f64,
    pub b: f64,
    pub c: f64,
    pub d: f64,
    pub e: f64,
    pub f: f64,
}
Expand description

2D transformation matrix in homogeneous coordinates

Represents a 3x3 matrix in the form:

[a c e]   [x]   [ax + cy + e]
[b d f] × [y] = [bx + dy + f]
[0 0 1]   [1]   [    1      ]

Common transformations:

  • Identity: a=1, b=0, c=0, d=1, e=0, f=0
  • Translation: a=1, b=0, c=0, d=1, e=tx, f=ty
  • Scale: a=sx, b=0, c=0, d=sy, e=0, f=0
  • Y-flip: a=1, b=0, c=0, d=-1, e=0, f=page_height

Fields§

§a: f64

Scale/rotation X component

§b: f64

Skew Y component

§c: f64

Skew X component

§d: f64

Scale/rotation Y component

§e: f64

Translation X component

§f: f64

Translation Y component

Implementations§

Source§

impl TransformMatrix

Source

pub const IDENTITY: Self

Identity transformation (no change)

Source

pub fn new(a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) -> Self

Create a new transformation matrix

Source

pub fn translate(tx: f64, ty: f64) -> Self

Create translation matrix

Source

pub fn scale(sx: f64, sy: f64) -> Self

Create scaling matrix

Source

pub fn rotate(angle: f64) -> Self

Create rotation matrix (angle in radians)

Source

pub fn flip_y(page_height: f64) -> Self

Create Y-axis flip transformation for given page height

Source

pub fn multiply(&self, other: &TransformMatrix) -> Self

Matrix multiplication: self * other

Source

pub fn transform_point(&self, point: Point) -> Point

Transform a point using this matrix

Source

pub fn to_pdf_ctm(&self) -> String

Convert to PDF CTM (Current Transformation Matrix) string

Trait Implementations§

Source§

impl Clone for TransformMatrix

Source§

fn clone(&self) -> TransformMatrix

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TransformMatrix

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TransformMatrix

Source§

fn eq(&self, other: &TransformMatrix) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for TransformMatrix

Source§

impl StructuralPartialEq for TransformMatrix

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more