Struct tiny_skia::Transform

source ·
pub struct Transform {
    pub sx: f32,
    pub kx: f32,
    pub ky: f32,
    pub sy: f32,
    pub tx: f32,
    pub ty: f32,
}
Expand description

An affine transformation matrix.

Unlike other types, doesn’t guarantee to be valid. This is Skia quirk. Meaning Transform(0, 0, 0, 0, 0, 0) is ok, while it’s technically not. Non-finite values are also not an error.

Fields§

§sx: f32§kx: f32§ky: f32§sy: f32§tx: f32§ty: f32

Implementations§

source§

impl Transform

source

pub fn identity() -> Transform

Creates an identity transform.

source

pub fn from_row( sx: f32, ky: f32, kx: f32, sy: f32, tx: f32, ty: f32 ) -> Transform

Creates a new Transform.

We are using column-major-column-vector matrix notation, therefore it’s ky-kx, not kx-ky.

source

pub fn from_translate(tx: f32, ty: f32) -> Transform

Creates a new translating Transform.

source

pub fn from_scale(sx: f32, sy: f32) -> Transform

Creates a new scaling Transform.

source

pub fn from_skew(kx: f32, ky: f32) -> Transform

Creates a new skewing Transform.

source

pub fn from_rotate(angle: f32) -> Transform

Creates a new rotating Transform.

source

pub fn from_rotate_at(angle: f32, tx: f32, ty: f32) -> Transform

Creates a new rotating Transform at the specified position.

source

pub fn is_finite(&self) -> bool

Checks that transform is finite.

source

pub fn is_identity(&self) -> bool

Checks that transform is identity.

The transform type is detected on creation, so this method is essentially free.

source

pub fn is_scale(&self) -> bool

Checks that transform is scale-only.

The transform type is detected on creation, so this method is essentially free.

source

pub fn is_skew(&self) -> bool

Checks that transform is skew-only.

The transform type is detected on creation, so this method is essentially free.

source

pub fn is_translate(&self) -> bool

Checks that transform is translate-only.

The transform type is detected on creation, so this method is essentially free.

source

pub fn is_scale_translate(&self) -> bool

Checks that transform contains only scale and translate.

The transform type is detected on creation, so this method is essentially free.

source

pub fn has_scale(&self) -> bool

Checks that transform contains a scale part.

The transform type is detected on creation, so this method is essentially free.

source

pub fn has_skew(&self) -> bool

Checks that transform contains a skew part.

The transform type is detected on creation, so this method is essentially free.

source

pub fn has_translate(&self) -> bool

Checks that transform contains a translate part.

The transform type is detected on creation, so this method is essentially free.

source

pub fn pre_scale(&self, sx: f32, sy: f32) -> Transform

Pre-scales the current transform.

source

pub fn post_scale(&self, sx: f32, sy: f32) -> Transform

Post-scales the current transform.

source

pub fn pre_translate(&self, tx: f32, ty: f32) -> Transform

Pre-translates the current transform.

source

pub fn post_translate(&self, tx: f32, ty: f32) -> Transform

Post-translates the current transform.

source

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

Pre-concats the current transform.

source

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

Post-concats the current transform.

source

pub fn map_points(&self, points: &mut [Point])

Transforms a slice of points using the current transform.

source

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

Returns an inverted transform.

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<(), Error>

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

impl Default for Transform

source§

fn default() -> Transform

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

impl PartialEq<Transform> 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.