setBackground method

void setBackground(
  1. int x,
  2. int y,
  3. int bg
)

Sets background color at coordinates.

Performance Warning: Invoking individual property setters (setCharacter, setForeground, etc.) inside a per-cell hot render loop causes severe thrashing due to redundant bounds checking and method overhead. Prefer using setCell to write all attributes at once. For massive regional updates, manipulate the raw 1D arrays (characters and attributes) directly via List.setRange().

Implementation

void setBackground(int x, int y, int bg) {
  if (isCellValid(x, y)) {
    attributes[(y * width + x) * 3 + 1] = blendColor(
      bg,
      attributes[(y * width + x) * 3 + 1],
    );
  }
}