paint method
Performs direct rendering modifications to the relative buffer.
Implementation
@override
void paint(Buffer buffer, Rect area, Style baseStyle) {
if (!isVisible) return;
final p = progress;
// Oscillate brightness intensity using a sine wave
final intensity = (sin(p * pi * pulses * 2 - pi / 2) + 1.0) / 2.0;
final W = area.width;
final H = area.height;
for (var y = 0; y < H; y++) {
for (var x = 0; x < W; x++) {
final bgArgb = buffer.getBackground(x, y);
final originalBg = bgArgb == 0
? (baseStyle.background ?? Colors.black)
: Color.argb(bgArgb);
// Cap blending factor at 60% to maintain baseline legibility of text content
final blendedBg = interpolateColor(
originalBg,
flashColor,
intensity * 0.6,
);
buffer.setAttributes(x, y, bg: blendedBg.argb);
}
}
}