pub struct Transform2D {
    pub previous: Option<Box<Transform2D>>,
    pub rotate: Option<f64>,
    pub translate: Option<[f64; 2]>,
    pub anchor: Option<[Size; 2]>,
    pub align: Option<[Size; 2]>,
    pub scale: Option<[f64; 2]>,
}
Expand description

A sugary representation of an Affine transform+, including anchor and align as layout-computed properties.

translate represents an (x,y) affine translation scale represents an (x,y) non-uniform affine scale rotate represents a (z) affine rotation (intuitive 2D rotation) anchor represents the “(0,0)” point of the render node as it relates to its own bounding box. By default that’s the top-left of the element, but anchor allows that to be offset either by a pixel or percentage-of-element-size for each of (x,y) align the offset of this element’s anchor as it relates to the element’s parent. By default this is the top-left corner of the parent container, but can be set to be any value [0,1] for each of (x,y), representing the percentage (between 0.0 and 1.0) multiplied by the parent container size. For example, an align of (0.5, 0.5) will center an element’s anchor point both vertically and horizontally within the parent container. Combined with an anchor of (Size::Percent(50.0), Size::Percent(50.0)), an element will appear fully centered within its parent.

Fields§

§previous: Option<Box<Transform2D>>§rotate: Option<f64>§translate: Option<[f64; 2]>

over z axis

§anchor: Option<[Size; 2]>§align: Option<[Size; 2]>§scale: Option<[f64; 2]>

Implementations§

source§

impl Transform2D

source

pub fn scale(x: Numeric, y: Numeric) -> Self

Scale coefficients (1.0 == 100%) over x-y plane

source

pub fn rotate(z: Numeric) -> Self

Rotation over z axis

source

pub fn translate(x: Numeric, y: Numeric) -> Self

Translation across x-y plane, pixels

source

pub fn align(x: Size, y: Size) -> Self

Describe alignment within parent bounding box, as a starting point before affine transformations are applied

source

pub fn anchor(x: Size, y: Size) -> Self

Describe alignment of the (0,0) position of this element as it relates to its own bounding box

source

pub fn default_wrapped() -> Rc<RefCell<dyn PropertyInstance<Self>>>

Trait Implementations§

source§

impl Clone for Transform2D

source§

fn clone(&self) -> Transform2D

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 Default for Transform2D

source§

fn default() -> Transform2D

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

impl Mul<Transform2D> for Transform2D

§

type Output = Transform2D

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more

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.