pub struct Matrix(/* private fields */);Expand description
Full 4×4 column-major transform (glam-backed — the byte layout Flutter and Impeller use).
Canvas semantics throughout valo: the current transform maps LOCAL
(drawn) coordinates to the list’s ROOT space, and then(local) appends
a transform that applies to subsequently drawn geometry FIRST — i.e.
current ∘ local, matrix product current × local. Same convention as
Skia/Impeller’s transform stack.
2D content maps as (x, y, 0, 1): the w row does perspective (the hardware divide, with perspective-correct interpolation); the z output is IGNORED for painting — valo writes its own per-draw depth (2.5D, Flutter’s model).
Implementations§
Source§impl Matrix
impl Matrix
pub const IDENTITY: Matrix
pub fn translation(tx: f32, ty: f32) -> Self
pub fn scale(sx: f32, sy: f32) -> Self
pub fn rotation(radians: f32) -> Self
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
The classic 2×3 affine (column vectors (a,b), (c,d), translation).
Sourcepub fn from_flutter_array(values: &[f32; 16]) -> Self
pub fn from_flutter_array(values: &[f32; 16]) -> Self
The 16 column-major floats Flutter-architecture hosts hand a canvas.
pub fn to_flutter_array(&self) -> [f32; 16]
Sourcepub fn then(&self, other: &Matrix) -> Matrix
pub fn then(&self, other: &Matrix) -> Matrix
self ∘ other: apply other first, then self (product self × other).
Sourcepub fn is_affine(&self) -> bool
pub fn is_affine(&self) -> bool
True when the w row is inert for 2D content ((0, 0, ·, 1) — the z column never matters because inputs have z = 0).
pub fn kind(&self) -> MatrixKind
pub fn map_point(&self, p: Point) -> Point
Sourcepub fn map_rect(&self, r: &Rect) -> Rect
pub fn map_rect(&self, r: &Rect) -> Rect
Axis-aligned bounds of the mapped rect: exact for rectilinear
transforms, conservative under rotation, and Rect::EVERYTHING
when any corner reaches the eye plane (w ≤ ε) — culling must never
reject such content, and layers clamp to their clip instead.
Sourcepub fn max_scale(&self) -> f32
pub fn max_scale(&self) -> f32
Maximum length the XY basis vectors scale a unit vector to — the device-scale factor text pickers and blur sigmas care about (Impeller’s maxBasisLengthXY; ignores perspective, so approximate under it).
Sourcepub fn to_affine(&self) -> [f32; 6]
pub fn to_affine(&self) -> [f32; 6]
The 2D affine block [a, b, c, d, tx, ty] (column vectors (a,b),
(c,d), translation) — ignores any perspective row; pair with
Self::is_affine where exactness matters (gradient locals and
embed quads are affine by construction).
Sourcepub fn determinant(&self) -> f32
pub fn determinant(&self) -> f32
The 2D block’s determinant (orientation / area factor of the xy plane — what stroking and winding care about).