forked from ondras/rot.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rot.d.ts
1682 lines (1682 loc) · 55.4 KB
/
rot.d.ts
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
declare module "rot" {
import './extensions/raf';
/**
* @namespace Top-level ROT namespace
*/
export const ROT: {
isSupported(): boolean;
DEFAULT_WIDTH: number;
DEFAULT_HEIGHT: number;
DIRS: {
"4": number[][];
"6": number[][];
"8": number[][];
};
VK_CANCEL: number;
VK_HELP: number;
VK_BACK_SPACE: number;
VK_TAB: number;
VK_CLEAR: number;
VK_RETURN: number;
VK_ENTER: number;
VK_SHIFT: number;
VK_CONTROL: number;
VK_ALT: number;
VK_PAUSE: number;
VK_CAPS_LOCK: number;
VK_ESCAPE: number;
VK_SPACE: number;
VK_PAGE_UP: number;
VK_PAGE_DOWN: number;
VK_END: number;
VK_HOME: number;
VK_LEFT: number;
VK_UP: number;
VK_RIGHT: number;
VK_DOWN: number;
VK_PRINTSCREEN: number;
VK_INSERT: number;
VK_DELETE: number;
VK_0: number;
VK_1: number;
VK_2: number;
VK_3: number;
VK_4: number;
VK_5: number;
VK_6: number;
VK_7: number;
VK_8: number;
VK_9: number;
VK_COLON: number;
VK_SEMICOLON: number;
VK_LESS_THAN: number;
VK_EQUALS: number;
VK_GREATER_THAN: number;
VK_QUESTION_MARK: number;
VK_AT: number;
VK_A: number;
VK_B: number;
VK_C: number;
VK_D: number;
VK_E: number;
VK_F: number;
VK_G: number;
VK_H: number;
VK_I: number;
VK_J: number;
VK_K: number;
VK_L: number;
VK_M: number;
VK_N: number;
VK_O: number;
VK_P: number;
VK_Q: number;
VK_R: number;
VK_S: number;
VK_T: number;
VK_U: number;
VK_V: number;
VK_W: number;
VK_X: number;
VK_Y: number;
VK_Z: number;
VK_CONTEXT_MENU: number;
VK_NUMPAD0: number;
VK_NUMPAD1: number;
VK_NUMPAD2: number;
VK_NUMPAD3: number;
VK_NUMPAD4: number;
VK_NUMPAD5: number;
VK_NUMPAD6: number;
VK_NUMPAD7: number;
VK_NUMPAD8: number;
VK_NUMPAD9: number;
VK_MULTIPLY: number;
VK_ADD: number;
VK_SEPARATOR: number;
VK_SUBTRACT: number;
VK_DECIMAL: number;
VK_DIVIDE: number;
VK_F1: number;
VK_F2: number;
VK_F3: number;
VK_F4: number;
VK_F5: number;
VK_F6: number;
VK_F7: number;
VK_F8: number;
VK_F9: number;
VK_F10: number;
VK_F11: number;
VK_F12: number;
VK_F13: number;
VK_F14: number;
VK_F15: number;
VK_F16: number;
VK_F17: number;
VK_F18: number;
VK_F19: number;
VK_F20: number;
VK_F21: number;
VK_F22: number;
VK_F23: number;
VK_F24: number;
VK_NUM_LOCK: number;
VK_SCROLL_LOCK: number;
VK_CIRCUMFLEX: number;
VK_EXCLAMATION: number;
VK_DOUBLE_QUOTE: number;
VK_HASH: number;
VK_DOLLAR: number;
VK_PERCENT: number;
VK_AMPERSAND: number;
VK_UNDERSCORE: number;
VK_OPEN_PAREN: number;
VK_CLOSE_PAREN: number;
VK_ASTERISK: number;
VK_PLUS: number;
VK_PIPE: number;
VK_HYPHEN_MINUS: number;
VK_OPEN_CURLY_BRACKET: number;
VK_CLOSE_CURLY_BRACKET: number;
VK_TILDE: number;
VK_COMMA: number;
VK_PERIOD: number;
VK_SLASH: number;
VK_BACK_QUOTE: number;
VK_OPEN_BRACKET: number;
VK_BACK_SLASH: number;
VK_CLOSE_BRACKET: number;
VK_QUOTE: number;
VK_META: number;
VK_ALTGR: number;
VK_WIN: number;
VK_KANA: number;
VK_HANGUL: number;
VK_EISU: number;
VK_JUNJA: number;
VK_FINAL: number;
VK_HANJA: number;
VK_KANJI: number;
VK_CONVERT: number;
VK_NONCONVERT: number;
VK_ACCEPT: number;
VK_MODECHANGE: number;
VK_SELECT: number;
VK_PRINT: number;
VK_EXECUTE: number;
VK_SLEEP: number;
};
}
declare module "rot/rng" {
/**
* @namespace
* 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.
*/
export class RNG {
private static _s0;
private static _s1;
private static _s2;
private static _c;
private static _frac;
private static _seed;
/**
* @returns {number}
*/
static getSeed(): number;
/**
* @param {number} seed Seed the number generator
*/
static setSeed(seed: any): typeof RNG;
/**
* @returns {float} Pseudorandom value [0,1), uniformly distributed
*/
static getUniform(): number;
/**
* @param {int} lowerBound The lower end of the range to return a value from, inclusive
* @param {int} upperBound The upper end of the range to return a value from, inclusive
* @returns {int} Pseudorandom value [lowerBound, upperBound], using ROT.RNG.getUniform() to distribute the value
*/
static getUniformInt(lowerBound: any, upperBound: any): number;
/**
* @param {float} [mean=0] Mean value
* @param {float} [stddev=1] Standard deviation. ~95% of the absolute values will be lower than 2*stddev.
* @returns {float} A normally distributed pseudorandom value
*/
static getNormal(mean: any, stddev: any): any;
/**
* @returns {int} Pseudorandom value [1,100] inclusive, uniformly distributed
*/
static getPercentage(): number;
/**
* @param {object} data key=whatever, value=weight (relative probability)
* @returns {string} whatever
*/
static getWeightedValue(data: any): string;
/**
* Get RNG state. Useful for storing the state and re-setting it via setState.
* @returns {?} Internal state
*/
static getState(): number[];
/**
* Set a previously retrieved state.
* @param {?} state
*/
static setState(state: any): typeof RNG;
/**
* Returns a cloned RNG
*/
static clone(): typeof RNG;
}
}
interface String {
capitalize(): string;
lpad(character: string, count: number): string;
rpad(character: string, count: number): string;
format(): string;
}
declare type StringFormatter = ((template: any) => string) | any;
interface StringConstructor {
format: StringFormatter;
}
declare module "rot/color" {
import './extensions/string';
/**
* @namespace Color operations
*/
export class Color {
static fromString(str: any): any;
/**
* Add two or more colors
* @param {number[]} color1
* @param {number[]} color2
* @returns {number[]}
*/
static add(color1: any, color2: any): any;
/**
* Add two or more colors, MODIFIES FIRST ARGUMENT
* @param {number[]} color1
* @param {number[]} color2
* @returns {number[]}
*/
static add_(color1: any, color2: any): any;
/**
* Multiply (mix) two or more colors
* @param {number[]} color1
* @param {number[]} color2
* @returns {number[]}
*/
static multiply(color1: any, color2: any): any;
/**
* Multiply (mix) two or more colors, MODIFIES FIRST ARGUMENT
* @param {number[]} color1
* @param {number[]} color2
* @returns {number[]}
*/
static multiply_(color1: any, color2: any): any;
/**
* Interpolate (blend) two colors with a given factor
* @param {number[]} color1
* @param {number[]} color2
* @param {float} [factor=0.5] 0..1
* @returns {number[]}
*/
static interpolate(color1: any, color2: any, factor: any): any;
/**
* Interpolate (blend) two colors with a given factor in HSL mode
* @param {number[]} color1
* @param {number[]} color2
* @param {float} [factor=0.5] 0..1
* @returns {number[]}
*/
static interpolateHSL(color1: any, color2: any, factor: any): any[];
/**
* Create a new random color based on this one
* @param {number[]} color
* @param {number[]} diff Set of standard deviations
* @returns {number[]}
*/
static randomize(color: any, diff: any): any;
/**
* Converts an RGB color value to HSL. Expects 0..255 inputs, produces 0..1 outputs.
* @param {number[]} color
* @returns {number[]}
*/
static rgb2hsl(color: any): any[];
/**
* Converts an HSL color value to RGB. Expects 0..1 inputs, produces 0..255 outputs.
* @param {number[]} color
* @returns {number[]}
*/
static hsl2rgb(color: any): any[];
static toRGB(color: any): string;
static toHex(color: any): string;
private static _clamp(num);
static _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];
};
}
}
declare module "rot/display/backend" {
/**
* @class Abstract display backend module
* @private
*/
export abstract class DisplayBackend {
protected _context: CanvasRenderingContext2D;
constructor(context: CanvasRenderingContext2D);
compute(options: any): void;
draw(data: any, clearBefore: any): void;
computeSize(availWidth: any, availHeight: any): void;
computeFontSize(availWidth: any, availHeight: any): void;
eventToPosition(x: any, y: any): void;
}
}
declare module "rot/text" {
/**
* @namespace
* Contains text tokenization and breaking routines
*/
export enum Tokens {
TYPE_TEXT = 0,
TYPE_NEWLINE = 1,
TYPE_FG = 2,
TYPE_BG = 3,
}
export class TextTokenizer {
private RE_COLORS;
/**
* Measure size of a resulting text block
*/
measure(str: any, maxWidth: any): {
width: number;
height: number;
};
/**
* Convert string to a series of a formatting commands
*/
tokenize(str: any, maxWidth: any): any;
private _breakLines(tokens, maxWidth);
/**
* Create new tokens and insert them into the stream
* @param {object[]} tokens
* @param {int} tokenIndex Token being processed
* @param {int} breakIndex Index within current token's value
* @param {bool} removeBreakChar Do we want to remove the breaking character?
* @returns {string} remaining unbroken token value
*/
private _breakInsideToken(tokens, tokenIndex, breakIndex, removeBreakChar);
}
}
interface Number {
mod(n: number): number;
}
declare module "rot/display/hex" {
import '../extensions/number';
import { DisplayBackend } from "rot/display/backend";
/**
* @class Hexagonal backend
* @private
*/
export class HexDisplay extends DisplayBackend {
private _spacingX;
private _spacingY;
private _hexSize;
private _options;
constructor(context: any);
compute(options: any): void;
draw(data: any, clearBefore: any): void;
computeSize(availWidth: any, availHeight: any): number[];
computeFontSize(availWidth: any, availHeight: any): number;
eventToPosition(x: any, y: any): any[];
/**
* Arguments are pixel values. If "transposed" mode is enabled, then these two are already swapped.
*/
_fill(cx: any, cy: any): void;
}
}
declare module "rot/display/rect" {
import { DisplayBackend } from "rot/display/backend";
/**
* @class Rectangular backend
* @private
*/
export class RectDisplay extends DisplayBackend {
static cache: boolean;
private _spacingX;
private _spacingY;
private _canvasCache;
private _options;
constructor(context: any);
compute(options: any): void;
draw(data: any, clearBefore: any): void;
_drawWithCache(data: any, clearBefore: any): void;
_drawNoCache(data: any, clearBefore: any): void;
computeSize(availWidth: any, availHeight: any): number[];
computeFontSize(availWidth: any, availHeight: any): number;
eventToPosition(x: any, y: any): number[];
}
}
declare module "rot/display/tile" {
import { DisplayBackend } from "rot/display/backend";
/**
* @class Tile backend
* @private
*/
export class TileDisplay extends DisplayBackend {
private _options;
private _colorCanvas;
constructor(context: any);
compute(options: any): void;
draw(data: any, clearBefore: any): void;
computeSize(availWidth: any, availHeight: any): number[];
computeFontSize(availWidth: any, availHeight: any): number[];
eventToPosition(x: any, y: any): number[];
}
}
declare module "rot/display/display" {
import './extensions/string';
/**
* @class Visual map display
* @param {object} [options]
* @param {int} [options.width=ROT.DEFAULT_WIDTH]
* @param {int} [options.height=ROT.DEFAULT_HEIGHT]
* @param {int} [options.fontSize=15]
* @param {string} [options.fontFamily="monospace"]
* @param {string} [options.fontStyle=""] bold/italic/none/both
* @param {string} [options.fg="#ccc"]
* @param {string} [options.bg="#000"]
* @param {float} [options.spacing=1]
* @param {float} [options.border=0]
* @param {string} [options.layout="rect"]
* @param {bool} [options.forceSquareRatio=false]
* @param {int} [options.tileWidth=32]
* @param {int} [options.tileHeight=32]
* @param {object} [options.tileMap={}]
* @param {image} [options.tileSet=null]
* @param {image} [options.tileColorize=false]
*/
export interface DisplayOptions {
width?: number;
height?: number;
transpose?: boolean;
layout?: string;
fontSize?: number;
spacing?: number;
border?: number;
forceSquareRatio?: boolean;
fontFamily?: string;
fontStyle?: string;
fg?: string;
bg?: string;
tileWidth?: number;
tileHeight?: number;
tileMap?: any;
tileSet?: any;
tileColorize?: boolean;
termColor?: string;
}
export class Display {
private _context;
private _data;
private _dirty;
private _options;
private _backend;
private _tokenizer;
constructor(options?: DisplayOptions);
/**
* Debug helper, ideal as a map generator callback. Always bound to this.
* @param {int} x
* @param {int} y
* @param {int} what
*/
DEBUG(x: any, y: any, what: any): void;
/**
* Clear the whole display (cover it with background color)
*/
clear(): void;
/**
* @see Display
*/
setOptions(options: any): this;
/**
* Returns currently set options
* @returns {object} Current options object
*/
getOptions(): any;
/**
* Returns the DOM node of this display
* @returns {node} DOM node
*/
getContainer(): HTMLCanvasElement;
/**
* Compute the maximum width/height to fit into a set of given constraints
* @param {int} availWidth Maximum allowed pixel width
* @param {int} availHeight Maximum allowed pixel height
* @returns {int[2]} cellWidth,cellHeight
*/
computeSize(availWidth: any, availHeight: any): any;
/**
* Compute the maximum font size to fit into a set of given constraints
* @param {int} availWidth Maximum allowed pixel width
* @param {int} availHeight Maximum allowed pixel height
* @returns {int} fontSize
*/
computeFontSize(availWidth: any, availHeight: any): any;
/**
* Convert a DOM event (mouse or touch) to map coordinates. Uses first touch for multi-touch.
* @param {Event} e event
* @returns {int[2]} -1 for values outside of the canvas
*/
eventToPosition(e: any): any;
/**
* @param {int} x
* @param {int} y
* @param {string || string[]} ch One or more chars (will be overlapping themselves)
* @param {string} [fg] foreground color
* @param {string} [bg] background color
*/
draw(x: any, y: any, ch: any, fg?: string, bg?: string): void;
/**
* Draws a text at given position. Optionally wraps at a maximum length. Currently does not work with hex layout.
* @param {int} x
* @param {int} y
* @param {string} text May contain color/background format specifiers, %c{name}/%b{name}, both optional. %c{}/%b{} resets to default.
* @param {int} [maxWidth] wrap at what width?
* @returns {int} lines drawn
*/
drawText(x: any, y: any, text: any, maxWidth: any): number;
/**
* Timer tick: update dirty parts
*/
private _tick();
/**
* @param {string} key What to draw
* @param {bool} clearBefore Is it necessary to clean before?
*/
private _draw(key, clearBefore);
}
}
declare module "rot/eventqueue" {
/**
* @class Generic event queue: stores events and retrieves them based on their time
*/
export class EventQueue {
private _time;
private _events;
private _eventTimes;
constructor();
/**
* @returns {number} Elapsed time
*/
getTime(): number;
/**
* Clear all scheduled events
*/
clear(): this;
/**
* @param {?} event
* @param {number} time
*/
add(event: any, time: any): void;
/**
* Locates the nearest event, advances time if necessary. Returns that event and removes it from the queue.
* @returns {? || null} The event previously added by addEvent, null if no event available
*/
get(): number;
/**
* Get the time associated with the given event
* @param {?} event
* @returns {number} time
*/
getEventTime(event: any): number;
/**
* Remove an event from the queue
* @param {?} event
* @returns {bool} success?
*/
remove(event: any): boolean;
/**
* Remove an event from the queue
* @param {int} index
*/
private _remove(index);
}
}
declare module "rot/scheduler/scheduler" {
import { EventQueue } from "rot/eventqueue";
/**
* @class Abstract scheduler
*/
export class Scheduler {
protected _queue: EventQueue;
protected _repeat: any;
protected _current: any;
constructor();
/**
* @see ROT.EventQueue#getTime
*/
getTime(): number;
/**
* @param {?} item
* @param {bool} repeat
*/
add(item: any, repeat: any): this;
/**
* Get the time the given item is scheduled for
* @param {?} item
* @returns {number} time
*/
getTimeOf(item: any): number;
/**
* Clear all items
*/
clear(): this;
/**
* Remove a previously added item
* @param {?} item
* @returns {bool} successful?
*/
remove(item: any): boolean;
/**
* Schedule next item
* @returns {?}
*/
next(): any;
}
}
declare module "rot/engine" {
import { Scheduler } from "rot/scheduler/scheduler";
/**
* @class Asynchronous main loop
* @param {ROT.Scheduler} scheduler
*/
export class Engine {
private _scheduler;
private _lock;
constructor(scheduler: Scheduler);
/**
* Start the main loop. When this call returns, the loop is locked.
*/
start(): this;
/**
* Interrupt the engine by an asynchronous action
*/
lock(): this;
/**
* Resume execution (paused by a previous lock)
*/
unlock(): this;
}
}
declare module "rot/extensions/array" {
global {
interface Array<T> {
random(): T;
randomize(): T[];
}
}
}
interface Window {
mozRequestAnimationFrame(func: FrameRequestCallback): number;
oRequestAnimationFrame(func: FrameRequestCallback): number;
msRequestAnimationFrame(func: FrameRequestCallback): number;
mozCancelAnimationFrame(handle: number): void;
oCancelAnimationFrame(handle: number): void;
msCancelAnimationFrame(handle: number): void;
}
declare module "rot/fov/fov" {
export interface FOVOptions {
topology?: number;
}
/**
* @class Abstract FOV algorithm
* @param {function} lightPassesCallback Does the light pass through x,y?
* @param {object} [options]
* @param {int} [options.topology=8] 4/6/8
*/
export class FOV {
protected _lightPasses: any;
protected _options: any;
constructor(lightPassesCallback: any, options?: FOVOptions);
/**
* Compute visibility for a 360-degree circle
* @param {int} x
* @param {int} y
* @param {int} R Maximum visibility radius
* @param {function} callback
*/
compute(x: any, y: any, R: any, callback: any): void;
/**
* Return all neighbors in a concentric ring
* @param {int} cx center-x
* @param {int} cy center-y
* @param {int} r range
*/
protected _getCircle(cx: any, cy: any, r: any): any[];
}
}
declare module "rot/fov/discrete-shadowcasting" {
import { FOV, FOVOptions } from "rot/fov/fov";
/**
* @class Discrete shadowcasting algorithm. Obsoleted by Precise shadowcasting.
* @augments ROT.FOV
*/
export class DiscreteShadowcasting extends FOV {
private _coords;
private _map;
constructor(lightPassesCallback: any, options?: FOVOptions);
/**
* @see ROT.FOV#compute
*/
compute(x: any, y: any, R: any, callback: any): void;
/**
* @param {int} A start angle
* @param {int} B end angle
* @param {bool} blocks Does current cell block visibility?
* @param {int[][]} DATA shadowed angle pairs
*/
_visibleCoords(A: any, B: any, blocks: any, DATA: any): any;
}
}
declare module "rot/fov/precise-shadowcasting" {
import { FOV, FOVOptions } from "rot/fov/fov";
/**
* @class Precise shadowcasting algorithm
* @augments ROT.FOV
*/
export class PreciseShadowcasting extends FOV {
constructor(lightPassesCallback: any, options?: FOVOptions);
/**
* @see ROT.FOV#compute
*/
compute(x: any, y: any, R: any, callback: any): void;
/**
* @param {int[2]} A1 arc start
* @param {int[2]} A2 arc end
* @param {bool} blocks Does current arc block visibility?
* @param {int[][]} SHADOWS list of active shadows
*/
private _checkVisibility(A1, A2, blocks, SHADOWS);
}
}
declare module "rot/fov/recursive-shadowcasting" {
import { FOV, FOVOptions } from "rot/fov/fov";
/**
* @class Recursive shadowcasting algorithm
* Currently only supports 4/8 topologies, not hexagonal.
* Based on Peter Harkins' implementation of Björn Bergström's algorithm described here: http://www.roguebasin.com/index.php?title=FOV_using_recursive_shadowcasting
* @augments ROT.FOV
*/
export class RecursiveShadowcasting extends FOV {
constructor(lightPassesCallback: any, options?: FOVOptions);
/**
* Compute visibility for a 360-degree circle
* @param {int} x
* @param {int} y
* @param {int} R Maximum visibility radius
* @param {function} callback
*/
compute(x: any, y: any, R: any, callback: any): void;
/**
* Compute visibility for a 180-degree arc
* @param {int} x
* @param {int} y
* @param {int} R Maximum visibility radius
* @param {int} dir Direction to look in (expressed in a ROT.DIRS value);
* @param {function} callback
*/
compute180(x: any, y: any, R: any, dir: any, callback: any): void;
/**
* Compute visibility for a 90-degree arc
* @param {int} x
* @param {int} y
* @param {int} R Maximum visibility radius
* @param {int} dir Direction to look in (expressed in a ROT.DIRS value);
* @param {function} callback
*/
compute90(x: any, y: any, R: any, dir: any, callback: any): void;
/**
* Render one octant (45-degree arc) of the viewshed
* @param {int} x
* @param {int} y
* @param {int} octant Octant to be rendered
* @param {int} R Maximum visibility radius
* @param {function} callback
*/
private _renderOctant(x, y, octant, R, callback);
/**
* Actually calculates the visibility
* @param {int} startX The starting X coordinate
* @param {int} startY The starting Y coordinate
* @param {int} row The row to render
* @param {float} visSlopeStart The slope to start at
* @param {float} visSlopeEnd The slope to end at
* @param {int} radius The radius to reach out to
* @param {int} xx
* @param {int} xy
* @param {int} yx
* @param {int} yy
* @param {function} callback The callback to use when we hit a block that is visible
*/
private _castVisibility(startX, startY, row, visSlopeStart, visSlopeEnd, radius, xx, xy, yx, yy, callback);
/** Octants used for translating recursive shadowcasting offsets */
static OCTANTS: number[][];
}
}
declare module "rot/lighting" {
/**
* @class Lighting computation, based on a traditional FOV for multiple light sources and multiple passes.
* @param {function} reflectivityCallback Callback to retrieve cell reflectivity (0..1)
* @param {object} [options]
* @param {int} [options.passes=1] Number of passes. 1 equals to simple FOV of all light sources, >1 means a *highly simplified* radiosity-like algorithm.
* @param {int} [options.emissionThreshold=100] Cells with emissivity > threshold will be treated as light source in the next pass.
* @param {int} [options.range=10] Max light range
*/
export class Lighting {
private _reflectivityCallback;
private _options;
private _fov;
private _lights;
private _reflectivityCache;
private _fovCache;
constructor(reflectivityCallback: any, options: any);
/**
* Adjust options at runtime
* @see Lighting
* @param {object} [options]
*/
setOptions(options: any): this;
/**
* Set the used Field-Of-View algo
* @param {ROT.FOV} fov
*/
setFOV(fov: any): this;