Table of Contents

Class FloatMatrix

Namespace
Gamelogic.Fx
Assembly
Gamelogic.Fx.dll

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

width int

The width of the matrix.

height int

The height of the matrix.

values float[]

The values to initialize the matrix with. If null, or omitted, the matrix is initialized with zeros.

Exceptions

ArgumentException

Fields

Empty

Represents a matrix with zero width and height.

public static readonly IFloatMatrix Empty

Field Value

IFloatMatrix

Properties

Height

Gets the height of this matrix.

public int Height { get; }

Property Value

int

this[int, int]

Gets the value at the specified coordinates.

public float this[int x, int y] { get; }

Parameters

x int

The x-coordinate of the matrix.

y int

The y-coordinate of the matrix.

Property Value

float

this[int2]

Gets the value at the specified coordinates.

public float this[int2 index] { get; }

Parameters

index int2

The 2D index into the matrix.

Property Value

float

Length

Gets the number of values in this matrix.

public int Length { get; }

Property Value

int

Values

Gets the values of this matrix, as a one dimensional array.

public IEnumerable<float> Values { get; }

Property Value

IEnumerable<float>

Width

Gets the width of this matrix.

public int Width { get; }

Property Value

int

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

FloatMatrix

IsConstant()

Returns whether all values in this matrix are effectively the same.

public bool IsConstant()

Returns

bool

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

bool

Normalize()

Normalizes the values in this matrix to be between 0 and 1.

public IFloatMatrix Normalize()

Returns

IFloatMatrix

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

other IFloatMatrix

The other matrix to copy from.