tiny_skia

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

angle in degrees.

source

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

Creates a new rotating Transform at the specified position.

angle in degrees.

source

pub fn from_bbox(bbox: NonZeroRect) -> Transform

Converts Rect into a bounding box Transform.

source

pub fn is_finite(&self) -> bool

Checks that transform is finite.

source

pub fn is_valid(&self) -> bool

Checks that transform is finite and has non-zero scale.

source

pub fn is_identity(&self) -> bool

Checks that transform is identity.

source

pub fn is_scale(&self) -> bool

Checks that transform is scale-only.

source

pub fn is_skew(&self) -> bool

Checks that transform is skew-only.

source

pub fn is_translate(&self) -> bool

Checks that transform is translate-only.

source

pub fn is_scale_translate(&self) -> bool

Checks that transform contains only scale and translate.

source

pub fn has_scale(&self) -> bool

Checks that transform contains a scale part.

source

pub fn has_skew(&self) -> bool

Checks that transform contains a skew part.

source

pub fn has_translate(&self) -> bool

Checks that transform contains a translate part.

source

pub fn get_scale(&self) -> (f32, f32)

Returns transform’s scale part.

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_rotate(&self, angle: f32) -> Transform

Pre-rotates the current transform.

angle in degrees.

source

pub fn post_rotate(&self, angle: f32) -> Transform

Post-rotates the current transform.

angle in degrees.

source

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

Pre-rotates the current transform by the specified position.

angle in degrees.

source

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

Post-rotates the current transform by the specified position.

angle in degrees.

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_point(&self, point: &mut Point)

Transforms a points using 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 for Transform

source§

fn eq(&self, other: &Transform) -> 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 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.