getAsTranslation static method
- Matrix4 transform
Returns the given transform
matrix as an Offset, if the matrix is
nothing but a 2D translation.
Otherwise, returns null.
Implementation
static Offset? getAsTranslation(Matrix4 transform) {
// Values are stored in column-major order, so the appearance
// of dx is transposed from the top-right to the bottom-left.
if (transform.storage case [
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
final double dx, final double dy, 0.0, 1.0,
]) {
return Offset(dx, dy);
}
return null;
}