Transform2D class

A 2D affine transform represented as a 2×3 matrix.

The matrix maps points in the following form: x' = a*x + c*y + tx y' = b*x + d*y + ty

This matches Flutter's Canvas.transform convention when expanded into a 4×4 column-major matrix via toCanvasTransform.

Constructors

Transform2D({required double a, required double b, required double c, required double d, required double tx, required double ty})
const
Transform2D.fromJsonMap(Map<String, Object?> map)
Decodes a transform from a JSON-friendly map.
factory
Transform2D.rotationDeg(double degrees)
factory
Transform2D.scale(double sx, double sy)
factory
Transform2D.translation(Offset delta)
factory
Transform2D.trs({Offset translation = Offset.zero, double rotationDeg = 0, double scaleX = 1, double scaleY = 1})
Builds a translate * rotate * scale transform.
factory

Properties

a double
final
b double
final
c double
final
d double
final
hashCode int
The hash code for this object.
no setterinherited
isFinite bool
Returns true when all matrix components are finite.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
translation Offset
no setter
tx double
final
ty double
final

Methods

applyToPoint(Offset point) Offset
applyToRect(Rect rect) Rect
Applies the transform to rect and returns its axis-aligned world bounds.
invert() Transform2D?
Returns the inverse transform, or null if the matrix is singular.
multiply(Transform2D other) Transform2D
Returns a composition of this transform with other (this * other).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toCanvasTransform() Float64List
Expands this 2×3 matrix into a 4×4 column-major matrix for Flutter.
toJsonMap() Map<String, double>
Encodes this transform into a JSON-friendly map.
toString() String
A string representation of this object.
inherited
withTranslation(Offset translation) Transform2D
writeToCanvasTransform(Float64List out) → void
Writes this transform into out as a 4×4 column-major matrix for Flutter.

Operators

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

Constants

identity → const Transform2D