litecanvas 0.209.0 → 0.301.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 +1 -2
- package/dist/dist.dev.js +174 -160
- package/dist/dist.js +18 -14
- package/dist/dist.min.js +1 -1
- package/package.json +4 -4
- package/src/index.js +190 -172
- package/src/version.js +1 -1
- package/types/global.d.ts +11 -11
- package/types/types.d.ts +11 -11
package/dist/dist.dev.js
CHANGED
|
@@ -115,12 +115,12 @@
|
|
|
115
115
|
var assert = (condition, message = "Assertion failed") => {
|
|
116
116
|
if (!condition) throw new Error("[Litecanvas] " + message);
|
|
117
117
|
};
|
|
118
|
-
var version = "0.
|
|
118
|
+
var version = "0.301.0";
|
|
119
119
|
function litecanvas(settings = {}) {
|
|
120
120
|
const root = window,
|
|
121
121
|
math = Math,
|
|
122
122
|
perf = performance,
|
|
123
|
-
|
|
123
|
+
TAU = math.PI * 2,
|
|
124
124
|
raf = requestAnimationFrame,
|
|
125
125
|
isNumber = Number.isFinite,
|
|
126
126
|
_browserEventListeners = [],
|
|
@@ -146,11 +146,11 @@
|
|
|
146
146
|
};
|
|
147
147
|
DEV: assert(
|
|
148
148
|
null == settings || "object" === typeof settings,
|
|
149
|
-
"litecanvas() 1st
|
|
149
|
+
"litecanvas() 1st argument must be a object",
|
|
150
150
|
);
|
|
151
151
|
settings = Object.assign(defaults, settings);
|
|
152
152
|
let _loop = settings.loop,
|
|
153
|
-
_initialized
|
|
153
|
+
_initialized,
|
|
154
154
|
_paused,
|
|
155
155
|
_canvas,
|
|
156
156
|
_canvasScale = 1,
|
|
@@ -176,35 +176,34 @@
|
|
|
176
176
|
T: 0,
|
|
177
177
|
MX: -1,
|
|
178
178
|
MY: -1,
|
|
179
|
-
|
|
180
|
-
HALF_PI: TWO_PI / 4,
|
|
179
|
+
TAU,
|
|
181
180
|
lerp: (start, end, t) => {
|
|
182
|
-
DEV: assert(isNumber(start), "lerp() 1st
|
|
183
|
-
DEV: assert(isNumber(end), "lerp() 2nd
|
|
184
|
-
DEV: assert(isNumber(t), "lerp() 3rd
|
|
181
|
+
DEV: assert(isNumber(start), "lerp() 1st argument must be a number");
|
|
182
|
+
DEV: assert(isNumber(end), "lerp() 2nd argument must be a number");
|
|
183
|
+
DEV: assert(isNumber(t), "lerp() 3rd argument must be a number");
|
|
185
184
|
return start + t * (end - start);
|
|
186
185
|
},
|
|
187
186
|
deg2rad: (degs) => {
|
|
188
|
-
DEV: assert(isNumber(degs), "deg2rad() 1st
|
|
187
|
+
DEV: assert(isNumber(degs), "deg2rad() 1st argument must be a number");
|
|
189
188
|
return (math.PI / 180) * degs;
|
|
190
189
|
},
|
|
191
190
|
rad2deg: (rads) => {
|
|
192
|
-
DEV: assert(isNumber(rads), "rad2deg() 1st
|
|
191
|
+
DEV: assert(isNumber(rads), "rad2deg() 1st argument must be a number");
|
|
193
192
|
return (180 / math.PI) * rads;
|
|
194
193
|
},
|
|
195
194
|
mod(a, b) {
|
|
196
|
-
DEV: assert(isNumber(a), "mod() 1st
|
|
195
|
+
DEV: assert(isNumber(a), "mod() 1st argument must be a number");
|
|
197
196
|
DEV: assert(
|
|
198
197
|
isNumber(b) && b >= 0,
|
|
199
|
-
"mod() 2nd
|
|
198
|
+
"mod() 2nd argument must be a non-negative number",
|
|
200
199
|
);
|
|
201
200
|
return ((a % b) + b) % b || 0;
|
|
202
201
|
},
|
|
203
202
|
round: (n, precision = 0) => {
|
|
204
|
-
DEV: assert(isNumber(n), "round() 1st
|
|
203
|
+
DEV: assert(isNumber(n), "round() 1st argument must be a number");
|
|
205
204
|
DEV: assert(
|
|
206
205
|
isNumber(precision) && precision >= 0,
|
|
207
|
-
"round() 2nd
|
|
206
|
+
"round() 2nd argument must be a non-negative number",
|
|
208
207
|
);
|
|
209
208
|
if (!precision) {
|
|
210
209
|
return math.round(n);
|
|
@@ -213,64 +212,64 @@
|
|
|
213
212
|
return math.round(n * multiplier) / multiplier;
|
|
214
213
|
},
|
|
215
214
|
clamp: (value, min, max) => {
|
|
216
|
-
DEV: assert(isNumber(value), "clamp() 1st
|
|
217
|
-
DEV: assert(isNumber(min), "clamp() 2nd
|
|
218
|
-
DEV: assert(isNumber(max), "clamp() 3rd
|
|
215
|
+
DEV: assert(isNumber(value), "clamp() 1st argument must be a number");
|
|
216
|
+
DEV: assert(isNumber(min), "clamp() 2nd argument must be a number");
|
|
217
|
+
DEV: assert(isNumber(max), "clamp() 3rd argument must be a number");
|
|
219
218
|
DEV: assert(
|
|
220
219
|
max >= min,
|
|
221
|
-
"clamp() the 2nd
|
|
220
|
+
"clamp() the 2nd argument must be less than the 3rd argument",
|
|
222
221
|
);
|
|
223
222
|
if (value < min) return min;
|
|
224
223
|
if (value > max) return max;
|
|
225
224
|
return value;
|
|
226
225
|
},
|
|
227
226
|
dist: (x1, y1, x2, y2) => {
|
|
228
|
-
DEV: assert(isNumber(x1), "dist() 1st
|
|
229
|
-
DEV: assert(isNumber(y1), "dist() 2nd
|
|
230
|
-
DEV: assert(isNumber(x2), "dist() 3rd
|
|
231
|
-
DEV: assert(isNumber(y2), "dist() 4th
|
|
227
|
+
DEV: assert(isNumber(x1), "dist() 1st argument must be a number");
|
|
228
|
+
DEV: assert(isNumber(y1), "dist() 2nd argument must be a number");
|
|
229
|
+
DEV: assert(isNumber(x2), "dist() 3rd argument must be a number");
|
|
230
|
+
DEV: assert(isNumber(y2), "dist() 4th argument must be a number");
|
|
232
231
|
return math.hypot(x2 - x1, y2 - y1);
|
|
233
232
|
},
|
|
234
233
|
wrap: (value, min, max) => {
|
|
235
|
-
DEV: assert(isNumber(value), "wrap() 1st
|
|
236
|
-
DEV: assert(isNumber(min), "wrap() 2nd
|
|
237
|
-
DEV: assert(isNumber(max), "wrap() 3rd
|
|
234
|
+
DEV: assert(isNumber(value), "wrap() 1st argument must be a number");
|
|
235
|
+
DEV: assert(isNumber(min), "wrap() 2nd argument must be a number");
|
|
236
|
+
DEV: assert(isNumber(max), "wrap() 3rd argument must be a number");
|
|
238
237
|
DEV: assert(
|
|
239
238
|
max > min,
|
|
240
|
-
"wrap() the 2nd
|
|
239
|
+
"wrap() the 2nd argument must be less than the 3rd argument",
|
|
241
240
|
);
|
|
242
241
|
return value - (max - min) * math.floor((value - min) / (max - min));
|
|
243
242
|
},
|
|
244
243
|
map(value, start1, stop1, start2, stop2, withinBounds) {
|
|
245
|
-
DEV: assert(isNumber(value), "map() 1st
|
|
246
|
-
DEV: assert(isNumber(start1), "map() 2nd
|
|
247
|
-
DEV: assert(isNumber(stop1), "map() 3rd
|
|
248
|
-
DEV: assert(isNumber(start2), "map() 4th
|
|
249
|
-
DEV: assert(isNumber(stop2), "map() 5th
|
|
244
|
+
DEV: assert(isNumber(value), "map() 1st argument must be a number");
|
|
245
|
+
DEV: assert(isNumber(start1), "map() 2nd argument must be a number");
|
|
246
|
+
DEV: assert(isNumber(stop1), "map() 3rd argument must be a number");
|
|
247
|
+
DEV: assert(isNumber(start2), "map() 4th argument must be a number");
|
|
248
|
+
DEV: assert(isNumber(stop2), "map() 5th argument must be a number");
|
|
250
249
|
DEV: assert(
|
|
251
250
|
stop1 !== start1,
|
|
252
|
-
"map() the 2nd
|
|
251
|
+
"map() the 2nd argument must be different than the 3rd argument",
|
|
253
252
|
);
|
|
254
253
|
const result =
|
|
255
254
|
((value - start1) / (stop1 - start1)) * (stop2 - start2) + start2;
|
|
256
255
|
return withinBounds ? instance.clamp(result, start2, stop2) : result;
|
|
257
256
|
},
|
|
258
257
|
norm: (value, start, stop) => {
|
|
259
|
-
DEV: assert(isNumber(value), "norm() 1st
|
|
260
|
-
DEV: assert(isNumber(start), "norm() 2nd
|
|
261
|
-
DEV: assert(isNumber(stop), "norm() 3rd
|
|
258
|
+
DEV: assert(isNumber(value), "norm() 1st argument must be a number");
|
|
259
|
+
DEV: assert(isNumber(start), "norm() 2nd argument must be a number");
|
|
260
|
+
DEV: assert(isNumber(stop), "norm() 3rd argument must be a number");
|
|
262
261
|
DEV: assert(
|
|
263
262
|
start !== stop,
|
|
264
|
-
"norm() the 2nd
|
|
263
|
+
"norm() the 2nd argument must be different than the 3rd argument",
|
|
265
264
|
);
|
|
266
265
|
return instance.map(value, start, stop, 0, 1);
|
|
267
266
|
},
|
|
268
267
|
rand: (min = 0, max = 1) => {
|
|
269
|
-
DEV: assert(isNumber(min), "rand() 1st
|
|
270
|
-
DEV: assert(isNumber(max), "rand() 2nd
|
|
268
|
+
DEV: assert(isNumber(min), "rand() 1st argument must be a number");
|
|
269
|
+
DEV: assert(isNumber(max), "rand() 2nd argument must be a number");
|
|
271
270
|
DEV: assert(
|
|
272
271
|
max >= min,
|
|
273
|
-
"rand() the 1st
|
|
272
|
+
"rand() the 1st argument must be less than the 2nd argument",
|
|
274
273
|
);
|
|
275
274
|
const a = 1664525;
|
|
276
275
|
const c = 1013904223;
|
|
@@ -279,25 +278,25 @@
|
|
|
279
278
|
return (_rngSeed / m) * (max - min) + min;
|
|
280
279
|
},
|
|
281
280
|
randi: (min = 0, max = 1) => {
|
|
282
|
-
DEV: assert(isNumber(min), "randi() 1st
|
|
283
|
-
DEV: assert(isNumber(max), "randi() 2nd
|
|
281
|
+
DEV: assert(isNumber(min), "randi() 1st argument must be a number");
|
|
282
|
+
DEV: assert(isNumber(max), "randi() 2nd argument must be a number");
|
|
284
283
|
DEV: assert(
|
|
285
284
|
max >= min,
|
|
286
|
-
"randi() the 1st
|
|
285
|
+
"randi() the 1st argument must be less than the 2nd argument",
|
|
287
286
|
);
|
|
288
287
|
return ~~instance.rand(min, max + 1);
|
|
289
288
|
},
|
|
290
289
|
rseed(value) {
|
|
291
290
|
DEV: assert(
|
|
292
291
|
isNumber(value) && value >= 0,
|
|
293
|
-
"rseed() 1st
|
|
292
|
+
"rseed() 1st argument must be a non-negative integer",
|
|
294
293
|
);
|
|
295
294
|
_rngSeed = ~~value;
|
|
296
295
|
},
|
|
297
296
|
cls(color) {
|
|
298
297
|
DEV: assert(
|
|
299
298
|
null == color || (isNumber(color) && color >= 0),
|
|
300
|
-
"cls() 1st
|
|
299
|
+
"cls() 1st argument must be a non-negative number",
|
|
301
300
|
);
|
|
302
301
|
if (null == color) {
|
|
303
302
|
_ctx.clearRect(0, 0, instance.W, instance.H);
|
|
@@ -306,25 +305,25 @@
|
|
|
306
305
|
}
|
|
307
306
|
},
|
|
308
307
|
rect(x, y, width, height, color, radii) {
|
|
309
|
-
DEV: assert(isNumber(x), "rect() 1st
|
|
310
|
-
DEV: assert(isNumber(y), "rect() 2nd
|
|
308
|
+
DEV: assert(isNumber(x), "rect() 1st argument must be a number");
|
|
309
|
+
DEV: assert(isNumber(y), "rect() 2nd argument must be a number");
|
|
311
310
|
DEV: assert(
|
|
312
311
|
isNumber(width) && width > 0,
|
|
313
|
-
"rect() 3rd
|
|
312
|
+
"rect() 3rd argument must be a positive number",
|
|
314
313
|
);
|
|
315
314
|
DEV: assert(
|
|
316
315
|
isNumber(height) && height >= 0,
|
|
317
|
-
"rect() 4th
|
|
316
|
+
"rect() 4th argument must be a non-negative number",
|
|
318
317
|
);
|
|
319
318
|
DEV: assert(
|
|
320
319
|
null == color || (isNumber(color) && color >= 0),
|
|
321
|
-
"rect() 5th
|
|
320
|
+
"rect() 5th argument must be a non-negative number",
|
|
322
321
|
);
|
|
323
322
|
DEV: assert(
|
|
324
323
|
null == radii ||
|
|
325
324
|
isNumber(radii) ||
|
|
326
325
|
(Array.isArray(radii) && radii.length >= 1),
|
|
327
|
-
"rect() 6th
|
|
326
|
+
"rect() 6th argument must be a number or array of numbers",
|
|
328
327
|
);
|
|
329
328
|
beginPath(_ctx);
|
|
330
329
|
_ctx[radii ? "roundRect" : "rect"](
|
|
@@ -337,102 +336,102 @@
|
|
|
337
336
|
instance.stroke(color);
|
|
338
337
|
},
|
|
339
338
|
rectfill(x, y, width, height, color, radii) {
|
|
340
|
-
DEV: assert(isNumber(x), "rectfill() 1st
|
|
341
|
-
DEV: assert(isNumber(y), "rectfill() 2nd
|
|
339
|
+
DEV: assert(isNumber(x), "rectfill() 1st argument must be a number");
|
|
340
|
+
DEV: assert(isNumber(y), "rectfill() 2nd argument must be a number");
|
|
342
341
|
DEV: assert(
|
|
343
342
|
isNumber(width) && width >= 0,
|
|
344
|
-
"rectfill() 3rd
|
|
343
|
+
"rectfill() 3rd argument must be a non-negative number",
|
|
345
344
|
);
|
|
346
345
|
DEV: assert(
|
|
347
346
|
isNumber(height) && height >= 0,
|
|
348
|
-
"rectfill() 4th
|
|
347
|
+
"rectfill() 4th argument must be a non-negative number",
|
|
349
348
|
);
|
|
350
349
|
DEV: assert(
|
|
351
350
|
null == color || (isNumber(color) && color >= 0),
|
|
352
|
-
"rectfill() 5th
|
|
351
|
+
"rectfill() 5th argument must be a non-negative number",
|
|
353
352
|
);
|
|
354
353
|
DEV: assert(
|
|
355
354
|
null == radii ||
|
|
356
355
|
isNumber(radii) ||
|
|
357
356
|
(Array.isArray(radii) && radii.length >= 1),
|
|
358
|
-
"rectfill() 6th
|
|
357
|
+
"rectfill() 6th argument must be a number or array of at least 2 numbers",
|
|
359
358
|
);
|
|
360
359
|
beginPath(_ctx);
|
|
361
360
|
_ctx[radii ? "roundRect" : "rect"](~~x, ~~y, ~~width, ~~height, radii);
|
|
362
361
|
instance.fill(color);
|
|
363
362
|
},
|
|
364
363
|
oval(x, y, radiusX, radiusY, color) {
|
|
365
|
-
DEV: assert(isNumber(x), "oval() 1st
|
|
366
|
-
DEV: assert(isNumber(y), "oval() 2nd
|
|
364
|
+
DEV: assert(isNumber(x), "oval() 1st argument must be a number");
|
|
365
|
+
DEV: assert(isNumber(y), "oval() 2nd argument must be a number");
|
|
367
366
|
DEV: assert(
|
|
368
367
|
isNumber(radiusX) && radiusX >= 0,
|
|
369
|
-
"oval() 3rd
|
|
368
|
+
"oval() 3rd argument must be a non-negative number",
|
|
370
369
|
);
|
|
371
370
|
DEV: assert(
|
|
372
371
|
isNumber(radiusY) && radiusY >= 0,
|
|
373
|
-
"oval() 4th
|
|
372
|
+
"oval() 4th argument must be a non-negative number",
|
|
374
373
|
);
|
|
375
374
|
DEV: assert(
|
|
376
375
|
null == color || (isNumber(color) && color >= 0),
|
|
377
|
-
"oval() 5th
|
|
376
|
+
"oval() 5th argument must be a non-negative number",
|
|
378
377
|
);
|
|
379
378
|
beginPath(_ctx);
|
|
380
|
-
_ctx.ellipse(~~x, ~~y, ~~radiusX, ~~radiusY, 0, 0,
|
|
379
|
+
_ctx.ellipse(~~x, ~~y, ~~radiusX, ~~radiusY, 0, 0, TAU);
|
|
381
380
|
instance.stroke(color);
|
|
382
381
|
},
|
|
383
382
|
ovalfill(x, y, radiusX, radiusY, color) {
|
|
384
|
-
DEV: assert(isNumber(x), "ovalfill() 1st
|
|
385
|
-
DEV: assert(isNumber(y), "ovalfill() 2nd
|
|
383
|
+
DEV: assert(isNumber(x), "ovalfill() 1st argument must be a number");
|
|
384
|
+
DEV: assert(isNumber(y), "ovalfill() 2nd argument must be a number");
|
|
386
385
|
DEV: assert(
|
|
387
386
|
isNumber(radiusX) && radiusX >= 0,
|
|
388
|
-
"ovalfill() 3rd
|
|
387
|
+
"ovalfill() 3rd argument must be a non-negative number",
|
|
389
388
|
);
|
|
390
389
|
DEV: assert(
|
|
391
390
|
isNumber(radiusY) && radiusY >= 0,
|
|
392
|
-
"ovalfill() 4th
|
|
391
|
+
"ovalfill() 4th argument must be a non-negative number",
|
|
393
392
|
);
|
|
394
393
|
DEV: assert(
|
|
395
394
|
null == color || (isNumber(color) && color >= 0),
|
|
396
|
-
"ovalfill() 5th
|
|
395
|
+
"ovalfill() 5th argument must be a non-negative number",
|
|
397
396
|
);
|
|
398
397
|
beginPath(_ctx);
|
|
399
|
-
_ctx.ellipse(~~x, ~~y, ~~radiusX, ~~radiusY, 0, 0,
|
|
398
|
+
_ctx.ellipse(~~x, ~~y, ~~radiusX, ~~radiusY, 0, 0, TAU);
|
|
400
399
|
instance.fill(color);
|
|
401
400
|
},
|
|
402
401
|
circ(x, y, radius, color) {
|
|
403
|
-
DEV: assert(isNumber(x), "circ() 1st
|
|
404
|
-
DEV: assert(isNumber(y), "circ() 2nd
|
|
402
|
+
DEV: assert(isNumber(x), "circ() 1st argument must be a number");
|
|
403
|
+
DEV: assert(isNumber(y), "circ() 2nd argument must be a number");
|
|
405
404
|
DEV: assert(
|
|
406
405
|
isNumber(radius) && radius >= 0,
|
|
407
|
-
"circ() 3rd
|
|
406
|
+
"circ() 3rd argument must be a non-negative number",
|
|
408
407
|
);
|
|
409
408
|
DEV: assert(
|
|
410
409
|
null == color || (isNumber(color) && color >= 0),
|
|
411
|
-
"circ() 4th
|
|
410
|
+
"circ() 4th argument must be a non-negative number",
|
|
412
411
|
);
|
|
413
412
|
instance.oval(x, y, radius, radius, color);
|
|
414
413
|
},
|
|
415
414
|
circfill(x, y, radius, color) {
|
|
416
|
-
DEV: assert(isNumber(x), "circfill() 1st
|
|
417
|
-
DEV: assert(isNumber(y), "circfill() 2nd
|
|
415
|
+
DEV: assert(isNumber(x), "circfill() 1st argument must be a number");
|
|
416
|
+
DEV: assert(isNumber(y), "circfill() 2nd argument must be a number");
|
|
418
417
|
DEV: assert(
|
|
419
418
|
isNumber(radius) && radius >= 0,
|
|
420
|
-
"circfill() 3rd
|
|
419
|
+
"circfill() 3rd argument must be a non-negative number",
|
|
421
420
|
);
|
|
422
421
|
DEV: assert(
|
|
423
422
|
null == color || (isNumber(color) && color >= 0),
|
|
424
|
-
"circfill() 4th
|
|
423
|
+
"circfill() 4th argument must be a non-negative number",
|
|
425
424
|
);
|
|
426
425
|
instance.ovalfill(x, y, radius, radius, color);
|
|
427
426
|
},
|
|
428
427
|
shape(points) {
|
|
429
428
|
DEV: assert(
|
|
430
429
|
Array.isArray(points),
|
|
431
|
-
"shape() 1st
|
|
430
|
+
"shape() 1st argument must be an array of numbers",
|
|
432
431
|
);
|
|
433
432
|
DEV: assert(
|
|
434
433
|
points.length >= 6,
|
|
435
|
-
"shape() 1st
|
|
434
|
+
"shape() 1st argument must be an array with at least 6 numbers (3 points)",
|
|
436
435
|
);
|
|
437
436
|
beginPath(_ctx);
|
|
438
437
|
for (let i = 0; i < points.length; i += 2) {
|
|
@@ -445,19 +444,19 @@
|
|
|
445
444
|
_ctx.lineTo(~~points[0], ~~points[1]);
|
|
446
445
|
},
|
|
447
446
|
line(x1, y1, x2, y2, color) {
|
|
448
|
-
DEV: assert(isNumber(x1), "line() 1st
|
|
449
|
-
DEV: assert(isNumber(y1), "line() 2nd
|
|
447
|
+
DEV: assert(isNumber(x1), "line() 1st argument must be a number");
|
|
448
|
+
DEV: assert(isNumber(y1), "line() 2nd argument must be a number");
|
|
450
449
|
DEV: assert(
|
|
451
450
|
isNumber(x2),
|
|
452
|
-
"line() 3rd
|
|
451
|
+
"line() 3rd argument must be a non-negative number",
|
|
453
452
|
);
|
|
454
453
|
DEV: assert(
|
|
455
454
|
isNumber(y2),
|
|
456
|
-
"line() 4th
|
|
455
|
+
"line() 4th argument must be a non-negative number",
|
|
457
456
|
);
|
|
458
457
|
DEV: assert(
|
|
459
458
|
null == color || (isNumber(color) && color >= 0),
|
|
460
|
-
"line() 5th
|
|
459
|
+
"line() 5th argument must be a non-negative number",
|
|
461
460
|
);
|
|
462
461
|
beginPath(_ctx);
|
|
463
462
|
let xfix = _outline_fix && ~~x1 === ~~x2 ? 0.5 : 0;
|
|
@@ -469,7 +468,7 @@
|
|
|
469
468
|
linewidth(value) {
|
|
470
469
|
DEV: assert(
|
|
471
470
|
isNumber(value) && value >= 0,
|
|
472
|
-
"linewidth() 1st
|
|
471
|
+
"linewidth() 1st argument must be a non-negative integer",
|
|
473
472
|
);
|
|
474
473
|
_ctx.lineWidth = ~~value;
|
|
475
474
|
_outline_fix = ~~value % 2 ? 0.5 : 0;
|
|
@@ -477,25 +476,25 @@
|
|
|
477
476
|
linedash(segments, offset = 0) {
|
|
478
477
|
DEV: assert(
|
|
479
478
|
Array.isArray(segments) && segments.length > 0,
|
|
480
|
-
"linedash() 1st
|
|
479
|
+
"linedash() 1st argument must be an array of numbers",
|
|
481
480
|
);
|
|
482
481
|
DEV: assert(
|
|
483
482
|
isNumber(offset),
|
|
484
|
-
"linedash() 2nd
|
|
483
|
+
"linedash() 2nd argument must be a number",
|
|
485
484
|
);
|
|
486
485
|
_ctx.setLineDash(segments);
|
|
487
486
|
_ctx.lineDashOffset = offset;
|
|
488
487
|
},
|
|
489
488
|
text(x, y, message, color = _defaultTextColor, fontStyle = "normal") {
|
|
490
|
-
DEV: assert(isNumber(x), "text() 1st
|
|
491
|
-
DEV: assert(isNumber(y), "text() 2nd
|
|
489
|
+
DEV: assert(isNumber(x), "text() 1st argument must be a number");
|
|
490
|
+
DEV: assert(isNumber(y), "text() 2nd argument must be a number");
|
|
492
491
|
DEV: assert(
|
|
493
492
|
null == color || (isNumber(color) && color >= 0),
|
|
494
|
-
"text() 4th
|
|
493
|
+
"text() 4th argument must be a non-negative number",
|
|
495
494
|
);
|
|
496
495
|
DEV: assert(
|
|
497
496
|
"string" === typeof fontStyle,
|
|
498
|
-
"text() 5th
|
|
497
|
+
"text() 5th argument must be a string",
|
|
499
498
|
);
|
|
500
499
|
_ctx.font = `${fontStyle} ${_fontSize}px ${_fontFamily}`;
|
|
501
500
|
_ctx.fillStyle = getColor(color);
|
|
@@ -509,31 +508,25 @@
|
|
|
509
508
|
}
|
|
510
509
|
},
|
|
511
510
|
textgap(value) {
|
|
512
|
-
DEV: assert(
|
|
513
|
-
isNumber(value),
|
|
514
|
-
"textgap() 1st parameter must be a number",
|
|
515
|
-
);
|
|
511
|
+
DEV: assert(isNumber(value), "textgap() 1st argument must be a number");
|
|
516
512
|
_fontLineHeight = value;
|
|
517
513
|
},
|
|
518
514
|
textfont(family) {
|
|
519
515
|
DEV: assert(
|
|
520
516
|
"string" === typeof family,
|
|
521
|
-
"textfont() 1st
|
|
517
|
+
"textfont() 1st argument must be a string",
|
|
522
518
|
);
|
|
523
519
|
_fontFamily = family;
|
|
524
520
|
},
|
|
525
521
|
textsize(size) {
|
|
526
|
-
DEV: assert(
|
|
527
|
-
isNumber(size),
|
|
528
|
-
"textsize() 1st parameter must be a number",
|
|
529
|
-
);
|
|
522
|
+
DEV: assert(isNumber(size), "textsize() 1st argument must be a number");
|
|
530
523
|
_fontSize = size;
|
|
531
524
|
},
|
|
532
525
|
textalign(align, baseline) {
|
|
533
526
|
DEV: assert(
|
|
534
527
|
null == align ||
|
|
535
528
|
["left", "right", "center", "start", "end"].includes(align),
|
|
536
|
-
"textalign() 1st
|
|
529
|
+
"textalign() 1st argument must be null or one of the following strings: center, left, right, start or end.",
|
|
537
530
|
);
|
|
538
531
|
DEV: assert(
|
|
539
532
|
null == baseline ||
|
|
@@ -545,22 +538,22 @@
|
|
|
545
538
|
"alphabetic",
|
|
546
539
|
"ideographic",
|
|
547
540
|
].includes(baseline),
|
|
548
|
-
"textalign() 2nd
|
|
541
|
+
"textalign() 2nd argument must be null or one of the following strings: middle, top, bottom, hanging, alphabetic or ideographic.",
|
|
549
542
|
);
|
|
550
543
|
if (align) _ctx.textAlign = align;
|
|
551
544
|
if (baseline) _ctx.textBaseline = baseline;
|
|
552
545
|
},
|
|
553
546
|
image(x, y, source) {
|
|
554
|
-
DEV: assert(isNumber(x), "image() 1st
|
|
555
|
-
DEV: assert(isNumber(y), "image() 2nd
|
|
547
|
+
DEV: assert(isNumber(x), "image() 1st argument must be a number");
|
|
548
|
+
DEV: assert(isNumber(y), "image() 2nd argument must be a number");
|
|
556
549
|
_ctx.drawImage(source, ~~x, ~~y);
|
|
557
550
|
},
|
|
558
551
|
spr(x, y, pixels) {
|
|
559
|
-
DEV: assert(isNumber(x), "spr() 1st
|
|
560
|
-
DEV: assert(isNumber(y), "spr() 2nd
|
|
552
|
+
DEV: assert(isNumber(x), "spr() 1st argument must be a number");
|
|
553
|
+
DEV: assert(isNumber(y), "spr() 2nd argument must be a number");
|
|
561
554
|
DEV: assert(
|
|
562
555
|
"string" === typeof pixels,
|
|
563
|
-
"spr() 3rd
|
|
556
|
+
"spr() 3rd argument must be a string",
|
|
564
557
|
);
|
|
565
558
|
const rows = pixels
|
|
566
559
|
.replace(/[^\w.\n]/g, "")
|
|
@@ -583,25 +576,25 @@
|
|
|
583
576
|
paint(width, height, callback, options = {}) {
|
|
584
577
|
DEV: assert(
|
|
585
578
|
isNumber(width) && width >= 1,
|
|
586
|
-
"paint() 1st
|
|
579
|
+
"paint() 1st argument must be a number >= 1",
|
|
587
580
|
);
|
|
588
581
|
DEV: assert(
|
|
589
582
|
isNumber(height) && height >= 1,
|
|
590
|
-
"paint() 2nd
|
|
583
|
+
"paint() 2nd argument must be a number >= 1",
|
|
591
584
|
);
|
|
592
585
|
DEV: assert(
|
|
593
586
|
"function" === typeof callback,
|
|
594
|
-
"paint() 3rd
|
|
587
|
+
"paint() 3rd argument must be a function",
|
|
595
588
|
);
|
|
596
589
|
DEV: assert(
|
|
597
590
|
(options && null == options.scale) ||
|
|
598
591
|
(isNumber(options.scale) && options.scale > 0),
|
|
599
|
-
"paint() 4th
|
|
592
|
+
"paint() 4th argument (options.scale) must be a positive number",
|
|
600
593
|
);
|
|
601
594
|
DEV: assert(
|
|
602
595
|
(options && null == options.canvas) ||
|
|
603
596
|
options.canvas instanceof OffscreenCanvas,
|
|
604
|
-
"paint() 4th
|
|
597
|
+
"paint() 4th argument (options.canvas) must be an OffscreenCanvas",
|
|
605
598
|
);
|
|
606
599
|
const canvas = options.canvas || new OffscreenCanvas(1, 1),
|
|
607
600
|
scale = options.scale || 1,
|
|
@@ -619,7 +612,7 @@
|
|
|
619
612
|
null == context ||
|
|
620
613
|
context instanceof CanvasRenderingContext2D ||
|
|
621
614
|
context instanceof OffscreenCanvasRenderingContext2D,
|
|
622
|
-
"ctx() 1st
|
|
615
|
+
"ctx() 1st argument must be an [Offscreen]CanvasRenderingContext2D",
|
|
623
616
|
);
|
|
624
617
|
if (context) {
|
|
625
618
|
_ctx = context;
|
|
@@ -635,18 +628,15 @@
|
|
|
635
628
|
) {
|
|
636
629
|
DEV: assert(
|
|
637
630
|
isNumber(translateX),
|
|
638
|
-
"push() 1st
|
|
631
|
+
"push() 1st argument must be a number",
|
|
639
632
|
);
|
|
640
633
|
DEV: assert(
|
|
641
634
|
isNumber(translateY),
|
|
642
|
-
"push() 2nd
|
|
643
|
-
);
|
|
644
|
-
DEV: assert(
|
|
645
|
-
isNumber(rotation),
|
|
646
|
-
"push() 3rd parameter must be a number",
|
|
635
|
+
"push() 2nd argument must be a number",
|
|
647
636
|
);
|
|
648
|
-
DEV: assert(isNumber(
|
|
649
|
-
DEV: assert(isNumber(
|
|
637
|
+
DEV: assert(isNumber(rotation), "push() 3rd argument must be a number");
|
|
638
|
+
DEV: assert(isNumber(scaleX), "push() 4th argument must be a number");
|
|
639
|
+
DEV: assert(isNumber(scaleY), "push() 5th argument must be a number");
|
|
650
640
|
_ctx.save();
|
|
651
641
|
instance.translate(translateX, translateY);
|
|
652
642
|
instance.rotate(rotation);
|
|
@@ -656,30 +646,30 @@
|
|
|
656
646
|
_ctx.restore();
|
|
657
647
|
},
|
|
658
648
|
translate(x, y) {
|
|
659
|
-
DEV: assert(isNumber(x), "translate() 1st
|
|
660
|
-
DEV: assert(isNumber(y), "translate() 2nd
|
|
649
|
+
DEV: assert(isNumber(x), "translate() 1st argument must be a number");
|
|
650
|
+
DEV: assert(isNumber(y), "translate() 2nd argument must be a number");
|
|
661
651
|
_ctx.translate(~~x, ~~y);
|
|
662
652
|
},
|
|
663
653
|
scale(x, y = x) {
|
|
664
|
-
DEV: assert(isNumber(x), "scale() 1st
|
|
665
|
-
DEV: assert(isNumber(y), "scale() 2nd
|
|
654
|
+
DEV: assert(isNumber(x), "scale() 1st argument must be a number");
|
|
655
|
+
DEV: assert(isNumber(y), "scale() 2nd argument must be a number");
|
|
666
656
|
_ctx.scale(x, y);
|
|
667
657
|
},
|
|
668
658
|
rotate(radians) {
|
|
669
659
|
DEV: assert(
|
|
670
660
|
isNumber(radians),
|
|
671
|
-
"rotate() 1st
|
|
661
|
+
"rotate() 1st argument must be a number",
|
|
672
662
|
);
|
|
673
663
|
_ctx.rotate(radians);
|
|
674
664
|
},
|
|
675
665
|
alpha(value) {
|
|
676
|
-
DEV: assert(isNumber(value), "alpha() 1st
|
|
666
|
+
DEV: assert(isNumber(value), "alpha() 1st argument must be a number");
|
|
677
667
|
_ctx.globalAlpha = instance.clamp(value, 0, 1);
|
|
678
668
|
},
|
|
679
669
|
fill(color) {
|
|
680
670
|
DEV: assert(
|
|
681
671
|
null == color || (isNumber(color) && color >= 0),
|
|
682
|
-
"fill() 1st
|
|
672
|
+
"fill() 1st argument must be a non-negative number",
|
|
683
673
|
);
|
|
684
674
|
_ctx.fillStyle = getColor(color);
|
|
685
675
|
_ctx.fill();
|
|
@@ -687,7 +677,7 @@
|
|
|
687
677
|
stroke(color) {
|
|
688
678
|
DEV: assert(
|
|
689
679
|
null == color || (isNumber(color) && color >= 0),
|
|
690
|
-
"stroke() 1st
|
|
680
|
+
"stroke() 1st argument must be a non-negative number",
|
|
691
681
|
);
|
|
692
682
|
_ctx.strokeStyle = getColor(color);
|
|
693
683
|
_ctx.stroke();
|
|
@@ -695,7 +685,7 @@
|
|
|
695
685
|
clip(callback) {
|
|
696
686
|
DEV: assert(
|
|
697
687
|
"function" === typeof callback,
|
|
698
|
-
"clip() 1st
|
|
688
|
+
"clip() 1st argument must be a function (ctx) => void",
|
|
699
689
|
);
|
|
700
690
|
beginPath(_ctx);
|
|
701
691
|
callback(_ctx);
|
|
@@ -704,15 +694,15 @@
|
|
|
704
694
|
sfx(zzfxParams, pitchSlide, volumeFactor) {
|
|
705
695
|
DEV: assert(
|
|
706
696
|
null == zzfxParams || Array.isArray(zzfxParams),
|
|
707
|
-
"sfx() 1st
|
|
697
|
+
"sfx() 1st argument must be an array",
|
|
708
698
|
);
|
|
709
699
|
DEV: assert(
|
|
710
700
|
null == pitchSlide || isNumber(pitchSlide),
|
|
711
|
-
"sfx() 2nd
|
|
701
|
+
"sfx() 2nd argument must be a number",
|
|
712
702
|
);
|
|
713
703
|
DEV: assert(
|
|
714
704
|
null == volumeFactor || isNumber(volumeFactor),
|
|
715
|
-
"sfx() 3rd
|
|
705
|
+
"sfx() 3rd argument must be a number",
|
|
716
706
|
);
|
|
717
707
|
if (
|
|
718
708
|
!root.zzfxV ||
|
|
@@ -732,7 +722,7 @@
|
|
|
732
722
|
volume(value) {
|
|
733
723
|
DEV: assert(
|
|
734
724
|
isNumber(value) && value >= 0,
|
|
735
|
-
"volume() 1st
|
|
725
|
+
"volume() 1st argument must be a non-negative number",
|
|
736
726
|
);
|
|
737
727
|
root.zzfxV = value;
|
|
738
728
|
},
|
|
@@ -740,22 +730,41 @@
|
|
|
740
730
|
use(callback, config = {}) {
|
|
741
731
|
DEV: assert(
|
|
742
732
|
"function" === typeof callback,
|
|
743
|
-
"use() 1st
|
|
733
|
+
"use() 1st argument must be a function (instance, config) => any",
|
|
744
734
|
);
|
|
745
735
|
DEV: assert(
|
|
746
736
|
"object" === typeof config,
|
|
747
|
-
"use() 2nd
|
|
737
|
+
"use() 2nd argument must be an object",
|
|
748
738
|
);
|
|
749
739
|
loadPlugin(callback, config);
|
|
750
740
|
},
|
|
741
|
+
resize(width, height = width, autoscale) {
|
|
742
|
+
DEV: assert(
|
|
743
|
+
isNumber(width) && width >= 1,
|
|
744
|
+
"resize() 1st argument must be a number >= 1",
|
|
745
|
+
);
|
|
746
|
+
DEV: assert(
|
|
747
|
+
isNumber(height) && height >= 1,
|
|
748
|
+
"resize() 2nd argument must be a number >= 1",
|
|
749
|
+
);
|
|
750
|
+
DEV: assert(
|
|
751
|
+
null == autoscale ||
|
|
752
|
+
"boolean" === typeof autoscale ||
|
|
753
|
+
(isNumber(autoscale) && autoscale > 1),
|
|
754
|
+
"resize() 3rd argument must be a boolean or a number > 1",
|
|
755
|
+
);
|
|
756
|
+
settings.height = height;
|
|
757
|
+
settings.autoscale = null == autoscale ? settings.autoscale : autoscale;
|
|
758
|
+
resizeCanvas();
|
|
759
|
+
},
|
|
751
760
|
listen: (eventName, callback) => {
|
|
752
761
|
DEV: assert(
|
|
753
762
|
"string" === typeof eventName,
|
|
754
|
-
"listen() 1st
|
|
763
|
+
"listen() 1st argument must be a string",
|
|
755
764
|
);
|
|
756
765
|
DEV: assert(
|
|
757
766
|
"function" === typeof callback,
|
|
758
|
-
"listen() 2nd
|
|
767
|
+
"listen() 2nd argument must be a function",
|
|
759
768
|
);
|
|
760
769
|
eventName = lowerCase(eventName);
|
|
761
770
|
_eventListeners[eventName] = _eventListeners[eventName] || new Set();
|
|
@@ -764,11 +773,11 @@
|
|
|
764
773
|
unlisten: (eventName, callback) => {
|
|
765
774
|
DEV: assert(
|
|
766
775
|
"string" === typeof eventName,
|
|
767
|
-
"unlisten() 1st
|
|
776
|
+
"unlisten() 1st argument must be a string",
|
|
768
777
|
);
|
|
769
778
|
DEV: assert(
|
|
770
779
|
"function" === typeof callback,
|
|
771
|
-
"unlisten() 2nd
|
|
780
|
+
"unlisten() 2nd argument must be a function",
|
|
772
781
|
);
|
|
773
782
|
eventName = lowerCase(eventName);
|
|
774
783
|
if (_eventListeners[eventName]) {
|
|
@@ -778,7 +787,7 @@
|
|
|
778
787
|
emit(eventName, arg1, arg2, arg3, arg4) {
|
|
779
788
|
DEV: assert(
|
|
780
789
|
"string" === typeof eventName,
|
|
781
|
-
"emit() 1st
|
|
790
|
+
"emit() 1st argument must be a string",
|
|
782
791
|
);
|
|
783
792
|
if (_initialized) {
|
|
784
793
|
eventName = lowerCase(eventName);
|
|
@@ -798,11 +807,11 @@
|
|
|
798
807
|
pal(colors, textColor = 3) {
|
|
799
808
|
DEV: assert(
|
|
800
809
|
null == colors || (Array.isArray(colors) && colors.length > 0),
|
|
801
|
-
"pal() 1st
|
|
810
|
+
"pal() 1st argument must be null or an array of colors",
|
|
802
811
|
);
|
|
803
812
|
DEV: assert(
|
|
804
813
|
isNumber(textColor) && textColor >= 0,
|
|
805
|
-
"pal() 2nd
|
|
814
|
+
"pal() 2nd argument must be a non-negative number",
|
|
806
815
|
);
|
|
807
816
|
_colorPalette = colors || defaultPalette;
|
|
808
817
|
_colorPaletteState = [];
|
|
@@ -812,11 +821,11 @@
|
|
|
812
821
|
palc(a, b) {
|
|
813
822
|
DEV: assert(
|
|
814
823
|
null == a || (isNumber(a) && a >= 0),
|
|
815
|
-
"palc() 1st
|
|
824
|
+
"palc() 1st argument must be a positive number",
|
|
816
825
|
);
|
|
817
826
|
DEV: assert(
|
|
818
827
|
isNumber(a) ? isNumber(b) && b >= 0 : null == b,
|
|
819
|
-
"palc() 2nd
|
|
828
|
+
"palc() 2nd argument must be a positive number",
|
|
820
829
|
);
|
|
821
830
|
if (null == a) {
|
|
822
831
|
_colorPaletteState = [];
|
|
@@ -827,7 +836,7 @@
|
|
|
827
836
|
def(key, value) {
|
|
828
837
|
DEV: assert(
|
|
829
838
|
"string" === typeof key,
|
|
830
|
-
"def() 1st
|
|
839
|
+
"def() 1st argument must be a string",
|
|
831
840
|
);
|
|
832
841
|
DEV: if (null == value) {
|
|
833
842
|
console.warn(
|
|
@@ -842,19 +851,19 @@
|
|
|
842
851
|
timescale(value) {
|
|
843
852
|
DEV: assert(
|
|
844
853
|
isNumber(value) && value >= 0,
|
|
845
|
-
"timescale() 1st
|
|
854
|
+
"timescale() 1st argument must be a non-negative number",
|
|
846
855
|
);
|
|
847
856
|
_timeScale = value;
|
|
848
857
|
},
|
|
849
858
|
framerate(value) {
|
|
850
859
|
DEV: assert(
|
|
851
860
|
isNumber(value) && value >= 1,
|
|
852
|
-
"framerate() 1st
|
|
861
|
+
"framerate() 1st argument must be a number >= 1",
|
|
853
862
|
);
|
|
854
863
|
_fpsInterval = 1e3 / ~~value;
|
|
855
864
|
},
|
|
856
865
|
stat(index) {
|
|
857
|
-
DEV: assert(isNumber(index), "stat() 1st
|
|
866
|
+
DEV: assert(isNumber(index), "stat() 1st argument must be a number");
|
|
858
867
|
const internals = [
|
|
859
868
|
settings,
|
|
860
869
|
_initialized,
|
|
@@ -873,11 +882,14 @@
|
|
|
873
882
|
];
|
|
874
883
|
DEV: assert(
|
|
875
884
|
index >= 0 && index < internals.length,
|
|
876
|
-
"stat() 1st
|
|
885
|
+
"stat() 1st argument must be a number between 0 and " +
|
|
877
886
|
(internals.length - 1),
|
|
878
887
|
);
|
|
879
888
|
return internals[index];
|
|
880
889
|
},
|
|
890
|
+
ispaused() {
|
|
891
|
+
return _paused;
|
|
892
|
+
},
|
|
881
893
|
pause() {
|
|
882
894
|
if (!_paused) {
|
|
883
895
|
_paused = true;
|
|
@@ -896,9 +908,6 @@
|
|
|
896
908
|
instance.emit("resumed");
|
|
897
909
|
}
|
|
898
910
|
},
|
|
899
|
-
ispaused() {
|
|
900
|
-
return _paused;
|
|
901
|
-
},
|
|
902
911
|
quit() {
|
|
903
912
|
instance.emit("quit");
|
|
904
913
|
instance.pause();
|
|
@@ -1031,9 +1040,9 @@
|
|
|
1031
1040
|
const _keysPress = new Set();
|
|
1032
1041
|
const keyCheck = (keySet, key = "") => {
|
|
1033
1042
|
key = lowerCase(key);
|
|
1034
|
-
return
|
|
1035
|
-
? keySet.
|
|
1036
|
-
: keySet.
|
|
1043
|
+
return key
|
|
1044
|
+
? keySet.has("space" === key ? " " : key)
|
|
1045
|
+
: keySet.size > 0;
|
|
1037
1046
|
};
|
|
1038
1047
|
let _lastKey = "";
|
|
1039
1048
|
on(root, "keydown", (event) => {
|
|
@@ -1052,14 +1061,14 @@
|
|
|
1052
1061
|
instance.def("iskeydown", (key) => {
|
|
1053
1062
|
DEV: assert(
|
|
1054
1063
|
null == key || "string" === typeof key,
|
|
1055
|
-
"iskeydown() 1st
|
|
1064
|
+
"iskeydown() 1st argument must be a string",
|
|
1056
1065
|
);
|
|
1057
1066
|
return keyCheck(_keysDown, key);
|
|
1058
1067
|
});
|
|
1059
1068
|
instance.def("iskeypressed", (key) => {
|
|
1060
1069
|
DEV: assert(
|
|
1061
1070
|
null == key || "string" === typeof key,
|
|
1062
|
-
"iskeypressed() 1st
|
|
1071
|
+
"iskeypressed() 1st argument must be a string",
|
|
1063
1072
|
);
|
|
1064
1073
|
return keyCheck(_keysPress, key);
|
|
1065
1074
|
});
|
|
@@ -1110,11 +1119,9 @@
|
|
|
1110
1119
|
);
|
|
1111
1120
|
_ctx = _canvas.getContext("2d");
|
|
1112
1121
|
on(_canvas, "click", () => focus());
|
|
1113
|
-
resizeCanvas();
|
|
1114
1122
|
if (!_canvas.parentNode) {
|
|
1115
1123
|
d.body.appendChild(_canvas);
|
|
1116
1124
|
}
|
|
1117
|
-
_canvas.style.imageRendering = "pixelated";
|
|
1118
1125
|
_canvas.oncontextmenu = () => false;
|
|
1119
1126
|
}
|
|
1120
1127
|
function resizeCanvas() {
|
|
@@ -1132,6 +1139,11 @@
|
|
|
1132
1139
|
null == settings.height || (settings.width > 0 && settings.height > 0),
|
|
1133
1140
|
'litecanvas() option "width" is required when the option "height" is defined',
|
|
1134
1141
|
);
|
|
1142
|
+
DEV: assert(
|
|
1143
|
+
"boolean" === typeof settings.autoscale ||
|
|
1144
|
+
(isNumber(settings.autoscale) && settings.autoscale > 1),
|
|
1145
|
+
'litecanvas() option "autoscale" must be boolean or a number > 1',
|
|
1146
|
+
);
|
|
1135
1147
|
const width = settings.width > 0 ? settings.width : innerWidth,
|
|
1136
1148
|
height =
|
|
1137
1149
|
settings.width > 0 ? settings.height || settings.width : innerHeight;
|
|
@@ -1139,6 +1151,7 @@
|
|
|
1139
1151
|
instance.def("H", height);
|
|
1140
1152
|
_canvas.width = width;
|
|
1141
1153
|
_canvas.height = height;
|
|
1154
|
+
_canvas.style = "image-rendering:pixelated";
|
|
1142
1155
|
if (settings.autoscale) {
|
|
1143
1156
|
let maxScale = +settings.autoscale;
|
|
1144
1157
|
if (!_canvas.style.display) {
|
|
@@ -1186,6 +1199,7 @@
|
|
|
1186
1199
|
DEV: console.info(`[litecanvas] version ${version} started`);
|
|
1187
1200
|
DEV: console.debug(`[litecanvas] litecanvas() options =`, settings);
|
|
1188
1201
|
setupCanvas();
|
|
1202
|
+
resizeCanvas();
|
|
1189
1203
|
if (_loop) {
|
|
1190
1204
|
for (const eventName in _loop) {
|
|
1191
1205
|
if (_loop[eventName]) instance.listen(eventName, _loop[eventName]);
|