litecanvas 0.63.0 → 0.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/dist.js +35 -22
- package/dist/dist.min.js +1 -1
- package/package.json +1 -1
- package/src/index.js +38 -23
- package/src/palette.js +2 -3
- package/types/index.d.ts +158 -174
- package/types/types.d.ts +154 -176
package/types/index.d.ts
CHANGED
|
@@ -25,9 +25,9 @@ declare global {
|
|
|
25
25
|
/** the center Y of the game screen */
|
|
26
26
|
var CENTERY: number
|
|
27
27
|
/** The current mouse's horizontal (X) position or -1 (if the mouse was not used or detected) */
|
|
28
|
-
var MOUSEX: number
|
|
28
|
+
var MOUSEX: number
|
|
29
29
|
/** The current mouse's vertical (Y) position or -1 (if the mouse was not used or detected) */
|
|
30
|
-
var MOUSEY: number
|
|
30
|
+
var MOUSEY: number
|
|
31
31
|
/** the default `sfx()` sound */
|
|
32
32
|
var DEFAULT_SFX: number[]
|
|
33
33
|
|
|
@@ -53,55 +53,55 @@ declare global {
|
|
|
53
53
|
/**
|
|
54
54
|
* Calculates a linear (interpolation) value over t%.
|
|
55
55
|
*
|
|
56
|
-
* @param
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @returns
|
|
56
|
+
* @param start
|
|
57
|
+
* @param end
|
|
58
|
+
* @param t The progress in percentage, where 0 = 0% and 1 = 100%.
|
|
59
|
+
* @returns The unterpolated value
|
|
60
60
|
* @tutorial https://gamedev.net/tutorials/programming/general-and-gameplay-programming/a-brief-introduction-to-lerp-r4954/
|
|
61
61
|
*/
|
|
62
62
|
function lerp(start: number, end: number, t: number): number
|
|
63
63
|
/**
|
|
64
64
|
* Convert degrees to radians
|
|
65
65
|
*
|
|
66
|
-
* @param
|
|
67
|
-
* @returns
|
|
66
|
+
* @param degs
|
|
67
|
+
* @returns the value in radians
|
|
68
68
|
*/
|
|
69
69
|
function deg2rad(degs: number): number
|
|
70
70
|
/**
|
|
71
71
|
* Convert radians to degrees
|
|
72
72
|
*
|
|
73
|
-
* @param
|
|
74
|
-
* @returns
|
|
73
|
+
* @param rads
|
|
74
|
+
* @returns the value in degrees
|
|
75
75
|
*/
|
|
76
76
|
function rad2deg(rads: number): number
|
|
77
77
|
/**
|
|
78
78
|
* Constrains a number between `min` and `max`.
|
|
79
79
|
*
|
|
80
|
-
* @param
|
|
81
|
-
* @param
|
|
82
|
-
* @param
|
|
83
|
-
* @returns
|
|
80
|
+
* @param value
|
|
81
|
+
* @param min
|
|
82
|
+
* @param max
|
|
83
|
+
* @returns
|
|
84
84
|
*/
|
|
85
85
|
function clamp(value: number, min: number, max: number): number
|
|
86
86
|
/**
|
|
87
87
|
* Wraps a number between `min` (inclusive) and `max` (exclusive).
|
|
88
88
|
*
|
|
89
|
-
* @param
|
|
90
|
-
* @param
|
|
91
|
-
* @param
|
|
92
|
-
* @returns
|
|
89
|
+
* @param value
|
|
90
|
+
* @param min
|
|
91
|
+
* @param max
|
|
92
|
+
* @returns
|
|
93
93
|
*/
|
|
94
94
|
function wrap(value: number, min: number, max: number): number
|
|
95
95
|
/**
|
|
96
96
|
* Re-maps a number from one range to another.
|
|
97
97
|
*
|
|
98
|
-
* @param
|
|
99
|
-
* @param
|
|
100
|
-
* @param
|
|
101
|
-
* @param
|
|
102
|
-
* @param
|
|
103
|
-
* @param
|
|
104
|
-
* @returns
|
|
98
|
+
* @param value the value to be remapped.
|
|
99
|
+
* @param min1 lower bound of the value's current range.
|
|
100
|
+
* @param max1 upper bound of the value's current range.
|
|
101
|
+
* @param min2 lower bound of the value's target range.
|
|
102
|
+
* @param max2 upper bound of the value's target range.
|
|
103
|
+
* @param [withinBounds=false] constrain the value to the newly mapped range
|
|
104
|
+
* @returns the remapped number
|
|
105
105
|
*/
|
|
106
106
|
function map(
|
|
107
107
|
value: number,
|
|
@@ -116,10 +116,10 @@ declare global {
|
|
|
116
116
|
* Identical to `map(value, min, max, 0, 1)`.
|
|
117
117
|
* Note: Numbers outside the range are not clamped to 0 and 1.
|
|
118
118
|
*
|
|
119
|
-
* @param
|
|
120
|
-
* @param
|
|
121
|
-
* @param
|
|
122
|
-
* @returns
|
|
119
|
+
* @param value
|
|
120
|
+
* @param min
|
|
121
|
+
* @param max
|
|
122
|
+
* @returns the normalized number.
|
|
123
123
|
*/
|
|
124
124
|
function norm(value: number, min: number, max: number): number
|
|
125
125
|
/**
|
|
@@ -192,17 +192,17 @@ declare global {
|
|
|
192
192
|
/**
|
|
193
193
|
* Generates a pseudorandom float between min (inclusive) and max (exclusive)
|
|
194
194
|
*
|
|
195
|
-
* @param
|
|
196
|
-
* @param
|
|
197
|
-
* @returns
|
|
195
|
+
* @param [min=0.0]
|
|
196
|
+
* @param [max=1.0]
|
|
197
|
+
* @returns the random number
|
|
198
198
|
*/
|
|
199
199
|
function rand(min?: number, max?: number): number
|
|
200
200
|
/**
|
|
201
201
|
* Generates a pseudorandom integer between min (inclusive) and max (inclusive)
|
|
202
202
|
*
|
|
203
|
-
* @param
|
|
204
|
-
* @param
|
|
205
|
-
* @returns
|
|
203
|
+
* @param [min=0]
|
|
204
|
+
* @param [max=1]
|
|
205
|
+
* @returns the random number
|
|
206
206
|
*/
|
|
207
207
|
function randi(min?: number, max?: number): number
|
|
208
208
|
|
|
@@ -210,19 +210,19 @@ declare global {
|
|
|
210
210
|
/**
|
|
211
211
|
* Clear the game screen
|
|
212
212
|
*
|
|
213
|
-
* @param
|
|
213
|
+
* @param color The background color index or `null`
|
|
214
214
|
*/
|
|
215
215
|
function cls(color: number | null): void
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
218
|
* Draw a rectangle outline
|
|
219
219
|
*
|
|
220
|
-
* @param
|
|
221
|
-
* @param
|
|
222
|
-
* @param
|
|
223
|
-
* @param
|
|
224
|
-
* @param
|
|
225
|
-
* @param
|
|
220
|
+
* @param x
|
|
221
|
+
* @param y
|
|
222
|
+
* @param width
|
|
223
|
+
* @param height
|
|
224
|
+
* @param [color=0] the color index
|
|
225
|
+
* @param [radii] A number or list specifying the radii used to draw a rounded-borders rectangle
|
|
226
226
|
*/
|
|
227
227
|
function rect(
|
|
228
228
|
x: number,
|
|
@@ -235,12 +235,12 @@ declare global {
|
|
|
235
235
|
/**
|
|
236
236
|
* Draw a color-filled rectangle
|
|
237
237
|
*
|
|
238
|
-
* @param
|
|
239
|
-
* @param
|
|
240
|
-
* @param
|
|
241
|
-
* @param
|
|
242
|
-
* @param
|
|
243
|
-
* @param
|
|
238
|
+
* @param x
|
|
239
|
+
* @param y
|
|
240
|
+
* @param width
|
|
241
|
+
* @param height
|
|
242
|
+
* @param [color=0] the color index
|
|
243
|
+
* @param [radii] A number or list specifying the radii used to draw a rounded-borders rectangle
|
|
244
244
|
*/
|
|
245
245
|
function rectfill(
|
|
246
246
|
x: number,
|
|
@@ -253,19 +253,19 @@ declare global {
|
|
|
253
253
|
/**
|
|
254
254
|
* Draw a circle outline
|
|
255
255
|
*
|
|
256
|
-
* @param
|
|
257
|
-
* @param
|
|
258
|
-
* @param
|
|
259
|
-
* @param
|
|
256
|
+
* @param x
|
|
257
|
+
* @param y
|
|
258
|
+
* @param radius
|
|
259
|
+
* @param [color=0] the color index
|
|
260
260
|
*/
|
|
261
261
|
function circ(x: number, y: number, radius: number, color?: number): void
|
|
262
262
|
/**
|
|
263
263
|
* Draw a color-filled circle
|
|
264
264
|
*
|
|
265
|
-
* @param
|
|
266
|
-
* @param
|
|
267
|
-
* @param
|
|
268
|
-
* @param
|
|
265
|
+
* @param x
|
|
266
|
+
* @param y
|
|
267
|
+
* @param radius
|
|
268
|
+
* @param [color=0] the color index
|
|
269
269
|
*/
|
|
270
270
|
function circfill(
|
|
271
271
|
x: number,
|
|
@@ -276,11 +276,11 @@ declare global {
|
|
|
276
276
|
/**
|
|
277
277
|
* Draw a line
|
|
278
278
|
*
|
|
279
|
-
* @param
|
|
280
|
-
* @param
|
|
281
|
-
* @param
|
|
282
|
-
* @param
|
|
283
|
-
* @param
|
|
279
|
+
* @param x1
|
|
280
|
+
* @param y1
|
|
281
|
+
* @param x2
|
|
282
|
+
* @param y2
|
|
283
|
+
* @param [color=0] the color index
|
|
284
284
|
*/
|
|
285
285
|
function line(
|
|
286
286
|
x1: number,
|
|
@@ -292,53 +292,53 @@ declare global {
|
|
|
292
292
|
/**
|
|
293
293
|
* Sets the thickness of lines
|
|
294
294
|
*
|
|
295
|
-
* @param
|
|
295
|
+
* @param value
|
|
296
296
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineWidth
|
|
297
297
|
*/
|
|
298
298
|
function linewidth(value: number): void
|
|
299
299
|
/**
|
|
300
300
|
* Sets the line dash pattern used when drawing lines
|
|
301
301
|
*
|
|
302
|
-
* @param
|
|
303
|
-
* @param
|
|
302
|
+
* @param segments the line dash pattern
|
|
303
|
+
* @param [offset=0] the line dash offset, or "phase".
|
|
304
304
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
|
|
305
305
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
|
|
306
306
|
*/
|
|
307
|
-
function linedash(segments: number
|
|
307
|
+
function linedash(segments: number[], offset?: number): void
|
|
308
308
|
|
|
309
309
|
/** TEXT RENDERING API */
|
|
310
310
|
/**
|
|
311
311
|
* Draw text
|
|
312
312
|
*
|
|
313
|
-
* @param
|
|
314
|
-
* @param
|
|
315
|
-
* @param
|
|
316
|
-
* @param
|
|
313
|
+
* @param x
|
|
314
|
+
* @param y
|
|
315
|
+
* @param text the text message
|
|
316
|
+
* @param [color=3] the color index
|
|
317
317
|
*/
|
|
318
318
|
function text(x: number, y: number, text: string, color?: number): void
|
|
319
319
|
/**
|
|
320
320
|
* Set the font family
|
|
321
321
|
*
|
|
322
|
-
* @param
|
|
322
|
+
* @param fontFamily
|
|
323
323
|
*/
|
|
324
324
|
function textfont(fontFamily: string): void
|
|
325
325
|
/**
|
|
326
326
|
* Set the font size
|
|
327
327
|
*
|
|
328
|
-
* @param
|
|
328
|
+
* @param size
|
|
329
329
|
*/
|
|
330
330
|
function textsize(size: string): void
|
|
331
331
|
/**
|
|
332
332
|
* Sets whether a font should be styled with a normal, italic, or bold.
|
|
333
333
|
*
|
|
334
|
-
* @param
|
|
334
|
+
* @param style
|
|
335
335
|
*/
|
|
336
336
|
function textstyle(style: string): void
|
|
337
337
|
/**
|
|
338
338
|
* Sets the alignment used when drawing texts
|
|
339
339
|
*
|
|
340
|
-
* @param
|
|
341
|
-
* @param
|
|
340
|
+
* @param align the horizontal alignment. Possible values: "left", "right", "center", "start" or "end"
|
|
341
|
+
* @param baseline the vertical alignment. Possible values: "top", "bottom", "middle", "hanging" or "ideographic"
|
|
342
342
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textBaseline
|
|
343
343
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
|
|
344
344
|
*/
|
|
@@ -346,9 +346,8 @@ declare global {
|
|
|
346
346
|
/**
|
|
347
347
|
* Returns a TextMetrics object that contains information about the measured text (such as its width, for example)
|
|
348
348
|
*
|
|
349
|
-
* @param
|
|
350
|
-
* @param
|
|
351
|
-
* @returns {TextMetrics}
|
|
349
|
+
* @param text
|
|
350
|
+
* @param [size]
|
|
352
351
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics
|
|
353
352
|
*/
|
|
354
353
|
function textmetrics(text: string, size?: number): TextMetrics
|
|
@@ -357,9 +356,9 @@ declare global {
|
|
|
357
356
|
/**
|
|
358
357
|
* Draw an image
|
|
359
358
|
*
|
|
360
|
-
* @param
|
|
361
|
-
* @param
|
|
362
|
-
* @param
|
|
359
|
+
* @param x
|
|
360
|
+
* @param y
|
|
361
|
+
* @param image
|
|
363
362
|
*/
|
|
364
363
|
function image(
|
|
365
364
|
x: number,
|
|
@@ -369,11 +368,10 @@ declare global {
|
|
|
369
368
|
/**
|
|
370
369
|
* Creates a offscreen canvas to draw on it
|
|
371
370
|
*
|
|
372
|
-
* @param
|
|
373
|
-
* @param
|
|
374
|
-
* @param
|
|
375
|
-
* @param
|
|
376
|
-
* @returns {OffscreenCanvas}
|
|
371
|
+
* @param width
|
|
372
|
+
* @param height
|
|
373
|
+
* @param draw
|
|
374
|
+
* @param [options]
|
|
377
375
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas
|
|
378
376
|
*/
|
|
379
377
|
function paint(
|
|
@@ -389,9 +387,12 @@ declare global {
|
|
|
389
387
|
/** ADVANCED GRAPHICS API */
|
|
390
388
|
/**
|
|
391
389
|
* Get or set the canvas context 2D
|
|
390
|
+
*
|
|
391
|
+
* @param [context] an new canvas context
|
|
392
|
+
* @returns the current canvas context
|
|
392
393
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D
|
|
393
394
|
*/
|
|
394
|
-
function ctx(
|
|
395
|
+
function ctx(context?: CanvasRenderingContext2D): CanvasRenderingContext2D
|
|
395
396
|
/**
|
|
396
397
|
* saves the current drawing style settings and transformations
|
|
397
398
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/save
|
|
@@ -405,31 +406,31 @@ declare global {
|
|
|
405
406
|
/**
|
|
406
407
|
* Adds a translation transformation to the current matrix
|
|
407
408
|
*
|
|
408
|
-
* @param
|
|
409
|
-
* @param
|
|
409
|
+
* @param x
|
|
410
|
+
* @param y
|
|
410
411
|
*/
|
|
411
412
|
function translate(x: number, y: number): void
|
|
412
413
|
/**
|
|
413
414
|
* Adds a scaling transformation to the canvas units horizontally and/or vertically.
|
|
414
415
|
*
|
|
415
|
-
* @param
|
|
416
|
-
* @param
|
|
416
|
+
* @param x
|
|
417
|
+
* @param [y]
|
|
417
418
|
*/
|
|
418
419
|
function scale(x: number, y?: number): void
|
|
419
420
|
/**
|
|
420
421
|
* Adds a rotation to the transformation matrix
|
|
421
422
|
*
|
|
422
|
-
* @param
|
|
423
|
+
* @param radians
|
|
423
424
|
*/
|
|
424
425
|
function rotate(radians: number): void
|
|
425
426
|
/**
|
|
426
|
-
* @param
|
|
427
|
-
* @param
|
|
428
|
-
* @param
|
|
429
|
-
* @param
|
|
430
|
-
* @param
|
|
431
|
-
* @param
|
|
432
|
-
* @param
|
|
427
|
+
* @param a
|
|
428
|
+
* @param b
|
|
429
|
+
* @param c
|
|
430
|
+
* @param d
|
|
431
|
+
* @param e
|
|
432
|
+
* @param f
|
|
433
|
+
* @param [resetFirst=true] `false` to use _ctx.transform(); by default use _ctx.setTransform()
|
|
433
434
|
*
|
|
434
435
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setTransform
|
|
435
436
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform
|
|
@@ -446,7 +447,7 @@ declare global {
|
|
|
446
447
|
/**
|
|
447
448
|
* Sets the alpha (transparency) value to apply when drawing new shapes and images
|
|
448
449
|
*
|
|
449
|
-
* @param
|
|
450
|
+
* @param alpha float from 0 to 1 (e.g: 0.5 = 50% transparent)
|
|
450
451
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalAlpha
|
|
451
452
|
*/
|
|
452
453
|
function alpha(alpha: number): void
|
|
@@ -455,61 +456,40 @@ declare global {
|
|
|
455
456
|
* path as an argument (creates a copy), or optionally with a string
|
|
456
457
|
* consisting of SVG path data.
|
|
457
458
|
*
|
|
458
|
-
* @param
|
|
459
|
-
* @returns Path2D
|
|
459
|
+
* @param [arg]
|
|
460
460
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Path2D/Path2D
|
|
461
461
|
*/
|
|
462
462
|
function path(arg?: Path2D | string): Path2D
|
|
463
463
|
/**
|
|
464
464
|
* Fills the current or given path with a given color.
|
|
465
465
|
*
|
|
466
|
-
* @param
|
|
467
|
-
* @param
|
|
466
|
+
* @param color
|
|
467
|
+
* @param [path]
|
|
468
468
|
*/
|
|
469
469
|
function fill(color: number, path?: Path2D): void
|
|
470
470
|
/**
|
|
471
471
|
* Outlines the current or given path with a given color.
|
|
472
472
|
*
|
|
473
|
-
* @param
|
|
474
|
-
* @param
|
|
473
|
+
* @param color
|
|
474
|
+
* @param [path]
|
|
475
475
|
*/
|
|
476
476
|
function stroke(color: number, path?: Path2D): void
|
|
477
477
|
/**
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
* Note: Clip paths cannot be reverted directly. You must save your
|
|
481
|
-
* canvas state using push() before calling cliprect(), and restore it
|
|
482
|
-
* once you have finished drawing in the clipped area using pop().
|
|
483
|
-
*
|
|
484
|
-
* @param {number} x
|
|
485
|
-
* @param {number} y
|
|
486
|
-
* @param {number} width
|
|
487
|
-
* @param {number} height
|
|
488
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clip
|
|
489
|
-
*/
|
|
490
|
-
function cliprect(x: number, y: number, width: number, height: number): void
|
|
491
|
-
/**
|
|
492
|
-
* Create a circular clipping region.
|
|
493
|
-
*
|
|
494
|
-
* Note: Clip paths cannot be reverted directly. You must save your
|
|
495
|
-
* canvas state using push() before calling clipcirc(), and restore it
|
|
496
|
-
* once you have finished drawing in the clipped area using pop().
|
|
478
|
+
* Turn given path into a clipping region.
|
|
497
479
|
*
|
|
498
|
-
* @param
|
|
499
|
-
* @param {number} y
|
|
500
|
-
* @param {number} radius
|
|
480
|
+
* @param path
|
|
501
481
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clip
|
|
502
482
|
*/
|
|
503
|
-
function
|
|
483
|
+
function clip(path: Path2D): void
|
|
504
484
|
|
|
505
485
|
/** SOUND API */
|
|
506
486
|
/**
|
|
507
487
|
* Play a sound effects using ZzFX library.
|
|
508
488
|
* If the first argument is omitted, plays an default sound.
|
|
509
489
|
*
|
|
510
|
-
* @param
|
|
511
|
-
* @param
|
|
512
|
-
* @param
|
|
490
|
+
* @param [zzfxParams] a ZzFX array of params
|
|
491
|
+
* @param [pitchSlide=0] a value to increment/decrement the pitch
|
|
492
|
+
* @param [volumeFactor=1] the volume factor
|
|
513
493
|
* @returns The sound that was played or `false`
|
|
514
494
|
*
|
|
515
495
|
* @see https://github.com/KilledByAPixel/ZzFX
|
|
@@ -523,7 +503,7 @@ declare global {
|
|
|
523
503
|
* Set the ZzFX's global volume factor.
|
|
524
504
|
* Note: use 0 to mute all sound effects.
|
|
525
505
|
*
|
|
526
|
-
* @param
|
|
506
|
+
* @param value
|
|
527
507
|
*/
|
|
528
508
|
function volume(value: number): void
|
|
529
509
|
|
|
@@ -541,15 +521,14 @@ declare global {
|
|
|
541
521
|
/**
|
|
542
522
|
* Check a collision between two rectangles
|
|
543
523
|
*
|
|
544
|
-
* @param
|
|
545
|
-
* @param
|
|
546
|
-
* @param
|
|
547
|
-
* @param
|
|
548
|
-
* @param
|
|
549
|
-
* @param
|
|
550
|
-
* @param
|
|
551
|
-
* @param
|
|
552
|
-
* @returns {boolean}
|
|
524
|
+
* @param x1 first rectangle position X
|
|
525
|
+
* @param y1 first rectangle position Y
|
|
526
|
+
* @param w1 first rectangle width
|
|
527
|
+
* @param h1 first rectangle height
|
|
528
|
+
* @param x2 second rectangle position X
|
|
529
|
+
* @param y2 second rectangle position Y
|
|
530
|
+
* @param w2 second rectangle width
|
|
531
|
+
* @param h2 second rectangle height
|
|
553
532
|
*/
|
|
554
533
|
function colrect(
|
|
555
534
|
x1: number,
|
|
@@ -564,13 +543,12 @@ declare global {
|
|
|
564
543
|
/**
|
|
565
544
|
* Check a collision between two circles
|
|
566
545
|
*
|
|
567
|
-
* @param
|
|
568
|
-
* @param
|
|
569
|
-
* @param
|
|
570
|
-
* @param
|
|
571
|
-
* @param
|
|
572
|
-
* @param
|
|
573
|
-
* @returns {boolean}
|
|
546
|
+
* @param x1 first circle position X
|
|
547
|
+
* @param y1 first circle position Y
|
|
548
|
+
* @param r1 first circle position radius
|
|
549
|
+
* @param x2 second circle position X
|
|
550
|
+
* @param y2 second circle position Y
|
|
551
|
+
* @param r2 second circle position radius
|
|
574
552
|
*/
|
|
575
553
|
function colcirc(
|
|
576
554
|
x1: number,
|
|
@@ -580,65 +558,71 @@ declare global {
|
|
|
580
558
|
y2: number,
|
|
581
559
|
r2: number
|
|
582
560
|
): boolean
|
|
583
|
-
/**
|
|
584
|
-
* The scale of the game's delta time (dt).
|
|
585
|
-
* Values higher than 1 increase the speed of time, while values smaller than 1 decrease it.
|
|
586
|
-
* A value of 0 freezes time and is effectively equivalent to pausing.
|
|
587
|
-
*
|
|
588
|
-
* @param {number} value
|
|
589
|
-
*/
|
|
590
|
-
function timescale(value: number): void
|
|
591
561
|
|
|
592
562
|
/** PLUGINS API */
|
|
593
563
|
/**
|
|
594
564
|
* Prepares a plugin to be loaded
|
|
595
565
|
*
|
|
596
|
-
* @param
|
|
566
|
+
* @param callback
|
|
597
567
|
*/
|
|
598
568
|
function use(callback: pluginCallback): void
|
|
599
569
|
/**
|
|
600
570
|
* Add a game loop event listener
|
|
601
571
|
*
|
|
602
|
-
* @param
|
|
603
|
-
* @param
|
|
604
|
-
* @returns
|
|
572
|
+
* @param event The game event type
|
|
573
|
+
* @param callback the function that is called when the event occurs
|
|
574
|
+
* @returns a function to remove the listener
|
|
605
575
|
*/
|
|
606
576
|
function listen(event: string, callback: Function): Function | null
|
|
607
577
|
/**
|
|
608
578
|
* Call all listeners attached to a game event
|
|
609
579
|
*
|
|
610
580
|
* @param event The game event type
|
|
611
|
-
* @param arg1 any data to be passed over the listeners
|
|
612
|
-
* @param arg2 any data to be passed over the listeners
|
|
613
|
-
* @param arg3 any data to be passed over the listeners
|
|
614
|
-
* @param arg4 any data to be passed over the listeners
|
|
581
|
+
* @param [arg1] any data to be passed over the listeners
|
|
582
|
+
* @param [arg2] any data to be passed over the listeners
|
|
583
|
+
* @param [arg3] any data to be passed over the listeners
|
|
584
|
+
* @param [arg4] any data to be passed over the listeners
|
|
615
585
|
*/
|
|
616
586
|
function emit(
|
|
617
587
|
event: string,
|
|
618
|
-
arg1
|
|
619
|
-
arg2
|
|
620
|
-
arg3
|
|
621
|
-
arg4
|
|
588
|
+
arg1?: any,
|
|
589
|
+
arg2?: any,
|
|
590
|
+
arg3?: any,
|
|
591
|
+
arg4?: any
|
|
622
592
|
): void
|
|
623
593
|
/**
|
|
624
594
|
* Get the color value
|
|
625
595
|
*
|
|
626
|
-
* @param
|
|
627
|
-
* @returns
|
|
596
|
+
* @param index The color number
|
|
597
|
+
* @returns the color value
|
|
628
598
|
*/
|
|
629
599
|
function getcolor(index: number): string
|
|
630
600
|
/**
|
|
631
601
|
* Create or update a instance variable
|
|
632
602
|
*
|
|
633
|
-
* @param
|
|
634
|
-
* @param
|
|
603
|
+
* @param key
|
|
604
|
+
* @param value
|
|
635
605
|
*/
|
|
636
606
|
function setvar(key: string, value: any): void
|
|
637
607
|
/**
|
|
638
608
|
* Resizes the game canvas and emit the "resized" event
|
|
639
609
|
*
|
|
640
|
-
* @param
|
|
641
|
-
* @param
|
|
610
|
+
* @param width
|
|
611
|
+
* @param height
|
|
642
612
|
*/
|
|
643
613
|
function resize(width: number, height: number): void
|
|
614
|
+
/**
|
|
615
|
+
* The scale of the game's delta time (dt).
|
|
616
|
+
* Values higher than 1 increase the speed of time, while values smaller than 1 decrease it.
|
|
617
|
+
* A value of 0 freezes time and is effectively equivalent to pausing.
|
|
618
|
+
*
|
|
619
|
+
* @param value
|
|
620
|
+
*/
|
|
621
|
+
function timescale(value: number): void
|
|
622
|
+
/**
|
|
623
|
+
* Set the target FPS at runtime.
|
|
624
|
+
*
|
|
625
|
+
* @param fps
|
|
626
|
+
*/
|
|
627
|
+
function setfps(fps: number): void
|
|
644
628
|
}
|