GMatrix class

Represents a 2D affine transformation matrix that can be used to manipulate graphical elements, such as lines, rectangles, paths, and bitmaps.

The GMatrix class provides various methods for performing common matrix operations such as concatenation, inversion, scaling, rotation, and translation. It also provides methods for converting between matrices and other formats, such as points, rectangles, and lists.

The GMatrix class has six fields that define the properties of the matrix:

  • a, b, c, d: These fields represent the six elements of the 3x3 transformation matrix in the order: [a, b, 0, c, d, 0, 0, 0, 1].

  • tx and ty: These fields define the translation vector.

Constructors

GMatrix([double a = 1, double b = 0, double c = 0, double d = 1, double tx = 0, double ty = 0])
Constructor with optional parameters for all matrix values.
GMatrix.fromList(List<double> value)
Creates a new GMatrix object from a list of 6 doubles.

Properties

a double
The value that affects the positioning of pixels along the x axis when scaling or rotating an image.
getter/setter pair
b double
The value that affects the positioning of pixels along the y axis when rotating or skewing an image.
getter/setter pair
c double
The value that affects the positioning of pixels along the x axis when rotating or skewing an image.
getter/setter pair
d double
The value that affects the positioning of pixels along the y axis when scaling or rotating an image.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tx double
The distance by which to translate each point along the x axis.
getter/setter pair
ty double
The distance by which to translate each point along the y axis.
getter/setter pair

Methods

append(GMatrix matrix) GMatrix
Multiplies this matrix by another matrix, concatenating the two matrices.
clone() GMatrix
Creates a new instance of GMatrix with the same values as the current instance, and returns it.
concat(GMatrix matrix) GMatrix
Concatenates the given matrix with this matrix by multiplying the two matrices together. This matrix is on the right-hand side and the given matrix is on the left-hand side. Returns the current matrix for chaining.
copyFrom(GMatrix source) GMatrix
Copies all of the matrix data from the source matrix into this matrix.
deltaTransformPoint(GPoint point, [GPoint? out]) GPoint
Given a point in the pre-transformed coordinate space, returns the coordinates of that point after the transformation occurs. Unlike the standard transformation applied using the transformPoint() method, the deltaTransformPoint() method's transformation does not consider the translation parameters tx and ty.
identity() GMatrix
Sets each matrix property to a value that causes a null transformation. An object transformed by applying an identity matrix will be identical to the original.
invert() GMatrix
Inverts this matrix, i.e. applies a matrix transformation that is the opposite of the original one.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rotate(double angle) → void
Applies a rotation transformation to this matrix object.
scale(double scaleX, [double? scaleY]) GMatrix
Applies a scaling transformation to this matrix.
setTo(double a, double b, double c, double d, double tx, double ty) GMatrix
Sets the members of this matrix to the specified values.
setTransform(double x, double y, double pivotX, double pivotY, double scaleX, double scaleY, double skewX, double skewY, double rotation) GMatrix
Utility function that calculates directly the transformation for a DisplayObject.
skew(double skewX, double skewY) → void
Applies a skew transformation (in radians) to the matrix.
toNative() Matrix4
Returns a native Matrix4 instance based on this GMatrix a,b,c,d,tx,ty
toString() String
Returns a text value listing the properties of this matrix object.
override
transformCoords(double x, double y, [GPoint? out]) GPoint
Transforms the given point (x,y) using this matrix and stores the result in the out point or a new GPoint instance if out is not provided.
transformInverseCoords(double x, double y, [GPoint? out]) GPoint
Transforms the given coordinates x and y from the global coordinate space to the local coordinate space of this matrix. The transformed coordinates are stored in the out point object if provided, or a new GPoint object is created and returned. The original point object is not modified.
transformInversePoint(GPoint point, [GPoint? out]) GPoint
Transforms a GPoint object using the inverse of this GMatrix object and returns a new GPoint object containing the transformed point.
transformPoint(GPoint point, [GPoint? out]) GPoint
Returns the result of applying the geometric transformation represented by the Matrix object to the specified point.
translate(double dx, double dy) GMatrix
Translates the matrix along the x and y axes, as specified by the dx and dy parameters.
zoomAroundPoint(GPoint center, double zoomFactor) GMatrix
Simple utility to zoom by zoomFactor around the point center that returns the new matrix.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromNative(Matrix4 m) GMatrix
Creates a new GMatrix object based on the Matrix4 counterpart.