pub struct Matrix(/* private fields */);Expand description
Matrix is a full 4×4 column-major transform.
Valo maps two-dimensional input as (x, y, 0, 1), including perspective
division. The renderer ignores transformed z for draw ordering.
Implementations§
Source§impl Matrix
impl Matrix
Sourcepub fn translation(tx: f32, ty: f32) -> Self
pub fn translation(tx: f32, ty: f32) -> Self
translation creates a two-dimensional translation.
Sourcepub fn rotation(radians: f32) -> Self
pub fn rotation(radians: f32) -> Self
rotation creates a rotation around the origin.
Positive angles rotate clockwise in Valo’s y-down coordinate system.
Sourcepub fn from_affine(a: f32, b: f32, c: f32, d: f32, tx: f32, ty: f32) -> Self
pub fn from_affine(a: f32, b: f32, c: f32, d: f32, tx: f32, ty: f32) -> Self
from_affine creates a matrix from [a, b, c, d, tx, ty].
The linear columns are (a, b) and (c, d).
Sourcepub fn from_flutter_array(values: &[f32; 16]) -> Self
pub fn from_flutter_array(values: &[f32; 16]) -> Self
from_flutter_array creates a matrix from 16 column-major Flutter values.
Sourcepub fn to_flutter_array(&self) -> [f32; 16]
pub fn to_flutter_array(&self) -> [f32; 16]
to_flutter_array returns 16 column-major Flutter values.
Sourcepub fn then(&self, other: &Matrix) -> Matrix
pub fn then(&self, other: &Matrix) -> Matrix
then composes this matrix with other.
The result applies other first and this matrix second.
Sourcepub fn is_affine(&self) -> bool
pub fn is_affine(&self) -> bool
is_affine reports whether two-dimensional input has no perspective.
Sourcepub fn kind(&self) -> MatrixKind
pub fn kind(&self) -> MatrixKind
kind classifies this matrix for two-dimensional rendering.
Sourcepub fn map_point(&self, p: Point) -> Point
pub fn map_point(&self, p: Point) -> Point
map_point transforms a point and applies perspective division.
Points at or behind the eye plane use a small positive divisor.
Sourcepub fn map_rect(&self, r: &Rect) -> Rect
pub fn map_rect(&self, r: &Rect) -> Rect
map_rect returns axis-aligned bounds around a transformed rectangle.
It returns Rect::EVERYTHING when a corner reaches or crosses the
eye plane and finite conservative bounds cannot be proven.
Sourcepub fn max_scale(&self) -> f32
pub fn max_scale(&self) -> f32
max_scale returns the larger length of the transformed x and y basis vectors.
It ignores perspective and is therefore approximate for general matrices.
Sourcepub fn to_affine(&self) -> [f32; 6]
pub fn to_affine(&self) -> [f32; 6]
to_affine returns [a, b, c, d, tx, ty] from the two-dimensional block.
Perspective components are omitted; check Self::is_affine when
exact conversion is required.
Sourcepub fn determinant(&self) -> f32
pub fn determinant(&self) -> f32
determinant returns the signed area scale of the two-dimensional block.