melonjs 15.2.1 → 15.4.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 -1
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
- package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
- package/dist/melonjs.mjs/_virtual/howler.js +1 -1
- package/dist/melonjs.mjs/_virtual/index.js +1 -1
- package/dist/melonjs.mjs/application/application.js +75 -23
- package/dist/melonjs.mjs/application/header.js +2 -2
- package/dist/melonjs.mjs/application/resize.js +13 -11
- package/dist/melonjs.mjs/application/settings.js +37 -1
- package/dist/melonjs.mjs/audio/audio.js +4 -6
- package/dist/melonjs.mjs/camera/camera2d.js +12 -14
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +3 -4
- package/dist/melonjs.mjs/geometries/ellipse.js +26 -59
- package/dist/melonjs.mjs/geometries/line.js +18 -25
- package/dist/melonjs.mjs/geometries/path2d.js +16 -13
- package/dist/melonjs.mjs/geometries/point.js +8 -16
- package/dist/melonjs.mjs/geometries/poly.js +40 -97
- package/dist/melonjs.mjs/geometries/rectangle.js +37 -91
- package/dist/melonjs.mjs/geometries/roundrect.js +26 -35
- package/dist/melonjs.mjs/index.js +6 -6
- package/dist/melonjs.mjs/input/gamepad.js +1 -1
- package/dist/melonjs.mjs/input/input.js +1 -1
- package/dist/melonjs.mjs/input/keyboard.js +3 -3
- package/dist/melonjs.mjs/input/pointer.js +4 -4
- package/dist/melonjs.mjs/input/pointerevent.js +6 -7
- package/dist/melonjs.mjs/lang/console.js +1 -1
- package/dist/melonjs.mjs/lang/deprecated.js +2 -2
- package/dist/melonjs.mjs/level/level.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +16 -33
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +3 -4
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +4 -4
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +4 -7
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +37 -47
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +3 -3
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
- package/dist/melonjs.mjs/loader/cache.js +1 -1
- package/dist/melonjs.mjs/loader/loader.js +1 -1
- package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +4 -5
- package/dist/melonjs.mjs/loader/settings.js +1 -1
- package/dist/melonjs.mjs/math/color.js +5 -5
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +5 -59
- package/dist/melonjs.mjs/math/matrix3.js +82 -141
- package/dist/melonjs.mjs/math/observable_vector2.js +7 -7
- package/dist/melonjs.mjs/math/observable_vector3.js +5 -5
- package/dist/melonjs.mjs/math/vector2.js +7 -91
- package/dist/melonjs.mjs/math/vector3.js +6 -90
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
- package/dist/melonjs.mjs/particles/emitter.js +2 -2
- package/dist/melonjs.mjs/particles/particle.js +2 -2
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +22 -20
- package/dist/melonjs.mjs/physics/bounds.js +27 -33
- package/dist/melonjs.mjs/physics/collision.js +5 -5
- package/dist/melonjs.mjs/physics/detector.js +10 -10
- package/dist/melonjs.mjs/physics/quadtree.js +5 -5
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +3 -4
- package/dist/melonjs.mjs/physics/world.js +6 -9
- package/dist/melonjs.mjs/plugin/plugin.js +3 -3
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +4 -4
- package/dist/melonjs.mjs/renderable/container.js +25 -25
- package/dist/melonjs.mjs/renderable/draggable.js +1 -1
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +4 -4
- package/dist/melonjs.mjs/renderable/light2d.js +3 -3
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
- package/dist/melonjs.mjs/renderable/renderable.js +31 -39
- package/dist/melonjs.mjs/renderable/sprite.js +3 -3
- package/dist/melonjs.mjs/renderable/text/bitmaptext.js +421 -0
- package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +195 -0
- package/dist/melonjs.mjs/renderable/text/glyph.js +65 -0
- package/dist/melonjs.mjs/renderable/text/text.js +422 -0
- package/dist/melonjs.mjs/renderable/text/textmetrics.js +175 -0
- package/dist/melonjs.mjs/renderable/text/textstyle.js +21 -0
- package/dist/melonjs.mjs/renderable/trigger.js +10 -10
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +7 -7
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +7 -7
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +3 -3
- package/dist/melonjs.mjs/state/stage.js +13 -14
- package/dist/melonjs.mjs/state/state.js +4 -51
- package/dist/melonjs.mjs/system/device.js +51 -10
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +46 -2
- package/dist/melonjs.mjs/system/platform.js +18 -18
- package/dist/melonjs.mjs/system/pooling.js +10 -10
- package/dist/melonjs.mjs/system/save.js +1 -1
- package/dist/melonjs.mjs/system/timer.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptext.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptextdata.js +3 -6
- package/dist/melonjs.mjs/text/glyph.js +1 -1
- package/dist/melonjs.mjs/text/text.js +1 -1
- package/dist/melonjs.mjs/text/textmetrics.js +1 -1
- package/dist/melonjs.mjs/text/textstyle.js +1 -1
- package/dist/melonjs.mjs/tweens/easing.js +1 -1
- package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
- package/dist/melonjs.mjs/tweens/tween.js +2 -2
- package/dist/melonjs.mjs/utils/agent.js +1 -1
- package/dist/melonjs.mjs/utils/array.js +1 -1
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +2 -3
- package/dist/melonjs.mjs/utils/string.js +1 -1
- package/dist/melonjs.mjs/utils/utils.js +1 -1
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +5 -18
- package/dist/melonjs.mjs/video/renderer.js +17 -30
- package/dist/melonjs.mjs/video/texture/atlas.js +13 -13
- package/dist/melonjs.mjs/video/texture/cache.js +1 -1
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +15 -15
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +5 -29
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +13 -14
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +2 -3
- package/dist/melonjs.mjs/video/webgl/glshader.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +4 -4
- package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +62 -67
- package/dist/melonjs.module.js +1272 -1713
- package/dist/types/application/application.d.ts +32 -31
- package/dist/types/application/header.d.ts +2 -2
- package/dist/types/application/settings.d.ts +80 -16
- package/dist/types/audio/audio.d.ts +4 -6
- package/dist/types/camera/camera2d.d.ts +13 -16
- package/dist/types/entity/entity.d.ts +0 -1
- package/dist/types/geometries/ellipse.d.ts +18 -50
- package/dist/types/geometries/path2d.d.ts +1 -1
- package/dist/types/geometries/point.d.ts +5 -13
- package/dist/types/geometries/poly.d.ts +26 -75
- package/dist/types/geometries/rectangle.d.ts +12 -58
- package/dist/types/geometries/roundrect.d.ts +2 -11
- package/dist/types/index.d.ts +3 -3
- package/dist/types/input/gamepad.d.ts +31 -31
- package/dist/types/input/keyboard.d.ts +105 -105
- package/dist/types/input/pointer.d.ts +21 -21
- package/dist/types/input/pointerevent.d.ts +6 -6
- package/dist/types/level/tiled/TMXLayer.d.ts +1 -1
- package/dist/types/level/tiled/TMXUtils.d.ts +4 -6
- package/dist/types/math/matrix2.d.ts +9 -63
- package/dist/types/math/matrix3.d.ts +9 -68
- package/dist/types/math/observable_vector2.d.ts +2 -2
- package/dist/types/math/observable_vector3.d.ts +2 -2
- package/dist/types/math/vector2.d.ts +8 -92
- package/dist/types/math/vector3.d.ts +8 -92
- package/dist/types/particles/settings.d.ts +29 -29
- package/dist/types/physics/body.d.ts +10 -8
- package/dist/types/physics/bounds.d.ts +24 -30
- package/dist/types/physics/collision.d.ts +12 -12
- package/dist/types/physics/detector.d.ts +1 -1
- package/dist/types/physics/world.d.ts +4 -7
- package/dist/types/renderable/container.d.ts +19 -19
- package/dist/types/renderable/imagelayer.d.ts +6 -6
- package/dist/types/renderable/light2d.d.ts +7 -7
- package/dist/types/renderable/renderable.d.ts +10 -18
- package/dist/types/renderable/text/bitmaptext.d.ts +151 -0
- package/dist/types/renderable/text/bitmaptextdata.d.ts +35 -0
- package/dist/types/renderable/text/glyph.d.ts +28 -0
- package/dist/types/renderable/text/text.d.ts +159 -0
- package/dist/types/renderable/text/textmetrics.d.ts +47 -0
- package/dist/types/renderable/text/textstyle.d.ts +5 -0
- package/dist/types/renderable/ui/uibaseelement.d.ts +0 -1
- package/dist/types/renderable/ui/uispriteelement.d.ts +0 -1
- package/dist/types/renderable/ui/uitextbutton.d.ts +2 -7
- package/dist/types/state/stage.d.ts +3 -2
- package/dist/types/state/state.d.ts +11 -11
- package/dist/types/system/device.d.ts +16 -9
- package/dist/types/system/event.d.ts +40 -0
- package/dist/types/system/platform.d.ts +17 -17
- package/dist/types/utils/function.d.ts +1 -2
- package/dist/types/video/canvas/canvas_renderer.d.ts +0 -23
- package/dist/types/video/renderer.d.ts +16 -43
- package/dist/types/video/texture/canvas_texture.d.ts +14 -14
- package/dist/types/video/video.d.ts +4 -38
- package/dist/types/video/webgl/buffer/vertex.d.ts +2 -2
- package/dist/types/video/webgl/compositors/compositor.d.ts +24 -13
- package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +0 -1
- package/dist/types/video/webgl/compositors/quad_compositor.d.ts +0 -1
- package/dist/types/video/webgl/utils/precision.d.ts +1 -1
- package/dist/types/video/webgl/webgl_renderer.d.ts +48 -84
- package/package.json +15 -15
- package/src/application/application.js +73 -21
- package/src/application/header.js +1 -1
- package/src/application/resize.js +11 -9
- package/src/application/settings.js +36 -0
- package/src/audio/audio.js +3 -5
- package/src/camera/camera2d.js +11 -13
- package/src/entity/entity.js +2 -3
- package/src/geometries/ellipse.js +25 -58
- package/src/geometries/line.js +17 -24
- package/src/geometries/path2d.js +15 -12
- package/src/geometries/point.js +7 -15
- package/src/geometries/poly.js +39 -96
- package/src/geometries/rectangle.js +36 -90
- package/src/geometries/roundrect.js +25 -34
- package/src/index.js +4 -4
- package/src/input/keyboard.js +2 -2
- package/src/input/pointer.js +3 -3
- package/src/input/pointerevent.js +5 -6
- package/src/lang/deprecated.js +1 -1
- package/src/level/tiled/TMXLayer.js +15 -32
- package/src/level/tiled/TMXObject.js +2 -3
- package/src/level/tiled/TMXTile.js +3 -3
- package/src/level/tiled/TMXTileMap.js +2 -2
- package/src/level/tiled/TMXTileset.js +3 -6
- package/src/level/tiled/TMXTilesetGroup.js +1 -1
- package/src/level/tiled/TMXUtils.js +36 -46
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/src/loader/parser.js +3 -4
- package/src/math/color.js +4 -4
- package/src/math/matrix2.js +4 -58
- package/src/math/matrix3.js +81 -140
- package/src/math/observable_vector2.js +6 -6
- package/src/math/observable_vector3.js +4 -4
- package/src/math/vector2.js +6 -90
- package/src/math/vector3.js +5 -89
- package/src/particles/emitter.js +1 -1
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +21 -19
- package/src/physics/bounds.js +26 -32
- package/src/physics/collision.js +4 -4
- package/src/physics/detector.js +9 -9
- package/src/physics/quadtree.js +4 -4
- package/src/physics/sat.js +2 -3
- package/src/physics/world.js +5 -8
- package/src/polyfill/roundrect.js +163 -163
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/colorlayer.js +3 -3
- package/src/renderable/container.js +24 -24
- package/src/renderable/imagelayer.js +3 -3
- package/src/renderable/light2d.js +2 -2
- package/src/renderable/nineslicesprite.js +1 -1
- package/src/renderable/renderable.js +30 -38
- package/src/renderable/sprite.js +2 -2
- package/src/{text → renderable/text}/bitmaptext.js +8 -8
- package/src/{text → renderable/text}/bitmaptextdata.js +4 -7
- package/src/{text → renderable/text}/glyph.js +1 -1
- package/src/{text → renderable/text}/text.js +16 -17
- package/src/{text → renderable/text}/textmetrics.js +2 -2
- package/src/renderable/trigger.js +9 -9
- package/src/renderable/ui/uibaseelement.js +6 -6
- package/src/renderable/ui/uispriteelement.js +6 -6
- package/src/renderable/ui/uitextbutton.js +2 -2
- package/src/state/stage.js +12 -13
- package/src/state/state.js +2 -61
- package/src/system/device.js +50 -9
- package/src/system/event.js +44 -0
- package/src/system/platform.js +18 -18
- package/src/system/pooling.js +9 -9
- package/src/tweens/tween.js +1 -1
- package/src/utils/function.js +1 -2
- package/src/video/canvas/canvas_renderer.js +4 -17
- package/src/video/renderer.js +16 -29
- package/src/video/texture/atlas.js +12 -12
- package/src/video/texture/canvas_texture.js +14 -14
- package/src/video/video.js +7 -28
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/compositors/compositor.js +12 -13
- package/src/video/webgl/compositors/primitive_compositor.js +4 -4
- package/src/video/webgl/compositors/quad_compositor.js +1 -2
- package/src/video/webgl/glshader.js +1 -1
- package/src/video/webgl/utils/precision.js +3 -3
- package/src/video/webgl/webgl_renderer.js +61 -66
- /package/src/{text → renderable/text}/textstyle.js +0 -0
package/src/video/video.js
CHANGED
|
@@ -10,6 +10,7 @@ import { throttle } from "../utils/function.js";
|
|
|
10
10
|
/**
|
|
11
11
|
* Select the HTML5 Canvas renderer
|
|
12
12
|
* @memberof video
|
|
13
|
+
* @name CANVAS
|
|
13
14
|
* @static
|
|
14
15
|
*/
|
|
15
16
|
export { CANVAS } from "../const";
|
|
@@ -17,6 +18,7 @@ export { CANVAS } from "../const";
|
|
|
17
18
|
/**
|
|
18
19
|
* Select the WebGL renderer
|
|
19
20
|
* @memberof video
|
|
21
|
+
* @name WEBGL
|
|
20
22
|
* @static
|
|
21
23
|
*/
|
|
22
24
|
export { WEBGL } from "../const";
|
|
@@ -24,6 +26,7 @@ export { WEBGL } from "../const";
|
|
|
24
26
|
/**
|
|
25
27
|
* Auto-select the renderer (Attempt WebGL first, with fallback to Canvas)
|
|
26
28
|
* @memberof video
|
|
29
|
+
* @name AUTO
|
|
27
30
|
* @static
|
|
28
31
|
*/
|
|
29
32
|
export { AUTO } from "../const";
|
|
@@ -37,34 +40,10 @@ export let renderer = null;
|
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* Initialize the "video" system (create a canvas based on the given arguments, and the related renderer). <br>
|
|
40
|
-
* melonJS support various scaling mode, that can be enabled <u>once the scale option is set to <b>`auto`</b></u> : <br>
|
|
41
|
-
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
42
|
-
* <center><img src="images/scale-fit.png"/></center><br>
|
|
43
|
-
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
44
|
-
* <center><img src="images/scale-fill-min.png"/></center><br>
|
|
45
|
-
* - <i><b>`fill-max`</b></i> : Canvas is resized to fit maximum design resolution; content is scaled to design aspect ratio <br>
|
|
46
|
-
* <center><img src="images/scale-fill-max.png"/></center><br>
|
|
47
|
-
* - <i><b>`flex`</b><</i> : Canvas width & height is resized to fit; content is scaled to design aspect ratio <br>
|
|
48
|
-
* <center><img src="images/scale-flex.png"/></center><br>
|
|
49
|
-
* - <i><b>`flex-width`</b></i> : Canvas width is resized to fit; content is scaled to design aspect ratio <br>
|
|
50
|
-
* <center><img src="images/scale-flex-width.png"/></center><br>
|
|
51
|
-
* - <i><b>`flex-height`</b></i> : Canvas height is resized to fit; content is scaled to design aspect ratio <br>
|
|
52
|
-
* <center><img src="images/scale-flex-height.png"/></center><br>
|
|
53
|
-
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio
|
|
54
|
-
* <center><img src="images/scale-stretch.png"/></center><br>
|
|
55
43
|
* @memberof video
|
|
56
44
|
* @param {number} width - The width of the canvas viewport
|
|
57
45
|
* @param {number} height - The height of the canvas viewport
|
|
58
|
-
* @param {
|
|
59
|
-
* @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
60
|
-
* @param {number|Renderer} [options.renderer=video.AUTO] - renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO), or a custom renderer class
|
|
61
|
-
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
62
|
-
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
63
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
64
|
-
* @param {string} [options.powerPreference="default"] - a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
|
|
65
|
-
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
66
|
-
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
67
|
-
* @param {boolean} [options.consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
46
|
+
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
68
47
|
* @returns {boolean} false if initialization failed (canvas not supported)
|
|
69
48
|
* @example
|
|
70
49
|
* // init the video with a 640x480 canvas
|
|
@@ -82,7 +61,7 @@ export function init(width, height, options) {
|
|
|
82
61
|
}
|
|
83
62
|
|
|
84
63
|
try {
|
|
85
|
-
|
|
64
|
+
// initialize the default game Application with the given options
|
|
86
65
|
game.init(width, height, options);
|
|
87
66
|
} catch (e) {
|
|
88
67
|
console.log(e.message);
|
|
@@ -144,7 +123,7 @@ export function init(width, height, options) {
|
|
|
144
123
|
* @param {number} width - width
|
|
145
124
|
* @param {number} height - height
|
|
146
125
|
* @param {boolean} [returnOffscreenCanvas=false] - will return an OffscreenCanvas if supported
|
|
147
|
-
* @returns {HTMLCanvasElement|OffscreenCanvas}
|
|
126
|
+
* @returns {HTMLCanvasElement|OffscreenCanvas} a new Canvas element of the given size
|
|
148
127
|
*/
|
|
149
128
|
export function createCanvas(width, height, returnOffscreenCanvas = false) {
|
|
150
129
|
let _canvas;
|
|
@@ -173,7 +152,7 @@ export function createCanvas(width, height, returnOffscreenCanvas = false) {
|
|
|
173
152
|
/**
|
|
174
153
|
* return a reference to the parent DOM element holding the main canvas
|
|
175
154
|
* @memberof video
|
|
176
|
-
* @returns {HTMLElement}
|
|
155
|
+
* @returns {HTMLElement} the HTML parent element
|
|
177
156
|
*/
|
|
178
157
|
export function getParent() {
|
|
179
158
|
return game.getParentElement();
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @ignore
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export default class VertexArrayBuffer {
|
|
9
9
|
|
|
10
10
|
constructor(vertex_size, vertex_per_obj) {
|
|
11
11
|
// the size of one vertex in float
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
* @ignore
|
|
39
39
|
*/
|
|
40
40
|
isFull(vertex = this.objSize) {
|
|
41
|
-
|
|
41
|
+
return (this.vertexCount + vertex >= this.maxVertex);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -5,19 +5,19 @@ import GLShader from "../glshader.js";
|
|
|
5
5
|
* @classdesc
|
|
6
6
|
* A base Compositor object.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
export default class Compositor {
|
|
9
9
|
/**
|
|
10
10
|
* @param {WebGLRenderer} renderer - the current WebGL renderer session
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {object[]} attribute - an array of attributes definition
|
|
13
|
-
* @param {string} attribute.name - name of the attribute in the vertex shader
|
|
14
|
-
* @param {number} attribute.size - number of components per vertex attribute. Must be 1, 2, 3, or 4.
|
|
15
|
-
* @param {GLenum} attribute.type - data type of each component in the array
|
|
16
|
-
* @param {boolean} attribute.normalized - whether integer data values should be normalized into a certain range when being cast to a float
|
|
17
|
-
* @param {number} attribute.offset - offset in bytes of the first component in the vertex attribute array
|
|
18
|
-
* @param {object} shader - an array of attributes definition
|
|
19
|
-
* @param {string} shader.vertex - a string containing the GLSL source code to set
|
|
20
|
-
* @param {string} shader.fragment - a string containing the GLSL source code to set
|
|
11
|
+
* @param {object} settings - additional settings to initialize this compositors
|
|
12
|
+
* @param {object[]} settings.attribute - an array of attributes definition
|
|
13
|
+
* @param {string} settings.attribute.name - name of the attribute in the vertex shader
|
|
14
|
+
* @param {number} settings.attribute.size - number of components per vertex attribute. Must be 1, 2, 3, or 4.
|
|
15
|
+
* @param {GLenum} settings.attribute.type - data type of each component in the array
|
|
16
|
+
* @param {boolean} settings.attribute.normalized - whether integer data values should be normalized into a certain range when being cast to a float
|
|
17
|
+
* @param {number} settings.attribute.offset - offset in bytes of the first component in the vertex attribute array
|
|
18
|
+
* @param {object} settings.shader - an array of attributes definition
|
|
19
|
+
* @param {string} settings.shader.vertex - a string containing the GLSL source code to set
|
|
20
|
+
* @param {string} settings.shader.fragment - a string containing the GLSL source code to set
|
|
21
21
|
*/
|
|
22
22
|
constructor (renderer, settings) {
|
|
23
23
|
this.init(renderer, settings);
|
|
@@ -119,7 +119,6 @@ import GLShader from "../glshader.js";
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
|
-
* @ignore
|
|
123
122
|
* called by the WebGL renderer when a compositor become the current one
|
|
124
123
|
*/
|
|
125
124
|
bind() {
|
|
@@ -192,7 +191,7 @@ import GLShader from "../glshader.js";
|
|
|
192
191
|
|
|
193
192
|
/**
|
|
194
193
|
* set/change the current projection matrix
|
|
195
|
-
* @param {Matrix3d} matrix
|
|
194
|
+
* @param {Matrix3d} matrix - the new projection matrix
|
|
196
195
|
*/
|
|
197
196
|
setProjection(matrix) {
|
|
198
197
|
this.currentShader.setUniform("uProjectionMatrix", matrix);
|
|
@@ -8,7 +8,7 @@ import Compositor from "./compositor.js";
|
|
|
8
8
|
* Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU
|
|
9
9
|
* @augments Compositor
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
export default class PrimitiveCompositor extends Compositor {
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Initialize the compositor
|
|
@@ -35,8 +35,8 @@ import Compositor from "./compositor.js";
|
|
|
35
35
|
drawVertices(mode, verts, vertexCount = verts.length) {
|
|
36
36
|
let viewMatrix = this.viewMatrix;
|
|
37
37
|
let vertexData = this.vertexData;
|
|
38
|
-
let color = this.renderer.currentColor;
|
|
39
38
|
let alpha = this.renderer.getGlobalAlpha();
|
|
39
|
+
let colorUint32 = this.renderer.currentColor.toUint32(alpha);
|
|
40
40
|
|
|
41
41
|
if (vertexData.isFull(vertexCount)) {
|
|
42
42
|
// is the vertex buffer full if we add more vertices
|
|
@@ -52,11 +52,11 @@ import Compositor from "./compositor.js";
|
|
|
52
52
|
if (!viewMatrix.isIdentity()) {
|
|
53
53
|
verts.forEach((vert) => {
|
|
54
54
|
viewMatrix.apply(vert);
|
|
55
|
-
vertexData.push(vert.x, vert.y, undefined, undefined,
|
|
55
|
+
vertexData.push(vert.x, vert.y, undefined, undefined, colorUint32);
|
|
56
56
|
});
|
|
57
57
|
} else {
|
|
58
58
|
verts.forEach((vert) => {
|
|
59
|
-
vertexData.push(vert.x, vert.y, undefined, undefined,
|
|
59
|
+
vertexData.push(vert.x, vert.y, undefined, undefined, colorUint32);
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -18,7 +18,7 @@ let V_ARRAY = [
|
|
|
18
18
|
* Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU
|
|
19
19
|
* @augments Compositor
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
export default class QuadCompositor extends Compositor {
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Initialize the compositor
|
|
@@ -108,7 +108,6 @@ let V_ARRAY = [
|
|
|
108
108
|
/**
|
|
109
109
|
* delete the given WebGL texture
|
|
110
110
|
* @param {WebGLTexture} [texture] - a WebGL texture to delete
|
|
111
|
-
* @param {number} [unit] - Texture unit to delete
|
|
112
111
|
*/
|
|
113
112
|
deleteTexture2D(texture) {
|
|
114
113
|
this.gl.deleteTexture(texture);
|
|
@@ -9,7 +9,7 @@ import { minify } from "./utils/string.js";
|
|
|
9
9
|
* @classdesc
|
|
10
10
|
* a base GL Shader object
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
export default class GLShader {
|
|
13
13
|
/**
|
|
14
14
|
* @param {WebGLRenderingContext} gl - the current WebGL rendering context
|
|
15
15
|
* @param {string} vertex - a string containing the GLSL source code to set
|
|
@@ -13,17 +13,17 @@ export function setPrecision(src, precision) {
|
|
|
13
13
|
/**
|
|
14
14
|
* return the highest precision format supported by this device for GL Shaders
|
|
15
15
|
* @ignore
|
|
16
|
-
* @param {WebGLRenderingContext} gl
|
|
16
|
+
* @param {WebGLRenderingContext} gl - the current WebGL context
|
|
17
17
|
* @returns {boolean} "lowp", "mediump", or "highp"
|
|
18
18
|
*/
|
|
19
19
|
export function getMaxShaderPrecision(gl) {
|
|
20
20
|
if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&
|
|
21
21
|
gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0) {
|
|
22
|
-
|
|
22
|
+
return "highp";
|
|
23
23
|
}
|
|
24
24
|
if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 &&
|
|
25
25
|
gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0) {
|
|
26
|
-
|
|
26
|
+
return "mediump";
|
|
27
27
|
}
|
|
28
28
|
return "lowp";
|
|
29
29
|
}
|
|
@@ -15,23 +15,9 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
15
15
|
* a WebGL renderer object
|
|
16
16
|
* @augments Renderer
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
export default class WebGLRenderer extends Renderer {
|
|
19
19
|
/**
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {number} options.width - The width of the canvas without scaling
|
|
22
|
-
* @param {number} options.height - The height of the canvas without scaling
|
|
23
|
-
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
24
|
-
* @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing
|
|
25
|
-
* @param {boolean} [options.failIfMajorPerformanceCaveat=true] - If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
|
|
26
|
-
* @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas
|
|
27
|
-
* @param {boolean} [options.premultipliedAlpha=true] - in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
|
|
28
|
-
* @param {boolean} [options.subPixel=false] - Whether to enable subpixel renderering (performance hit when enabled)
|
|
29
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
30
|
-
* @param {boolean} [options.depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
31
|
-
* @param {string} [options.powerPreference="default"] - a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
|
|
32
|
-
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
33
|
-
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
34
|
-
* @param {Compositor} [options.compositor] - A class that implements the compositor API for sprite rendering
|
|
20
|
+
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
35
21
|
*/
|
|
36
22
|
constructor(options) {
|
|
37
23
|
// parent contructor
|
|
@@ -202,6 +188,17 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
202
188
|
reset() {
|
|
203
189
|
super.reset();
|
|
204
190
|
|
|
191
|
+
// clear all stacks
|
|
192
|
+
this._colorStack.forEach((color) => {
|
|
193
|
+
pool.push(color);
|
|
194
|
+
});
|
|
195
|
+
this._matrixStack.forEach((matrix) => {
|
|
196
|
+
pool.push(matrix);
|
|
197
|
+
});
|
|
198
|
+
this._colorStack.length = 0;
|
|
199
|
+
this._matrixStack.length = 0;
|
|
200
|
+
this._blendStack.length = 0;
|
|
201
|
+
|
|
205
202
|
// clear gl context
|
|
206
203
|
this.clear();
|
|
207
204
|
|
|
@@ -234,8 +231,8 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
234
231
|
/**
|
|
235
232
|
* add a new compositor to this renderer
|
|
236
233
|
* @param {Compositor} compositor - a compositor instance
|
|
237
|
-
* @param {
|
|
238
|
-
* @param {
|
|
234
|
+
* @param {string} name - a name uniquely identifying this compositor
|
|
235
|
+
* @param {boolean} [activate=false] - true if the given compositor should be set as the active one
|
|
239
236
|
*/
|
|
240
237
|
addCompositor(compositor, name = "default", activate = false) {
|
|
241
238
|
// make sure there is no existing compositor with the same name
|
|
@@ -254,9 +251,9 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
254
251
|
|
|
255
252
|
/**
|
|
256
253
|
* set the active compositor for this renderer
|
|
257
|
-
* @param {
|
|
254
|
+
* @param {string} name - a compositor name
|
|
258
255
|
* @param {GLShader} [shader] - an optional shader program to be used, instead of the default one, when activating the compositor
|
|
259
|
-
* @
|
|
256
|
+
* @returns {Compositor} an instance to the current active compositor
|
|
260
257
|
*/
|
|
261
258
|
setCompositor(name = "default", shader = this.customShader) {
|
|
262
259
|
let compositor = this.compositors.get(name);
|
|
@@ -295,7 +292,7 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
295
292
|
* Create a pattern with the specified repetition
|
|
296
293
|
* @param {HTMLImageElement|SVGImageElement|HTMLVideoElement|HTMLCanvasElement|ImageBitmap|OffscreenCanvas|VideoFrame} image - Source image to be used as the pattern's image
|
|
297
294
|
* @param {string} repeat - Define how the pattern should be repeated
|
|
298
|
-
* @returns {TextureAtlas}
|
|
295
|
+
* @returns {TextureAtlas} the patterned texture created
|
|
299
296
|
* @see ImageLayer#repeat
|
|
300
297
|
* @example
|
|
301
298
|
* let tileable = renderer.createPattern(image, "repeat");
|
|
@@ -332,7 +329,7 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
332
329
|
|
|
333
330
|
/**
|
|
334
331
|
* set/change the current projection matrix (WebGL only)
|
|
335
|
-
* @param {Matrix3d} matrix
|
|
332
|
+
* @param {Matrix3d} matrix - the new projection matrix
|
|
336
333
|
*/
|
|
337
334
|
setProjection(matrix) {
|
|
338
335
|
super.setProjection(matrix);
|
|
@@ -455,10 +452,10 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
455
452
|
/**
|
|
456
453
|
* Draw a pattern within the given rectangle.
|
|
457
454
|
* @param {TextureAtlas} pattern - Pattern object
|
|
458
|
-
* @param {number} x
|
|
459
|
-
* @param {number} y
|
|
460
|
-
* @param {number} width
|
|
461
|
-
* @param {number} height
|
|
455
|
+
* @param {number} x - x position where to draw the pattern
|
|
456
|
+
* @param {number} y - y position where to draw the pattern
|
|
457
|
+
* @param {number} width - width of the pattern
|
|
458
|
+
* @param {number} height - height of the pattern
|
|
462
459
|
* @see WebGLRenderer#createPattern
|
|
463
460
|
*/
|
|
464
461
|
drawPattern(pattern, x, y, width, height) {
|
|
@@ -469,10 +466,10 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
469
466
|
|
|
470
467
|
/**
|
|
471
468
|
* Returns the WebGL Context object of the given canvas element
|
|
472
|
-
* @param {HTMLCanvasElement} canvas
|
|
469
|
+
* @param {HTMLCanvasElement} canvas - the canvas element
|
|
473
470
|
* @param {boolean} [transparent=false] - use true to enable transparency
|
|
474
471
|
* @param {boolean} [depth=false] - use true to enable depth buffer testing
|
|
475
|
-
* @returns {WebGLRenderingContext}
|
|
472
|
+
* @returns {WebGLRenderingContext} the WebGL Context object
|
|
476
473
|
*/
|
|
477
474
|
getContextGL(canvas, transparent = false, depth = false) {
|
|
478
475
|
if (typeof canvas === "undefined" || canvas === null) {
|
|
@@ -521,7 +518,7 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
521
518
|
/**
|
|
522
519
|
* Returns the WebGLContext instance for the renderer
|
|
523
520
|
* return a reference to the system 2d Context
|
|
524
|
-
* @returns {WebGLRenderingContext}
|
|
521
|
+
* @returns {WebGLRenderingContext} the current WebGL context
|
|
525
522
|
*/
|
|
526
523
|
getContext() {
|
|
527
524
|
return this.gl;
|
|
@@ -540,7 +537,7 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
540
537
|
* <img src="images/screen-blendmode.png" width="510"/> <br>
|
|
541
538
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
542
539
|
* @param {string} [mode="normal"] - blend mode : "normal", "multiply", "lighter", "additive", "screen"
|
|
543
|
-
* @param {WebGLRenderingContext} [gl]
|
|
540
|
+
* @param {WebGLRenderingContext} [gl] - a WebGL context
|
|
544
541
|
*/
|
|
545
542
|
setBlendMode(mode = "normal", gl = this.gl) {
|
|
546
543
|
|
|
@@ -629,8 +626,8 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
629
626
|
|
|
630
627
|
/**
|
|
631
628
|
* scales the uniform matrix
|
|
632
|
-
* @param {number} x
|
|
633
|
-
* @param {number} y
|
|
629
|
+
* @param {number} x - x-axis scale
|
|
630
|
+
* @param {number} y - y-axis scale
|
|
634
631
|
*/
|
|
635
632
|
scale(x, y) {
|
|
636
633
|
this.currentTransform.scale(x, y);
|
|
@@ -684,11 +681,11 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
684
681
|
* Stroke an arc at the specified coordinates with given radius, start and end points
|
|
685
682
|
* @param {number} x - arc center point x-axis
|
|
686
683
|
* @param {number} y - arc center point y-axis
|
|
687
|
-
* @param {number} radius
|
|
684
|
+
* @param {number} radius - arc radius
|
|
688
685
|
* @param {number} start - start angle in radians
|
|
689
686
|
* @param {number} end - end angle in radians
|
|
690
687
|
* @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
|
|
691
|
-
* @param {boolean} [fill=false]
|
|
688
|
+
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
692
689
|
*/
|
|
693
690
|
strokeArc(x, y, radius, start, end, antiClockwise = false, fill = false) {
|
|
694
691
|
this.setCompositor("primitive");
|
|
@@ -706,7 +703,7 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
706
703
|
* Fill an arc at the specified coordinates with given radius, start and end points
|
|
707
704
|
* @param {number} x - arc center point x-axis
|
|
708
705
|
* @param {number} y - arc center point y-axis
|
|
709
|
-
* @param {number} radius
|
|
706
|
+
* @param {number} radius - arc radius
|
|
710
707
|
* @param {number} start - start angle in radians
|
|
711
708
|
* @param {number} end - end angle in radians
|
|
712
709
|
* @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
|
|
@@ -809,10 +806,10 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
809
806
|
|
|
810
807
|
/**
|
|
811
808
|
* Draw a stroke rectangle at the specified coordinates
|
|
812
|
-
* @param {number} x
|
|
813
|
-
* @param {number} y
|
|
814
|
-
* @param {number} width
|
|
815
|
-
* @param {number} height
|
|
809
|
+
* @param {number} x - x axis of the coordinate for the rectangle starting point.
|
|
810
|
+
* @param {number} y - y axis of the coordinate for the rectangle starting point.
|
|
811
|
+
* @param {number} width - The rectangle's width.
|
|
812
|
+
* @param {number} height - The rectangle's height.
|
|
816
813
|
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
817
814
|
*/
|
|
818
815
|
strokeRect(x, y, width, height, fill = false) {
|
|
@@ -828,10 +825,10 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
828
825
|
|
|
829
826
|
/**
|
|
830
827
|
* Draw a filled rectangle at the specified coordinates
|
|
831
|
-
* @param {number} x
|
|
832
|
-
* @param {number} y
|
|
833
|
-
* @param {number} width
|
|
834
|
-
* @param {number} height
|
|
828
|
+
* @param {number} x - x axis of the coordinate for the rectangle starting point.
|
|
829
|
+
* @param {number} y - y axis of the coordinate for the rectangle starting point.
|
|
830
|
+
* @param {number} width - The rectangle's width.
|
|
831
|
+
* @param {number} height - The rectangle's height.
|
|
835
832
|
*/
|
|
836
833
|
fillRect(x, y, width, height) {
|
|
837
834
|
this.strokeRect(x, y, width, height, true);
|
|
@@ -839,11 +836,11 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
839
836
|
|
|
840
837
|
/**
|
|
841
838
|
* Stroke a rounded rectangle at the specified coordinates
|
|
842
|
-
* @param {number} x
|
|
843
|
-
* @param {number} y
|
|
844
|
-
* @param {number} width
|
|
845
|
-
* @param {number} height
|
|
846
|
-
* @param {number} radius
|
|
839
|
+
* @param {number} x - x axis of the coordinate for the rounded rectangle starting point.
|
|
840
|
+
* @param {number} y - y axis of the coordinate for the rounded rectangle starting point.
|
|
841
|
+
* @param {number} width - The rounded rectangle's width.
|
|
842
|
+
* @param {number} height - The rounded rectangle's height.
|
|
843
|
+
* @param {number} radius - The rounded corner's radius.
|
|
847
844
|
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
848
845
|
*/
|
|
849
846
|
strokeRoundRect(x, y, width, height, radius, fill = false) {
|
|
@@ -860,11 +857,11 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
860
857
|
|
|
861
858
|
/**
|
|
862
859
|
* Draw a rounded filled rectangle at the specified coordinates
|
|
863
|
-
* @param {number} x
|
|
864
|
-
* @param {number} y
|
|
865
|
-
* @param {number} width
|
|
866
|
-
* @param {number} height
|
|
867
|
-
* @param {number} radius
|
|
860
|
+
* @param {number} x - x axis of the coordinate for the rounded rectangle starting point.
|
|
861
|
+
* @param {number} y - y axis of the coordinate for the rounded rectangle starting point.
|
|
862
|
+
* @param {number} width - The rounded rectangle's width.
|
|
863
|
+
* @param {number} height - The rounded rectangle's height.
|
|
864
|
+
* @param {number} radius - The rounded corner's radius.
|
|
868
865
|
*/
|
|
869
866
|
fillRoundRect(x, y, width, height, radius) {
|
|
870
867
|
this.strokeRoundRect(x, y, width, height, radius, true);
|
|
@@ -872,8 +869,8 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
872
869
|
|
|
873
870
|
/**
|
|
874
871
|
* Stroke a Point at the specified coordinates
|
|
875
|
-
* @param {number} x
|
|
876
|
-
* @param {number} y
|
|
872
|
+
* @param {number} x - x axis of the coordinate for the point.
|
|
873
|
+
* @param {number} y - y axis of the coordinate for the point.
|
|
877
874
|
*/
|
|
878
875
|
strokePoint(x, y) {
|
|
879
876
|
this.strokeLine(x, y, x + 1, y + 1);
|
|
@@ -881,10 +878,8 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
881
878
|
|
|
882
879
|
/**
|
|
883
880
|
* Draw a a point at the specified coordinates
|
|
884
|
-
* @param {number} x
|
|
885
|
-
* @param {number} y
|
|
886
|
-
* @param {number} width
|
|
887
|
-
* @param {number} height
|
|
881
|
+
* @param {number} x - x axis of the coordinate for the point.
|
|
882
|
+
* @param {number} y - y axis of the coordinate for the point.
|
|
888
883
|
*/
|
|
889
884
|
fillPoint(x, y) {
|
|
890
885
|
this.strokePoint(x, y);
|
|
@@ -917,8 +912,8 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
917
912
|
|
|
918
913
|
/**
|
|
919
914
|
* Translates the uniform matrix by the given coordinates
|
|
920
|
-
* @param {number} x
|
|
921
|
-
* @param {number} y
|
|
915
|
+
* @param {number} x - x axis of the coordinate for the translation.
|
|
916
|
+
* @param {number} y - y axis of the coordinate for the translation.
|
|
922
917
|
*/
|
|
923
918
|
translate(x, y) {
|
|
924
919
|
let currentTransform = this.currentTransform;
|
|
@@ -937,10 +932,10 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
937
932
|
* You can however save the current region using the save(),
|
|
938
933
|
* and restore it (with the restore() method) any time in the future.
|
|
939
934
|
* (<u>this is an experimental feature !</u>)
|
|
940
|
-
* @param {number} x
|
|
941
|
-
* @param {number} y
|
|
942
|
-
* @param {number} width
|
|
943
|
-
* @param {number} height
|
|
935
|
+
* @param {number} x - x axis of the coordinate for the upper-left corner of the rectangle to start clipping from.
|
|
936
|
+
* @param {number} y - y axis of the coordinate for the upper-left corner of the rectangle to start clipping from.
|
|
937
|
+
* @param {number} width - the width of the rectangle to start clipping from.
|
|
938
|
+
* @param {number} height - the height of the rectangle to start clipping from.
|
|
944
939
|
*/
|
|
945
940
|
clipRect(x, y, width, height) {
|
|
946
941
|
let canvas = this.getCanvas();
|
|
@@ -952,7 +947,7 @@ import { isPowerOfTwo } from "./../../math/math.js";
|
|
|
952
947
|
// if same as the current scissor box do nothing
|
|
953
948
|
if (currentScissor[0] === x && currentScissor[1] === y &&
|
|
954
949
|
currentScissor[2] === width && currentScissor[3] === height) {
|
|
955
|
-
|
|
950
|
+
return;
|
|
956
951
|
}
|
|
957
952
|
}
|
|
958
953
|
// flush the compositor
|
|
File without changes
|