Skip to main content

Transform2

Struct Transform2 

Source
pub struct Transform2<WFrom = Generic, WTo = WFrom> {
    pub m: [f64; 6],
    /* private fields */
}
Expand description

A 2D affine transform between two phantom coordinate spaces.

Fields§

§m: [f64; 6]

Affine matrix coefficients in kurbo-compatible [a, b, c, d, e, f] order.

Implementations§

Source§

impl<WFrom: Space, WTo: Space> Transform2<WFrom, WTo>

Source

pub fn new(m: [f64; 6]) -> Self

Constructs a transform from raw affine coefficients.

Source

pub fn identity() -> Self

Returns the identity transform.

Source

pub fn scale(s: f64) -> Self

Constructs a uniform scale transform.

Source

pub fn scale_sep(s: Vector2<WTo>) -> Self

Constructs a non-uniform scale transform.

Source

pub fn skew(k: Vector2<WTo>) -> Self

Constructs a skew transform.

Source

pub fn rotate(th: f64) -> Self

Constructs a rotation transform, in radians.

Source

pub fn translate(p: Vector2<WTo>) -> Self

Constructs a translation transform.

Source

pub fn determinant(self) -> f64

Returns the affine determinant.

Source

pub fn coeffs(&self) -> [f64; 6]

Returns raw affine coefficients in kurbo-compatible [a, b, c, d, e, f] order.

Source

pub fn get_translation(self) -> Vector2<WFrom>

Extracts the translation component as a vector.

Source

pub fn get_scale(self) -> Vector2<WTo>

Returns the transformed unit scale vector.

Source

pub fn cast_spaces<W: Space, T: Space>(self) -> Transform2<W, T>

Casts the phantom coordinate spaces without changing coefficients.

Source

pub fn inverse(self) -> Transform2<WTo, WFrom>

Produces NaN values when the determinant is zero.

Source

pub fn compose(p: Point2<WTo>, vx: Vector2<WTo>, vy: Vector2<WTo>) -> Self

Composes a transform from origin and basis vectors.

Source

pub fn decompose(&self) -> (Point2<WTo>, Vector2<WTo>, Vector2<WTo>)

Decomposes the transform into origin and transformed basis vectors.

Source

pub fn contains_point(&self, point: Point2<WTo>) -> bool

Returns true when point lands inside the transformed unit square.

Trait Implementations§

Source§

impl<F, T> Clone for Transform2<F, T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CoercionRules for Transform2

Source§

fn try_coerce(value: PaxValue) -> Result<Self, String>

Attempts to coerce value into Self.
Source§

fn allows_singleton_stack() -> bool

Opts appearance layers into scalar-to-singleton stack conversion. Ordinary vector values remain list-only.
Source§

fn is_identity_roundtrip() -> bool

Whether cloning Self preserves the semantics of converting that clone through ToPaxValue and back with try_coerce. Read more
Source§

impl<F, T> Copy for Transform2<F, T>

Source§

impl<F, T> Debug for Transform2<F, T>

Source§

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

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

impl<F: Space, T: Space> Default for Transform2<F, T>

Source§

fn default() -> Self

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

impl<T: Space, F: Space> From<Transform2<T, F>> for Affine

Source§

fn from(value: Transform2<T, F>) -> Self

Converts to this type from the input type.
Source§

impl HelperFunctions for Transform2

Source§

fn register_all_functions()

Registers all helper functions for this type.
Source§

impl<F: Space, T: Space> ImplToFromPaxAny for Transform2<F, T>

Source§

impl<W: Space, T: Space> Interpolatable for Transform2<W, T>

Source§

fn interpolate(&self, other: &Self, t: f64) -> Self

Interpolates this value toward other at time t on the unit interval. Read more
Source§

impl<F: Space, W: Space> Into<Transform2<F, W>> for TransformParts

Source§

fn into(self) -> Transform2<F, W>

Converts this type into the (usually inferred) input type.
Source§

impl<F: Space, T: Space> Into<TransformParts> for Transform2<F, T>

NOTE: the returned parts.skew.y will always be equal to 0,

Source§

fn into(self) -> TransformParts

Converts this type into the (usually inferred) input type.
Source§

impl<F: Space, T: Space> Mul<Point2<F>> for Transform2<F, T>

Source§

type Output = Point2<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point2<F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<W1: Space, W2: Space, W3: Space> Mul<Transform2<W1, W2>> for Transform2<W2, W3>

Source§

type Output = Transform2<W1, W3>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Transform2<W1, W2>) -> Self::Output

Performs the * operation. Read more
Source§

impl<F: Space, T: Space> Mul<Vector2<F>> for Transform2<F, T>

Source§

type Output = Vector2<T>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Vector2<F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<F, T> PartialEq for Transform2<F, T>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl ToPaxValue for Transform2

Source§

fn to_pax_value(self) -> PaxValue

Converts this value into a PaxValue.
Source§

fn nested_properties(&self) -> Vec<UntypedProperty>

Live properties read when snapshotting a compound value for PAXEL. Adapters observe these as well as the containing property.
Source§

fn to_pax_value_in_graph(self) -> PaxValue
where Self: Sized,

Converts against owner-thread graph views, including nested generated property fields. Requires an entered property graph for shared fields. Ordinary Self::to_pax_value reads published value snapshots.

Auto Trait Implementations§

§

impl<WFrom, WTo> Freeze for Transform2<WFrom, WTo>
where PhantomData<WFrom>: Freeze, PhantomData<WTo>: Freeze,

§

impl<WFrom, WTo> RefUnwindSafe for Transform2<WFrom, WTo>

§

impl<WFrom, WTo> Send for Transform2<WFrom, WTo>
where PhantomData<WFrom>: Send, PhantomData<WTo>: Send,

§

impl<WFrom, WTo> Sync for Transform2<WFrom, WTo>
where PhantomData<WFrom>: Sync, PhantomData<WTo>: Sync,

§

impl<WFrom, WTo> Unpin for Transform2<WFrom, WTo>
where PhantomData<WFrom>: Unpin, PhantomData<WTo>: Unpin,

§

impl<WFrom, WTo> UnsafeUnpin for Transform2<WFrom, WTo>

§

impl<WFrom, WTo> UnwindSafe for Transform2<WFrom, WTo>

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> PropertyValue for T
where T: Default + Clone + Interpolatable + 'static,

Source§

impl<T> RoundFrom<T> for T

Source§

fn round_from(x: T) -> T

Performs the conversion.
Source§

impl<T, U> RoundInto<U> for T
where U: RoundFrom<T>,

Source§

fn round_into(self) -> U

Performs the conversion.
Source§

impl<T> SharedPropertyValue for T
where T: PropertyValue + Send + Sync,

Source§

impl<T> ToFromPaxAny for T

Source§

fn to_pax_any(self) -> PaxAny

Converts this value into a PaxAny.
Source§

fn from_pax_any(pax_any: PaxAny) -> Result<T, String>

Attempts to recover this concrete type from a PaxAny.
Source§

fn ref_from_pax_any(pax_any: &PaxAny) -> Result<&T, String>

Attempts to borrow this concrete type from a PaxAny.
Source§

fn mut_from_pax_any(pax_any: &mut PaxAny) -> Result<&mut T, String>

Attempts to mutably borrow this concrete type from a PaxAny.
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more