Matrix Struct
Definition
A 3x3 matrix.
public struct Matrix
Remarks
Matrix layout: | 1st col | 2nd col | 3r col | 1st row | scaleX | skewY | perspX | 2nd row | skewX | scaleY | perspY | 3rd row | transX | transY | perspZ |
Note: Skia.SkMatrix uses a transposed layout (where for example skewX/skewY and persp0/transX are swapped).
Constructors
| Name | Description |
|---|---|
| Matrix (2 overloads) | Initializes a new instance of the Avalonia.Matrix struct (equivalent to a 2x3 Matrix without perspective). |
Matrix overloads
Matrix Constructor
Initializes a new instance of the Avalonia.Matrix struct (equivalent to a 2x3 Matrix without perspective).
public Matrix(double scaleX, double skewY, double skewX, double scaleY, double offsetX, double offsetY)
Parameters
scaleX double
The first element of the first row.
skewY double
The second element of the first row.
skewX double
The first element of the second row.
scaleY double
The second element of the second row.
offsetX double
The first element of the third row.
offsetY double
The second element of the third row.
Matrix Constructor
Initializes a new instance of the Avalonia.Matrix struct.
public Matrix(double scaleX, double skewY, double perspX, double skewX, double scaleY, double perspY, double offsetX, double offsetY, double perspZ)
Parameters
scaleX double
The first element of the first row.
skewY double
The second element of the first row.
perspX double
The third element of the first row.
skewX double
The first element of the second row.
scaleY double
The second element of the second row.
perspY double
The third element of the second row.
offsetX double
The first element of the third row.
offsetY double
The second element of the third row.
perspZ double
The third element of the third row.
Methods
| Name | Description |
|---|---|
| Append | Appends another matrix as post-multiplication operation. Equivalent to this * value; |
| ContainsPerspective | Determines if the current matrix contains perspective (non-affine) transforms (true) or only (affine) transforms that could be mapped into an 2x3 matrix (false). |
| CreateRotation (2 overloads) | Creates a rotation matrix using the given rotation in radians. |
| CreateScale (2 overloads) | Creates a scale matrix from the given vector scale. |
| CreateSkew | Creates a skew matrix from the given axis skew angles in radians. |
| CreateTranslation (2 overloads) | Creates a translation matrix from the given vector. |
| Equals (2 overloads) | Returns a boolean indicating whether the matrix is equal to the other given matrix. |
| GetDeterminant | Calculates the determinant for this matrix. |
| GetHashCode | Returns the hash code for this instance. |
| Invert | Inverts the Matrix. |
| Parse | Parses a Avalonia.Matrix string. |
| Prepend | Prepends another matrix as pre-multiplication operation. Equivalent to value * this; |
| ToRadians | Converts an angle in degrees to radians. |
| ToString | Returns a String representing this matrix instance. |
| Transform | Transforms the point with the matrix |
| TryDecomposeTransform | No summary available. |
| TryInvert | No summary available. |
Append Method
Appends another matrix as post-multiplication operation. Equivalent to this * value;
public Avalonia.Matrix Append(Avalonia.Matrix value)
Parameters
value Avalonia.Matrix
A matrix.
Returns
Post-multiplied matrix.
ContainsPerspective Method
Determines if the current matrix contains perspective (non-affine) transforms (true) or only (affine) transforms that could be mapped into an 2x3 matrix (false).
public bool ContainsPerspective()
Returns
bool
CreateRotation overloads
CreateRotation Method
Creates a rotation matrix using the given rotation in radians.
public Avalonia.Matrix CreateRotation(double radians)
Parameters
radians double
The amount of rotation, in radians.
Returns
A rotation matrix.
CreateRotation Method
Creates a rotation matrix using the given rotation in radians around center point.
public Avalonia.Matrix CreateRotation(double radians, Avalonia.Point center)
Parameters
radians double
The amount of rotation, in radians.
center Avalonia.Point
The location of center point.
Returns
CreateScale overloads
CreateScale Method
Creates a scale matrix from the given vector scale.
public Avalonia.Matrix CreateScale(Avalonia.Vector scales)
Parameters
scales Avalonia.Vector
The scale to use.
Returns
A scaling matrix.
CreateScale Method
Creates a scale matrix from the given X and Y components.
public Avalonia.Matrix CreateScale(double xScale, double yScale)
Parameters
xScale double
Value to scale by on the X-axis.
yScale double
Value to scale by on the Y-axis.
Returns
A scaling matrix.
CreateSkew Method
Creates a skew matrix from the given axis skew angles in radians.
public Avalonia.Matrix CreateSkew(double xAngle, double yAngle)
Parameters
xAngle double
The amount of skew along the X-axis, in radians.
yAngle double
The amount of skew along the Y-axis, in radians.
Returns
A rotation matrix.
CreateTranslation overloads
CreateTranslation Method
Creates a translation matrix from the given vector.
public Avalonia.Matrix CreateTranslation(Avalonia.Vector position)
Parameters
position Avalonia.Vector
The translation position.
Returns
A translation matrix.
CreateTranslation Method
Creates a translation matrix from the given X and Y components.
public Avalonia.Matrix CreateTranslation(double xPosition, double yPosition)
Parameters
xPosition double
The X position.
yPosition double
The Y position.
Returns
A translation matrix.
Equals overloads
Equals Method
Returns a boolean indicating whether the matrix is equal to the other given matrix.
public bool Equals(Avalonia.Matrix other)
Parameters
other Avalonia.Matrix
The other matrix to test equality against.
Returns
bool
True if this matrix is equal to other; False otherwise.
Equals Method
Returns a boolean indicating whether the given Object is equal to this matrix instance.
public bool Equals(object obj)
Parameters
obj object
The Object to compare against.
Returns
bool
True if the Object is equal to this matrix; False otherwise.
GetDeterminant Method
Calculates the determinant for this matrix.
public double GetDeterminant()
Returns
double
The determinant.
Remarks
The determinant is calculated by expanding the matrix with a third column whose values are (0,0,1).
GetHashCode Method
Returns the hash code for this instance.
public int GetHashCode()
Returns
int
The hash code.
Invert Method
Inverts the Matrix.
public Avalonia.Matrix Invert()
Returns
The inverted matrix.
Exceptions
Parse Method
Parses a Avalonia.Matrix string.
public Avalonia.Matrix Parse(string s)
Parameters
s string
Six or nine comma-delimited double values (m11, m12, m21, m22, offsetX, offsetY[, perspX, perspY, perspZ]) that describe the new Avalonia.Matrix
Returns
The Avalonia.Matrix.
Prepend Method
Prepends another matrix as pre-multiplication operation. Equivalent to value * this;
public Avalonia.Matrix Prepend(Avalonia.Matrix value)
Parameters
value Avalonia.Matrix
A matrix.
Returns
Pre-multiplied matrix.
ToRadians Method
Converts an angle in degrees to radians.
public double ToRadians(double angle)
Parameters
angle double
The angle in degrees.
Returns
double
The angle in radians.
ToString Method
Returns a String representing this matrix instance.
public string ToString()
Returns
string
The string representation.
Transform Method
Transforms the point with the matrix
public Avalonia.Point Transform(Avalonia.Point p)
Parameters
The point to be transformed
Returns
The transformed point
TryDecomposeTransform Method
public bool TryDecomposeTransform(Avalonia.Matrix matrix, Avalonia.Matrix.Decomposed& decomposed)
Parameters
matrix Avalonia.Matrix
decomposed Avalonia.Matrix.Decomposed&
Returns
bool
TryInvert Method
public bool TryInvert(Avalonia.Matrix& inverted)
Parameters
inverted Avalonia.Matrix&
Returns
bool
Properties
| Name | Description |
|---|---|
| HasInverse | HasInverse Property - returns true if this matrix is invertible, false otherwise. |
| Identity | Returns the multiplicative identity matrix. |
| IsIdentity | Returns whether the matrix is the identity matrix. |
| M11 | The first element of the first row (scaleX). |
| M12 | The second element of the first row (skewY). |
| M13 | The third element of the first row (perspX: input x-axis perspective factor). |
| M21 | The first element of the second row (skewX). |
| M22 | The second element of the second row (scaleY). |
| M23 | The third element of the second row (perspY: input y-axis perspective factor). |
| M31 | The first element of the third row (offsetX/translateX). |
| M32 | The second element of the third row (offsetY/translateY). |
| M33 | The third element of the third row (perspZ: perspective scale factor). |
HasInverse Property
HasInverse Property - returns true if this matrix is invertible, false otherwise.
public bool HasInverse { get; set; }
Identity Property
Returns the multiplicative identity matrix.
public Avalonia.Matrix Identity { get; set; }
IsIdentity Property
Returns whether the matrix is the identity matrix.
public bool IsIdentity { get; set; }
M11 Property
The first element of the first row (scaleX).
public double M11 { get; set; }
M12 Property
The second element of the first row (skewY).
public double M12 { get; set; }
M13 Property
The third element of the first row (perspX: input x-axis perspective factor).
public double M13 { get; set; }
M21 Property
The first element of the second row (skewX).
public double M21 { get; set; }
M22 Property
The second element of the second row (scaleY).
public double M22 { get; set; }
M23 Property
The third element of the second row (perspY: input y-axis perspective factor).
public double M23 { get; set; }
M31 Property
The first element of the third row (offsetX/translateX).
public double M31 { get; set; }
M32 Property
The second element of the third row (offsetY/translateY).
public double M32 { get; set; }
M33 Property
The third element of the third row (perspZ: perspective scale factor).
public double M33 { get; set; }