paint method

  1. @override
void paint(
  1. Buffer buffer,
  2. Rect area,
  3. Style baseStyle
)
override

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 cell = buffer.getCell(x, y);
      if (cell == null) continue;

      final originalBg =
          cell.style.background ?? baseStyle.background ?? Colors.black;
      // Cap blending factor at 60% to maintain baseline legibility of text content
      final blendedBg = interpolateColor(
        originalBg,
        flashColor,
        intensity * 0.6,
      );

      cell.style = cell.style.merge(Style(background: blendedBg));
    }
  }
}