localTransform property
This node's local transform.
The returned matrix is owned by this node and should not be retained.
Implementation
MMatrix3 get localTransform {
final transform = _lastLocalTransform;
final cosA = math.cos(angle);
final sinA = math.sin(angle);
final a = cosA * scale.x;
final b = sinA * scale.x;
final c = -sinA * scale.y;
final d = cosA * scale.y;
final anchor = this.anchor;
if (anchor.isZero) {
transform.setValues(
// dart format off
a, b, 0,
c, d, 0,
position.x, position.y, 1,
// dart format on
);
return transform;
}
final offsetX = -anchor.x * width;
final offsetY = -anchor.y * height;
transform.setValues(
// dart format off
a, b, 0,
c, d, 0,
offsetX * a + offsetY * c + position.x,
offsetX * b + offsetY * d + position.y, 1,
// dart format on
);
return transform;
}