setForeground method

void setForeground(
  1. int x,
  2. int y,
  3. int fg
)

Sets foreground 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 setForeground(int x, int y, int fg) {
  if (isCellValid(x, y)) {
    attributes[(y * width + x) * 3 + 0] = blendColor(
      fg,
      attributes[(y * width + x) * 3 + 0],
    );
  }
}