fadeEdges function

void fadeEdges(
  1. Particles ps,
  2. double x0,
  3. double x1, [
  4. double w = 30.0,
  5. double y1 = double.infinity,
])

Soft particles (smoke, dust, vapour) fade out over w px as they near the sides x0, x1.

Implementation

void fadeEdges(
  Particles ps,
  double x0,
  double x1, [
  double w = 30.0,
  double y1 = double.infinity,
]) {
  final l = ps.list;
  for (var i = l.length - 1; i >= 0; i--) {
    final q = l[i];
    if (!_soft.contains(q.k)) continue;
    final r = q.size * 1.65;
    final e = math.min((math.min(q.x - x0, x1 - q.x) - r) / w, (y1 - q.y - r) / 6.0);
    if (e <= 0.0) {
      l.removeAt(i);
    } else if (e < 1.0) {
      q.life = math.min(q.life, q.max * 0.42 * e);
    }
  }
}