littlejsengine 1.13.1 → 1.13.4
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 +15 -12
- package/dist/littlejs.d.ts +94 -74
- package/dist/littlejs.esm.js +422 -306
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +416 -306
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +414 -304
- package/examples/box2d/game.js +1 -1
- package/examples/box2d/gameObjects.js +1 -1
- package/examples/box2d/scenes.js +1 -1
- package/examples/breakoutTutorial/README.md +44 -41
- package/examples/breakoutTutorial/game.js +2 -2
- package/examples/electron/build.bat +7 -0
- package/examples/electron/build.js +124 -0
- package/examples/electron/electron.js +35 -0
- package/examples/electron/game.js +140 -0
- package/examples/electron/index.html +13 -0
- package/examples/electron/package.json +12 -0
- package/examples/electron/tiles.png +0 -0
- package/examples/empty/game.js +1 -0
- package/examples/htmlMenu/game.js +1 -1
- package/examples/index.html +154 -93
- package/examples/module/game.js +5 -2
- package/examples/particles/index.html +12 -3
- package/examples/platformer/gameEffects.js +3 -3
- package/examples/shorts/base.html +1 -1
- package/examples/shorts/blending.js +9 -5
- package/examples/shorts/box2d.js +1 -1
- package/examples/shorts/box2dCar.js +1 -1
- package/examples/shorts/clock.js +1 -1
- package/examples/shorts/colors.js +2 -2
- package/examples/shorts/maze.js +1 -1
- package/examples/shorts/nineSlice.js +9 -9
- package/examples/shorts/piano.js +2 -2
- package/examples/shorts/raycasting.js +2 -2
- package/examples/shorts/shapes.js +9 -9
- package/examples/shorts/slidingPuzzle.js +2 -2
- package/examples/shorts/starfield.js +5 -7
- package/examples/shorts/systemFont.js +1 -1
- package/examples/shorts/uiSystem.js +1 -0
- package/examples/starter/build.js +9 -8
- package/examples/starter/game.js +5 -2
- package/examples/starter/index.html +2 -2
- package/examples/stress/index.html +5 -5
- package/examples/style.css +5 -2
- package/examples/typescript/build.js +1 -1
- package/examples/typescript/game.js +2 -2
- package/examples/typescript/game.ts +5 -2
- package/examples/uiSystem/game.js +2 -1
- package/package.json +2 -2
- package/plugins/box2d.js +19 -94
- package/plugins/drawUtilities.js +24 -18
- package/plugins/postProcess.js +7 -0
- package/plugins/uiSystem.js +4 -4
- package/src/engine.js +7 -2
- package/src/engineAudio.js +1 -1
- package/src/engineDebug.js +2 -2
- package/src/engineDraw.js +243 -150
- package/src/engineExport.js +6 -0
- package/src/engineInput.js +2 -2
- package/src/engineMedals.js +4 -4
- package/src/engineObject.js +3 -3
- package/src/engineParticles.js +8 -1
- package/src/engineSettings.js +55 -8
- package/src/engineUtilities.js +7 -7
- package/src/engineWebGL.js +25 -5
package/README.md
CHANGED
|
@@ -36,27 +36,28 @@ LittleJS is a small but powerful game engine with many features and no dependenc
|
|
|
36
36
|
|
|
37
37
|
### ✨ Graphics
|
|
38
38
|
|
|
39
|
-
- Super fast
|
|
40
|
-
-
|
|
41
|
-
- Apply [Shadertoy](https://www.shadertoy.com)
|
|
39
|
+
- Super fast WebGL2 + Canvas2D hybrid rendering
|
|
40
|
+
- 100,000+ sprites at solid 60fps
|
|
41
|
+
- Apply [Shadertoy](https://www.shadertoy.com) style shaders for post-processing effects
|
|
42
42
|
- Robust particle effect system and [effect design tool](https://killedbyapixel.github.io/LittleJS/examples/particles/)
|
|
43
43
|
|
|
44
44
|
### 🔊 Audio
|
|
45
45
|
|
|
46
|
-
- Positional sound effects with
|
|
46
|
+
- Positional sound effects with distance falloff
|
|
47
47
|
- Use [ZzFX](https://killedbyapixel.github.io/ZzFX/) sound effect generator to play sounds without asset files
|
|
48
|
-
- Music with mp3, ogg, wave, or [ZzFXM](https://keithclark.github.io/ZzFXM/)
|
|
48
|
+
- Music and sound with mp3, ogg, wave, or [ZzFXM](https://keithclark.github.io/ZzFXM/)
|
|
49
49
|
|
|
50
50
|
### 🎮 Input
|
|
51
51
|
|
|
52
52
|
- Comprehensive input handling for keyboard, mouse, gamepad, and touch
|
|
53
|
+
- Automatic touch mouse emulation
|
|
53
54
|
- On screen touch gamepad designed for mobile devices
|
|
54
55
|
|
|
55
56
|
### 💥 Physics
|
|
56
57
|
|
|
57
58
|
- Robust arcade physics system with collision handling
|
|
58
|
-
-
|
|
59
|
-
-
|
|
59
|
+
- Box2d fully integrated for more realistic physics
|
|
60
|
+
- Tilemap collision with raycasting
|
|
60
61
|
|
|
61
62
|
### 🚀 Flexibility
|
|
62
63
|
|
|
@@ -65,11 +66,12 @@ LittleJS is a small but powerful game engine with many features and no dependenc
|
|
|
65
66
|
- Ideal for size coding competitions like [Js13kGames](https://js13kgames.com/)
|
|
66
67
|
- Open Source with the [MIT license](https://github.com/KilledByAPixel/LittleJS/blob/main/LICENSE) so it can be used for anything you want forever
|
|
67
68
|
|
|
68
|
-
### 🛠️
|
|
69
|
+
### 🛠️ Developer Tools
|
|
69
70
|
|
|
70
|
-
-
|
|
71
|
-
- 2D vector math library
|
|
71
|
+
- Live example browser with code editor
|
|
72
72
|
- Debug primitive rendering system
|
|
73
|
+
- Screenshot and video capture tools
|
|
74
|
+
- Node.js build system
|
|
73
75
|
- Bitmap font rendering and built in engine font
|
|
74
76
|
- Medal tracking system with [Newgrounds](https://www.newgrounds.com/) support
|
|
75
77
|
|
|
@@ -119,8 +121,9 @@ The starter example project includes a node js file [build.js](https://github.co
|
|
|
119
121
|
Here are a few of the many amazing games created with LittleJS...
|
|
120
122
|
|
|
121
123
|
- [Space Huggers](https://www.newgrounds.com/portal/view/819609) - Rogulike platformer shoot-em-up game with procedural levels. by [KilledByAPixel](https://frankforce.com/)
|
|
122
|
-
- [
|
|
124
|
+
- [L1ttl3 Paws](https://github.com/KilledByAPixel/JS13K2025) - Cat glider with procedural art and levels for JS13K! by [KilledByAPixel](https://frankforce.com/)
|
|
123
125
|
- [The Way of the Dodo](https://js13kgames.com/2024/games/the-way-of-the-dodo) - Single button platformer. JS13k 5th place winner! by [repsej](https://github.com/repsej)
|
|
126
|
+
- [Undergrowth](https://undergrowth.squidband.uk/) - An interactive music videogame for the band Squid. by [KilledByAPixel](https://frankforce.com/)
|
|
124
127
|
- [204Snake!](https://www.newgrounds.com/portal/view/960100) - A puzzle game that combines 2048 with snake. LittleJS Jam 1st place winner! by [Sodoj](https://sodoj.itch.io/) and [Shai-P](https://shai-p.itch.io/)
|
|
125
128
|
- [GATOR](https://www.newgrounds.com/portal/view/960757) - Retro platformer shooter game where you rescue animals. LittleJS Jam 2nd place winner! by [eoinmcg](https://eoinmcg.itch.io/)
|
|
126
129
|
- [A Hedgehog's search](https://willsm1111.itch.io/a-hedgehogs-search) - Adventure game staring a hedgehog. LittleJS Jam 3rd place winner! by [willsm1111](https://willsm1111.itch.io/)
|
|
@@ -142,4 +145,4 @@ Here are a few of the many amazing games created with LittleJS...
|
|
|
142
145
|
[deepscan]: https://deepscan.io/api/teams/22950/projects/26229/branches/831487/badge/grade.svg
|
|
143
146
|
[deepscan-url]: https://deepscan.io/dashboard#view=project&tid=22950&pid=26229&bid=831487
|
|
144
147
|
[discord]: https://img.shields.io/discord/939926111469568050
|
|
145
|
-
[discord-url]: https://discord.gg/zb7hcGkyZe
|
|
148
|
+
[discord-url]: https://discord.gg/zb7hcGkyZe
|
package/dist/littlejs.d.ts
CHANGED
|
@@ -262,6 +262,12 @@ declare module "littlejsengine" {
|
|
|
262
262
|
* @default
|
|
263
263
|
* @memberof Settings */
|
|
264
264
|
export let cameraScale: number;
|
|
265
|
+
/** Enable applying color to tiles when using canvas2d
|
|
266
|
+
* - This is slower but should be the same as webgl rendering
|
|
267
|
+
* @type {boolean}
|
|
268
|
+
* @default
|
|
269
|
+
* @memberof Settings */
|
|
270
|
+
export let canvasColorTiles: boolean;
|
|
265
271
|
/** The max size of the canvas, centered if window is larger
|
|
266
272
|
* @type {Vector2}
|
|
267
273
|
* @default Vector2(1920,1080)
|
|
@@ -273,13 +279,19 @@ declare module "littlejsengine" {
|
|
|
273
279
|
* @default Vector2()
|
|
274
280
|
* @memberof Settings */
|
|
275
281
|
export let canvasFixedSize: Vector2;
|
|
276
|
-
/** Use nearest
|
|
277
|
-
* - Must be set before startup to take effect
|
|
282
|
+
/** Use nearest canvas scaling for more pixelated look
|
|
278
283
|
* - If enabled sets css image-rendering:pixelated
|
|
279
284
|
* @type {boolean}
|
|
280
285
|
* @default
|
|
281
286
|
* @memberof Settings */
|
|
282
287
|
export let canvasPixelated: boolean;
|
|
288
|
+
/** Use nearest canvas scaling for more pixelated look
|
|
289
|
+
* - If enabled sets css image-rendering:pixelated
|
|
290
|
+
* - This defaults to false because text looks better with smoothing
|
|
291
|
+
* @type {boolean}
|
|
292
|
+
* @default
|
|
293
|
+
* @memberof Settings */
|
|
294
|
+
export let overlayCanvasPixelated: boolean;
|
|
283
295
|
/** Disables texture filtering for crisper pixel art
|
|
284
296
|
* @type {boolean}
|
|
285
297
|
* @default
|
|
@@ -451,6 +463,13 @@ declare module "littlejsengine" {
|
|
|
451
463
|
* @param {number} scale
|
|
452
464
|
* @memberof Settings */
|
|
453
465
|
export function setCameraScale(scale: number): void;
|
|
466
|
+
/** Set if tiles should be colorized when using canvas2d
|
|
467
|
+
* This can be slower but results should look nearly identical to webgl rendering
|
|
468
|
+
* It can be enabled/disabled at any time
|
|
469
|
+
* Optimized for performance, and will use faster method if color is white or untextured
|
|
470
|
+
* @param {boolean} colorTiles
|
|
471
|
+
* @memberof Settings */
|
|
472
|
+
export function setCanvasColorTiles(colorTiles: boolean): void;
|
|
454
473
|
/** Set max size of the canvas
|
|
455
474
|
* @param {Vector2} size
|
|
456
475
|
* @memberof Settings */
|
|
@@ -459,10 +478,17 @@ declare module "littlejsengine" {
|
|
|
459
478
|
* @param {Vector2} size
|
|
460
479
|
* @memberof Settings */
|
|
461
480
|
export function setCanvasFixedSize(size: Vector2): void;
|
|
462
|
-
/** Use nearest
|
|
481
|
+
/** Use nearest scaling algorithm for canvas for more pixelated look
|
|
482
|
+
* - If enabled sets css image-rendering:pixelated
|
|
463
483
|
* @param {boolean} pixelated
|
|
464
484
|
* @memberof Settings */
|
|
465
485
|
export function setCanvasPixelated(pixelated: boolean): void;
|
|
486
|
+
/** Use nearest scaling algorithm for canvas for more pixelated look
|
|
487
|
+
* - If enabled sets css image-rendering:pixelated
|
|
488
|
+
* - This defaults to false because text looks better with smoothing
|
|
489
|
+
* @param {boolean} pixelated
|
|
490
|
+
* @memberof Settings */
|
|
491
|
+
export function setOverlayCanvasPixelated(pixelated: boolean): void;
|
|
466
492
|
/** Disables texture filtering for crisper pixel art
|
|
467
493
|
* @param {boolean} pixelated
|
|
468
494
|
* @memberof Settings */
|
|
@@ -703,10 +729,11 @@ declare module "littlejsengine" {
|
|
|
703
729
|
* @memberof Utilities */
|
|
704
730
|
export function nearestPowerOfTwo(value: number): number;
|
|
705
731
|
/** Returns true if two axis aligned bounding boxes are overlapping
|
|
732
|
+
* this can be used for simple collision detection between objects
|
|
706
733
|
* @param {Vector2} posA - Center of box A
|
|
707
734
|
* @param {Vector2} sizeA - Size of box A
|
|
708
735
|
* @param {Vector2} posB - Center of box B
|
|
709
|
-
* @param {Vector2} [sizeB=(0,0)] - Size of box B, a point if undefined
|
|
736
|
+
* @param {Vector2} [sizeB=(0,0)] - Size of box B, uses a point if undefined
|
|
710
737
|
* @return {boolean} - True if overlapping
|
|
711
738
|
* @memberof Utilities */
|
|
712
739
|
export function isOverlapping(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB?: Vector2): boolean;
|
|
@@ -722,9 +749,10 @@ declare module "littlejsengine" {
|
|
|
722
749
|
* @param {number} [frequency] - Frequency of the wave in Hz
|
|
723
750
|
* @param {number} [amplitude] - Amplitude (max height) of the wave
|
|
724
751
|
* @param {number} [t=time] - Value to use for time of the wave
|
|
752
|
+
* @param {number} [offset] - Value to use for time offset of the wave
|
|
725
753
|
* @return {number} - Value waving between 0 and amplitude
|
|
726
754
|
* @memberof Utilities */
|
|
727
|
-
export function wave(frequency?: number, amplitude?: number, t?: number): number;
|
|
755
|
+
export function wave(frequency?: number, amplitude?: number, t?: number, offset?: number): number;
|
|
728
756
|
/** Formats seconds to mm:ss style for display purposes
|
|
729
757
|
* @param {number} t - time in seconds
|
|
730
758
|
* @return {string}
|
|
@@ -1126,6 +1154,20 @@ declare module "littlejsengine" {
|
|
|
1126
1154
|
* @memberof Utilities
|
|
1127
1155
|
*/
|
|
1128
1156
|
export function isColor(c: any): boolean;
|
|
1157
|
+
/**
|
|
1158
|
+
* Check if object is a valid Vector2
|
|
1159
|
+
* @param {any} v
|
|
1160
|
+
* @return {boolean}
|
|
1161
|
+
* @memberof Utilities
|
|
1162
|
+
*/
|
|
1163
|
+
export function isVector2(v: any): boolean;
|
|
1164
|
+
/**
|
|
1165
|
+
* Check if object is a valid number, not NaN or undefined, but it may be infinite
|
|
1166
|
+
* @param {any} n
|
|
1167
|
+
* @return {boolean}
|
|
1168
|
+
* @memberof Utilities
|
|
1169
|
+
*/
|
|
1170
|
+
export function isNumber(n: any): boolean;
|
|
1129
1171
|
/** Color - White #ffffff
|
|
1130
1172
|
* @type {Color}
|
|
1131
1173
|
* @memberof Utilities */
|
|
@@ -1186,10 +1228,10 @@ declare module "littlejsengine" {
|
|
|
1186
1228
|
* Create a tile info object using a grid based system
|
|
1187
1229
|
* - This can take vecs or floats for easier use and conversion
|
|
1188
1230
|
* - If an index is passed in, the tile size and index will determine the position
|
|
1189
|
-
* @param {Vector2|number} [pos=0]
|
|
1231
|
+
* @param {Vector2|number} [pos=0] - Index of tile in sheet
|
|
1190
1232
|
* @param {Vector2|number} [size=tileSizeDefault] - Size of tile in pixels
|
|
1191
|
-
* @param {number} [textureIndex]
|
|
1192
|
-
* @param {number} [padding]
|
|
1233
|
+
* @param {number} [textureIndex] - Texture index to use
|
|
1234
|
+
* @param {number} [padding] - How many pixels padding around tiles
|
|
1193
1235
|
* @return {TileInfo}
|
|
1194
1236
|
* @example
|
|
1195
1237
|
* tile(2) // a tile at index 2 using the default tile size of 16
|
|
@@ -1326,7 +1368,7 @@ declare module "littlejsengine" {
|
|
|
1326
1368
|
* @param {Color} [color=(1,1,1,1)]
|
|
1327
1369
|
* @param {number} [angle]
|
|
1328
1370
|
* @param {boolean} [useWebGL=glEnable]
|
|
1329
|
-
* @param {boolean} [screenSpace
|
|
1371
|
+
* @param {boolean} [screenSpace]
|
|
1330
1372
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1331
1373
|
* @memberof Draw */
|
|
1332
1374
|
export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
@@ -1335,42 +1377,48 @@ declare module "littlejsengine" {
|
|
|
1335
1377
|
* @param {Vector2} posB
|
|
1336
1378
|
* @param {number} [thickness]
|
|
1337
1379
|
* @param {Color} [color=(1,1,1,1)]
|
|
1380
|
+
* @param {Vector2} [pos=(0,0)] - Offset to apply
|
|
1381
|
+
* @param {number} [angle] - Angle to rotate by
|
|
1338
1382
|
* @param {boolean} [useWebGL=glEnable]
|
|
1339
|
-
* @param {boolean} [screenSpace
|
|
1383
|
+
* @param {boolean} [screenSpace]
|
|
1340
1384
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1341
1385
|
* @memberof Draw */
|
|
1342
|
-
export function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1386
|
+
export function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, pos?: Vector2, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1343
1387
|
/** Draw colored polygon using passed in points
|
|
1344
|
-
* @param {Array<Vector2>}
|
|
1388
|
+
* @param {Array<Vector2>} points - Array of Vector2 points
|
|
1345
1389
|
* @param {Color} [color=(1,1,1,1)]
|
|
1346
|
-
* @param {number} [lineWidth
|
|
1390
|
+
* @param {number} [lineWidth]
|
|
1347
1391
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1348
|
-
* @param {
|
|
1392
|
+
* @param {Vector2} [pos=(0,0)] - Offset to apply
|
|
1393
|
+
* @param {number} [angle] - Angle to rotate by
|
|
1394
|
+
* @param {boolean} [useWebGL] - Webgl not supported
|
|
1395
|
+
* @param {boolean} [screenSpace]
|
|
1349
1396
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1350
1397
|
* @memberof Draw */
|
|
1351
|
-
export function drawPoly(points: Array<Vector2>, color?: Color, lineWidth?: number, lineColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1398
|
+
export function drawPoly(points: Array<Vector2>, color?: Color, lineWidth?: number, lineColor?: Color, pos?: Vector2, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1352
1399
|
/** Draw colored ellipse using passed in point
|
|
1353
1400
|
* @param {Vector2} pos
|
|
1354
|
-
* @param {
|
|
1355
|
-
* @param {number} [height=1]
|
|
1356
|
-
* @param {number} [angle=0]
|
|
1401
|
+
* @param {Vector2} [size=(1,1)]
|
|
1357
1402
|
* @param {Color} [color=(1,1,1,1)]
|
|
1358
|
-
* @param {number} [
|
|
1403
|
+
* @param {number} [angle]
|
|
1404
|
+
* @param {number} [lineWidth]
|
|
1359
1405
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1360
|
-
* @param {boolean} [
|
|
1406
|
+
* @param {boolean} [useWebGL] - Webgl not supported
|
|
1407
|
+
* @param {boolean} [screenSpace]
|
|
1361
1408
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1362
1409
|
* @memberof Draw */
|
|
1363
|
-
export function drawEllipse(pos: Vector2,
|
|
1410
|
+
export function drawEllipse(pos: Vector2, size?: Vector2, color?: Color, angle?: number, lineWidth?: number, lineColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1364
1411
|
/** Draw colored circle using passed in point
|
|
1365
1412
|
* @param {Vector2} pos
|
|
1366
1413
|
* @param {number} [radius=1]
|
|
1367
1414
|
* @param {Color} [color=(1,1,1,1)]
|
|
1368
1415
|
* @param {number} [lineWidth=0]
|
|
1369
1416
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1417
|
+
* @param {boolean} [useWebGL] - Webgl not supported
|
|
1370
1418
|
* @param {boolean} [screenSpace=false]
|
|
1371
1419
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1372
1420
|
* @memberof Draw */
|
|
1373
|
-
export function drawCircle(pos: Vector2, radius?: number, color?: Color, lineWidth?: number, lineColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1421
|
+
export function drawCircle(pos: Vector2, radius?: number, color?: Color, lineWidth?: number, lineColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1374
1422
|
/** Draw directly to a 2d canvas context in world space
|
|
1375
1423
|
* @param {Vector2} pos
|
|
1376
1424
|
* @param {Vector2} size
|
|
@@ -1424,10 +1472,9 @@ declare module "littlejsengine" {
|
|
|
1424
1472
|
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1425
1473
|
/** Enable normal or additive blend mode
|
|
1426
1474
|
* @param {boolean} [additive]
|
|
1427
|
-
* @param {boolean} [useWebGL=glEnable]
|
|
1428
1475
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1429
1476
|
* @memberof Draw */
|
|
1430
|
-
export function setBlendMode(additive?: boolean,
|
|
1477
|
+
export function setBlendMode(additive?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1431
1478
|
/** Combines all LittleJS canvases onto the main canvas and clears them
|
|
1432
1479
|
* This is necessary for things like saving a screenshot
|
|
1433
1480
|
* @memberof Draw */
|
|
@@ -1490,12 +1537,13 @@ declare module "littlejsengine" {
|
|
|
1490
1537
|
/**
|
|
1491
1538
|
* LittleJS WebGL Interface
|
|
1492
1539
|
* - All webgl used by the engine is wrapped up here
|
|
1540
|
+
* - Will fall back to 2D canvas rendering if webgl is not supported
|
|
1493
1541
|
* - For normal stuff you won't need to see or call anything in this file
|
|
1494
1542
|
* - For advanced stuff there are helper functions to create shaders, textures, etc
|
|
1495
1543
|
* - Can be disabled with glEnable to revert to 2D canvas rendering
|
|
1496
1544
|
* - Batches sprite rendering on GPU for incredibly fast performance
|
|
1497
1545
|
* - Sprite transform math is done in the shader where possible
|
|
1498
|
-
* - Supports shadertoy style post processing shaders
|
|
1546
|
+
* - Supports shadertoy style post processing shaders via plugin
|
|
1499
1547
|
* @namespace WebGL
|
|
1500
1548
|
*/
|
|
1501
1549
|
/** The WebGL canvas which appears above the main canvas and below the overlay canvas
|
|
@@ -2972,42 +3020,10 @@ declare module "littlejsengine" {
|
|
|
2972
3020
|
* @param {Vector2} pos
|
|
2973
3021
|
* @param {number} angle
|
|
2974
3022
|
* @param {Color} [color]
|
|
2975
|
-
* @param {Color} [
|
|
2976
|
-
* @param {number} [lineWidth]
|
|
2977
|
-
* @param {CanvasRenderingContext2D} [context] */
|
|
2978
|
-
drawFixture(fixture: any, pos: Vector2, angle: number, color?: Color, outlineColor?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
2979
|
-
/** draws a circle
|
|
2980
|
-
* @param {Vector2} pos
|
|
2981
|
-
* @param {number} radius
|
|
2982
|
-
* @param {Color} [color]
|
|
2983
|
-
* @param {Color} [outlineColor]
|
|
2984
|
-
* @param {number} [lineWidth]
|
|
2985
|
-
* @param {CanvasRenderingContext2D} [context] */
|
|
2986
|
-
drawCircle(pos: Vector2, radius: number, color?: Color, outlineColor?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
2987
|
-
/** draws a polygon
|
|
2988
|
-
* @param {Vector2} pos
|
|
2989
|
-
* @param {number} angle
|
|
2990
|
-
* @param {Array<Vector2>} points
|
|
2991
|
-
* @param {Color} [color]
|
|
2992
|
-
* @param {Color} [outlineColor]
|
|
3023
|
+
* @param {Color} [lineColor]
|
|
2993
3024
|
* @param {number} [lineWidth]
|
|
2994
3025
|
* @param {CanvasRenderingContext2D} [context] */
|
|
2995
|
-
|
|
2996
|
-
/** draws a line
|
|
2997
|
-
* @param {Vector2} pos
|
|
2998
|
-
* @param {number} angle
|
|
2999
|
-
* @param {Vector2} posA
|
|
3000
|
-
* @param {Vector2} posB
|
|
3001
|
-
* @param {Color} [color]
|
|
3002
|
-
* @param {number} [lineWidth]
|
|
3003
|
-
* @param {CanvasRenderingContext2D} [context] */
|
|
3004
|
-
drawLine(pos: Vector2, angle: number, posA: Vector2, posB: Vector2, color?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
3005
|
-
/** performs a fill or stroke as a helper to the other draw functions
|
|
3006
|
-
* @param {Color} [color]
|
|
3007
|
-
* @param {Color} [outlineColor]
|
|
3008
|
-
* @param {number} [lineWidth]
|
|
3009
|
-
* @param {CanvasRenderingContext2D} [context] */
|
|
3010
|
-
drawFillStroke(color?: Color, outlineColor?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
3026
|
+
drawFixture(fixture: any, pos: Vector2, angle: number, color?: Color, lineColor?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
3011
3027
|
/** converts a box2d vec2 to a Vector2
|
|
3012
3028
|
* @param {Object} v */
|
|
3013
3029
|
vec2From(v: any): Vector2;
|
|
@@ -3042,13 +3058,13 @@ declare module "littlejsengine" {
|
|
|
3042
3058
|
* @param {number} [renderOrder] */
|
|
3043
3059
|
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, bodyType?: number, renderOrder?: number);
|
|
3044
3060
|
body: any;
|
|
3045
|
-
|
|
3061
|
+
lineColor: Color;
|
|
3046
3062
|
/** Draws all this object's fixtures
|
|
3047
3063
|
* @param {Color} [color]
|
|
3048
|
-
* @param {Color} [
|
|
3064
|
+
* @param {Color} [lineColor]
|
|
3049
3065
|
* @param {number} [lineWidth]
|
|
3050
3066
|
* @param {CanvasRenderingContext2D} [context] */
|
|
3051
|
-
drawFixtures(color?: Color,
|
|
3067
|
+
drawFixtures(color?: Color, lineColor?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
3052
3068
|
/** Called when a contact begins
|
|
3053
3069
|
* @param {Box2dObject} otherObject */
|
|
3054
3070
|
beginContact(otherObject: Box2dObject): void;
|
|
@@ -3797,14 +3813,15 @@ declare module "littlejsengine" {
|
|
|
3797
3813
|
* @param {Vector2} size - World space size
|
|
3798
3814
|
* @param {TileInfo} startTile - Starting tile for the nine-slice pattern
|
|
3799
3815
|
* @param {Color} [color] - Color to modulate with
|
|
3800
|
-
* @param {number} [borderSize
|
|
3816
|
+
* @param {number} [borderSize] - Width of the border sections
|
|
3801
3817
|
* @param {Color} [additiveColor] - Additive color
|
|
3802
|
-
* @param {number} [extraSpace
|
|
3818
|
+
* @param {number} [extraSpace] - Extra spacing adjustment
|
|
3819
|
+
* @param {number} [angle] - Angle to rotate by
|
|
3803
3820
|
* @param {boolean} [useWebGL=glEnable] - Use WebGL for rendering
|
|
3804
3821
|
* @param {boolean} [screenSpace] - Use screen space coordinates
|
|
3805
3822
|
* @param {CanvasRenderingContext2D} [context] - Canvas context to use
|
|
3806
3823
|
* @memberof DrawUtilities */
|
|
3807
|
-
export function drawNineSlice(pos: Vector2, size: Vector2, startTile: TileInfo, color?: Color, borderSize?: number, additiveColor?: Color, extraSpace?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
3824
|
+
export function drawNineSlice(pos: Vector2, size: Vector2, startTile: TileInfo, color?: Color, borderSize?: number, additiveColor?: Color, extraSpace?: number, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
3808
3825
|
/**
|
|
3809
3826
|
* LittleJS Drawing Utilities Plugin
|
|
3810
3827
|
* - Extra drawing functions for LittleJS
|
|
@@ -3816,31 +3833,34 @@ declare module "littlejsengine" {
|
|
|
3816
3833
|
* @param {Vector2} pos - Screen space position
|
|
3817
3834
|
* @param {Vector2} size - Screen space size
|
|
3818
3835
|
* @param {TileInfo} startTile - Starting tile for the nine-slice pattern
|
|
3819
|
-
* @param {number} [borderSize
|
|
3820
|
-
* @param {number} [extraSpace
|
|
3836
|
+
* @param {number} [borderSize] - Width of the border sections
|
|
3837
|
+
* @param {number} [extraSpace] - Extra spacing adjustment
|
|
3838
|
+
* @param {number} [angle] - Angle to rotate by
|
|
3821
3839
|
* @memberof DrawUtilities */
|
|
3822
|
-
export function drawNineSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, borderSize?: number, extraSpace?: number): void;
|
|
3840
|
+
export function drawNineSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, borderSize?: number, extraSpace?: number, angle?: number): void;
|
|
3823
3841
|
/** Draw a scalable three-slice UI element in world space
|
|
3824
3842
|
* This function can apply color and additive color if webgl is enabled
|
|
3825
3843
|
* @param {Vector2} pos - World space position
|
|
3826
3844
|
* @param {Vector2} size - World space size
|
|
3827
3845
|
* @param {TileInfo} startTile - Starting tile for the three-slice pattern
|
|
3828
3846
|
* @param {Color} [color] - Color to modulate with
|
|
3829
|
-
* @param {number} [borderSize
|
|
3847
|
+
* @param {number} [borderSize] - Width of the border sections
|
|
3830
3848
|
* @param {Color} [additiveColor] - Additive color
|
|
3831
|
-
* @param {number} [extraSpace
|
|
3849
|
+
* @param {number} [extraSpace] - Extra spacing adjustment
|
|
3850
|
+
* @param {number} [angle] - Angle to rotate by
|
|
3832
3851
|
* @param {boolean} [useWebGL=glEnable] - Use WebGL for rendering
|
|
3833
3852
|
* @param {boolean} [screenSpace] - Use screen space coordinates
|
|
3834
3853
|
* @param {CanvasRenderingContext2D} [context] - Canvas context to use
|
|
3835
3854
|
* @memberof DrawUtilities */
|
|
3836
|
-
export function drawThreeSlice(pos: Vector2, size: Vector2, startTile: TileInfo, color?: Color, borderSize?: number, additiveColor?: Color, extraSpace?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
3855
|
+
export function drawThreeSlice(pos: Vector2, size: Vector2, startTile: TileInfo, color?: Color, borderSize?: number, additiveColor?: Color, extraSpace?: number, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
3837
3856
|
/** Draw a scalable three-slice UI element to the overlay canvas in screen space
|
|
3838
3857
|
* This function can not apply color because it draws using the overlay 2d context
|
|
3839
3858
|
* @param {Vector2} pos - Screen space position
|
|
3840
3859
|
* @param {Vector2} size - Screen space size
|
|
3841
3860
|
* @param {TileInfo} startTile - Starting tile for the three-slice pattern
|
|
3842
|
-
* @param {number} [borderSize
|
|
3843
|
-
* @param {number} [extraSpace
|
|
3861
|
+
* @param {number} [borderSize] - Width of the border sections
|
|
3862
|
+
* @param {number} [extraSpace] - Extra spacing adjustment
|
|
3863
|
+
* @param {number} [angle] - Angle to rotate by
|
|
3844
3864
|
* @memberof DrawUtilities */
|
|
3845
|
-
export function drawThreeSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, borderSize?: number, extraSpace?: number): void;
|
|
3865
|
+
export function drawThreeSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, borderSize?: number, extraSpace?: number, angle?: number): void;
|
|
3846
3866
|
}
|