updateVisibility method

void updateVisibility(
  1. Size bounds
)

Updates the visibility status of the particle based on its position.

Implementation

void updateVisibility(Size bounds) {
  // Include a margin to account for particles near the edges of the viewport.
  const margin = 50.0;
  isVisible = position.dx >= -margin &&
      position.dx <= bounds.width + margin &&
      position.dy >= -margin &&
      position.dy <= bounds.height + margin;
}