centerRect method

Rect centerRect(
  1. int width,
  2. int height
)

Create a new Rect with the given width and height that is centered on this rectangle.

Implementation

Rect centerRect(int width, int height) {
  var x = left + ((right - left - width) ~/ 2);
  var y = top + ((bottom - top - height) ~/ 2);
  return Rect(Vec2(x, y), Vec2(width, height));
}