Skip to content

Commit

Permalink
Merge pull request #46 from Jason-Patrick/feature/Non-Clustered-Big-P…
Browse files Browse the repository at this point in the history
…arks

Issue-45: Option for non-clustered big parks
  • Loading branch information
ProbableTrain authored May 15, 2020
2 parents b46dae8 + cb665e9 commit 5c4471f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/ts/ui/main_gui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import PolygonUtil from '../impl/polygon_util';
export default class MainGUI {
private numBigParks: number = 2;
private numSmallParks: number = 0;
private clusterBigParks: boolean = false;

private domainController = DomainController.getInstance();
private intersections: Vector[] = [];
Expand Down Expand Up @@ -108,6 +109,7 @@ export default class MainGUI {
this.addParks();
this.redraw = true;
}}, 'Generate');
parks.add(this, 'clusterBigParks');
parks.add(this, 'numBigParks');
parks.add(this, 'numSmallParks');

Expand Down Expand Up @@ -200,13 +202,21 @@ export default class MainGUI {
const polygons = p.polygons;

if (this.minorRoads.allStreamlines.length === 0) {
// Big parks - add consecutive polygons
// Big parks
this.bigParks = [];
this.smallParks = [];
if (polygons.length > this.numBigParks) {
const parkIndex = Math.floor(Math.random() * (polygons.length - this.numBigParks));
for (let i = parkIndex; i < parkIndex + this.numBigParks; i++) {
this.bigParks.push(polygons[i]);
if (this.clusterBigParks) {
// Group in adjacent polygons
const parkIndex = Math.floor(Math.random() * (polygons.length - this.numBigParks));
for (let i = parkIndex; i < parkIndex + this.numBigParks; i++) {
this.bigParks.push(polygons[i]);
}
} else {
for (let i = 0; i < this.numBigParks; i++) {
const parkIndex = Math.floor(Math.random() * polygons.length);
this.bigParks.push(polygons[parkIndex]);
}
}
} else {
this.bigParks.push(...polygons);
Expand Down

0 comments on commit 5c4471f

Please sign in to comment.