Name
Matrix
Synopsis
This class encapsulates a 3x3 transformation matrix for use with most
of the graphics elements in the System.Drawing
and
nested namespaces.
You can get an array of the Elements
in the array
(ordered {1,1},{1,2},{2,1},{2,2},{3,1},{3,2}). {1,3}, {2,3}, {3,3}
are wired to {0,0,1} and hence do not appear in the array. {3,1} and
{3,2} apply a translation and can be retrieved independently through
the OffsetX
and OffsetY
properties. You can also determine if the matrix
IsInvertible
(you invert it with the aptly named
Invert()
method). If the matrix is the identity
matrix {1,0,0},{0,1,0},{0,0,1}, IsIdentity
will be
true.
There are then a host of methods that allow you to transform the
matrix. You can Rotate()
, Translate()
, Scale()
, and Shear()
the object. You can also Reset()
the
matrix back to the identity or Multiply()
by
another matrix. Each method can be performed either prepending or
appending the transform: matrix arithmetic is not commutative.
In addition to being able to apply the matrix to a variety of
different graphics structures, you can use the
TransformPoints()
and TransformVectors()
methods to transform a set of points. The latter does not
apply the offset with the transform.
public sealed class Matrix : MarshalByRefObject : IDisposable { // Public Constructors public Matrix(); public Matrix(System.Drawing.RectangleF rect, System.Drawing.PointF[ ] plgpts); public Matrix(System.Drawing.Rectangle rect, System.Drawing.Point[ ] plgpts); public Matrix(float
Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.