Struct usvgr::Transform

source ·
pub struct Transform {
    pub a: f64,
    pub b: f64,
    pub c: f64,
    pub d: f64,
    pub e: f64,
    pub f: f64,
}
Expand description

Representation of the <transform> type.

Fields§

§a: f64§b: f64§c: f64§d: f64§e: f64§f: f64

Implementations§

source§

impl Transform

source

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

Constructs a new transform.

source

pub fn new_translate(x: f64, y: f64) -> Self

Constructs a new translate transform.

source

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

Constructs a new scale transform.

source

pub fn new_rotate(angle: f64) -> Self

Constructs a new rotate transform.

source

pub fn from_bbox(bbox: Rect) -> Self

Converts Rect into bbox Transform.

source

pub fn translate(&mut self, x: f64, y: f64)

Translates the current transform.

source

pub fn scale(&mut self, sx: f64, sy: f64)

Scales the current transform.

source

pub fn rotate(&mut self, angle: f64)

Rotates the current transform.

source

pub fn rotate_at(&mut self, angle: f64, x: f64, y: f64)

Rotates the current transform at the specified position.

source

pub fn append(&mut self, other: &Transform)

Appends transform to the current transform.

source

pub fn prepend(&mut self, other: &Transform)

Prepends transform to the current transform.

source

pub fn is_default(&self) -> bool

Returns true if the transform is default, aka (1 0 0 1 0 0).

source

pub fn get_translate(&self) -> (f64, f64)

Returns transform’s translate part.

source

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

Returns transform’s scale part.

source

pub fn apply(&self, x: f64, y: f64) -> (f64, f64)

Applies transform to selected coordinates.

source

pub fn apply_to(&self, x: &mut f64, y: &mut f64)

Applies transform to selected coordinates.

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() -> Transform

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

impl From<Transform> for Transform

source§

fn from(ts: Transform) -> Self

Converts to this type from the input type.
source§

impl<'a> FromValue<'a> for Transform

source§

fn get(node: Node<'a>, aid: AId) -> Option<Self>

source§

impl FuzzyEq for Transform

source§

fn fuzzy_eq(&self, other: &Self) -> bool

Returns true if values are approximately equal.
source§

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

Returns true if values are not approximately equal.
source§

impl Hash for Transform

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Transform

source§

fn eq(&self, other: &Self) -> 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 ToTokens for Transform

source§

fn to_tokens(&self, tokens: &mut TokenStream)

Write self to the given TokenStream. Read more
source§

fn to_token_stream(&self) -> TokenStream

Convert self directly into a TokenStream object. Read more
source§

fn into_token_stream(self) -> TokenStream
where Self: Sized,

Convert self directly into a TokenStream object. Read more
source§

impl Copy for Transform

source§

impl Eq 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> IsDefault for T
where T: Default + PartialEq + Copy,

source§

fn is_default(&self) -> bool

Checks that type has a default value.
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, 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.