fillForegroundStyle method
Fills the foreground style of all cells in bounds using blend.
Implementation
void fillForegroundStyle(Rect bounds, Style style, BlendOption blend) {
final fgVal = style.foreground?.argb ?? 0;
final styleMods = style.modifiers;
final startY = max(0, bounds.y);
final endY = min(height, bounds.y + bounds.height);
final startX = max(0, bounds.x);
final endX = min(width, bounds.x + bounds.width);
if (startX >= endX || startY >= endY) return;
for (var y = startY; y < endY; y++) {
final rowOffset = y * width;
for (var x = startX; x < endX; x++) {
final idx = rowOffset + x;
final attrIdx = idx * 3;
if (blend == BlendOption.replace) {
attributes[attrIdx + 0] = fgVal;
attributes[attrIdx + 1] = style.background?.argb ?? 0;
attributes[attrIdx + 2] = styleMods;
} else if (blend == BlendOption.colorOnly) {
if (fgVal != 0) {
attributes[attrIdx + 0] = fgVal;
}
} else if (blend == BlendOption.addModifiers) {
attributes[attrIdx + 2] |= styleMods;
}
}
}
}