drawBox method

void drawBox(
  1. int x,
  2. int y,
  3. int width,
  4. int height, {
  5. bool value = true,
  6. bool antiAliased = false,
  7. Style? cellStyle,
})

Draws a box outline in sub-pixel coordinates.

Implementation

void drawBox(
  int x,
  int y,
  int width,
  int height, {
  bool value = true,
  bool antiAliased = false,
  Style? cellStyle,
}) {
  if (width <= 0 || height <= 0) return;

  // Top & bottom horizontal lines
  for (var px = x; px < x + width; px++) {
    setPixel(px, y, value, antiAliased: antiAliased, cellStyle: cellStyle);
    setPixel(
      px,
      y + height - 1,
      value,
      antiAliased: antiAliased,
      cellStyle: cellStyle,
    );
  }
  // Left & right vertical lines
  for (var py = y + 1; py < y + height - 1; py++) {
    setPixel(x, py, value, antiAliased: antiAliased, cellStyle: cellStyle);
    setPixel(
      x + width - 1,
      py,
      value,
      antiAliased: antiAliased,
      cellStyle: cellStyle,
    );
  }
}