updateCanvasSize method

void updateCanvasSize(
  1. double width,
  2. double height
)

Implementation

void updateCanvasSize(double width, double height) {
  flockingEngine.width = width;
  flockingEngine.height = height;

  // Reposicionar boids que quedaron fuera del área visible
  for (var boid in flockingEngine.boids) {
    if (boid.x > width) boid.x = boid.x % width;
    if (boid.y > height) boid.y = boid.y % height;
  }
}