Rectangle<T extends num> constructor

const Rectangle<T extends num>(T left T top T width T height)

Create a rectangle spanned by (left, top) and (left+width, top+height).

The rectangle contains the points with x-coordinate between left and left + width, and with y-coordinate between top and top + height, both inclusive.

The width and height should be non-negative. If width or height are negative, they are clamped to zero.

If width and height are zero, the "rectangle" comprises only the single point (left, top).

Implementation

const Rectangle(this.left, this.top, T width, T height)
    : this.width = (width < 0) ? -width * 0 : width, // Inline _clampToZero.
      this.height = (height < 0) ? -height * 0 : height;