-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.bundle.js
More file actions
3515 lines (3183 loc) · 227 KB
/
Copy pathmain.bundle.js
File metadata and controls
3515 lines (3183 loc) · 227 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
webpackJsonp(["main"],{
/***/ "./src/$$_lazy_route_resource lazy recursive":
/***/ (function(module, exports) {
function webpackEmptyAsyncContext(req) {
// Here Promise.resolve().then() is used instead of new Promise() to prevent
// uncatched exception popping up in devtools
return Promise.resolve().then(function() {
throw new Error("Cannot find module '" + req + "'.");
});
}
webpackEmptyAsyncContext.keys = function() { return []; };
webpackEmptyAsyncContext.resolve = webpackEmptyAsyncContext;
module.exports = webpackEmptyAsyncContext;
webpackEmptyAsyncContext.id = "./src/$$_lazy_route_resource lazy recursive";
/***/ }),
/***/ "./src/app/about/about.component.css":
/***/ (function(module, exports) {
module.exports = ""
/***/ }),
/***/ "./src/app/about/about.component.html":
/***/ (function(module, exports) {
module.exports = "<p>\n The Laser-Cut Maze Designer was created by Aaron Rodriguez.\n</p>\n<p>\n The source code can be found on\n <a href=\"https://github.com/adashrod/LaserCutMazesAngular\" target=\"_blank\" appTrackClick category=\"About\" label=\"githubProject\">GitHub</a>.\n If you find a bug and would like to submit a report (or a feature request), you can do so\n <a href=\"https://github.com/adashrod/LaserCutMazesAngular/issues\" target=\"_blank\" appTrackClick category=\"About\" label=\"githubProjectIssues\">here</a>.\n</p>\n<p>\n Aaron's other projects can also be found on <a href=\"https://github.com/adashrod\" target=\"_blank\" appTrackClick category=\"About\" label=\"githubHome\">GitHub</a>.\n</p>\n"
/***/ }),
/***/ "./src/app/about/about.component.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AboutComponent; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("./node_modules/@angular/core/esm5/core.js");
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var AboutComponent = /** @class */ (function () {
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
function AboutComponent() {
}
AboutComponent = __decorate([
Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["n" /* Component */])({
selector: "app-about",
template: __webpack_require__("./src/app/about/about.component.html"),
styles: [__webpack_require__("./src/app/about/about.component.css")]
})
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
], AboutComponent);
return AboutComponent;
}());
/***/ }),
/***/ "./src/app/algorithms/depth-first-search-algorithm.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_app_algorithms_maze_generator__ = __webpack_require__("./src/app/algorithms/maze-generator.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__ = __webpack_require__("./src/app/common/ordered-pair.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_app_direction__ = __webpack_require__("./src/app/direction.ts");
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* An implementation of https://en.wikipedia.org/wiki/Depth-first_search
* @author adashrod@gmail.com
*/
var DepthFirstSearchAlgorithm = /** @class */ (function (_super) {
__extends(DepthFirstSearchAlgorithm, _super);
function DepthFirstSearchAlgorithm() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.explored = new Map(); // using a map with stringified keys as a HashSet
_this.deltas = [new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](0, -1), new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](1, 0),
new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](0, 1), new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](-1, 0)];
return _this;
}
Object.defineProperty(DepthFirstSearchAlgorithm.prototype, "name", {
get: function () {
return "Depth-First Search";
},
enumerable: false,
configurable: true
});
DepthFirstSearchAlgorithm.prototype.buildPaths = function (maze) {
this.maze = maze;
this.explored.clear();
var stack = [];
var current = new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](this.rng(maze.numCols), this.rng(maze.numRows));
this.explored.set(new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](current.x, current.y).toString(), true);
var numSpaces = maze.numRows * maze.numCols;
while (this.explored.size < numSpaces) {
var neighbors = this.findUnexploredNeighbors(current.x, current.y);
if (neighbors.length > 0) {
var randomNeighbor = neighbors[this.rng(neighbors.length)];
stack.push(current);
var direction = __WEBPACK_IMPORTED_MODULE_2_app_direction__["a" /* default */].determineDirection(current, randomNeighbor);
maze.grid[current.y][current.x].openWall(direction);
maze.grid[randomNeighbor.y][randomNeighbor.x].openWall(direction.opposite);
current = randomNeighbor;
this.explored.set(new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](current.x, current.y).toString(), true);
}
else {
if (stack.length === 0) {
break;
}
current = stack.pop();
}
}
};
DepthFirstSearchAlgorithm.prototype.findUnexploredNeighbors = function (x, y) {
var neighbors = [];
for (var _i = 0, _a = this.deltas; _i < _a.length; _i++) {
var delta = _a[_i];
if (this.maze.isInBounds(x + delta.x, y + delta.y) &&
!this.explored.has(new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](x + delta.x, y + delta.y).toString())) {
neighbors.push(new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](x + delta.x, y + delta.y));
}
}
return neighbors;
};
return DepthFirstSearchAlgorithm;
}(__WEBPACK_IMPORTED_MODULE_0_app_algorithms_maze_generator__["a" /* default */]));
/* harmony default export */ __webpack_exports__["a"] = (DepthFirstSearchAlgorithm);
/***/ }),
/***/ "./src/app/algorithms/empty-algorithm.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_app_algorithms_maze_generator__ = __webpack_require__("./src/app/algorithms/maze-generator.ts");
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var EmptyAlgorithm = /** @class */ (function (_super) {
__extends(EmptyAlgorithm, _super);
function EmptyAlgorithm() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.name = "Do-It-Yourself";
return _this;
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
EmptyAlgorithm.prototype.buildPaths = function (maze) { };
return EmptyAlgorithm;
}(__WEBPACK_IMPORTED_MODULE_0_app_algorithms_maze_generator__["a" /* default */]));
/* harmony default export */ __webpack_exports__["a"] = (EmptyAlgorithm);
/***/ }),
/***/ "./src/app/algorithms/kruskals-algorithm.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_app_algorithms_maze_generator__ = __webpack_require__("./src/app/algorithms/maze-generator.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__ = __webpack_require__("./src/app/common/ordered-pair.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_app_direction__ = __webpack_require__("./src/app/direction.ts");
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var Tree = /** @class */ (function () {
function Tree() {
this.parent = this;
}
Object.defineProperty(Tree.prototype, "root", {
get: function () {
return this.parent === this ? this.parent : this.parent.root;
},
enumerable: false,
configurable: true
});
Tree.prototype.isConnectedTo = function (otherTree) {
return this.root === otherTree.root;
};
Tree.prototype.merge = function (otherTree) {
otherTree.root.parent = this;
};
return Tree;
}());
/**
* An edge is determined by the coordinates of the two spaces that it separates
*/
var Edge = /** @class */ (function () {
function Edge(a, b) {
this.a = a;
this.b = b;
}
return Edge;
}());
/**
* An implementation of https://en.wikipedia.org/wiki/Kruskal%27s_algorithm for generating random 2D mazes with square
* spaces
* @author adashrod@gmail.com
*/
var KruskalsAlgorithm = /** @class */ (function (_super) {
__extends(KruskalsAlgorithm, _super);
function KruskalsAlgorithm() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.parallelMatrix = [];
_this.edges = [];
return _this;
}
Object.defineProperty(KruskalsAlgorithm.prototype, "name", {
get: function () {
return "Kruskal's";
},
enumerable: false,
configurable: true
});
KruskalsAlgorithm.prototype.buildPaths = function (maze) {
this.parallelMatrix = [];
this.edges = [];
for (var y = 0; y < maze.numRows; y++) {
this.parallelMatrix.push([]);
for (var x = 0; x < maze.numCols; x++) {
this.parallelMatrix[y].push(new Tree());
if (x + 1 < maze.numCols) {
this.edges.push(new Edge(new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](x, y), new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](x + 1, y)));
}
if (y + 1 < maze.numRows) {
this.edges.push(new Edge(new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](x, y), new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](x, y + 1)));
}
}
}
this.shuffleEdges();
for (var _i = 0, _a = this.edges; _i < _a.length; _i++) {
var e = _a[_i];
var s1 = e.a;
var s2 = e.b;
var tree1 = this.parallelMatrix[s1.y][s1.x];
var tree2 = this.parallelMatrix[s2.y][s2.x];
if (!tree1.isConnectedTo(tree2)) {
tree1.merge(tree2);
var oneToTwo = __WEBPACK_IMPORTED_MODULE_2_app_direction__["a" /* default */].determineDirection(s1, s2);
maze.grid[s1.y][s1.x].openWall(oneToTwo);
maze.grid[s2.y][s2.x].openWall(oneToTwo.opposite);
}
}
};
KruskalsAlgorithm.prototype.shuffleEdges = function () {
for (var i = 0; i < this.edges.length - 1; i++) {
var randIndex = this.rng(this.edges.length - i) + i;
var temp = this.edges[i];
this.edges[i] = this.edges[randIndex];
this.edges[randIndex] = temp;
}
};
return KruskalsAlgorithm;
}(__WEBPACK_IMPORTED_MODULE_0_app_algorithms_maze_generator__["a" /* default */]));
/* harmony default export */ __webpack_exports__["a"] = (KruskalsAlgorithm);
/***/ }),
/***/ "./src/app/algorithms/maze-generator.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_random_seed__ = __webpack_require__("./node_modules/random-seed/index.js");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_random_seed___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_random_seed__);
/**
* Subclasses can use any maze-generation algorithm to build the paths of a maze
* @author adashrod@gmail.com
*/
var MazeGenerator = /** @class */ (function () {
function MazeGenerator() {
this.rng = Object(__WEBPACK_IMPORTED_MODULE_0_random_seed__["create"])();
}
Object.defineProperty(MazeGenerator.prototype, "seed", {
get: function () {
return this._seed;
},
set: function (seed) {
this._seed = seed.toString();
this.rng = Object(__WEBPACK_IMPORTED_MODULE_0_random_seed__["create"])(this._seed);
},
enumerable: false,
configurable: true
});
return MazeGenerator;
}());
/* harmony default export */ __webpack_exports__["a"] = (MazeGenerator);
/***/ }),
/***/ "./src/app/algorithms/prims-algorithm.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_app_algorithms_maze_generator__ = __webpack_require__("./src/app/algorithms/maze-generator.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__ = __webpack_require__("./src/app/common/ordered-pair.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_app_direction__ = __webpack_require__("./src/app/direction.ts");
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* An implementation of https://en.wikipedia.org/wiki/Prim%27s_algorithm for generating random 2D mazes with square
* spaces
* @author adashrod@gmail.com
*/
var PrimsAlgorithm = /** @class */ (function (_super) {
__extends(PrimsAlgorithm, _super);
function PrimsAlgorithm() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.nextSpaces = [];
// for onPath and exploringNext, using a map with stringified keys as a HashSet
_this.onPath = new Map();
_this.exploringNext = new Map();
_this.deltas = [new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](0, -1), new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](1, 0),
new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](0, 1), new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](-1, 0)];
return _this;
}
Object.defineProperty(PrimsAlgorithm.prototype, "name", {
get: function () {
return "Prim's";
},
enumerable: false,
configurable: true
});
PrimsAlgorithm.prototype.buildPaths = function (maze) {
this.maze = maze;
this.onPath.clear();
this.exploringNext.clear();
this.markOnPathAndAddUnexploredNeighborsToNext(this.rng(maze.numCols), this.rng(maze.numRows));
while (this.nextSpaces.length > 0) {
var removed = this.nextSpaces.splice(this.rng(this.nextSpaces.length), 1)[0];
var neighbors = this.findOnPathNeighbors(removed.x, removed.y);
var randNeighbor = neighbors[this.rng(neighbors.length)];
var direction = __WEBPACK_IMPORTED_MODULE_2_app_direction__["a" /* default */].determineDirection(removed, randNeighbor);
maze.grid[removed.y][removed.x].openWall(direction);
maze.grid[randNeighbor.y][randNeighbor.x].openWall(direction.opposite);
this.markOnPathAndAddUnexploredNeighborsToNext(removed.x, removed.y);
}
};
PrimsAlgorithm.prototype.addToNextIfUnexplored = function (x, y) {
if (this.maze.isInBounds(x, y) && this.isUnexplored(x, y)) {
this.exploringNext.set(new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](x, y).toString(), true);
this.nextSpaces.push(new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](x, y));
}
};
PrimsAlgorithm.prototype.markOnPathAndAddUnexploredNeighborsToNext = function (x, y) {
this.onPath.set(new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](x, y).toString(), true);
for (var _i = 0, _a = this.deltas; _i < _a.length; _i++) {
var delta = _a[_i];
this.addToNextIfUnexplored(x + delta.x, y + delta.y);
}
};
PrimsAlgorithm.prototype.findOnPathNeighbors = function (x, y) {
var n = [];
for (var _i = 0, _a = this.deltas; _i < _a.length; _i++) {
var delta = _a[_i];
if (this.maze.isInBounds(x + delta.x, y + delta.y) &&
this.onPath.has(new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](x + delta.x, y + delta.y).toString())) {
n.push(new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](x + delta.x, y + delta.y));
}
}
return n;
};
PrimsAlgorithm.prototype.isUnexplored = function (x, y) {
var space = this.maze.grid[y][x];
var wallsClosed = !space.isOpen(__WEBPACK_IMPORTED_MODULE_2_app_direction__["a" /* default */].NORTH) && !space.isOpen(__WEBPACK_IMPORTED_MODULE_2_app_direction__["a" /* default */].EAST) &&
!space.isOpen(__WEBPACK_IMPORTED_MODULE_2_app_direction__["a" /* default */].SOUTH) && !space.isOpen(__WEBPACK_IMPORTED_MODULE_2_app_direction__["a" /* default */].WEST);
return wallsClosed && !this.exploringNext.has(new __WEBPACK_IMPORTED_MODULE_1_app_common_ordered_pair__["a" /* default */](x, y).toString());
};
return PrimsAlgorithm;
}(__WEBPACK_IMPORTED_MODULE_0_app_algorithms_maze_generator__["a" /* default */]));
/* harmony default export */ __webpack_exports__["a"] = (PrimsAlgorithm);
/***/ }),
/***/ "./src/app/app.component.css":
/***/ (function(module, exports) {
module.exports = ".end-container {\n width: 100%;\n height: 170px;\n background: #5c2018;\n}\n\nheader, footer {\n width: 800px;\n height: 100%;\n background: #5c2018 url(\"https://adashrod.github.io/LaserCutMazes/assets/logo1.png\") no-repeat 0 0;\n margin: 0 auto;\n color: #bc4639;\n font-size: 34px;\n}\n\n.page-title, .copyright {\n padding-left: 180px;\n}\n\n.copyright {\n font-size: 16px;\n padding-top: 10px;\n}\n\nheader nav {\n padding: 75px 0 0 500px;\n}\n\nfooter nav {\n padding: 75px 0 0 200px;\n}\n\nnav a {\n color: #4285f4;\n font-size: 16px;\n}\n\nnav a.active {\n font-style: italic;\n}\n\n.main-body {\n border-top: 1px solid #bc4639;\n margin: 0 auto;\n padding: 5px;\n width: 800px;\n background: #bc4639;\n}\n"
/***/ }),
/***/ "./src/app/app.component.html":
/***/ (function(module, exports) {
module.exports = "<div class=\"end-container\">\n <header>\n <div class=\"page-title\">Laser-Cut Maze Designer</div>\n <nav>\n <a routerLink=\"/LaserCutMazes/welcome\" routerLinkActive=\"active\">Home</a>\n <a routerLink=\"/LaserCutMazes/designer\" routerLinkActive=\"active\">Maze Designer</a>\n <a routerLink=\"/LaserCutMazes/help\" routerLinkActive=\"active\">Help</a>\n <a routerLink=\"/LaserCutMazes/about\" routerLinkActive=\"active\">About</a>\n </nav>\n </header>\n</div>\n<div class=\"main-body\">\n <router-outlet></router-outlet>\n</div>\n<div class=\"end-container\">\n <footer>\n <div class=\"copyright\">© 2018 Aaron Rodriguez</div>\n <nav>\n <a routerLink=\"/LaserCutMazes/welcome\" routerLinkActive=\"active\">Home</a>\n <a routerLink=\"/LaserCutMazes/designer\" routerLinkActive=\"active\">Maze Designer</a>\n <a routerLink=\"/LaserCutMazes/help\" routerLinkActive=\"active\">Help</a>\n <a routerLink=\"/LaserCutMazes/about\" routerLinkActive=\"active\">About</a>\n </nav>\n </footer>\n</div>\n"
/***/ }),
/***/ "./src/app/app.component.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AppComponent; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("./node_modules/@angular/core/esm5/core.js");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_router__ = __webpack_require__("./node_modules/@angular/router/esm5/router.js");
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var AppComponent = /** @class */ (function () {
function AppComponent(router) {
this.router = router;
var w = window;
this.router.events.subscribe(function (event) {
if (event instanceof __WEBPACK_IMPORTED_MODULE_1__angular_router__["a" /* NavigationEnd */] && typeof w.ga === "function") {
w.ga("set", "page", event.urlAfterRedirects);
w.ga("send", "pageview");
}
});
}
AppComponent = __decorate([
Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["n" /* Component */])({
selector: "app-root",
template: __webpack_require__("./src/app/app.component.html"),
styles: [__webpack_require__("./src/app/app.component.css")]
}),
__metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_1__angular_router__["b" /* Router */]])
], AppComponent);
return AppComponent;
}());
/***/ }),
/***/ "./src/app/app.module.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AppModule; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("./node_modules/@angular/core/esm5/core.js");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_forms__ = __webpack_require__("./node_modules/@angular/forms/esm5/forms.js");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__angular_platform_browser__ = __webpack_require__("./node_modules/@angular/platform-browser/esm5/platform-browser.js");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__angular_router__ = __webpack_require__("./node_modules/@angular/router/esm5/router.js");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_app_about_about_component__ = __webpack_require__("./src/app/about/about.component.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_app_app_component__ = __webpack_require__("./src/app/app.component.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_app_help_modal_help_modal_component__ = __webpack_require__("./src/app/help-modal/help-modal.component.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_app_help_help_component__ = __webpack_require__("./src/app/help/help.component.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_app_lightbox_thumbnail_lightbox_thumbnail_component__ = __webpack_require__("./src/app/lightbox-thumbnail/lightbox-thumbnail.component.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_app_maze_builder_maze_builder_component__ = __webpack_require__("./src/app/maze-builder/maze-builder.component.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_app_track_click_directive__ = __webpack_require__("./src/app/track-click.directive.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_app_welcome_welcome_component__ = __webpack_require__("./src/app/welcome/welcome.component.ts");
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var appRoutes = [{
path: "LaserCutMazes/welcome",
component: __WEBPACK_IMPORTED_MODULE_11_app_welcome_welcome_component__["a" /* WelcomeComponent */]
}, {
path: "LaserCutMazes/designer",
component: __WEBPACK_IMPORTED_MODULE_9_app_maze_builder_maze_builder_component__["a" /* MazeBuilderComponent */]
}, {
path: "LaserCutMazes/help",
component: __WEBPACK_IMPORTED_MODULE_7_app_help_help_component__["a" /* HelpComponent */]
}, {
path: "LaserCutMazes/about",
component: __WEBPACK_IMPORTED_MODULE_4_app_about_about_component__["a" /* AboutComponent */]
}, {
path: "LaserCutMazes",
redirectTo: "LaserCutMazes/welcome",
pathMatch: "prefix"
}];
var AppModule = /** @class */ (function () {
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
function AppModule() {
}
AppModule = __decorate([
Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["I" /* NgModule */])({
declarations: [
__WEBPACK_IMPORTED_MODULE_4_app_about_about_component__["a" /* AboutComponent */],
__WEBPACK_IMPORTED_MODULE_5_app_app_component__["a" /* AppComponent */],
__WEBPACK_IMPORTED_MODULE_7_app_help_help_component__["a" /* HelpComponent */],
__WEBPACK_IMPORTED_MODULE_6_app_help_modal_help_modal_component__["a" /* HelpModalComponent */],
__WEBPACK_IMPORTED_MODULE_8_app_lightbox_thumbnail_lightbox_thumbnail_component__["a" /* LightboxThumbnailComponent */],
__WEBPACK_IMPORTED_MODULE_9_app_maze_builder_maze_builder_component__["a" /* MazeBuilderComponent */],
__WEBPACK_IMPORTED_MODULE_11_app_welcome_welcome_component__["a" /* WelcomeComponent */],
__WEBPACK_IMPORTED_MODULE_10_app_track_click_directive__["a" /* TrackClickDirective */]
],
imports: [
__WEBPACK_IMPORTED_MODULE_2__angular_platform_browser__["a" /* BrowserModule */],
__WEBPACK_IMPORTED_MODULE_1__angular_forms__["a" /* FormsModule */],
__WEBPACK_IMPORTED_MODULE_3__angular_router__["c" /* RouterModule */].forRoot(appRoutes)
],
providers: [],
bootstrap: [__WEBPACK_IMPORTED_MODULE_5_app_app_component__["a" /* AppComponent */]]
})
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
], AppModule);
return AppModule;
}());
/***/ }),
/***/ "./src/app/common/ordered-pair.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_big_js__ = __webpack_require__("./node_modules/big.js/big.js");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_big_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_big_js__);
/**
* A container for two numeric coordinates
* @author adashrod@gmail.com
*/
var OrderedPair = /** @class */ (function () {
function OrderedPair(x, y) {
this.x = x;
this.y = y;
}
OrderedPair.prototype.equals = function (aPair) {
if (this.x instanceof __WEBPACK_IMPORTED_MODULE_0_big_js___default.a && this.y instanceof __WEBPACK_IMPORTED_MODULE_0_big_js___default.a && aPair.x instanceof __WEBPACK_IMPORTED_MODULE_0_big_js___default.a && aPair.y instanceof __WEBPACK_IMPORTED_MODULE_0_big_js___default.a) {
return this.x.eq(aPair.x) && this.y.eq(aPair.y);
}
return this.x === aPair.x && this.y === aPair.y;
};
OrderedPair.prototype.toString = function () {
var _a, _b;
return "OrderedPair(".concat((_a = this.x) === null || _a === void 0 ? void 0 : _a.toString(), ", ").concat((_b = this.y) === null || _b === void 0 ? void 0 : _b.toString(), ")");
};
return OrderedPair;
}());
/* harmony default export */ __webpack_exports__["a"] = (OrderedPair);
/***/ }),
/***/ "./src/app/common/unit.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_big_js__ = __webpack_require__("./node_modules/big.js/big.js");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_big_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_big_js__);
var Unit = /** @class */ (function () {
function Unit(singularName, pluralSuffix, perInch) {
this.singularName = singularName;
this.pluralName = singularName + pluralSuffix;
this.perInch = perInch;
}
Unit.values = function () {
return [Unit.INCHES, Unit.CENTIMETERS, Unit.MILLIMETERS];
};
Unit.INCHES = new Unit("inch", "es", new __WEBPACK_IMPORTED_MODULE_0_big_js___default.a(1));
Unit.CENTIMETERS = new Unit("centimeter", "s", new __WEBPACK_IMPORTED_MODULE_0_big_js___default.a("2.54"));
Unit.MILLIMETERS = new Unit("millimeter", "s", new __WEBPACK_IMPORTED_MODULE_0_big_js___default.a("25.4"));
return Unit;
}());
/* harmony default export */ __webpack_exports__["a"] = (Unit);
/***/ }),
/***/ "./src/app/direction.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/**
* four directions for relating Spaces to each other
*/
var Direction = /** @class */ (function () {
function Direction(name) {
this.name = name;
}
/**
* Determines the direction that relates "from" to "to", e.g. if "to" is to the EAST of "from", EAST is returned
*/
Direction.determineDirection = function (from, to) {
var xComp = from.x - to.x;
if (xComp < 0) {
return Direction.EAST;
}
if (xComp > 0) {
return Direction.WEST;
}
var yComp = from.y - to.y;
if (yComp < 0) {
return Direction.SOUTH;
}
if (yComp > 0) {
return Direction.NORTH;
}
throw new Error("Indeterminate: the 2 OrderedPairs couldn't be compared: ".concat(from.toString(), ", ").concat(to.toString()));
};
Object.defineProperty(Direction.prototype, "opposite", {
get: function () {
if (this === Direction.NORTH) {
return Direction.SOUTH;
}
if (this === Direction.EAST) {
return Direction.WEST;
}
if (this === Direction.SOUTH) {
return Direction.NORTH;
}
if (this === Direction.WEST) {
return Direction.EAST;
}
throw new Error("invalid direction");
},
enumerable: false,
configurable: true
});
Direction.prototype.toString = function () {
return this.name;
};
Direction.NORTH = new Direction("NORTH");
Direction.EAST = new Direction("EAST");
Direction.SOUTH = new Direction("SOUTH");
Direction.WEST = new Direction("WEST");
return Direction;
}());
/* harmony default export */ __webpack_exports__["a"] = (Direction);
/***/ }),
/***/ "./src/app/factories/linear-wall-model-generator.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_app_common_ordered_pair__ = __webpack_require__("./src/app/common/ordered-pair.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_app_direction__ = __webpack_require__("./src/app/direction.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_app_models_linear_wall_model__ = __webpack_require__("./src/app/models/linear-wall-model.ts");
/**
* An instance of LinearWallModelGenerator can be used to create a {@link LinearWallModel} from a {@link Maze}
* @author adashrod@gmail.com
*/
var LinearWallModelGenerator = /** @class */ (function () {
function LinearWallModelGenerator(maze) {
this.maze = maze;
}
LinearWallModelGenerator.prototype.generate = function () {
var width = this.maze.numCols;
var height = this.maze.numRows;
var lastCol = width - 1;
var lastRow = height - 1;
var linearWallModel = new __WEBPACK_IMPORTED_MODULE_2_app_models_linear_wall_model__["b" /* default */](width, height, this.favorEwWalls);
if (this.favorEwWalls) {
// make north walls of the rows
for (var y = 0; y < height; y++) {
this.makeWallsForLane(linearWallModel, y, width, false, __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].NORTH, null, false);
}
// south wall of row
this.makeWallsForLane(linearWallModel, lastRow, width, false, __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].SOUTH, null, true);
// make west walls of columns
for (var x = 0; x < width; x++) {
this.makeWallsForLane(linearWallModel, x, height, true, __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].WEST, __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].SOUTH, false);
}
// east wall of column
this.makeWallsForLane(linearWallModel, lastCol, height, true, __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].EAST, __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].SOUTH, true);
}
else {
// make west walls of columns
for (var x = 0; x < width; x++) {
this.makeWallsForLane(linearWallModel, x, height, true, __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].WEST, null, false);
}
// east wall of column
this.makeWallsForLane(linearWallModel, lastCol, height, true, __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].EAST, null, true);
// make north walls of the rows
for (var y = 0; y < height; y++) {
this.makeWallsForLane(linearWallModel, y, width, false, __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].NORTH, __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].EAST, false);
}
// south wall of row
this.makeWallsForLane(linearWallModel, lastRow, width, false, __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].SOUTH, __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].EAST, true);
}
return linearWallModel;
};
/**
* traverses a lane (row or column) of the maze, making as many walls that are needed for that lane, consolidating
* adjacent walls when possible.
* e.g. a row like ___ __ (3 spaces with walls, 1 empty, 2 more with walls)
* This would make two walls; one 3 spaces long and the other 2 spaces long
* e.g. when an overlapCheckDirection is used: ___|_
* |
* There's a wall 4 spaces long, and a perpendicular wall. If building vertical walls first, this horizontal
* wall would be split into 2 separate horizontal walls: one length 3, and one length 1, end-to-end, but separate
* so that the perpendicular wall doesn't overlap. If doing horizontal walls first, this would result in one
* horizontal wall 4 spaces long and two separate vertical walls.
* @param linearWallModel the model walls are being added to
* @param majorTraversalIndex the index of the lane being traversed
* @param minorTraversalMax number of spaces in the lane
* @param xMajor true if doing an x-major (column-major) traversal
* @param continuationCheckDirection direction to check that the wall continues, e.g. if doing a row-major traversal
* (moving east), one should check that there are walls on the north or south sides
* of the spaces to see how far they continue
* @param overlapCheckDirection direction to check for perpendicular walls, e.g. if doing a row-major traversal
* (moving east), one should check that there are perpendicular walls to the east
* which would determine the end of the current wall
* @param isFinalWall true if this is the last row/column being checked, used for determining
* coordinates since n rows means n+1 rows of horizontal walls
*/
LinearWallModelGenerator.prototype.makeWallsForLane = function (linearWallModel, majorTraversalIndex, minorTraversalMax, xMajor, continuationCheckDirection, overlapCheckDirection, isFinalWall) {
for (var i = 0; i < minorTraversalMax; i++) {
var y = xMajor ? i : majorTraversalIndex;
var x = xMajor ? majorTraversalIndex : i;
var currentSpace = this.maze.grid[y][x];
if (!currentSpace.isOpen(continuationCheckDirection)) {
var lengthAndAdditive = this.calculateWallLength(xMajor, continuationCheckDirection, overlapCheckDirection, isFinalWall, x, y);
var length_1 = lengthAndAdditive.x;
var additive = lengthAndAdditive.y;
linearWallModel.addWall(this.createWallHelper(xMajor, isFinalWall, x, y, length_1));
i += length_1 + additive;
}
}
};
LinearWallModelGenerator.prototype.calculateWallLength = function (xMajor, continuationCheckDirection, overlapCheckDirection, isFinalWall, x, y) {
var length, additive = 0;
for (length = 1; this.maze.isInBounds(xMajor ? x : x + length, xMajor ? y + length : y); length++) {
// wall continuation check
var nextSpace = this.findNextSpace(xMajor, x, y, length);
if (nextSpace.isOpen(continuationCheckDirection)) {
break;
}
// wall overlap check
if (overlapCheckDirection != null) {
var sameLaneX = this.findSameLaneX(xMajor, x, length), sameLaneY = this.findSameLaneY(xMajor, y, length);
var prevLaneX = this.findPrevLaneX(xMajor, x, length), prevLaneY = this.findPrevLaneY(xMajor, y, length);
var spaceInSameLane = this.maze.grid[sameLaneY][sameLaneX];
var spaceInPrevLane = this.findSpaceInPrevLane(prevLaneX, prevLaneY);
// 1st condition: check for perpendicular wall in same lane; 2nd: check for perpendicular wall
// in prev lane, but not for row because we don't care about prev lane when doing the outer
// check
if (!spaceInSameLane.isOpen(overlapCheckDirection) ||
(!isFinalWall && spaceInPrevLane != null && !spaceInPrevLane.isOpen(overlapCheckDirection))) {
// i += length puts i just past the wall that's blocked by a perpendicular one; -1 is needed
// so that the next loop iter still checks that space after i++ happens
additive = -1;
break;
}
}
}
return new __WEBPACK_IMPORTED_MODULE_0_app_common_ordered_pair__["a" /* default */](length, additive);
};
LinearWallModelGenerator.prototype.findNextSpace = function (xMajor, x, y, length) {
return this.maze.grid[xMajor ? y + length : y][xMajor ? x : x + length];
};
LinearWallModelGenerator.prototype.findSameLaneX = function (xMajor, x, length) {
return xMajor ? x : x + length - 1;
};
LinearWallModelGenerator.prototype.findSameLaneY = function (xMajor, y, length) {
return xMajor ? y + length - 1 : y;
};
LinearWallModelGenerator.prototype.findPrevLaneX = function (xMajor, x, length) {
return xMajor ? x - 1 : x + length - 1;
};
LinearWallModelGenerator.prototype.findPrevLaneY = function (xMajor, y, length) {
return xMajor ? y + length - 1 : y - 1;
};
LinearWallModelGenerator.prototype.findSpaceInPrevLane = function (prevLaneX, prevLaneY) {
return this.maze.isInBounds(prevLaneX, prevLaneY) ? this.maze.grid[prevLaneY][prevLaneX] : null;
};
LinearWallModelGenerator.prototype.createWallHelper = function (xMajor, isFinalWall, x, y, length) {
var startX, startY, endX, endY;
if (xMajor) {
startY = y;
endY = y + length;
if (isFinalWall) {
startX = x + 1;
endX = x + 1;
}
else {
startX = x;
endX = x;
}
}
else {
startX = x;
endX = x + length;
if (isFinalWall) {
startY = y + 1;
endY = y + 1;
}
else {
startY = y;
endY = y;
}
}
var start = new __WEBPACK_IMPORTED_MODULE_0_app_common_ordered_pair__["a" /* default */](startX, startY), end = new __WEBPACK_IMPORTED_MODULE_0_app_common_ordered_pair__["a" /* default */](endX, endY);
return new __WEBPACK_IMPORTED_MODULE_2_app_models_linear_wall_model__["a" /* Wall */](start, end);
};
return LinearWallModelGenerator;
}());
/* harmony default export */ __webpack_exports__["a"] = (LinearWallModelGenerator);
/***/ }),
/***/ "./src/app/factories/rectangular-wall-model-generator.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_app_common_ordered_pair__ = __webpack_require__("./src/app/common/ordered-pair.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_app_direction__ = __webpack_require__("./src/app/direction.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_app_models_rectangular_wall_model__ = __webpack_require__("./src/app/models/rectangular-wall-model.ts");
/**
* An instance of RectangularWallModelGenerator can be used to create a {@link RectangularWallModel} from
* a {@link LinearWallModel}
* @author adashrod@gmail.com
*/
var RectangularWallModelGenerator = /** @class */ (function () {
function RectangularWallModelGenerator(model) {
this.isWall = [];
this.model = model;
var r = 2 * model.height + 1, c = 2 * model.width + 1;
for (var y = 0; y < r; y++) {
this.isWall.push([]);
for (var x = 0; x < c; x++) {
this.isWall[y].push(false);
}
}
}
RectangularWallModelGenerator.prototype.generate = function () {
var rectangularWallModel = new __WEBPACK_IMPORTED_MODULE_2_app_models_rectangular_wall_model__["b" /* default */](this.isWall[0].length, this.isWall.length);
var verticalWalls = [], horizontalWalls = [];
for (var _i = 0, _a = this.model.walls; _i < _a.length; _i++) {
var wall = _a[_i];
var wallDirection = __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].determineDirection(wall.start, wall.end);
if (wallDirection === __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].NORTH || wallDirection === __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].WEST) {
throw new Error("wall direction should only be EAST or SOUTH (start-to-end should be left-to-right or top-to-bottom): " +
wall.toString());
}
var isVertical = wallDirection === __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].SOUTH;
if (isVertical) {
verticalWalls.push(wall);
}
else {
horizontalWalls.push(wall);
}
}
if (this.model.favorEwWalls) {
this.createWallSpacesFromLinearWalls(rectangularWallModel, horizontalWalls, false, true);
this.createWallSpacesFromLinearWalls(rectangularWallModel, verticalWalls, true, false);
}
else {
this.createWallSpacesFromLinearWalls(rectangularWallModel, verticalWalls, true, true);
this.createWallSpacesFromLinearWalls(rectangularWallModel, horizontalWalls, false, false);
}
for (var r = 0; r < this.isWall.length; r++) {
var row = this.isWall[r];
for (var c = 0; c < row.length; c++) {
rectangularWallModel.isWall[r][c] = this.isWall[r][c];
}
}
return rectangularWallModel;
};
RectangularWallModelGenerator.prototype.createWallSpacesFromLinearWalls = function (rectangularWallModel, walls, wallsAreVertical, isFirstSetOfWalls) {
var endDirection = wallsAreVertical ? __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].SOUTH : __WEBPACK_IMPORTED_MODULE_1_app_direction__["a" /* default */].EAST;
for (var _i = 0, walls_1 = walls; _i < walls_1.length; _i++) {
var wall = walls_1[_i];
var wsx = wall.start.x * 2, wex = wall.end.x * 2, wsy = wall.start.y * 2, wey = wall.end.y * 2;
if (!isFirstSetOfWalls) {
if (wallsAreVertical) {
if (this.isWall[wsy][wsx]) {
wsy++;
}
if (this.isWall[wey][wex]) {
wey--;
}
}
else {
if (this.isWall[wsy][wsx]) {
wsx++;
}
if (this.isWall[wey][wex]) {
wex--;
}
}
}
var rectWall = new __WEBPACK_IMPORTED_MODULE_2_app_models_rectangular_wall_model__["a" /* Wall */](new __WEBPACK_IMPORTED_MODULE_0_app_common_ordered_pair__["a" /* default */](wsx, wsy), new __WEBPACK_IMPORTED_MODULE_0_app_common_ordered_pair__["a" /* default */](wex, wey), endDirection);
rectangularWallModel.addWall(rectWall);
this.fillOutWallSpaces(wallsAreVertical, wsx, wsy, wex, wey);
}
};
RectangularWallModelGenerator.prototype.fillOutWallSpaces = function (wallsAreVertical, wsx, wsy, wex, wey) {
if (wallsAreVertical) {
for (var y = wsy; y <= wey; y++) {
this.isWall[y][wsx] = true;
}
}
else {
for (var x = wsx; x <= wex; x++) {
this.isWall[wsy][x] = true;
}
}
};
return RectangularWallModelGenerator;
}());
/* harmony default export */ __webpack_exports__["a"] = (RectangularWallModelGenerator);
/***/ }),
/***/ "./src/app/factories/sheet-wall-model-generator.ts":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_app_common_ordered_pair__ = __webpack_require__("./src/app/common/ordered-pair.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_app_direction__ = __webpack_require__("./src/app/direction.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_app_factories_sheet_wall_tiling_optimizer__ = __webpack_require__("./src/app/factories/sheet-wall-tiling-optimizer.ts");
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_app_misc_big_util__ = __webpack_require__("./src/app/misc/big-util.ts");