getPointsAround method

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

Implementation

List<PointData<T>> getPointsAround(Point point, Offset offset) {
  _CellKey cellKey = _cellKey(point);
  List<PointData<T>> results = [];

  // Calculate the range of cells to check
  int startX = cellKey.x - (offset.dx / cellSize.width).floor();
  int startY = cellKey.y - (offset.dy / cellSize.height).floor();
  int endX = cellKey.x + (offset.dx / cellSize.width).ceil();
  int endY = cellKey.y + (offset.dy / cellSize.height).ceil();

  for (int x = startX; x <= endX; x++) {
    for (int y = startY; y <= endY; y++) {
      Point currentCellKey = Point(x, y);
      if (_cellMap.containsKey(currentCellKey)) {
        for (Point p in _cellMap[currentCellKey]!) {
          results.add(PointData(p, _pointData[p] as T));
        }
      }
    }
  }

  return results;
}