scaleBy method

Matrix4Transform scaleBy({
  1. double? x = 1,
  2. double? y = 1,
  3. Offset? origin,
})

Scales by a factor of x (horizontal) and y (vertical). Gets bigger for >1. Smaller for <1. Same size for 1 (and passing null is the same as passing 1). No size for 0.

Implementation

Matrix4Transform scaleBy({double? x = 1, double? y = 1, Offset? origin}) {
  x ??= 1;
  y ??= 1;

  if (x == 1 && y == 1)
    return this;
  else if ((origin == null) || (origin.dx == 0.0 && origin.dy == 0.0))
    return Matrix4Transform._(//
        m.clone()..multiply(Matrix4.identity()..scale(x, y)));
  else
    return Matrix4Transform._(//
        m.clone()
          ..translate(origin.dx, origin.dy)
          ..multiply(Matrix4.identity()..scale(x, y))
          ..translate(-origin.dx, -origin.dy));
}