getAsScale static method

double? getAsScale(
  1. Matrix4 transform
)

Returns the given transform matrix as a double describing a uniform scale, if the matrix is nothing but a symmetric 2D scale transform.

Otherwise, returns null.

Implementation

static double? getAsScale(Matrix4 transform) {
  // Values are stored in column-major order
  // (but this symmetric matrix is unaffected).
  if (transform.storage case [
    final double diagonal1, 0.0, 0.0, 0.0,
    0.0, final double diagonal2, 0.0, 0.0,
    0.0, 0.0, 1.0, 0.0,
    0.0, 0.0, 0.0, 1.0,
  ] when diagonal1 == diagonal2) {
    return diagonal1;
  }
  return null;
}