• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Class Matrix

Represents a 2D affine transformation matrix. Internal storage: [M11, M12, M21, M22, DX, DY] (GDI+ element order). Row-vector transform: x' = xM11 + yM21 + DX, y' = xM12 + yM22 + DY.

Inheritance
object
Matrix
Implements
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DRIT.Drawing.Drawing2D
Assembly: DRIT.Drawing.dll
Syntax
public sealed class Matrix : IDisposable
Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Constructors

Matrix()

Initializes a new Matrix as the identity matrix.

Declaration
public Matrix()
Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Matrix(RectangleF, PointF[])

Creates a matrix that maps rect to the parallelogram defined by three destination points (top-left, top-right, bottom-left).

Declaration
public Matrix(RectangleF rect, PointF[] plgpts)
Parameters
Type Name Description
RectangleF rect
PointF[] plgpts
Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Matrix(float, float, float, float, float, float)

Initializes a new Matrix with the specified elements.

Declaration
public Matrix(float m11, float m12, float m21, float m22, float dx, float dy)
Parameters
Type Name Description
float m11

The element at row 1, column 1.

float m12

The element at row 1, column 2.

float m21

The element at row 2, column 1.

float m22

The element at row 2, column 2.

float dx

The horizontal translation component.

float dy

The vertical translation component.

Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Properties

Elements

Returns a copy of the six elements [M11, M12, M21, M22, DX, DY].

Declaration
public float[] Elements { get; }
Property Value
Type Description
float[]
Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

IsIdentity

Gets a value indicating whether this matrix is the identity matrix.

Declaration
public bool IsIdentity { get; }
Property Value
Type Description
bool
Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

IsInvertible

Gets a value indicating whether this matrix is invertible.

Declaration
public bool IsInvertible { get; }
Property Value
Type Description
bool
Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

OffsetX

Gets the horizontal translation component of this matrix.

Declaration
public float OffsetX { get; }
Property Value
Type Description
float
Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

OffsetY

Gets the vertical translation component of this matrix.

Declaration
public float OffsetY { get; }
Property Value
Type Description
float
Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Methods

Clone()

Creates an exact copy of this Matrix.

Declaration
public Matrix Clone()
Returns
Type Description
Matrix

A new Matrix with the same elements.

Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Dispose()

Releases all resources used by this Matrix.

Declaration
public void Dispose()
Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Invert()

Inverts this matrix.

Declaration
public void Invert()
Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Exceptions
Type Condition
InvalidOperationException

Thrown when the matrix is not invertible.

Multiply(Matrix, MatrixOrder)

Multiplies this matrix by matrix in the specified order. Prepend: result = matrix * this (matrix applied first to points). Append: result = this * matrix (matrix applied after this to points).

Declaration
public void Multiply(Matrix matrix, MatrixOrder order = MatrixOrder.Prepend)
Parameters
Type Name Description
Matrix matrix
MatrixOrder order
Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Reset()

Resets this matrix to the identity matrix.

Declaration
public void Reset()
Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Rotate(float, MatrixOrder)

Rotates this matrix by the specified angle.

Declaration
public void Rotate(float angle, MatrixOrder order = MatrixOrder.Prepend)
Parameters
Type Name Description
float angle

The angle of rotation in degrees.

MatrixOrder order

The order of multiplication (prepend or append).

Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

RotateAt(float, PointF, MatrixOrder)

Rotates this matrix by the specified angle around the specified point.

Declaration
public void RotateAt(float angle, PointF center, MatrixOrder order = MatrixOrder.Prepend)
Parameters
Type Name Description
float angle

The angle of rotation in degrees.

PointF center

The center point of rotation.

MatrixOrder order

The order of multiplication (prepend or append).

Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Scale(float, float, MatrixOrder)

Scales this matrix by the specified factors.

Declaration
public void Scale(float scaleX, float scaleY, MatrixOrder order = MatrixOrder.Prepend)
Parameters
Type Name Description
float scaleX

The horizontal scale factor.

float scaleY

The vertical scale factor.

MatrixOrder order

The order of multiplication (prepend or append).

Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Shear(float, float, MatrixOrder)

Shears this matrix by the specified factors.

Declaration
public void Shear(float shearX, float shearY, MatrixOrder order = MatrixOrder.Prepend)
Parameters
Type Name Description
float shearX

The horizontal shear factor.

float shearY

The vertical shear factor.

MatrixOrder order

The order of multiplication (prepend or append).

Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

TransformPoints(PointF[])

Transforms an array of points by this matrix.

Declaration
public void TransformPoints(PointF[] pts)
Parameters
Type Name Description
PointF[] pts

The array of points to transform.

Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

TransformPoints(Point[])

Transforms an array of points by this matrix.

Declaration
public void TransformPoints(Point[] pts)
Parameters
Type Name Description
Point[] pts

The array of points to transform.

Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

TransformVectors(PointF[])

Transforms an array of vectors by this matrix, ignoring the translation components.

Declaration
public void TransformVectors(PointF[] pts)
Parameters
Type Name Description
PointF[] pts

The array of vectors to transform.

Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Translate(float, float, MatrixOrder)

Translates this matrix by the specified offsets.

Declaration
public void Translate(float offsetX, float offsetY, MatrixOrder order = MatrixOrder.Prepend)
Parameters
Type Name Description
float offsetX

The horizontal translation.

float offsetY

The vertical translation.

MatrixOrder order

The order of multiplication (prepend or append).

Remarks

A Matrix can be used to transform coordinates when drawing with Graphics. It supports translation, scaling, rotation, and shearing operations.

Implements

IDisposable
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX