Line data Source code
1 : /**
2 : * The RectPlacer returns all tiles between the two given points that meet the Constraint.
3 : */
4 : function RectPlacer(start, end, failFraction = Infinity)
5 : {
6 3 : this.bounds = getBoundingBox([start, end]);
7 3 : this.bounds.min.floor();
8 3 : this.bounds.max.floor();
9 3 : this.failFraction = failFraction;
10 : }
11 :
12 7 : RectPlacer.prototype.place = function(constraint)
13 : {
14 3 : const bboxPoints = getPointsInBoundingBox(this.bounds);
15 67 : const points = bboxPoints.filter(point => g_Map.inMapBounds(point) && constraint.allows(point));
16 3 : return (bboxPoints.length - points.length) / bboxPoints.length <= this.failFraction ? points : undefined;
17 : };
|