FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    Matrix

    struct · ferroui-base · v0.5.0

    struct Matrix
    

    A 3x3 matrix.

    Matrix layout:

            | 1st col | 2nd col | 3rd col |
    1st row | scaleX  | skewY   | perspX  |
    2nd row | skewX   | scaleY  | perspY  |
    3rd row | transX  | transY  | perspZ  |
    

    Note: the default value is the all-zero matrix, not the identity.

    View source

    Members

    m11

    m11: f64
    

    The first element of the first row (scaleX).

    Source

    m12

    m12: f64
    

    The second element of the first row (skewY).

    Source

    m13

    m13: f64
    

    The third element of the first row (perspX).

    Source

    m21

    m21: f64
    

    The first element of the second row (skewX).

    Source

    m22

    m22: f64
    

    The second element of the second row (scaleY).

    Source

    m23

    m23: f64
    

    The third element of the second row (perspY).

    Source

    m31

    m31: f64
    

    The first element of the third row (offsetX/translateX).

    Source

    m32

    m32: f64
    

    The second element of the third row (offsetY/translateY).

    Source

    m33

    m33: f64
    

    The third element of the third row (perspZ).

    Source

    IDENTITY

    const IDENTITY: Matrix
    

    A multiplicative identity matrix.

    Source

    new

    const fn new(scale_x: f64, skew_y: f64, skew_x: f64, scale_y: f64, offset_x: f64, offset_y: f64) -> Self
    

    Initializes an affine Matrix (the third column is 0, 0, 1).

    Source

    new_3x3

    const fn new_3x3(scale_x: f64, skew_y: f64, persp_x: f64, skew_x: f64, scale_y: f64, persp_y: f64, offset_x: f64, offset_y: f64, persp_z: f64) -> Self
    

    Initializes a full 3x3 Matrix, given in row order.

    Source

    is_identity

    fn is_identity(self: &Self) -> bool
    

    Returns whether the matrix is the multiplicative identity matrix or not.

    Source

    has_inverse

    fn has_inverse(self: &Self) -> bool
    

    Returns whether the matrix has an inverse.

    Source

    create_rotation

    fn create_rotation(radians: f64) -> Matrix
    

    Creates a rotation matrix using the given rotation in radians.

    Source

    create_rotation_at

    fn create_rotation_at(radians: f64, center: Point) -> Matrix
    

    Creates a rotation matrix using the given rotation in radians around a center point.

    Source

    create_skew

    fn create_skew(x_angle: f64, y_angle: f64) -> Matrix
    

    Creates a skew matrix from the given axis skew angles in radians.

    Source

    create_scale

    const fn create_scale(x_scale: f64, y_scale: f64) -> Matrix
    

    Creates a scale matrix from the given X and Y components.

    Source

    create_scale_vector

    const fn create_scale_vector(scales: Vector) -> Matrix
    

    Creates a scale matrix from the given vector scale.

    Source

    create_translation_vector

    const fn create_translation_vector(position: Vector) -> Matrix
    

    Creates a translation matrix from the given vector.

    Source

    create_translation

    const fn create_translation(x_position: f64, y_position: f64) -> Matrix
    

    Creates a translation matrix from the given X and Y components.

    Source

    to_radians

    fn to_radians(angle: f64) -> f64
    

    Converts an angle in degrees to radians.

    Source

    append

    fn append(self: &Self, value: Matrix) -> Matrix
    

    Appends another matrix as post-multiplication operation. Equivalent to self * value.

    Source

    prepend

    fn prepend(self: &Self, value: Matrix) -> Matrix
    

    Prepends another matrix as pre-multiplication operation. Equivalent to value * self.

    Source

    get_determinant

    fn get_determinant(self: &Self) -> f64
    

    Calculates the determinant for this matrix.

    Source

    transform

    fn transform(self: &Self, p: Point) -> Point
    

    Transforms the point with the matrix.

    Source

    equals

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

    Returns a boolean indicating whether the matrix is equal to the other given matrix (exact comparison of every element).

    Source

    contains_perspective

    fn contains_perspective(self: &Self) -> bool
    

    Determines if the current matrix contains perspective (non-affine) transforms.

    Source

    try_invert

    fn try_invert(self: &Self) -> Option<Matrix>
    

    Attempts to invert the matrix. Returns None when it is not invertible.

    Source

    invert

    fn invert(self: &Self) -> Matrix
    

    Inverts the matrix.

    Panics

    Panics if the matrix is not invertible; use try_invert when that is a possibility.

    Source

    parse

    fn parse(s: &str) -> Result<Self, FormatError>
    

    Parses a Matrix string: six (affine) or nine comma/space separated values.

    Nine values are given in the order m11, m12, m21, m22, m31, m32, m13, m23, m33.

    Source

    try_decompose_transform

    fn try_decompose_transform(matrix: Matrix) -> Option<MatrixDecomposed>
    

    Decomposes the given matrix into translation, rotation, scale and skew. Returns None for singular matrices and matrices containing perspective.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ToString
    • ErasedDestructor
    • IntoEither
    • From<Matrix>
    • ExpressionVariantValue
    • ServerPropertyValue
    • BatchValue
    • MarkupTyped
    • ValueTypeRegistration
    • Clone
    • Copy
    • Debug
    • StructuralPartialEq
    • PartialEq
    • Default
    • Mul
    • MulAssign
    • Neg
    • FromStr
    • Display
    • Mul<Matrix>
    • MulAssign<Matrix>

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.