splitVertical function

({Rectangle bottom, Rectangle top}) splitVertical(
  1. Rectangle area,
  2. Constraint c
)

Splits area vertically into top/bottom.

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

Implementation

({Rectangle top, Rectangle bottom}) splitVertical(
  Rectangle area,
  Constraint c,
) {
  final height = (c.apply(area.height) < area.height)
      ? c.apply(area.height)
      : area.height;
  final top = Rectangle(
    minX: area.minX,
    minY: area.minY,
    maxX: area.maxX,
    maxY: area.minY + height,
  );
  final bottom = Rectangle(
    minX: area.minX,
    minY: area.minY + height,
    maxX: area.maxX,
    maxY: area.maxY,
  );
  return (top: top, bottom: bottom);
}