fill method

void fill(
  1. int x,
  2. int y,
  3. int width,
  4. int height, [
  5. Color? color,
])

Clears and fills the given rectangle with the given (or default) background Color.

Implementation

void fill(final int x, int y, int width, int height, [Color? color]) {
  color ??= background;

  // fail fast
  boundsCheck(x, y);
  boundsCheck(x + width - 1, y + height - 1);

  var char = Char.create(CharCode.space, foreground, color);

  for (var fy = y; fy < y + height; fy++) {
    for (var fx = x; fx < x + width; fx++) {
      drawChar(fx, fy, char);
    }
  }
}