getPointsAround method

List<PointData<T>> getPointsAround(
  1. Point<num> point,
  2. Offset offset
)

Implementation

List<PointData<T>> getPointsAround(Point point, Offset offset) {
  final left = point.x - offset.dx;
  final right = point.x + offset.dx;
  final top = point.y - offset.dy;
  final bottom = point.y + offset.dy;
  final start = _cellKey(Point(left, top));
  final end = _cellKey(Point(right, bottom));
  final results = <PointData<T>>[];

  for (int x = start.x; x <= end.x; x++) {
    for (int y = start.y; y <= end.y; y++) {
      final points = _cellMap[Point(x, y)];
      if (points != null) {
        for (final item in points) {
          final candidate = item.point;
          if (candidate.x >= left &&
              candidate.x <= right &&
              candidate.y >= top &&
              candidate.y <= bottom) {
            results.add(item);
          }
        }
      }
    }
  }

  return results;
}