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;

  _ensureHistory(width, height);
  final retained = persistence.clamp(0.0, 1.0);
  final liveBoost = currentBoost.clamp(0.0, 1.0);

  for (var y = 0; y < height; y++) {
    for (var x = 0; x < width; x++) {
      final current = source.cellAt(x, y) ?? Cell.emptyCell();
      final previous = _history!.cellAt(x, y) ?? Cell.emptyCell();

      if (_isVisibleGlyph(current)) {
        final output = liveBoost <= 0
            ? current
            : _scaleCellChannels(current, 1.0 + liveBoost, background: false);
        target.setCell(x, y, output);
        continue;
      }

      if (_isVisibleGlyph(previous) && retained > 0) {
        final ghost = _scaleCellChannels(
          previous,
          retained,
          background: false,
        );
        target.setCell(
          x,
          y,
          Cell(
            content: ghost.content,
            width: ghost.width,
            style: ghost.style.copyWith(clearBg: true),
            link: ghost.link,
            drawable: ghost.drawable,
          ),
        );
        continue;
      }

      target.setCell(x, y, current);
    }
  }

  _history!
    ..clear()
    ..clearDirtyTracking();
  _copyBuffer(target, _history!);
  _history!.clearDirtyTracking();
}