cullParticles function
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);
}
}