Class FloatMatrix
A serializable data-driven dither matrix. Stores an array of normalized float values along with matrix dimensions.
[Serializable]
public sealed class FloatMatrix : IFloatMatrix
- Inheritance
-
FloatMatrix
- Implements
- Inherited Members
Constructors
FloatMatrix(int, int, float[])
Initializes a new instance of the FloatMatrix class.
public FloatMatrix(int width, int height, float[] values = null)
Parameters
widthintThe width of the matrix.
heightintThe height of the matrix.
valuesfloat[]The values to initialize the matrix with. If null, or omitted, the matrix is initialized with zeros.
Exceptions
Fields
Empty
Represents a matrix with zero width and height.
public static readonly IFloatMatrix Empty
Field Value
Properties
Height
Gets the height of this matrix.
public int Height { get; }
Property Value
this[int, int]
Gets the value at the specified coordinates.
public float this[int x, int y] { get; }
Parameters
Property Value
this[int2]
Gets the value at the specified coordinates.
public float this[int2 index] { get; }
Parameters
indexint2The 2D index into the matrix.
Property Value
Length
Gets the number of values in this matrix.
public int Length { get; }
Property Value
Values
Gets the values of this matrix, as a one dimensional array.
public IEnumerable<float> Values { get; }
Property Value
Width
Gets the width of this matrix.
public int Width { get; }
Property Value
Methods
AddColumn()
Adds a column to the matrix at the end.
public void AddColumn()
AddRow()
Adds a row to the matrix at the end.
public void AddRow()
Clone()
Creates a deep copy of this matrix.
public FloatMatrix Clone()
Returns
IsConstant()
Returns whether all values in this matrix are effectively the same.
public bool IsConstant()
Returns
Remarks
This can be called before normalization to check if normalization would produce a matrix of zeros.
IsValid()
Returns whether this matrix is in a valid state (dimensions and value array are consistent).
public bool IsValid()
Returns
Normalize()
Normalizes the values in this matrix to be between 0 and 1.
public IFloatMatrix Normalize()
Returns
Remarks
If the matrix is empty, an empty matrix is returned.
If all values in the matrix are the same, a matrix of the same dimensions filled with zeros is returned.
Otherwise, a new matrix with the same dimensions is returned, with values normalized between 0 and 1.
RemoveColumn()
Removes the last column from the matrix if there is one.
public void RemoveColumn()
RemoveRow()
Removes the last row from the matrix if there is one.
public void RemoveRow()
SetFrom(IFloatMatrix)
Sets the values and dimensions of this matrix from another matrix.
public void SetFrom(IFloatMatrix other)
Parameters
otherIFloatMatrixThe other matrix to copy from.