cullParticles function

void cullParticles(
  1. Particles ps,
  2. double x0,
  3. double y0,
  4. double x1,
  5. double y1,
)

Drop particles that leave the box (local px), so nothing is drawn past the canvas.

Implementation

void cullParticles(
    Particles ps, double x0, double y0, double x1, double y1) {
  final l = ps.list;
  for (var i = l.length - 1; i >= 0; i--) {
    final q = l[i];
    if (q.x < x0 || q.x > x1 || q.y < y0 || q.y > y1) l.removeAt(i);
  }
}