applyEffect method

  1. @override
void applyEffect(
  1. Buffer target,
  2. Rect bounds
)
override

Applies the effect directly to the target buffer within bounds.

Implementation

@override
void applyEffect(Buffer target, Rect bounds) {
  final startY = max(0, bounds.y);
  final endY = min(target.height, bounds.y + bounds.height);
  final startX = max(0, bounds.x);
  final endX = min(target.width, bounds.x + bounds.width);
  if (startX >= endX || startY >= endY) return;

  final mutator = ColorMutator(
    scalar,
    barrierColor: barrierColor,
    palette: palette,
  );
  final defFg = defaultForeground?.argb ?? 0;
  final defBg = defaultBackground?.argb ?? 0;
  final attrs = target.attributes;
  final width = target.width;

  for (var y = startY; y < endY; y++) {
    final rowOffset = y * width;
    for (var x = startX; x < endX; x++) {
      _dimCell(
        attrs,
        (rowOffset + x) * 3,
        mutator,
        defFg: defFg,
        defBg: defBg,
      );
    }
  }
}