Skip to main content

Matrix

Struct Matrix 

Source
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

Source

pub const IDENTITY: Matrix

IDENTITY leaves coordinates unchanged.

Source

pub fn translation(tx: f32, ty: f32) -> Self

translation creates a two-dimensional translation.

Source

pub fn scale(sx: f32, sy: f32) -> Self

scale creates a two-dimensional scale.

Source

pub fn rotation(radians: f32) -> Self

rotation creates a rotation around the origin.

Positive angles rotate clockwise in Valo’s y-down coordinate system.

Source

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).

Source

pub fn from_flutter_array(values: &[f32; 16]) -> Self

from_flutter_array creates a matrix from 16 column-major Flutter values.

Source

pub fn to_flutter_array(&self) -> [f32; 16]

to_flutter_array returns 16 column-major Flutter values.

Source

pub fn to_mat4(self) -> Mat4

to_mat4 returns the backing glam matrix.

Source

pub fn then(&self, other: &Matrix) -> Matrix

then composes this matrix with other.

The result applies other first and this matrix second.

Source

pub fn is_affine(&self) -> bool

is_affine reports whether two-dimensional input has no perspective.

Source

pub fn kind(&self) -> MatrixKind

kind classifies this matrix for two-dimensional rendering.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn determinant(&self) -> f32

determinant returns the signed area scale of the two-dimensional block.

Source

pub fn invert(&self) -> Option<Matrix>

invert returns the inverse matrix or None when no finite inverse exists.

Trait Implementations§

Source§

impl Clone for Matrix

Source§

fn clone(&self) -> Matrix

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 Copy for Matrix

Source§

impl Debug for Matrix

Source§

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

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

impl Default for Matrix

Source§

fn default() -> Self

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

impl PartialEq for Matrix

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Matrix

Auto Trait Implementations§

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> 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 = 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 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.