transform

Rotation and 2D transform types used by layout and rendering.

Structs

Transform2D

A sugared representation of an Affine transform combined with an anchor layout property.

Properties

previous

Type: Option<Box<Transform2D>>

Linked list of ancestral Transform2Ds

rotate

Type: Option<Rotation>

Represents affine rotation over z axis (single-dimensional for 2D rendering)

translate

Type: Option<[Size; 2]>

Represents affine translation across the x-y plane

anchor

Type: Option<[Size; 2]>

Represents the alignment of the (0,0) position of this element as it relates to its own bounding box. (origin offset)

scale

Type: Option<[Size; 2]>

Represents affine scale coefficients across the x-y plane

skew

Type: Option<[Rotation; 2]>

Represents affine skew over x and y axes

Implementations

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

Transform origin point for this element, relative to its own bounding box.

rotate
pub fn rotate(z: Rotation) -> Self

Rotation over the z axis.

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

Scale coefficients over the x-y plane.

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

Translation over the x-y plane.

Enums

Rotation

Encodes a rotation in various units

Variants

Radians(Numeric)

Radian units (2π rad for one full rotation)

Degrees(Numeric)

Degree units (360 deg for one full rotation)

Percent(Numeric)

Percentage units (100% for one full rotation)

Implementations

ZERO
pub fn ZERO() -> Self

Returns zero degrees.

get_as_degrees
pub fn get_as_degrees(&self) -> f64

Returns the rotation as degrees, regardless of the original unit

get_as_radians
pub fn get_as_radians(&self) -> f64

Returns the rotation as radians, regardless of the original unit

to_float_0_1
pub fn to_float_0_1(&self) -> f64

Returns a normalized float proportional to 0deg : 0.0 :: 360deg : 1.0.

For example, 0rad maps to 0.0, 100% maps to 1.0, and 720deg maps to 2.0.