apply method

  1. @override
void apply(
  1. Buffer source,
  2. Buffer target,
  3. double dt
)
override

Implementation

@override
void apply(Buffer source, Buffer target, double dt) {
  final width = source.width();
  final height = source.height();
  if (width <= 0 || height <= 0) return;

  final effectiveDt = dt <= 0 ? 1 / 60 : dt;
  _phase = (_phase + effectiveDt * barSpeed).remainder(1.0);
  final bandHeight = math.max(
    1.0,
    height * barHeightFraction.clamp(0.02, 1.0),
  );
  final centerY = _phase * height;

  for (var y = 0; y < height; y++) {
    final scanlineFactor = y.isEven
        ? 1.0
        : 1.0 - lineStrength.clamp(0.0, 1.0);
    final distanceToBand = (y - centerY).abs();
    final bandBoost =
        _rollingBand(distanceToBand, bandHeight) *
        barStrength.clamp(0.0, 1.0);
    final factor = (scanlineFactor + bandBoost).clamp(0.0, 2.0);

    for (var x = 0; x < width; x++) {
      final cell = source.cellAt(x, y);
      if (cell == null) continue;
      target.setCell(x, y, _scaleCell(cell, factor));
    }
  }
}