topCenterRect function

Rectangle topCenterRect(
  1. Rectangle area,
  2. int width,
  3. int height
)

Returns a new Rectangle at the top-center of area with width and height.

Upstream: TopCenterRect in third_party/ultraviolet/layout.go.

Implementation

Rectangle topCenterRect(Rectangle area, int width, int height) {
  final centerX = area.minX + area.width ~/ 2;
  final minX = centerX - width ~/ 2;
  return rect(minX, area.minY, width, height).intersect(area);
}