Struct rasterize::Transform

source ·
pub struct Transform(/* private fields */);
Expand description

2D affine transformation

Stored as an array [m00, m01, m02, m10, m11, m12], semantically corresponds to a matrix: ┌ ┐ │ m00 m01 m02 │ │ m11 m11 m12 │ │ 0 0 1 │ └ ┘

Implementations§

source§

impl Transform

source

pub fn new( m00: Scalar, m01: Scalar, m02: Scalar, m10: Scalar, m11: Scalar, m12: Scalar ) -> Self

source

pub fn identity() -> Self

source

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

Apply this transformation to a point

source

pub fn invert(&self) -> Option<Self>

Find the inverse transformation

source

pub fn pre_translate(&self, tx: Scalar, ty: Scalar) -> Self

Apply translation by [tx, ty] before self

source

pub fn new_translate(tx: Scalar, ty: Scalar) -> Self

source

pub fn pre_scale(&self, sx: Scalar, sy: Scalar) -> Self

Apply scale transformation by [sx, sy] before self

source

pub fn new_scale(sx: Scalar, sy: Scalar) -> Self

source

pub fn pre_rotate(&self, a: Scalar) -> Self

Apply rotation by a angle around the origin before self

source

pub fn new_rotate(a: Scalar) -> Self

source

pub fn pre_rotate_around(&self, a: Scalar, p: impl Into<Point>) -> Self

Apply rotation around point p by angle a before self

source

pub fn pre_skew(&self, ax: Scalar, ay: Scalar) -> Self

Apply skew transformation by [ax, ay] before self

source

pub fn new_skew(ax: Scalar, ay: Scalar) -> Self

source

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

Apply other transformation before the current one

source

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

Apply other transformation after the current one

source

pub fn line_to_line(src: Line, dst: Line) -> Option<Self>

Create transformation which converts src line segment to dst line segment

source

pub fn make_horizontal(line: Line) -> Transform

Create transformation which makes line horizontal with origin at (0, 0).

source

pub fn fit_bbox(src: BBox, dst: BBox, align: Align) -> Transform

Create transformation that is required to fit src box into dst.

source

pub fn fit_size(src: BBox, size: Size, align: Align) -> Transform

Create transformation needed to fit source bounding box to provided size image

Trait Implementations§

source§

impl Clone for Transform

source§

fn clone(&self) -> Transform

Returns a copy 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 Transform

source§

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

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

impl Default for Transform

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for Transform

source§

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

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

impl FromStr for Transform

§

type Err = SvgParserError

The associated error which can be returned from parsing.
source§

fn from_str(text: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Mul for Transform

source§

fn mul(self, other: Transform) -> Self::Output

Multiply matrices representing transformations

§

type Output = Transform

The resulting type after applying the * operator.
source§

impl PartialEq for Transform

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Transform

source§

impl StructuralPartialEq for Transform

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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

§

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.