Matrix

Struct Matrix 

Source
pub struct Matrix<P> {
    pub a: P,
    pub b: P,
    pub c: P,
    pub d: P,
    pub e: P,
    pub f: P,
}
Expand description

A font matrix

⎛ a b 0 ⎞
⎜ c d 0 ⎟
⎝ e f 1 ⎠

Fields§

§a: P

M1,1

§b: P

M1,2

§c: P

M2,1

§d: P

M2,2

§e: P

M3,1

§f: P

M3,2

Implementations§

Source§

impl Matrix<f32>

A matrix

Source

pub fn identity() -> Self

use pdf_create::common::Matrix;
let id = Matrix::<f32>::identity();
assert_eq!(id, id * id);
Source

pub fn inverse_y() -> Self

use pdf_create::common::Matrix;
let id = Matrix::<f32>::identity();
let ivy = Matrix::<f32>::inverse_y();
assert_eq!(ivy, ivy * id);
assert_eq!(id, ivy * ivy);
Source

pub fn inverse_x() -> Self

use pdf_create::common::Matrix;
let id = Matrix::<f32>::identity();
let ivx = Matrix::<f32>::inverse_x();
assert_eq!(ivx, ivx * id);
assert_eq!(id, ivx * ivx);
Source

pub fn inverse_xy() -> Self

Inverts both coordinates

Source

pub fn translate(x: f32, y: f32) -> Self

use pdf_create::common::Matrix;
let ty1 = Matrix::<f32>::translate(0.0, 3.0);
let ty2 = Matrix::<f32>::translate(0.0, 5.0);
let tx1 = Matrix::<f32>::translate(2.0, 0.0);
let tx2 = Matrix::<f32>::translate(7.0, 0.0);
let res = Matrix::<f32>::translate(9.0, 8.0);
assert_eq!(res, ty1 * ty2 * tx1 * tx2);
assert_eq!(res, ty1 * tx2 * ty2 * tx1);
Source

pub fn scale(x: f32, y: f32) -> Self

Create a scaling matrix

Source

pub fn default_glyph() -> Self

Create a default 1:1000 glyph matrix

Trait Implementations§

Source§

impl<P: Clone> Clone for Matrix<P>

Source§

fn clone(&self) -> Matrix<P>

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<P: Debug> Debug for Matrix<P>

Source§

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

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

impl<P> Mul for Matrix<P>
where P: Copy + Mul<Output = P> + Add<Output = P>,

Source§

type Output = Matrix<P>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<P: PartialEq> PartialEq for Matrix<P>

Source§

fn eq(&self, other: &Matrix<P>) -> 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<P: Serialize> Serialize for Matrix<P>

Source§

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

Write the object to a stream
Source§

impl<P: Copy> Copy for Matrix<P>

Source§

impl<P: Eq> Eq for Matrix<P>

Source§

impl<P> StructuralPartialEq for Matrix<P>

Auto Trait Implementations§

§

impl<P> Freeze for Matrix<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for Matrix<P>
where P: RefUnwindSafe,

§

impl<P> Send for Matrix<P>
where P: Send,

§

impl<P> Sync for Matrix<P>
where P: Sync,

§

impl<P> Unpin for Matrix<P>
where P: Unpin,

§

impl<P> UnwindSafe for Matrix<P>
where P: UnwindSafe,

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, 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.