-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrote-0.3.0.js
8051 lines (7543 loc) · 649 KB
/
rote-0.3.0.js
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
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 17);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/**
* This code is an implementation of Alea algorithm; (C) 2010 Johannes Baagøe.
* Alea is licensed according to the http://en.wikipedia.org/wiki/MIT_License.
*/
const FRAC = 2.3283064365386963e-10; /* 2^-32 */
class RNG {
constructor() {
this._seed = 0;
this._s0 = 0;
this._s1 = 0;
this._s2 = 0;
this._c = 0;
}
getSeed() { return this._seed; }
/**
* Seed the number generator
*/
setSeed(seed) {
seed = (seed < 1 ? 1 / seed : seed);
this._seed = seed;
this._s0 = (seed >>> 0) * FRAC;
seed = (seed * 69069 + 1) >>> 0;
this._s1 = seed * FRAC;
seed = (seed * 69069 + 1) >>> 0;
this._s2 = seed * FRAC;
this._c = 1;
return this;
}
/**
* @returns Pseudorandom value [0,1), uniformly distributed
*/
getUniform() {
let t = 2091639 * this._s0 + this._c * FRAC;
this._s0 = this._s1;
this._s1 = this._s2;
this._c = t | 0;
this._s2 = t - this._c;
return this._s2;
}
/**
* @param lowerBound The lower end of the range to return a value from, inclusive
* @param upperBound The upper end of the range to return a value from, inclusive
* @returns Pseudorandom value [lowerBound, upperBound], using ROT.RNG.getUniform() to distribute the value
*/
getUniformInt(lowerBound, upperBound) {
let max = Math.max(lowerBound, upperBound);
let min = Math.min(lowerBound, upperBound);
return Math.floor(this.getUniform() * (max - min + 1)) + min;
}
/**
* @param mean Mean value
* @param stddev Standard deviation. ~95% of the absolute values will be lower than 2*stddev.
* @returns A normally distributed pseudorandom value
*/
getNormal(mean = 0, stddev = 1) {
let u, v, r;
do {
u = 2 * this.getUniform() - 1;
v = 2 * this.getUniform() - 1;
r = u * u + v * v;
} while (r > 1 || r == 0);
let gauss = u * Math.sqrt(-2 * Math.log(r) / r);
return mean + gauss * stddev;
}
/**
* @returns Pseudorandom value [1,100] inclusive, uniformly distributed
*/
getPercentage() {
return 1 + Math.floor(this.getUniform() * 100);
}
/**
* @returns Randomly picked item, null when length=0
*/
getItem(array) {
if (!array.length) {
return null;
}
return array[Math.floor(this.getUniform() * array.length)];
}
/**
* @returns New array with randomized items
*/
shuffle(array) {
let result = [];
let clone = array.slice();
while (clone.length) {
let index = clone.indexOf(this.getItem(clone));
result.push(clone.splice(index, 1)[0]);
}
return result;
}
/**
* @param data key=whatever, value=weight (relative probability)
* @returns whatever
*/
getWeightedValue(data) {
let total = 0;
for (let id in data) {
total += data[id];
}
let random = this.getUniform() * total;
let id, part = 0;
for (id in data) {
part += data[id];
if (random < part) {
return id;
}
}
// If by some floating-point annoyance we have
// random >= total, just return the last id.
return id;
}
/**
* Get RNG state. Useful for storing the state and re-setting it via setState.
* @returns Internal state
*/
getState() { return [this._s0, this._s1, this._s2, this._c]; }
/**
* Set a previously retrieved state.
*/
setState(state) {
this._s0 = state[0];
this._s1 = state[1];
this._s2 = state[2];
this._c = state[3];
return this;
}
/**
* Returns a cloned RNG
*/
clone() {
let clone = new RNG();
return clone.setState(this.getState());
}
}
/* harmony default export */ __webpack_exports__["a"] = (new RNG().setSeed(Date.now()));
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mod", function() { return mod; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clamp", function() { return clamp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "capitalize", function() { return capitalize; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "format", function() { return format; });
/**
* Always positive modulus
* @param x Operand
* @param n Modulus
* @returns x modulo n
*/
function mod(x, n) {
return (x % n + n) % n;
}
function clamp(val, min = 0, max = 1) {
if (val < min)
return min;
if (val > max)
return max;
return val;
}
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.substring(1);
}
/**
* Format a string in a flexible way. Scans for %s strings and replaces them with arguments. List of patterns is modifiable via String.format.map.
* @param {string} template
* @param {any} [argv]
*/
function format(template, ...args) {
let map = format.map;
let replacer = function (match, group1, group2, index) {
if (template.charAt(index - 1) == "%") {
return match.substring(1);
}
if (!args.length) {
return match;
}
let obj = args[0];
let group = group1 || group2;
let parts = group.split(",");
let name = parts.shift() || "";
let method = map[name.toLowerCase()];
if (!method) {
return match;
}
obj = args.shift();
let replaced = obj[method].apply(obj, parts);
let first = name.charAt(0);
if (first != first.toLowerCase()) {
replaced = capitalize(replaced);
}
return replaced;
};
return template.replace(/%(?:([a-z]+)|(?:{([^}]+)}))/gi, replacer);
}
format.map = {
"s": "toString"
};
/***/ }),
/* 2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromString", function() { return fromString; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add_", function() { return add_; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply_", function() { return multiply_; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "interpolate", function() { return interpolate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lerp", function() { return lerp; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHSL", function() { return interpolateHSL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lerpHSL", function() { return lerpHSL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "randomize", function() { return randomize; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgb2hsl", function() { return rgb2hsl; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hsl2rgb", function() { return hsl2rgb; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toRGB", function() { return toRGB; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toHex", function() { return toHex; });
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
/* harmony import */ var _rng_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
function fromString(str) {
let cached, r;
if (str in CACHE) {
cached = CACHE[str];
}
else {
if (str.charAt(0) == "#") { // hex rgb
let matched = str.match(/[0-9a-f]/gi) || [];
let values = matched.map((x) => parseInt(x, 16));
if (values.length == 3) {
cached = values.map((x) => x * 17);
}
else {
for (let i = 0; i < 3; i++) {
values[i + 1] += 16 * values[i];
values.splice(i, 1);
}
cached = values;
}
}
else if ((r = str.match(/rgb\(([0-9, ]+)\)/i))) { // decimal rgb
cached = r[1].split(/\s*,\s*/).map((x) => parseInt(x));
}
else { // html name
cached = [0, 0, 0];
}
CACHE[str] = cached;
}
return cached.slice();
}
/**
* Add two or more colors
*/
function add(color1, ...colors) {
let result = color1.slice();
for (let i = 0; i < 3; i++) {
for (let j = 0; j < colors.length; j++) {
result[i] += colors[j][i];
}
}
return result;
}
/**
* Add two or more colors, MODIFIES FIRST ARGUMENT
*/
function add_(color1, ...colors) {
for (let i = 0; i < 3; i++) {
for (let j = 0; j < colors.length; j++) {
color1[i] += colors[j][i];
}
}
return color1;
}
/**
* Multiply (mix) two or more colors
*/
function multiply(color1, ...colors) {
let result = color1.slice();
for (let i = 0; i < 3; i++) {
for (let j = 0; j < colors.length; j++) {
result[i] *= colors[j][i] / 255;
}
result[i] = Math.round(result[i]);
}
return result;
}
/**
* Multiply (mix) two or more colors, MODIFIES FIRST ARGUMENT
*/
function multiply_(color1, ...colors) {
for (let i = 0; i < 3; i++) {
for (let j = 0; j < colors.length; j++) {
color1[i] *= colors[j][i] / 255;
}
color1[i] = Math.round(color1[i]);
}
return color1;
}
/**
* Interpolate (blend) two colors with a given factor
*/
function interpolate(color1, color2, factor = 0.5) {
let result = color1.slice();
for (let i = 0; i < 3; i++) {
result[i] = Math.round(result[i] + factor * (color2[i] - color1[i]));
}
return result;
}
const lerp = interpolate;
/**
* Interpolate (blend) two colors with a given factor in HSL mode
*/
function interpolateHSL(color1, color2, factor = 0.5) {
let hsl1 = rgb2hsl(color1);
let hsl2 = rgb2hsl(color2);
for (let i = 0; i < 3; i++) {
hsl1[i] += factor * (hsl2[i] - hsl1[i]);
}
return hsl2rgb(hsl1);
}
const lerpHSL = interpolateHSL;
/**
* Create a new random color based on this one
* @param color
* @param diff Set of standard deviations
*/
function randomize(color, diff) {
if (!(diff instanceof Array)) {
diff = Math.round(_rng_js__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].getNormal(0, diff));
}
let result = color.slice();
for (let i = 0; i < 3; i++) {
result[i] += (diff instanceof Array ? Math.round(_rng_js__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].getNormal(0, diff[i])) : diff);
}
return result;
}
/**
* Converts an RGB color value to HSL. Expects 0..255 inputs, produces 0..1 outputs.
*/
function rgb2hsl(color) {
let r = color[0] / 255;
let g = color[1] / 255;
let b = color[2] / 255;
let max = Math.max(r, g, b), min = Math.min(r, g, b);
let h = 0, s, l = (max + min) / 2;
if (max == min) {
s = 0; // achromatic
}
else {
let d = max - min;
s = (l > 0.5 ? d / (2 - max - min) : d / (max + min));
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
}
h /= 6;
}
return [h, s, l];
}
function hue2rgb(p, q, t) {
if (t < 0)
t += 1;
if (t > 1)
t -= 1;
if (t < 1 / 6)
return p + (q - p) * 6 * t;
if (t < 1 / 2)
return q;
if (t < 2 / 3)
return p + (q - p) * (2 / 3 - t) * 6;
return p;
}
/**
* Converts an HSL color value to RGB. Expects 0..1 inputs, produces 0..255 outputs.
*/
function hsl2rgb(color) {
let l = color[2];
if (color[1] == 0) {
l = Math.round(l * 255);
return [l, l, l];
}
else {
let s = color[1];
let q = (l < 0.5 ? l * (1 + s) : l + s - l * s);
let p = 2 * l - q;
let r = hue2rgb(p, q, color[0] + 1 / 3);
let g = hue2rgb(p, q, color[0]);
let b = hue2rgb(p, q, color[0] - 1 / 3);
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
}
}
function toRGB(color) {
let clamped = color.map(x => Object(_util_js__WEBPACK_IMPORTED_MODULE_0__["clamp"])(x, 0, 255));
return `rgb(${clamped.join(",")})`;
}
function toHex(color) {
let clamped = color.map(x => Object(_util_js__WEBPACK_IMPORTED_MODULE_0__["clamp"])(x, 0, 255).toString(16).padStart(2, "0"));
return `#${clamped.join("")}`;
}
const CACHE = {
"black": [0, 0, 0],
"navy": [0, 0, 128],
"darkblue": [0, 0, 139],
"mediumblue": [0, 0, 205],
"blue": [0, 0, 255],
"darkgreen": [0, 100, 0],
"green": [0, 128, 0],
"teal": [0, 128, 128],
"darkcyan": [0, 139, 139],
"deepskyblue": [0, 191, 255],
"darkturquoise": [0, 206, 209],
"mediumspringgreen": [0, 250, 154],
"lime": [0, 255, 0],
"springgreen": [0, 255, 127],
"aqua": [0, 255, 255],
"cyan": [0, 255, 255],
"midnightblue": [25, 25, 112],
"dodgerblue": [30, 144, 255],
"forestgreen": [34, 139, 34],
"seagreen": [46, 139, 87],
"darkslategray": [47, 79, 79],
"darkslategrey": [47, 79, 79],
"limegreen": [50, 205, 50],
"mediumseagreen": [60, 179, 113],
"turquoise": [64, 224, 208],
"royalblue": [65, 105, 225],
"steelblue": [70, 130, 180],
"darkslateblue": [72, 61, 139],
"mediumturquoise": [72, 209, 204],
"indigo": [75, 0, 130],
"darkolivegreen": [85, 107, 47],
"cadetblue": [95, 158, 160],
"cornflowerblue": [100, 149, 237],
"mediumaquamarine": [102, 205, 170],
"dimgray": [105, 105, 105],
"dimgrey": [105, 105, 105],
"slateblue": [106, 90, 205],
"olivedrab": [107, 142, 35],
"slategray": [112, 128, 144],
"slategrey": [112, 128, 144],
"lightslategray": [119, 136, 153],
"lightslategrey": [119, 136, 153],
"mediumslateblue": [123, 104, 238],
"lawngreen": [124, 252, 0],
"chartreuse": [127, 255, 0],
"aquamarine": [127, 255, 212],
"maroon": [128, 0, 0],
"purple": [128, 0, 128],
"olive": [128, 128, 0],
"gray": [128, 128, 128],
"grey": [128, 128, 128],
"skyblue": [135, 206, 235],
"lightskyblue": [135, 206, 250],
"blueviolet": [138, 43, 226],
"darkred": [139, 0, 0],
"darkmagenta": [139, 0, 139],
"saddlebrown": [139, 69, 19],
"darkseagreen": [143, 188, 143],
"lightgreen": [144, 238, 144],
"mediumpurple": [147, 112, 216],
"darkviolet": [148, 0, 211],
"palegreen": [152, 251, 152],
"darkorchid": [153, 50, 204],
"yellowgreen": [154, 205, 50],
"sienna": [160, 82, 45],
"brown": [165, 42, 42],
"darkgray": [169, 169, 169],
"darkgrey": [169, 169, 169],
"lightblue": [173, 216, 230],
"greenyellow": [173, 255, 47],
"paleturquoise": [175, 238, 238],
"lightsteelblue": [176, 196, 222],
"powderblue": [176, 224, 230],
"firebrick": [178, 34, 34],
"darkgoldenrod": [184, 134, 11],
"mediumorchid": [186, 85, 211],
"rosybrown": [188, 143, 143],
"darkkhaki": [189, 183, 107],
"silver": [192, 192, 192],
"mediumvioletred": [199, 21, 133],
"indianred": [205, 92, 92],
"peru": [205, 133, 63],
"chocolate": [210, 105, 30],
"tan": [210, 180, 140],
"lightgray": [211, 211, 211],
"lightgrey": [211, 211, 211],
"palevioletred": [216, 112, 147],
"thistle": [216, 191, 216],
"orchid": [218, 112, 214],
"goldenrod": [218, 165, 32],
"crimson": [220, 20, 60],
"gainsboro": [220, 220, 220],
"plum": [221, 160, 221],
"burlywood": [222, 184, 135],
"lightcyan": [224, 255, 255],
"lavender": [230, 230, 250],
"darksalmon": [233, 150, 122],
"violet": [238, 130, 238],
"palegoldenrod": [238, 232, 170],
"lightcoral": [240, 128, 128],
"khaki": [240, 230, 140],
"aliceblue": [240, 248, 255],
"honeydew": [240, 255, 240],
"azure": [240, 255, 255],
"sandybrown": [244, 164, 96],
"wheat": [245, 222, 179],
"beige": [245, 245, 220],
"whitesmoke": [245, 245, 245],
"mintcream": [245, 255, 250],
"ghostwhite": [248, 248, 255],
"salmon": [250, 128, 114],
"antiquewhite": [250, 235, 215],
"linen": [250, 240, 230],
"lightgoldenrodyellow": [250, 250, 210],
"oldlace": [253, 245, 230],
"red": [255, 0, 0],
"fuchsia": [255, 0, 255],
"magenta": [255, 0, 255],
"deeppink": [255, 20, 147],
"orangered": [255, 69, 0],
"tomato": [255, 99, 71],
"hotpink": [255, 105, 180],
"coral": [255, 127, 80],
"darkorange": [255, 140, 0],
"lightsalmon": [255, 160, 122],
"orange": [255, 165, 0],
"lightpink": [255, 182, 193],
"pink": [255, 192, 203],
"gold": [255, 215, 0],
"peachpuff": [255, 218, 185],
"navajowhite": [255, 222, 173],
"moccasin": [255, 228, 181],
"bisque": [255, 228, 196],
"mistyrose": [255, 228, 225],
"blanchedalmond": [255, 235, 205],
"papayawhip": [255, 239, 213],
"lavenderblush": [255, 240, 245],
"seashell": [255, 245, 238],
"cornsilk": [255, 248, 220],
"lemonchiffon": [255, 250, 205],
"floralwhite": [255, 250, 240],
"snow": [255, 250, 250],
"yellow": [255, 255, 0],
"lightyellow": [255, 255, 224],
"ivory": [255, 255, 240],
"white": [255, 255, 255]
};
/***/ }),
/* 3 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
var text_namespaceObject = {};
__webpack_require__.r(text_namespaceObject);
__webpack_require__.d(text_namespaceObject, "TYPE_TEXT", function() { return TYPE_TEXT; });
__webpack_require__.d(text_namespaceObject, "TYPE_NEWLINE", function() { return TYPE_NEWLINE; });
__webpack_require__.d(text_namespaceObject, "TYPE_FG", function() { return TYPE_FG; });
__webpack_require__.d(text_namespaceObject, "TYPE_BG", function() { return TYPE_BG; });
__webpack_require__.d(text_namespaceObject, "measure", function() { return measure; });
__webpack_require__.d(text_namespaceObject, "tokenize", function() { return tokenize; });
// EXTERNAL MODULE: ./node_modules/rot-js/lib/rng.js
var rng = __webpack_require__(0);
// EXTERNAL MODULE: ./node_modules/rot-js/lib/display/backend.js
var backend = __webpack_require__(6);
// CONCATENATED MODULE: ./node_modules/rot-js/lib/display/canvas.js
class canvas_Canvas extends backend["a" /* default */] {
constructor() {
super();
this._ctx = document.createElement("canvas").getContext("2d");
}
schedule(cb) { requestAnimationFrame(cb); }
getContainer() { return this._ctx.canvas; }
setOptions(opts) {
super.setOptions(opts);
const style = (opts.fontStyle ? `${opts.fontStyle} ` : ``);
const font = `${style} ${opts.fontSize}px ${opts.fontFamily}`;
this._ctx.font = font;
this._updateSize();
this._ctx.font = font;
this._ctx.textAlign = "center";
this._ctx.textBaseline = "middle";
}
clear() {
this._ctx.fillStyle = this._options.bg;
this._ctx.fillRect(0, 0, this._ctx.canvas.width, this._ctx.canvas.height);
}
eventToPosition(x, y) {
let canvas = this._ctx.canvas;
let rect = canvas.getBoundingClientRect();
x -= rect.left;
y -= rect.top;
x *= canvas.width / rect.width;
y *= canvas.height / rect.height;
if (x < 0 || y < 0 || x >= canvas.width || y >= canvas.height) {
return [-1, -1];
}
return this._normalizedEventToPosition(x, y);
}
}
// EXTERNAL MODULE: ./node_modules/rot-js/lib/util.js
var util = __webpack_require__(1);
// CONCATENATED MODULE: ./node_modules/rot-js/lib/display/hex.js
/**
* @class Hexagonal backend
* @private
*/
class hex_Hex extends canvas_Canvas {
constructor() {
super();
this._spacingX = 0;
this._spacingY = 0;
this._hexSize = 0;
}
draw(data, clearBefore) {
let [x, y, ch, fg, bg] = data;
let px = [
(x + 1) * this._spacingX,
y * this._spacingY + this._hexSize
];
if (this._options.transpose) {
px.reverse();
}
if (clearBefore) {
this._ctx.fillStyle = bg;
this._fill(px[0], px[1]);
}
if (!ch) {
return;
}
this._ctx.fillStyle = fg;
let chars = [].concat(ch);
for (let i = 0; i < chars.length; i++) {
this._ctx.fillText(chars[i], px[0], Math.ceil(px[1]));
}
}
computeSize(availWidth, availHeight) {
if (this._options.transpose) {
availWidth += availHeight;
availHeight = availWidth - availHeight;
availWidth -= availHeight;
}
let width = Math.floor(availWidth / this._spacingX) - 1;
let height = Math.floor((availHeight - 2 * this._hexSize) / this._spacingY + 1);
return [width, height];
}
computeFontSize(availWidth, availHeight) {
if (this._options.transpose) {
availWidth += availHeight;
availHeight = availWidth - availHeight;
availWidth -= availHeight;
}
let hexSizeWidth = 2 * availWidth / ((this._options.width + 1) * Math.sqrt(3)) - 1;
let hexSizeHeight = availHeight / (2 + 1.5 * (this._options.height - 1));
let hexSize = Math.min(hexSizeWidth, hexSizeHeight);
// compute char ratio
let oldFont = this._ctx.font;
this._ctx.font = "100px " + this._options.fontFamily;
let width = Math.ceil(this._ctx.measureText("W").width);
this._ctx.font = oldFont;
let ratio = width / 100;
hexSize = Math.floor(hexSize) + 1; // closest larger hexSize
// FIXME char size computation does not respect transposed hexes
let fontSize = 2 * hexSize / (this._options.spacing * (1 + ratio / Math.sqrt(3)));
// closest smaller fontSize
return Math.ceil(fontSize) - 1;
}
_normalizedEventToPosition(x, y) {
let nodeSize;
if (this._options.transpose) {
x += y;
y = x - y;
x -= y;
nodeSize = this._ctx.canvas.width;
}
else {
nodeSize = this._ctx.canvas.height;
}
let size = nodeSize / this._options.height;
y = Math.floor(y / size);
if (Object(util["mod"])(y, 2)) { /* odd row */
x -= this._spacingX;
x = 1 + 2 * Math.floor(x / (2 * this._spacingX));
}
else {
x = 2 * Math.floor(x / (2 * this._spacingX));
}
return [x, y];
}
/**
* Arguments are pixel values. If "transposed" mode is enabled, then these two are already swapped.
*/
_fill(cx, cy) {
let a = this._hexSize;
let b = this._options.border;
const ctx = this._ctx;
ctx.beginPath();
if (this._options.transpose) {
ctx.moveTo(cx - a + b, cy);
ctx.lineTo(cx - a / 2 + b, cy + this._spacingX - b);
ctx.lineTo(cx + a / 2 - b, cy + this._spacingX - b);
ctx.lineTo(cx + a - b, cy);
ctx.lineTo(cx + a / 2 - b, cy - this._spacingX + b);
ctx.lineTo(cx - a / 2 + b, cy - this._spacingX + b);
ctx.lineTo(cx - a + b, cy);
}
else {
ctx.moveTo(cx, cy - a + b);
ctx.lineTo(cx + this._spacingX - b, cy - a / 2 + b);
ctx.lineTo(cx + this._spacingX - b, cy + a / 2 - b);
ctx.lineTo(cx, cy + a - b);
ctx.lineTo(cx - this._spacingX + b, cy + a / 2 - b);
ctx.lineTo(cx - this._spacingX + b, cy - a / 2 + b);
ctx.lineTo(cx, cy - a + b);
}
ctx.fill();
}
_updateSize() {
const opts = this._options;
const charWidth = Math.ceil(this._ctx.measureText("W").width);
this._hexSize = Math.floor(opts.spacing * (opts.fontSize + charWidth / Math.sqrt(3)) / 2);
this._spacingX = this._hexSize * Math.sqrt(3) / 2;
this._spacingY = this._hexSize * 1.5;
let xprop;
let yprop;
if (opts.transpose) {
xprop = "height";
yprop = "width";
}
else {
xprop = "width";
yprop = "height";
}
this._ctx.canvas[xprop] = Math.ceil((opts.width + 1) * this._spacingX);
this._ctx.canvas[yprop] = Math.ceil((opts.height - 1) * this._spacingY + 2 * this._hexSize);
}
}
// CONCATENATED MODULE: ./node_modules/rot-js/lib/display/rect.js
/**
* @class Rectangular backend
* @private
*/
class rect_Rect extends canvas_Canvas {
constructor() {
super();
this._spacingX = 0;
this._spacingY = 0;
this._canvasCache = {};
}
setOptions(options) {
super.setOptions(options);
this._canvasCache = {};
}
draw(data, clearBefore) {
if (rect_Rect.cache) {
this._drawWithCache(data);
}
else {
this._drawNoCache(data, clearBefore);
}
}
_drawWithCache(data) {
let [x, y, ch, fg, bg] = data;
let hash = "" + ch + fg + bg;
let canvas;
if (hash in this._canvasCache) {
canvas = this._canvasCache[hash];
}
else {
let b = this._options.border;
canvas = document.createElement("canvas");
let ctx = canvas.getContext("2d");
canvas.width = this._spacingX;
canvas.height = this._spacingY;
ctx.fillStyle = bg;
ctx.fillRect(b, b, canvas.width - b, canvas.height - b);
if (ch) {
ctx.fillStyle = fg;
ctx.font = this._ctx.font;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
let chars = [].concat(ch);
for (let i = 0; i < chars.length; i++) {
ctx.fillText(chars[i], this._spacingX / 2, Math.ceil(this._spacingY / 2));
}
}
this._canvasCache[hash] = canvas;
}
this._ctx.drawImage(canvas, x * this._spacingX, y * this._spacingY);
}
_drawNoCache(data, clearBefore) {
let [x, y, ch, fg, bg] = data;
if (clearBefore) {
let b = this._options.border;
this._ctx.fillStyle = bg;
this._ctx.fillRect(x * this._spacingX + b, y * this._spacingY + b, this._spacingX - b, this._spacingY - b);
}
if (!ch) {
return;
}
this._ctx.fillStyle = fg;
let chars = [].concat(ch);
for (let i = 0; i < chars.length; i++) {
this._ctx.fillText(chars[i], (x + 0.5) * this._spacingX, Math.ceil((y + 0.5) * this._spacingY));
}
}
computeSize(availWidth, availHeight) {
let width = Math.floor(availWidth / this._spacingX);
let height = Math.floor(availHeight / this._spacingY);
return [width, height];
}
computeFontSize(availWidth, availHeight) {
let boxWidth = Math.floor(availWidth / this._options.width);
let boxHeight = Math.floor(availHeight / this._options.height);
/* compute char ratio */
let oldFont = this._ctx.font;
this._ctx.font = "100px " + this._options.fontFamily;
let width = Math.ceil(this._ctx.measureText("W").width);
this._ctx.font = oldFont;
let ratio = width / 100;
let widthFraction = ratio * boxHeight / boxWidth;
if (widthFraction > 1) { /* too wide with current aspect ratio */
boxHeight = Math.floor(boxHeight / widthFraction);
}
return Math.floor(boxHeight / this._options.spacing);
}
_normalizedEventToPosition(x, y) {
return [Math.floor(x / this._spacingX), Math.floor(y / this._spacingY)];
}
_updateSize() {
const opts = this._options;
const charWidth = Math.ceil(this._ctx.measureText("W").width);
this._spacingX = Math.ceil(opts.spacing * charWidth);
this._spacingY = Math.ceil(opts.spacing * opts.fontSize);
if (opts.forceSquareRatio) {
this._spacingX = this._spacingY = Math.max(this._spacingX, this._spacingY);
}
this._ctx.canvas.width = opts.width * this._spacingX;
this._ctx.canvas.height = opts.height * this._spacingY;
}
}
rect_Rect.cache = false;
// CONCATENATED MODULE: ./node_modules/rot-js/lib/display/tile.js
/**
* @class Tile backend
* @private
*/
class tile_Tile extends canvas_Canvas {
constructor() {
super();
this._colorCanvas = document.createElement("canvas");
}
draw(data, clearBefore) {
let [x, y, ch, fg, bg] = data;
let tileWidth = this._options.tileWidth;
let tileHeight = this._options.tileHeight;
if (clearBefore) {
if (this._options.tileColorize) {
this._ctx.clearRect(x * tileWidth, y * tileHeight, tileWidth, tileHeight);
}
else {
this._ctx.fillStyle = bg;
this._ctx.fillRect(x * tileWidth, y * tileHeight, tileWidth, tileHeight);
}
}
if (!ch) {
return;
}
let chars = [].concat(ch);
let fgs = [].concat(fg);
let bgs = [].concat(bg);
for (let i = 0; i < chars.length; i++) {
let tile = this._options.tileMap[chars[i]];
if (!tile) {
throw new Error(`Char "${chars[i]}" not found in tileMap`);
}
if (this._options.tileColorize) { // apply colorization
let canvas = this._colorCanvas;
let context = canvas.getContext("2d");
context.globalCompositeOperation = "source-over";