apply method
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;
_time += effectiveDt;
final phaseOffset = phase + (_time * speed * math.pi * 2.0);
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
final dx = math.sin((y * xFrequency) + phaseOffset) * xAmplitude;
final dy = math.sin((x * yFrequency) + phaseOffset * 0.73) * yAmplitude;
final sx = (x + dx).round().clamp(0, width - 1);
final sy = (y + dy).round().clamp(0, height - 1);
final cell = source.cellAt(sx, sy);
if (cell == null || cell.width == 0) {
target.setCell(x, y, Cell.emptyCell());
} else {
target.setCell(x, y, cell);
}
}
}
}