melonjs 17.4.0 → 18.0.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/{dist/types → build}/application/application.d.ts +9 -10
- package/build/application/application.d.ts.map +1 -0
- package/build/application/defaultApplicationSettings.d.ts +18 -0
- package/build/application/defaultApplicationSettings.d.ts.map +1 -0
- package/{dist/types → build}/application/header.d.ts +1 -0
- package/build/application/header.d.ts.map +1 -0
- package/{dist/types → build}/application/resize.d.ts +1 -0
- package/build/application/resize.d.ts.map +1 -0
- package/build/application/scaleMethods.d.ts +44 -0
- package/build/application/scaleMethods.d.ts.map +1 -0
- package/build/application/settings.d.ts +85 -0
- package/build/application/settings.d.ts.map +1 -0
- package/{dist/types → build}/audio/audio.d.ts +35 -58
- package/build/audio/audio.d.ts.map +1 -0
- package/{dist/types → build}/camera/camera2d.d.ts +38 -76
- package/build/camera/camera2d.d.ts.map +1 -0
- package/build/const.d.ts +14 -0
- package/build/const.d.ts.map +1 -0
- package/build/geometries/earcut.d.ts +3 -0
- package/build/geometries/earcut.d.ts.map +1 -0
- package/build/geometries/ellipse.d.ts +117 -0
- package/build/geometries/ellipse.d.ts.map +1 -0
- package/build/geometries/line.d.ts +39 -0
- package/build/geometries/line.d.ts.map +1 -0
- package/build/geometries/observablePoint.d.ts +75 -0
- package/build/geometries/observablePoint.d.ts.map +1 -0
- package/{dist/types → build}/geometries/path2d.d.ts +8 -7
- package/build/geometries/path2d.d.ts.map +1 -0
- package/build/geometries/point.d.ts +44 -0
- package/build/geometries/point.d.ts.map +1 -0
- package/build/geometries/polygon.d.ts +182 -0
- package/build/geometries/polygon.d.ts.map +1 -0
- package/build/geometries/rectangle.d.ts +135 -0
- package/build/geometries/rectangle.d.ts.map +1 -0
- package/build/geometries/roundrect.d.ts +67 -0
- package/build/geometries/roundrect.d.ts.map +1 -0
- package/build/geometries/toarccanvas.d.ts +28 -0
- package/build/geometries/toarccanvas.d.ts.map +1 -0
- package/{dist/types → build}/index.d.ts +41 -45
- package/build/index.d.ts.map +1 -0
- package/build/index.js +28318 -0
- package/build/index.js.map +7 -0
- package/{dist/types → build}/input/gamepad.d.ts +3 -11
- package/build/input/gamepad.d.ts.map +1 -0
- package/{dist/types → build}/input/input.d.ts +4 -2
- package/build/input/input.d.ts.map +1 -0
- package/build/input/key.d.ts +105 -0
- package/build/input/key.d.ts.map +1 -0
- package/build/input/keyboard.d.ts +72 -0
- package/build/input/keyboard.d.ts.map +1 -0
- package/build/input/pointer.d.ts +180 -0
- package/build/input/pointer.d.ts.map +1 -0
- package/{dist/types → build}/input/pointerevent.d.ts +17 -16
- package/build/input/pointerevent.d.ts.map +1 -0
- package/{dist/types → build}/lang/console.d.ts +1 -0
- package/build/lang/console.d.ts.map +1 -0
- package/build/lang/deprecated.d.ts +24 -0
- package/build/lang/deprecated.d.ts.map +1 -0
- package/{dist/types → build}/level/level.d.ts +7 -7
- package/build/level/level.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/TMXGroup.d.ts +2 -2
- package/build/level/tiled/TMXGroup.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/TMXLayer.d.ts +4 -4
- package/build/level/tiled/TMXLayer.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/TMXObject.d.ts +3 -3
- package/build/level/tiled/TMXObject.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/TMXTile.d.ts +4 -5
- package/build/level/tiled/TMXTile.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/TMXTileMap.d.ts +4 -4
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/TMXTileset.d.ts +2 -2
- package/build/level/tiled/TMXTileset.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/TMXTilesetGroup.d.ts +1 -1
- package/build/level/tiled/TMXTilesetGroup.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/TMXUtils.d.ts +2 -1
- package/build/level/tiled/TMXUtils.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/constants.d.ts +1 -0
- package/build/level/tiled/constants.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/renderer/TMXHexagonalRenderer.d.ts +3 -4
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/renderer/TMXIsometricRenderer.d.ts +2 -3
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +1 -2
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/renderer/TMXRenderer.d.ts +7 -7
- package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/renderer/TMXStaggeredRenderer.d.ts +1 -2
- package/build/level/tiled/renderer/TMXStaggeredRenderer.d.ts.map +1 -0
- package/{dist/types → build}/level/tiled/renderer/autodetect.d.ts +4 -3
- package/build/level/tiled/renderer/autodetect.d.ts.map +1 -0
- package/build/loader/cache.d.ts +10 -0
- package/build/loader/cache.d.ts.map +1 -0
- package/{dist/types → build}/loader/loader.d.ts +19 -13
- package/build/loader/loader.d.ts.map +1 -0
- package/{dist/types → build}/loader/loadingscreen.d.ts +1 -0
- package/build/loader/loadingscreen.d.ts.map +1 -0
- package/{dist/types → build}/loader/parsers/binary.d.ts +2 -1
- package/build/loader/parsers/binary.d.ts.map +1 -0
- package/{dist/types → build}/loader/parsers/compressed_textures/compressed_image.d.ts +1 -0
- package/build/loader/parsers/compressed_textures/compressed_image.d.ts.map +1 -0
- package/build/loader/parsers/compressed_textures/parseDDS.d.ts +2 -0
- package/build/loader/parsers/compressed_textures/parseDDS.d.ts.map +1 -0
- package/build/loader/parsers/compressed_textures/parseKTX.d.ts +2 -0
- package/build/loader/parsers/compressed_textures/parseKTX.d.ts.map +1 -0
- package/build/loader/parsers/compressed_textures/parseKTX2.d.ts +2 -0
- package/build/loader/parsers/compressed_textures/parseKTX2.d.ts.map +1 -0
- package/build/loader/parsers/compressed_textures/parsePKM.d.ts +2 -0
- package/build/loader/parsers/compressed_textures/parsePKM.d.ts.map +1 -0
- package/build/loader/parsers/compressed_textures/parsePVR.d.ts +2 -0
- package/build/loader/parsers/compressed_textures/parsePVR.d.ts.map +1 -0
- package/{dist/types → build}/loader/parsers/fetchdata.d.ts +2 -1
- package/build/loader/parsers/fetchdata.d.ts.map +1 -0
- package/{dist/types → build}/loader/parsers/fontface.d.ts +2 -1
- package/build/loader/parsers/fontface.d.ts.map +1 -0
- package/{dist/types → build}/loader/parsers/image.d.ts +2 -1
- package/build/loader/parsers/image.d.ts.map +1 -0
- package/{dist/types → build}/loader/parsers/json.d.ts +2 -1
- package/build/loader/parsers/json.d.ts.map +1 -0
- package/{dist/types → build}/loader/parsers/script.d.ts +2 -1
- package/build/loader/parsers/script.d.ts.map +1 -0
- package/{dist/types → build}/loader/parsers/tmx.d.ts +2 -1
- package/build/loader/parsers/tmx.d.ts.map +1 -0
- package/{dist/types → build}/loader/parsers/video.d.ts +2 -1
- package/build/loader/parsers/video.d.ts.map +1 -0
- package/build/math/color.d.ts +192 -0
- package/build/math/color.d.ts.map +1 -0
- package/build/math/math.d.ts +128 -0
- package/build/math/math.d.ts.map +1 -0
- package/build/math/matrix2d.d.ts +163 -0
- package/build/math/matrix2d.d.ts.map +1 -0
- package/build/math/matrix3d.d.ts +188 -0
- package/build/math/matrix3d.d.ts.map +1 -0
- package/build/math/observableVector2d.d.ts +286 -0
- package/build/math/observableVector2d.d.ts.map +1 -0
- package/build/math/observableVector2d_old.d.ts +76 -0
- package/build/math/observableVector2d_old.d.ts.map +1 -0
- package/build/math/observableVector3d.d.ts +283 -0
- package/build/math/observableVector3d.d.ts.map +1 -0
- package/build/math/observableVector3d_old.d.ts +81 -0
- package/build/math/observableVector3d_old.d.ts.map +1 -0
- package/build/math/vector2d.d.ts +253 -0
- package/build/math/vector2d.d.ts.map +1 -0
- package/build/math/vector3d.d.ts +242 -0
- package/build/math/vector3d.d.ts.map +1 -0
- package/{dist/types → build}/particles/emitter.d.ts +7 -10
- package/build/particles/emitter.d.ts.map +1 -0
- package/build/particles/particle.d.ts +47 -0
- package/build/particles/particle.d.ts.map +1 -0
- package/{dist/types → build}/particles/settings.d.ts +1 -0
- package/build/particles/settings.d.ts.map +1 -0
- package/{dist/types → build}/physics/body.d.ts +27 -27
- package/build/physics/body.d.ts.map +1 -0
- package/build/physics/bounds.d.ts +192 -0
- package/build/physics/bounds.d.ts.map +1 -0
- package/{dist/types → build}/physics/collision.d.ts +5 -5
- package/build/physics/collision.d.ts.map +1 -0
- package/{dist/types → build}/physics/detector.d.ts +8 -6
- package/build/physics/detector.d.ts.map +1 -0
- package/{dist/types → build}/physics/quadtree.d.ts +5 -19
- package/build/physics/quadtree.d.ts.map +1 -0
- package/{dist/types → build}/physics/response.d.ts +46 -5
- package/build/physics/response.d.ts.map +1 -0
- package/{dist/types → build}/physics/sat.d.ts +3 -2
- package/build/physics/sat.d.ts.map +1 -0
- package/{dist/types → build}/physics/world.d.ts +5 -4
- package/build/physics/world.d.ts.map +1 -0
- package/{dist/types → build}/plugin/plugin.d.ts +8 -19
- package/build/plugin/plugin.d.ts.map +1 -0
- package/build/polyfill/console.d.ts +2 -0
- package/build/polyfill/console.d.ts.map +1 -0
- package/build/polyfill/index.d.ts +6 -0
- package/build/polyfill/index.d.ts.map +1 -0
- package/build/polyfill/roundrect.d.ts +2 -0
- package/build/polyfill/roundrect.d.ts.map +1 -0
- package/build/pool.d.ts +39 -0
- package/build/pool.d.ts.map +1 -0
- package/{dist/types → build}/renderable/collectable.d.ts +2 -2
- package/build/renderable/collectable.d.ts.map +1 -0
- package/{dist/types → build}/renderable/colorlayer.d.ts +6 -10
- package/build/renderable/colorlayer.d.ts.map +1 -0
- package/{dist/types → build}/renderable/container.d.ts +14 -15
- package/build/renderable/container.d.ts.map +1 -0
- package/{dist/types → build}/renderable/draggable.d.ts +5 -13
- package/build/renderable/draggable.d.ts.map +1 -0
- package/{dist/types → build}/renderable/dragndrop.d.ts +7 -21
- package/build/renderable/dragndrop.d.ts.map +1 -0
- package/{dist/types → build}/renderable/entity/entity.d.ts +12 -13
- package/build/renderable/entity/entity.d.ts.map +1 -0
- package/{dist/types → build}/renderable/imagelayer.d.ts +17 -9
- package/build/renderable/imagelayer.d.ts.map +1 -0
- package/build/renderable/light2d.d.ts +73 -0
- package/build/renderable/light2d.d.ts.map +1 -0
- package/{dist/types → build}/renderable/nineslicesprite.d.ts +3 -4
- package/build/renderable/nineslicesprite.d.ts.map +1 -0
- package/{dist/types → build}/renderable/renderable.d.ts +57 -60
- package/build/renderable/renderable.d.ts.map +1 -0
- package/{dist/types → build}/renderable/sprite.d.ts +28 -14
- package/build/renderable/sprite.d.ts.map +1 -0
- package/{dist/types → build}/renderable/text/bitmaptext.d.ts +6 -7
- package/build/renderable/text/bitmaptext.d.ts.map +1 -0
- package/build/renderable/text/bitmaptextdata.d.ts +17 -0
- package/build/renderable/text/bitmaptextdata.d.ts.map +1 -0
- package/{dist/types → build}/renderable/text/glyph.d.ts +15 -3
- package/build/renderable/text/glyph.d.ts.map +1 -0
- package/{dist/types → build}/renderable/text/text.d.ts +7 -16
- package/build/renderable/text/text.d.ts.map +1 -0
- package/{dist/types → build}/renderable/text/textmetrics.d.ts +8 -9
- package/build/renderable/text/textmetrics.d.ts.map +1 -0
- package/{dist/types → build}/renderable/text/textstyle.d.ts +1 -0
- package/build/renderable/text/textstyle.d.ts.map +1 -0
- package/{dist/types → build}/renderable/trigger.d.ts +18 -7
- package/build/renderable/trigger.d.ts.map +1 -0
- package/{dist/types → build}/renderable/ui/uibaseelement.d.ts +7 -7
- package/build/renderable/ui/uibaseelement.d.ts.map +1 -0
- package/{dist/types → build}/renderable/ui/uispriteelement.d.ts +4 -6
- package/build/renderable/ui/uispriteelement.d.ts.map +1 -0
- package/{dist/types → build}/renderable/ui/uitextbutton.d.ts +17 -4
- package/build/renderable/ui/uitextbutton.d.ts.map +1 -0
- package/{dist/types → build}/state/stage.d.ts +3 -3
- package/build/state/stage.d.ts.map +1 -0
- package/{dist/types → build}/state/state.d.ts +10 -9
- package/build/state/state.d.ts.map +1 -0
- package/{dist/types → build}/system/device.d.ts +49 -80
- package/build/system/device.d.ts.map +1 -0
- package/build/system/dom.d.ts +2 -0
- package/build/system/dom.d.ts.map +1 -0
- package/{dist/types → build}/system/event.d.ts +124 -291
- package/build/system/event.d.ts.map +1 -0
- package/build/system/eventEmitter.d.ts +19 -0
- package/build/system/eventEmitter.d.ts.map +1 -0
- package/build/system/eventEmitter.spec.d.ts +2 -0
- package/build/system/eventEmitter.spec.d.ts.map +1 -0
- package/{dist/types/system/pooling.d.ts → build/system/legacy_pool.d.ts} +22 -7
- package/build/system/legacy_pool.d.ts.map +1 -0
- package/build/system/platform.d.ts +34 -0
- package/build/system/platform.d.ts.map +1 -0
- package/build/system/pool.d.ts +26 -0
- package/build/system/pool.d.ts.map +1 -0
- package/build/system/save.d.ts +3 -0
- package/build/system/save.d.ts.map +1 -0
- package/build/system/timer.d.ts +118 -0
- package/build/system/timer.d.ts.map +1 -0
- package/build/tweens/easing.d.ts +93 -0
- package/build/tweens/easing.d.ts.map +1 -0
- package/build/tweens/interpolation.d.ts +7 -0
- package/build/tweens/interpolation.d.ts.map +1 -0
- package/build/tweens/tween.d.ts +234 -0
- package/build/tweens/tween.d.ts.map +1 -0
- package/build/utils/agent.d.ts +16 -0
- package/build/utils/agent.d.ts.map +1 -0
- package/build/utils/array-multimap.d.ts +14 -0
- package/build/utils/array-multimap.d.ts.map +1 -0
- package/build/utils/array.d.ts +30 -0
- package/build/utils/array.d.ts.map +1 -0
- package/build/utils/file.d.ts +16 -0
- package/build/utils/file.d.ts.map +1 -0
- package/build/utils/function.d.ts +24 -0
- package/build/utils/function.d.ts.map +1 -0
- package/build/utils/semver.d.ts +2 -0
- package/build/utils/semver.d.ts.map +1 -0
- package/build/utils/string.d.ts +35 -0
- package/build/utils/string.d.ts.map +1 -0
- package/build/utils/types.d.ts +5 -0
- package/build/utils/types.d.ts.map +1 -0
- package/build/utils/utils.d.ts +49 -0
- package/build/utils/utils.d.ts.map +1 -0
- package/build/version.d.ts +5 -0
- package/build/version.d.ts.map +1 -0
- package/{dist/types → build}/video/canvas/canvas_renderer.d.ts +40 -32
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -0
- package/{dist/types → build}/video/renderer.d.ts +36 -29
- package/build/video/renderer.d.ts.map +1 -0
- package/{dist/types → build}/video/rendertarget/canvasrendertarget.d.ts +8 -26
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -0
- package/{dist/types → build}/video/texture/atlas.d.ts +8 -8
- package/build/video/texture/atlas.d.ts.map +1 -0
- package/{dist/types → build}/video/texture/cache.d.ts +4 -3
- package/build/video/texture/cache.d.ts.map +1 -0
- package/{dist/types → build}/video/texture/parser/aseprite.d.ts +1 -0
- package/build/video/texture/parser/aseprite.d.ts.map +1 -0
- package/{dist/types → build}/video/texture/parser/spritesheet.d.ts +1 -0
- package/build/video/texture/parser/spritesheet.d.ts.map +1 -0
- package/{dist/types → build}/video/texture/parser/texturepacker.d.ts +1 -0
- package/build/video/texture/parser/texturepacker.d.ts.map +1 -0
- package/build/video/utils/autodetect.d.ts +8 -0
- package/build/video/utils/autodetect.d.ts.map +1 -0
- package/{dist/types → build}/video/video.d.ts +4 -3
- package/build/video/video.d.ts.map +1 -0
- package/{dist/types → build}/video/webgl/buffer/vertex.d.ts +5 -6
- package/build/video/webgl/buffer/vertex.d.ts.map +1 -0
- package/{dist/types → build}/video/webgl/compositors/compositor.d.ts +4 -4
- package/build/video/webgl/compositors/compositor.d.ts.map +1 -0
- package/{dist/types → build}/video/webgl/compositors/primitive_compositor.d.ts +4 -5
- package/build/video/webgl/compositors/primitive_compositor.d.ts.map +1 -0
- package/{dist/types → build}/video/webgl/compositors/quad_compositor.d.ts +4 -5
- package/build/video/webgl/compositors/quad_compositor.d.ts.map +1 -0
- package/{dist/types → build}/video/webgl/glshader.d.ts +2 -2
- package/build/video/webgl/glshader.d.ts.map +1 -0
- package/{dist/types → build}/video/webgl/utils/attributes.d.ts +1 -0
- package/build/video/webgl/utils/attributes.d.ts.map +1 -0
- package/{dist/types → build}/video/webgl/utils/precision.d.ts +1 -0
- package/build/video/webgl/utils/precision.d.ts.map +1 -0
- package/{dist/types → build}/video/webgl/utils/program.d.ts +1 -0
- package/build/video/webgl/utils/program.d.ts.map +1 -0
- package/{dist/types → build}/video/webgl/utils/string.d.ts +1 -0
- package/build/video/webgl/utils/string.d.ts.map +1 -0
- package/{dist/types → build}/video/webgl/utils/uniforms.d.ts +1 -0
- package/build/video/webgl/utils/uniforms.d.ts.map +1 -0
- package/{dist/types → build}/video/webgl/webgl_renderer.d.ts +37 -29
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -0
- package/package.json +83 -104
- package/LICENSE.md +0 -21
- package/README.md +0 -223
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +0 -14
- package/dist/melonjs.mjs/_virtual/earcut.js +0 -10
- package/dist/melonjs.mjs/_virtual/howler.js +0 -10
- package/dist/melonjs.mjs/_virtual/index.js +0 -10
- package/dist/melonjs.mjs/_virtual/re.js +0 -10
- package/dist/melonjs.mjs/application/application.js +0 -443
- package/dist/melonjs.mjs/application/header.js +0 -40
- package/dist/melonjs.mjs/application/resize.js +0 -128
- package/dist/melonjs.mjs/application/settings.js +0 -70
- package/dist/melonjs.mjs/audio/audio.js +0 -623
- package/dist/melonjs.mjs/camera/camera2d.js +0 -737
- package/dist/melonjs.mjs/const.js +0 -32
- package/dist/melonjs.mjs/geometries/ellipse.js +0 -253
- package/dist/melonjs.mjs/geometries/line.js +0 -113
- package/dist/melonjs.mjs/geometries/path2d.js +0 -479
- package/dist/melonjs.mjs/geometries/point.js +0 -85
- package/dist/melonjs.mjs/geometries/poly.js +0 -441
- package/dist/melonjs.mjs/geometries/rectangle.js +0 -335
- package/dist/melonjs.mjs/geometries/roundrect.js +0 -165
- package/dist/melonjs.mjs/geometries/toarccanvas.js +0 -103
- package/dist/melonjs.mjs/index.js +0 -239
- package/dist/melonjs.mjs/input/gamepad.js +0 -495
- package/dist/melonjs.mjs/input/input.js +0 -26
- package/dist/melonjs.mjs/input/keyboard.js +0 -470
- package/dist/melonjs.mjs/input/pointer.js +0 -393
- package/dist/melonjs.mjs/input/pointerevent.js +0 -807
- package/dist/melonjs.mjs/lang/console.js +0 -44
- package/dist/melonjs.mjs/lang/deprecated.js +0 -200
- package/dist/melonjs.mjs/level/level.js +0 -298
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +0 -120
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +0 -432
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +0 -295
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +0 -177
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +0 -574
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +0 -292
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +0 -74
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +0 -417
- package/dist/melonjs.mjs/level/tiled/constants.js +0 -17
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +0 -503
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +0 -215
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +0 -155
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +0 -113
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +0 -107
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +0 -38
- package/dist/melonjs.mjs/loader/cache.js +0 -30
- package/dist/melonjs.mjs/loader/loader.js +0 -729
- package/dist/melonjs.mjs/loader/loadingscreen.js +0 -118
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +0 -10
- package/dist/melonjs.mjs/loader/parsers/binary.js +0 -42
- package/dist/melonjs.mjs/loader/parsers/compressed_textures/compressed_image.js +0 -58
- package/dist/melonjs.mjs/loader/parsers/compressed_textures/parseDDS.js +0 -13
- package/dist/melonjs.mjs/loader/parsers/compressed_textures/parseKTX.js +0 -13
- package/dist/melonjs.mjs/loader/parsers/compressed_textures/parseKTX2.js +0 -13
- package/dist/melonjs.mjs/loader/parsers/compressed_textures/parsePKM.js +0 -13
- package/dist/melonjs.mjs/loader/parsers/compressed_textures/parsePVR.js +0 -136
- package/dist/melonjs.mjs/loader/parsers/fetchdata.js +0 -62
- package/dist/melonjs.mjs/loader/parsers/fontface.js +0 -62
- package/dist/melonjs.mjs/loader/parsers/image.js +0 -129
- package/dist/melonjs.mjs/loader/parsers/json.js +0 -43
- package/dist/melonjs.mjs/loader/parsers/script.js +0 -46
- package/dist/melonjs.mjs/loader/parsers/tmx.js +0 -103
- package/dist/melonjs.mjs/loader/parsers/video.js +0 -99
- package/dist/melonjs.mjs/math/color.js +0 -635
- package/dist/melonjs.mjs/math/math.js +0 -221
- package/dist/melonjs.mjs/math/matrix2.js +0 -495
- package/dist/melonjs.mjs/math/matrix3.js +0 -628
- package/dist/melonjs.mjs/math/observable_vector2.js +0 -468
- package/dist/melonjs.mjs/math/observable_vector3.js +0 -564
- package/dist/melonjs.mjs/math/vector2.js +0 -431
- package/dist/melonjs.mjs/math/vector3.js +0 -473
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +0 -45
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +0 -130
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +0 -694
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +0 -352
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +0 -12
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +0 -3246
- package/dist/melonjs.mjs/node_modules/semver/classes/comparator.js +0 -165
- package/dist/melonjs.mjs/node_modules/semver/classes/range.js +0 -565
- package/dist/melonjs.mjs/node_modules/semver/classes/semver.js +0 -317
- package/dist/melonjs.mjs/node_modules/semver/functions/clean.js +0 -17
- package/dist/melonjs.mjs/node_modules/semver/functions/cmp.js +0 -68
- package/dist/melonjs.mjs/node_modules/semver/functions/coerce.js +0 -73
- package/dist/melonjs.mjs/node_modules/semver/functions/compare-build.js +0 -18
- package/dist/melonjs.mjs/node_modules/semver/functions/compare-loose.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/compare.js +0 -16
- package/dist/melonjs.mjs/node_modules/semver/functions/diff.js +0 -76
- package/dist/melonjs.mjs/node_modules/semver/functions/eq.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/gt.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/gte.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/inc.js +0 -30
- package/dist/melonjs.mjs/node_modules/semver/functions/lt.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/lte.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/major.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/minor.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/neq.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/parse.js +0 -27
- package/dist/melonjs.mjs/node_modules/semver/functions/patch.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/prerelease.js +0 -17
- package/dist/melonjs.mjs/node_modules/semver/functions/rcompare.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/rsort.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/satisfies.js +0 -21
- package/dist/melonjs.mjs/node_modules/semver/functions/sort.js +0 -14
- package/dist/melonjs.mjs/node_modules/semver/functions/valid.js +0 -17
- package/dist/melonjs.mjs/node_modules/semver/index.js +0 -140
- package/dist/melonjs.mjs/node_modules/semver/internal/constants.js +0 -44
- package/dist/melonjs.mjs/node_modules/semver/internal/debug.js +0 -18
- package/dist/melonjs.mjs/node_modules/semver/internal/identifiers.js +0 -32
- package/dist/melonjs.mjs/node_modules/semver/internal/lrucache.js +0 -49
- package/dist/melonjs.mjs/node_modules/semver/internal/parse-options.js +0 -24
- package/dist/melonjs.mjs/node_modules/semver/internal/re.js +0 -234
- package/dist/melonjs.mjs/node_modules/semver/ranges/gtr.js +0 -15
- package/dist/melonjs.mjs/node_modules/semver/ranges/intersects.js +0 -18
- package/dist/melonjs.mjs/node_modules/semver/ranges/ltr.js +0 -15
- package/dist/melonjs.mjs/node_modules/semver/ranges/max-satisfying.js +0 -37
- package/dist/melonjs.mjs/node_modules/semver/ranges/min-satisfying.js +0 -36
- package/dist/melonjs.mjs/node_modules/semver/ranges/min-version.js +0 -74
- package/dist/melonjs.mjs/node_modules/semver/ranges/outside.js +0 -98
- package/dist/melonjs.mjs/node_modules/semver/ranges/simplify.js +0 -59
- package/dist/melonjs.mjs/node_modules/semver/ranges/subset.js +0 -261
- package/dist/melonjs.mjs/node_modules/semver/ranges/to-comparators.js +0 -19
- package/dist/melonjs.mjs/node_modules/semver/ranges/valid.js +0 -22
- package/dist/melonjs.mjs/particles/emitter.js +0 -265
- package/dist/melonjs.mjs/particles/particle.js +0 -190
- package/dist/melonjs.mjs/particles/settings.js +0 -317
- package/dist/melonjs.mjs/physics/body.js +0 -717
- package/dist/melonjs.mjs/physics/bounds.js +0 -415
- package/dist/melonjs.mjs/physics/collision.js +0 -135
- package/dist/melonjs.mjs/physics/detector.js +0 -227
- package/dist/melonjs.mjs/physics/quadtree.js +0 -402
- package/dist/melonjs.mjs/physics/response.js +0 -57
- package/dist/melonjs.mjs/physics/sat.js +0 -492
- package/dist/melonjs.mjs/physics/world.js +0 -228
- package/dist/melonjs.mjs/plugin/plugin.js +0 -172
- package/dist/melonjs.mjs/renderable/collectable.js +0 -60
- package/dist/melonjs.mjs/renderable/colorlayer.js +0 -83
- package/dist/melonjs.mjs/renderable/container.js +0 -1016
- package/dist/melonjs.mjs/renderable/draggable.js +0 -121
- package/dist/melonjs.mjs/renderable/dragndrop.js +0 -119
- package/dist/melonjs.mjs/renderable/entity/entity.js +0 -263
- package/dist/melonjs.mjs/renderable/imagelayer.js +0 -293
- package/dist/melonjs.mjs/renderable/light2d.js +0 -172
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +0 -248
- package/dist/melonjs.mjs/renderable/renderable.js +0 -878
- package/dist/melonjs.mjs/renderable/sprite.js +0 -700
- package/dist/melonjs.mjs/renderable/text/bitmaptext.js +0 -421
- package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +0 -195
- package/dist/melonjs.mjs/renderable/text/glyph.js +0 -65
- package/dist/melonjs.mjs/renderable/text/text.js +0 -424
- package/dist/melonjs.mjs/renderable/text/textmetrics.js +0 -176
- package/dist/melonjs.mjs/renderable/text/textstyle.js +0 -21
- package/dist/melonjs.mjs/renderable/trigger.js +0 -163
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +0 -285
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +0 -231
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +0 -146
- package/dist/melonjs.mjs/state/stage.js +0 -235
- package/dist/melonjs.mjs/state/state.js +0 -548
- package/dist/melonjs.mjs/system/device.js +0 -872
- package/dist/melonjs.mjs/system/dom.js +0 -79
- package/dist/melonjs.mjs/system/event.js +0 -606
- package/dist/melonjs.mjs/system/platform.js +0 -43
- package/dist/melonjs.mjs/system/pooling.js +0 -182
- package/dist/melonjs.mjs/system/save.js +0 -157
- package/dist/melonjs.mjs/system/timer.js +0 -274
- package/dist/melonjs.mjs/tweens/easing.js +0 -334
- package/dist/melonjs.mjs/tweens/interpolation.js +0 -112
- package/dist/melonjs.mjs/tweens/tween.js +0 -479
- package/dist/melonjs.mjs/utils/agent.js +0 -77
- package/dist/melonjs.mjs/utils/array.js +0 -63
- package/dist/melonjs.mjs/utils/file.js +0 -54
- package/dist/melonjs.mjs/utils/function.js +0 -69
- package/dist/melonjs.mjs/utils/string.js +0 -82
- package/dist/melonjs.mjs/utils/utils.js +0 -139
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +0 -914
- package/dist/melonjs.mjs/video/renderer.js +0 -402
- package/dist/melonjs.mjs/video/rendertarget/canvasrendertarget.js +0 -316
- package/dist/melonjs.mjs/video/texture/atlas.js +0 -465
- package/dist/melonjs.mjs/video/texture/cache.js +0 -186
- package/dist/melonjs.mjs/video/texture/parser/aseprite.js +0 -78
- package/dist/melonjs.mjs/video/texture/parser/spritesheet.js +0 -77
- package/dist/melonjs.mjs/video/texture/parser/texturepacker.js +0 -64
- package/dist/melonjs.mjs/video/utils/autodetect.js +0 -27
- package/dist/melonjs.mjs/video/video.js +0 -142
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +0 -146
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +0 -240
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +0 -82
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +0 -259
- package/dist/melonjs.mjs/video/webgl/glshader.js +0 -166
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +0 -10
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +0 -10
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +0 -10
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +0 -10
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +0 -25
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +0 -38
- package/dist/melonjs.mjs/video/webgl/utils/program.js +0 -67
- package/dist/melonjs.mjs/video/webgl/utils/string.js +0 -25
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +0 -92
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +0 -1246
- package/dist/melonjs.module.js +0 -43200
- package/dist/types/application/settings.d.ts +0 -106
- package/dist/types/const.d.ts +0 -21
- package/dist/types/geometries/ellipse.d.ts +0 -138
- package/dist/types/geometries/line.d.ts +0 -15
- package/dist/types/geometries/point.d.ts +0 -50
- package/dist/types/geometries/poly.d.ts +0 -186
- package/dist/types/geometries/rectangle.d.ts +0 -135
- package/dist/types/geometries/roundrect.d.ts +0 -43
- package/dist/types/geometries/toarccanvas.d.ts +0 -10
- package/dist/types/input/keyboard.d.ts +0 -205
- package/dist/types/input/pointer.d.ts +0 -261
- package/dist/types/lang/deprecated.d.ts +0 -68
- package/dist/types/loader/cache.d.ts +0 -9
- package/dist/types/loader/parsers/compressed_textures/parseDDS.d.ts +0 -1
- package/dist/types/loader/parsers/compressed_textures/parseKTX.d.ts +0 -1
- package/dist/types/loader/parsers/compressed_textures/parseKTX2.d.ts +0 -1
- package/dist/types/loader/parsers/compressed_textures/parsePKM.d.ts +0 -1
- package/dist/types/loader/parsers/compressed_textures/parsePVR.d.ts +0 -1
- package/dist/types/math/color.d.ts +0 -179
- package/dist/types/math/math.d.ts +0 -149
- package/dist/types/math/matrix2.d.ts +0 -174
- package/dist/types/math/matrix3.d.ts +0 -186
- package/dist/types/math/observable_vector2.d.ts +0 -278
- package/dist/types/math/observable_vector3.d.ts +0 -300
- package/dist/types/math/vector2.d.ts +0 -255
- package/dist/types/math/vector3.d.ts +0 -271
- package/dist/types/particles/particle.d.ts +0 -36
- package/dist/types/physics/bounds.d.ts +0 -203
- package/dist/types/polyfill/console.d.ts +0 -1
- package/dist/types/polyfill/index.d.ts +0 -1
- package/dist/types/polyfill/roundrect.d.ts +0 -1
- package/dist/types/renderable/light2d.d.ts +0 -60
- package/dist/types/renderable/text/bitmaptextdata.d.ts +0 -35
- package/dist/types/system/dom.d.ts +0 -1
- package/dist/types/system/platform.d.ts +0 -33
- package/dist/types/system/save.d.ts +0 -25
- package/dist/types/system/timer.d.ts +0 -126
- package/dist/types/tweens/easing.d.ts +0 -46
- package/dist/types/tweens/interpolation.d.ts +0 -18
- package/dist/types/tweens/tween.d.ts +0 -195
- package/dist/types/utils/agent.d.ts +0 -21
- package/dist/types/utils/array.d.ts +0 -39
- package/dist/types/utils/file.d.ts +0 -27
- package/dist/types/utils/function.d.ts +0 -31
- package/dist/types/utils/string.d.ts +0 -50
- package/dist/types/utils/utils.d.ts +0 -54
- package/dist/types/video/utils/autodetect.d.ts +0 -5
- package/src/application/application.js +0 -435
- package/src/application/header.js +0 -31
- package/src/application/resize.js +0 -119
- package/src/application/settings.js +0 -61
- package/src/audio/audio.js +0 -622
- package/src/camera/camera2d.js +0 -731
- package/src/const.js +0 -23
- package/src/geometries/ellipse.js +0 -244
- package/src/geometries/line.js +0 -104
- package/src/geometries/path2d.js +0 -470
- package/src/geometries/point.js +0 -76
- package/src/geometries/poly.js +0 -432
- package/src/geometries/rectangle.js +0 -326
- package/src/geometries/roundrect.js +0 -156
- package/src/geometries/toarccanvas.js +0 -94
- package/src/index.js +0 -315
- package/src/input/gamepad.js +0 -487
- package/src/input/input.js +0 -17
- package/src/input/keyboard.js +0 -461
- package/src/input/pointer.js +0 -386
- package/src/input/pointerevent.js +0 -798
- package/src/lang/console.js +0 -36
- package/src/lang/deprecated.js +0 -192
- package/src/level/level.js +0 -290
- package/src/level/tiled/TMXGroup.js +0 -111
- package/src/level/tiled/TMXLayer.js +0 -424
- package/src/level/tiled/TMXObject.js +0 -286
- package/src/level/tiled/TMXTile.js +0 -168
- package/src/level/tiled/TMXTileMap.js +0 -569
- package/src/level/tiled/TMXTileset.js +0 -284
- package/src/level/tiled/TMXTilesetGroup.js +0 -66
- package/src/level/tiled/TMXUtils.js +0 -408
- package/src/level/tiled/constants.js +0 -8
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +0 -497
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +0 -208
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +0 -149
- package/src/level/tiled/renderer/TMXRenderer.js +0 -103
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +0 -100
- package/src/level/tiled/renderer/autodetect.js +0 -29
- package/src/loader/cache.js +0 -22
- package/src/loader/loader.js +0 -728
- package/src/loader/loadingscreen.js +0 -112
- package/src/loader/melonjs_logo.png +0 -0
- package/src/loader/parsers/binary.js +0 -33
- package/src/loader/parsers/compressed_textures/compressed_image.js +0 -49
- package/src/loader/parsers/compressed_textures/parseDDS.js +0 -5
- package/src/loader/parsers/compressed_textures/parseKTX.js +0 -5
- package/src/loader/parsers/compressed_textures/parseKTX2.js +0 -5
- package/src/loader/parsers/compressed_textures/parsePKM.js +0 -5
- package/src/loader/parsers/compressed_textures/parsePVR.js +0 -127
- package/src/loader/parsers/fetchdata.js +0 -53
- package/src/loader/parsers/fontface.js +0 -54
- package/src/loader/parsers/image.js +0 -120
- package/src/loader/parsers/json.js +0 -35
- package/src/loader/parsers/script.js +0 -37
- package/src/loader/parsers/tmx.js +0 -95
- package/src/loader/parsers/video.js +0 -90
- package/src/math/color.js +0 -627
- package/src/math/math.js +0 -212
- package/src/math/matrix2.js +0 -487
- package/src/math/matrix3.js +0 -620
- package/src/math/observable_vector2.js +0 -460
- package/src/math/observable_vector3.js +0 -556
- package/src/math/vector2.js +0 -423
- package/src/math/vector3.js +0 -465
- package/src/particles/emitter.js +0 -258
- package/src/particles/particle.js +0 -182
- package/src/particles/settings.js +0 -310
- package/src/physics/body.js +0 -709
- package/src/physics/bounds.js +0 -407
- package/src/physics/collision.js +0 -128
- package/src/physics/detector.js +0 -218
- package/src/physics/quadtree.js +0 -393
- package/src/physics/response.js +0 -48
- package/src/physics/sat.js +0 -483
- package/src/physics/world.js +0 -220
- package/src/plugin/plugin.js +0 -163
- package/src/polyfill/console.js +0 -11
- package/src/polyfill/index.js +0 -13
- package/src/polyfill/roundrect.js +0 -237
- package/src/renderable/collectable.js +0 -51
- package/src/renderable/colorlayer.js +0 -74
- package/src/renderable/container.js +0 -1008
- package/src/renderable/draggable.js +0 -114
- package/src/renderable/dragndrop.js +0 -110
- package/src/renderable/entity/entity.js +0 -254
- package/src/renderable/imagelayer.js +0 -284
- package/src/renderable/light2d.js +0 -163
- package/src/renderable/nineslicesprite.js +0 -239
- package/src/renderable/renderable.js +0 -869
- package/src/renderable/sprite.js +0 -691
- package/src/renderable/text/bitmaptext.js +0 -418
- package/src/renderable/text/bitmaptextdata.js +0 -186
- package/src/renderable/text/glyph.js +0 -57
- package/src/renderable/text/text.js +0 -415
- package/src/renderable/text/textmetrics.js +0 -167
- package/src/renderable/text/textstyle.js +0 -12
- package/src/renderable/trigger.js +0 -154
- package/src/renderable/ui/uibaseelement.js +0 -276
- package/src/renderable/ui/uispriteelement.js +0 -223
- package/src/renderable/ui/uitextbutton.js +0 -140
- package/src/state/stage.js +0 -226
- package/src/state/state.js +0 -541
- package/src/system/device.js +0 -863
- package/src/system/dom.js +0 -70
- package/src/system/event.js +0 -597
- package/src/system/platform.js +0 -34
- package/src/system/pooling.js +0 -190
- package/src/system/save.js +0 -148
- package/src/system/timer.js +0 -281
- package/src/tweens/easing.js +0 -325
- package/src/tweens/interpolation.js +0 -103
- package/src/tweens/tween.js +0 -470
- package/src/utils/agent.js +0 -68
- package/src/utils/array.js +0 -54
- package/src/utils/file.js +0 -46
- package/src/utils/function.js +0 -60
- package/src/utils/string.js +0 -73
- package/src/utils/utils.js +0 -127
- package/src/video/canvas/canvas_renderer.js +0 -905
- package/src/video/renderer.js +0 -393
- package/src/video/rendertarget/canvasrendertarget.js +0 -309
- package/src/video/texture/atlas.js +0 -456
- package/src/video/texture/cache.js +0 -178
- package/src/video/texture/parser/aseprite.js +0 -69
- package/src/video/texture/parser/spritesheet.js +0 -68
- package/src/video/texture/parser/texturepacker.js +0 -55
- package/src/video/utils/autodetect.js +0 -18
- package/src/video/video.js +0 -160
- package/src/video/webgl/buffer/vertex.js +0 -137
- package/src/video/webgl/compositors/compositor.js +0 -231
- package/src/video/webgl/compositors/primitive_compositor.js +0 -73
- package/src/video/webgl/compositors/quad_compositor.js +0 -250
- package/src/video/webgl/glshader.js +0 -158
- package/src/video/webgl/shaders/primitive.frag +0 -5
- package/src/video/webgl/shaders/primitive.vert +0 -15
- package/src/video/webgl/shaders/quad.frag +0 -7
- package/src/video/webgl/shaders/quad.vert +0 -18
- package/src/video/webgl/utils/attributes.js +0 -16
- package/src/video/webgl/utils/precision.js +0 -29
- package/src/video/webgl/utils/program.js +0 -58
- package/src/video/webgl/utils/string.js +0 -16
- package/src/video/webgl/utils/uniforms.js +0 -84
- package/src/video/webgl/webgl_renderer.js +0 -1237
|
@@ -1,905 +0,0 @@
|
|
|
1
|
-
import Color from "./../../math/color.js";
|
|
2
|
-
import Renderer from "./../renderer.js";
|
|
3
|
-
import TextureCache from "./../texture/cache.js";
|
|
4
|
-
import * as event from "./../../system/event.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* additional import for TypeScript
|
|
8
|
-
* @import Rect from "./../../geometries/rectangle.js";
|
|
9
|
-
* @import RoundRect from "./../../geometries/roundrect.js";
|
|
10
|
-
* @import Polygon from "./../../geometries/poly.js";
|
|
11
|
-
* @import Line from "./../../geometries/line.js";
|
|
12
|
-
* @import Ellipse from "./../../geometries/ellipse.js";
|
|
13
|
-
* @import Matrix2d from "./../../math/matrix2.js";
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @classdesc
|
|
18
|
-
* a canvas renderer object
|
|
19
|
-
* @augments Renderer
|
|
20
|
-
*/
|
|
21
|
-
export default class CanvasRenderer extends Renderer {
|
|
22
|
-
/**
|
|
23
|
-
* @param {ApplicationSettings} [options] - optional parameters for the renderer
|
|
24
|
-
*/
|
|
25
|
-
constructor(options) {
|
|
26
|
-
// parent constructor
|
|
27
|
-
super(options);
|
|
28
|
-
|
|
29
|
-
this.setBlendMode(this.settings.blendMode);
|
|
30
|
-
|
|
31
|
-
// apply the default color to the 2d context
|
|
32
|
-
this.setColor(this.currentColor);
|
|
33
|
-
|
|
34
|
-
// create a texture cache
|
|
35
|
-
this.cache = new TextureCache();
|
|
36
|
-
|
|
37
|
-
if (this.settings.textureSeamFix !== false && !this.settings.antiAlias) {
|
|
38
|
-
// enable the tile texture seam fix with the canvas renderer
|
|
39
|
-
this.uvOffset = 1;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// set the renderer type
|
|
43
|
-
this.type = "CANVAS";
|
|
44
|
-
|
|
45
|
-
// context lost & restore event for canvas
|
|
46
|
-
this.getCanvas().addEventListener("contextlost", (e) => {
|
|
47
|
-
e.preventDefault();
|
|
48
|
-
this.isContextValid = false;
|
|
49
|
-
event.emit(event.ONCONTEXT_LOST, this);
|
|
50
|
-
}, false);
|
|
51
|
-
// ctx.restoreContext()
|
|
52
|
-
this.getCanvas().addEventListener("contextrestored", () => {
|
|
53
|
-
this.isContextValid = true;
|
|
54
|
-
event.emit(event.ONCONTEXT_RESTORED, this);
|
|
55
|
-
}, false);
|
|
56
|
-
|
|
57
|
-
// reset the renderer on game reset
|
|
58
|
-
event.on(event.GAME_RESET, () => {
|
|
59
|
-
this.reset();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Reset context state
|
|
65
|
-
*/
|
|
66
|
-
reset() {
|
|
67
|
-
super.reset();
|
|
68
|
-
this.clearColor(this.currentColor, this.settings.transparent !== true);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Reset the canvas transform to identity
|
|
73
|
-
*/
|
|
74
|
-
resetTransform() {
|
|
75
|
-
this.getContext().setTransform(1, 0, 0, 1, 0, 0);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* set a blend mode for the given context. <br>
|
|
80
|
-
* Supported blend mode between Canvas and WebGL remderer : <br>
|
|
81
|
-
* - "normal" : this is the default mode and draws new content on top of the existing content <br>
|
|
82
|
-
* <img src="images/normal-blendmode.png" width="510"/> <br>
|
|
83
|
-
* - "multiply" : the pixels of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result. <br>
|
|
84
|
-
* <img src="images/multiply-blendmode.png" width="510"/> <br>
|
|
85
|
-
* - "additive or lighter" : where both content overlap the color is determined by adding color values. <br>
|
|
86
|
-
* <img src="images/lighter-blendmode.png" width="510"/> <br>
|
|
87
|
-
* - "screen" : The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) <br>
|
|
88
|
-
* <img src="images/screen-blendmode.png" width="510"/> <br>
|
|
89
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
90
|
-
* @param {string} [mode="normal"] - blend mode : "normal", "multiply", "lighter, "additive", "screen"
|
|
91
|
-
* @param {CanvasRenderingContext2D} [context]
|
|
92
|
-
*/
|
|
93
|
-
setBlendMode(mode = "normal", context) {
|
|
94
|
-
context = context || this.getContext();
|
|
95
|
-
this.currentBlendMode = mode;
|
|
96
|
-
switch (mode) {
|
|
97
|
-
case "screen" :
|
|
98
|
-
context.globalCompositeOperation = "screen";
|
|
99
|
-
break;
|
|
100
|
-
|
|
101
|
-
case "lighter" :
|
|
102
|
-
case "additive" :
|
|
103
|
-
context.globalCompositeOperation = "lighter";
|
|
104
|
-
break;
|
|
105
|
-
|
|
106
|
-
case "multiply" :
|
|
107
|
-
context.globalCompositeOperation = "multiply";
|
|
108
|
-
break;
|
|
109
|
-
|
|
110
|
-
default : // normal
|
|
111
|
-
context.globalCompositeOperation = "source-over";
|
|
112
|
-
this.currentBlendMode = "normal";
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* prepare the framebuffer for drawing a new frame
|
|
119
|
-
*/
|
|
120
|
-
clear() {
|
|
121
|
-
if (this.settings.transparent === false) {
|
|
122
|
-
let canvas = this.getCanvas();
|
|
123
|
-
let context = this.getContext();
|
|
124
|
-
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Clears the main framebuffer with the given color
|
|
130
|
-
* @param {Color|string} [color="#000000"] - CSS color.
|
|
131
|
-
* @param {boolean} [opaque=false] - Allow transparency [default] or clear the surface completely [true]
|
|
132
|
-
*/
|
|
133
|
-
clearColor(color = "#000000", opaque = false) {
|
|
134
|
-
let canvas = this.getCanvas();
|
|
135
|
-
let context = this.getContext();
|
|
136
|
-
|
|
137
|
-
this.save();
|
|
138
|
-
this.resetTransform();
|
|
139
|
-
context.globalAlpha = 1;
|
|
140
|
-
context.globalCompositeOperation = opaque === true ? "copy" : "source-over";
|
|
141
|
-
context.fillStyle = (color instanceof Color) ? color.toRGBA() : color;
|
|
142
|
-
this.fillRect(0, 0, canvas.width, canvas.height);
|
|
143
|
-
this.restore();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
|
|
148
|
-
* @param {number} x - x axis of the coordinate for the rectangle starting point.
|
|
149
|
-
* @param {number} y - y axis of the coordinate for the rectangle starting point.
|
|
150
|
-
* @param {number} width - The rectangle's width.
|
|
151
|
-
* @param {number} height - The rectangle's height.
|
|
152
|
-
*/
|
|
153
|
-
clearRect(x, y, width, height) {
|
|
154
|
-
this.getContext().clearRect(x, y, width, height);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Create a pattern with the specified repetition
|
|
159
|
-
* @param {HTMLImageElement|SVGImageElement|HTMLVideoElement|HTMLCanvasElement|ImageBitmap|OffscreenCanvas|VideoFrame} image - Source image to be used as the pattern's image
|
|
160
|
-
* @param {string} repeat - Define how the pattern should be repeated
|
|
161
|
-
* @returns {CanvasPattern}
|
|
162
|
-
* @see ImageLayer#repeat
|
|
163
|
-
* @example
|
|
164
|
-
* let tileable = renderer.createPattern(image, "repeat");
|
|
165
|
-
* let horizontal = renderer.createPattern(image, "repeat-x");
|
|
166
|
-
* let vertical = renderer.createPattern(image, "repeat-y");
|
|
167
|
-
* let basic = renderer.createPattern(image, "no-repeat");
|
|
168
|
-
*/
|
|
169
|
-
createPattern(image, repeat) {
|
|
170
|
-
return this.getContext().createPattern(image, repeat);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Draw an image onto the main using the canvas api
|
|
175
|
-
* @param {HTMLImageElement|SVGImageElement|HTMLVideoElement|HTMLCanvasElement|ImageBitmap|OffscreenCanvas|VideoFrame} image - An element to draw into the context.
|
|
176
|
-
* @param {number} sx - The X coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.
|
|
177
|
-
* @param {number} sy - The Y coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.
|
|
178
|
-
* @param {number} sw - The width of the sub-rectangle of the source image to draw into the destination context. If not specified, the entire rectangle from the coordinates specified by sx and sy to the bottom-right corner of the image is used.
|
|
179
|
-
* @param {number} sh - The height of the sub-rectangle of the source image to draw into the destination context.
|
|
180
|
-
* @param {number} dx - The X coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
181
|
-
* @param {number} dy - The Y coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
182
|
-
* @param {number} dw - The width to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in width when drawn.
|
|
183
|
-
* @param {number} dh - The height to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.
|
|
184
|
-
* @example
|
|
185
|
-
* // Position the image on the canvas:
|
|
186
|
-
* renderer.drawImage(image, dx, dy);
|
|
187
|
-
* // Position the image on the canvas, and specify width and height of the image:
|
|
188
|
-
* renderer.drawImage(image, dx, dy, dWidth, dHeight);
|
|
189
|
-
* // Clip the image and position the clipped part on the canvas:
|
|
190
|
-
* renderer.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
|
|
191
|
-
*/
|
|
192
|
-
drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) {
|
|
193
|
-
if (this.getGlobalAlpha() < 1 / 255) {
|
|
194
|
-
// Fast path: don't draw fully transparent
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
let context = this.getContext();
|
|
198
|
-
|
|
199
|
-
if (typeof sw === "undefined") {
|
|
200
|
-
sw = dw = image.width;
|
|
201
|
-
sh = dh = image.height;
|
|
202
|
-
dx = sx;
|
|
203
|
-
dy = sy;
|
|
204
|
-
sx = 0;
|
|
205
|
-
sy = 0;
|
|
206
|
-
}
|
|
207
|
-
else if (typeof dx === "undefined") {
|
|
208
|
-
dx = sx;
|
|
209
|
-
dy = sy;
|
|
210
|
-
dw = sw;
|
|
211
|
-
dh = sh;
|
|
212
|
-
sw = image.width;
|
|
213
|
-
sh = image.height;
|
|
214
|
-
sx = 0;
|
|
215
|
-
sy = 0;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (this.settings.subPixel === false) {
|
|
219
|
-
// clamp to pixel grid
|
|
220
|
-
dx = ~~dx;
|
|
221
|
-
dy = ~~dy;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// apply a tint if required
|
|
225
|
-
let source = image;
|
|
226
|
-
let tint = this.currentTint.toArray();
|
|
227
|
-
if (tint[0] !== 1.0 || tint[1] !== 1.0 || tint[2] !== 1.0) {
|
|
228
|
-
// get a tinted version of this image from the texture cache
|
|
229
|
-
source = this.cache.tint(image, this.currentTint.toRGB());
|
|
230
|
-
}
|
|
231
|
-
context.drawImage(source, sx, sy, sw, sh, dx, dy, dw, dh);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Draw a pattern within the given rectangle.
|
|
236
|
-
* @param {CanvasPattern} pattern - Pattern object
|
|
237
|
-
* @param {number} x
|
|
238
|
-
* @param {number} y
|
|
239
|
-
* @param {number} width
|
|
240
|
-
* @param {number} height
|
|
241
|
-
* @see CanvasRenderer#createPattern
|
|
242
|
-
*/
|
|
243
|
-
drawPattern(pattern, x, y, width, height) {
|
|
244
|
-
if (this.getGlobalAlpha() < 1 / 255) {
|
|
245
|
-
// Fast path: don't draw fully transparent
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
let context = this.getContext();
|
|
249
|
-
let fillStyle = context.fillStyle;
|
|
250
|
-
context.fillStyle = pattern;
|
|
251
|
-
context.fillRect(x, y, width, height);
|
|
252
|
-
context.fillStyle = fillStyle;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path
|
|
257
|
-
* @example
|
|
258
|
-
* // First path
|
|
259
|
-
* renderer.beginPath();
|
|
260
|
-
* renderer.setColor("blue");
|
|
261
|
-
* renderer.moveTo(20, 20);
|
|
262
|
-
* renderer.lineTo(200, 20);
|
|
263
|
-
* renderer.stroke();
|
|
264
|
-
* // Second path
|
|
265
|
-
* renderer.beginPath();
|
|
266
|
-
* renderer.setColor("green");
|
|
267
|
-
* renderer.moveTo(20, 20);
|
|
268
|
-
* renderer.lineTo(120, 120);
|
|
269
|
-
* renderer.stroke();
|
|
270
|
-
*/
|
|
271
|
-
beginPath() {
|
|
272
|
-
this.getContext().beginPath();
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* begins a new sub-path at the point specified by the given (x, y) coordinates.
|
|
277
|
-
* @param {number} x - The x axis of the point.
|
|
278
|
-
* @param {number} y - The y axis of the point.
|
|
279
|
-
*/
|
|
280
|
-
moveTo(x, y) {
|
|
281
|
-
this.getContext().moveTo(x, y);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* adds a straight line to the current sub-path by connecting the sub-path's last point to the specified (x, y) coordinates.
|
|
286
|
-
*/
|
|
287
|
-
lineTo(x, y) {
|
|
288
|
-
this.getContext().lineTo(x, y);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* creates a rectangular path whose starting point is at (x, y) and whose size is specified by width and height.
|
|
293
|
-
* @param {number} x - The x axis of the coordinate for the rectangle starting point.
|
|
294
|
-
* @param {number} y - The y axis of the coordinate for the rectangle starting point.
|
|
295
|
-
* @param {number} width - The rectangle's width.
|
|
296
|
-
* @param {number} height - The rectangle's height.
|
|
297
|
-
*/
|
|
298
|
-
rect(x, y, width, height) {
|
|
299
|
-
this.getContext().rect(x, y, width, height);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* adds a rounded rectangle to the current path.
|
|
304
|
-
* @param {number} x - The x axis of the coordinate for the rectangle starting point.
|
|
305
|
-
* @param {number} y - The y axis of the coordinate for the rectangle starting point.
|
|
306
|
-
* @param {number} width - The rectangle's width.
|
|
307
|
-
* @param {number} height - The rectangle's height.
|
|
308
|
-
* @param {number} radius - The corner radius.
|
|
309
|
-
*/
|
|
310
|
-
roundRect(x, y, width, height, radii) {
|
|
311
|
-
this.getContext().roundRect(x, y, width, height, radii);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* stroke the given shape or the current defined path
|
|
316
|
-
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [shape] - a shape object to stroke
|
|
317
|
-
* @param {boolean} [fill=false] - fill the shape with the current color if true
|
|
318
|
-
*/
|
|
319
|
-
stroke(shape, fill) {
|
|
320
|
-
if (typeof shape === "undefined") {
|
|
321
|
-
if (fill === true) {
|
|
322
|
-
this.getContext().fill();
|
|
323
|
-
} else {
|
|
324
|
-
this.getContext().stroke();
|
|
325
|
-
}
|
|
326
|
-
} else {
|
|
327
|
-
super.stroke(shape, fill);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* fill the given shape or the current defined path
|
|
333
|
-
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [shape] - a shape object to fill
|
|
334
|
-
*/
|
|
335
|
-
fill(shape) {
|
|
336
|
-
this.stroke(shape, true);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* add a straight line from the current point to the start of the current sub-path. If the shape has already been closed or has only one point, this function does nothing
|
|
341
|
-
*/
|
|
342
|
-
closePath() {
|
|
343
|
-
this.getContext().closePath();
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Stroke an arc at the specified coordinates with given radius, start and end points
|
|
349
|
-
* @param {number} x - arc center point x-axis
|
|
350
|
-
* @param {number} y - arc center point y-axis
|
|
351
|
-
* @param {number} radius
|
|
352
|
-
* @param {number} start - start angle in radians
|
|
353
|
-
* @param {number} end - end angle in radians
|
|
354
|
-
* @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
|
|
355
|
-
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
356
|
-
*/
|
|
357
|
-
strokeArc(x, y, radius, start, end, antiClockwise, fill = false) {
|
|
358
|
-
if (this.getGlobalAlpha() < 1 / 255) {
|
|
359
|
-
// Fast path: don't draw fully transparent
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
let context = this.getContext();
|
|
363
|
-
|
|
364
|
-
context.translate(x, y);
|
|
365
|
-
context.beginPath();
|
|
366
|
-
context.arc(0, 0, radius, start, end, antiClockwise || false);
|
|
367
|
-
context[fill === true ? "fill" : "stroke"]();
|
|
368
|
-
context.translate(-x, -y);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Fill an arc at the specified coordinates with given radius, start and end points
|
|
373
|
-
* @param {number} x - arc center point x-axis
|
|
374
|
-
* @param {number} y - arc center point y-axis
|
|
375
|
-
* @param {number} radius
|
|
376
|
-
* @param {number} start - start angle in radians
|
|
377
|
-
* @param {number} end - end angle in radians
|
|
378
|
-
* @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
|
|
379
|
-
*/
|
|
380
|
-
fillArc(x, y, radius, start, end, antiClockwise) {
|
|
381
|
-
this.strokeArc(x, y, radius, start, end, antiClockwise || false, true);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Stroke an ellipse at the specified coordinates with given radius
|
|
386
|
-
* @param {number} x - ellipse center point x-axis
|
|
387
|
-
* @param {number} y - ellipse center point y-axis
|
|
388
|
-
* @param {number} w - horizontal radius of the ellipse
|
|
389
|
-
* @param {number} h - vertical radius of the ellipse
|
|
390
|
-
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
391
|
-
*/
|
|
392
|
-
strokeEllipse(x, y, w, h, fill = false) {
|
|
393
|
-
if (this.getGlobalAlpha() < 1 / 255) {
|
|
394
|
-
// Fast path: don't draw fully transparent
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
let context = this.getContext();
|
|
398
|
-
|
|
399
|
-
let hw = w,
|
|
400
|
-
hh = h,
|
|
401
|
-
lx = x - hw,
|
|
402
|
-
rx = x + hw,
|
|
403
|
-
ty = y - hh,
|
|
404
|
-
by = y + hh;
|
|
405
|
-
|
|
406
|
-
let xmagic = hw * 0.551784,
|
|
407
|
-
ymagic = hh * 0.551784,
|
|
408
|
-
xmin = x - xmagic,
|
|
409
|
-
xmax = x + xmagic,
|
|
410
|
-
ymin = y - ymagic,
|
|
411
|
-
ymax = y + ymagic;
|
|
412
|
-
|
|
413
|
-
context.beginPath();
|
|
414
|
-
context.moveTo(x, ty);
|
|
415
|
-
context.bezierCurveTo(xmax, ty, rx, ymin, rx, y);
|
|
416
|
-
context.bezierCurveTo(rx, ymax, xmax, by, x, by);
|
|
417
|
-
context.bezierCurveTo(xmin, by, lx, ymax, lx, y);
|
|
418
|
-
context.bezierCurveTo(lx, ymin, xmin, ty, x, ty);
|
|
419
|
-
context[fill === true ? "fill" : "stroke"]();
|
|
420
|
-
context.closePath();
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Fill an ellipse at the specified coordinates with given radius
|
|
425
|
-
* @param {number} x - ellipse center point x-axis
|
|
426
|
-
* @param {number} y - ellipse center point y-axis
|
|
427
|
-
* @param {number} w - horizontal radius of the ellipse
|
|
428
|
-
* @param {number} h - vertical radius of the ellipse
|
|
429
|
-
*/
|
|
430
|
-
fillEllipse(x, y, w, h) {
|
|
431
|
-
this.strokeEllipse(x, y, w, h, true);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Stroke a line of the given two points
|
|
436
|
-
* @param {number} startX - the start x coordinate
|
|
437
|
-
* @param {number} startY - the start y coordinate
|
|
438
|
-
* @param {number} endX - the end x coordinate
|
|
439
|
-
* @param {number} endY - the end y coordinate
|
|
440
|
-
*/
|
|
441
|
-
strokeLine(startX, startY, endX, endY) {
|
|
442
|
-
if (this.getGlobalAlpha() < 1 / 255) {
|
|
443
|
-
// Fast path: don't draw fully transparent
|
|
444
|
-
return;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
let context = this.getContext();
|
|
448
|
-
|
|
449
|
-
context.beginPath();
|
|
450
|
-
context.moveTo(startX, startY);
|
|
451
|
-
context.lineTo(endX, endY);
|
|
452
|
-
context.stroke();
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
* Fill a line of the given two points
|
|
457
|
-
* @param {number} startX - the start x coordinate
|
|
458
|
-
* @param {number} startY - the start y coordinate
|
|
459
|
-
* @param {number} endX - the end x coordinate
|
|
460
|
-
* @param {number} endY - the end y coordinate
|
|
461
|
-
*/
|
|
462
|
-
fillLine(startX, startY, endX, endY) {
|
|
463
|
-
this.strokeLine(startX, startY, endX, endY);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* Stroke the given me.Polygon on the screen
|
|
468
|
-
* @param {Polygon} poly - the shape to draw
|
|
469
|
-
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
470
|
-
*/
|
|
471
|
-
strokePolygon(poly, fill = false) {
|
|
472
|
-
if (this.getGlobalAlpha() < 1 / 255) {
|
|
473
|
-
// Fast path: don't draw fully transparent
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
let context = this.getContext();
|
|
477
|
-
let points = poly.points;
|
|
478
|
-
let pointsLength = points.length;
|
|
479
|
-
let firstPoint = points[0];
|
|
480
|
-
|
|
481
|
-
this.translate(poly.pos.x, poly.pos.y);
|
|
482
|
-
|
|
483
|
-
context.beginPath();
|
|
484
|
-
context.moveTo(firstPoint.x, firstPoint.y);
|
|
485
|
-
for (let i = 1; i < pointsLength; i++) {
|
|
486
|
-
const point = points[i];
|
|
487
|
-
context.lineTo(point.x, point.y);
|
|
488
|
-
}
|
|
489
|
-
context.lineTo(firstPoint.x, firstPoint.y);
|
|
490
|
-
context[fill === true ? "fill" : "stroke"]();
|
|
491
|
-
context.closePath();
|
|
492
|
-
|
|
493
|
-
this.translate(-poly.pos.x, -poly.pos.y);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Fill the given me.Polygon on the screen
|
|
498
|
-
* @param {Polygon} poly - the shape to draw
|
|
499
|
-
*/
|
|
500
|
-
fillPolygon(poly) {
|
|
501
|
-
this.strokePolygon(poly, true);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Stroke a rectangle at the specified coordinates
|
|
506
|
-
* @param {number} x
|
|
507
|
-
* @param {number} y
|
|
508
|
-
* @param {number} width
|
|
509
|
-
* @param {number} height
|
|
510
|
-
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
511
|
-
*/
|
|
512
|
-
strokeRect(x, y, width, height, fill = false) {
|
|
513
|
-
if (this.getGlobalAlpha() < 1 / 255) {
|
|
514
|
-
// Fast path: don't draw fully transparent
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
let context = this.getContext();
|
|
518
|
-
|
|
519
|
-
context[fill === true ? "fillRect" : "strokeRect"](x, y, width, height);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* Draw a filled rectangle at the specified coordinates
|
|
524
|
-
* @param {number} x
|
|
525
|
-
* @param {number} y
|
|
526
|
-
* @param {number} width
|
|
527
|
-
* @param {number} height
|
|
528
|
-
*/
|
|
529
|
-
fillRect(x, y, width, height) {
|
|
530
|
-
this.strokeRect(x, y, width, height, true);
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* Stroke a rounded rectangle at the specified coordinates
|
|
535
|
-
* @param {number} x
|
|
536
|
-
* @param {number} y
|
|
537
|
-
* @param {number} width
|
|
538
|
-
* @param {number} height
|
|
539
|
-
* @param {number} radius
|
|
540
|
-
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
541
|
-
*/
|
|
542
|
-
strokeRoundRect(x, y, width, height, radius, fill = false) {
|
|
543
|
-
if (this.getGlobalAlpha() < 1 / 255) {
|
|
544
|
-
// Fast path: don't draw fully transparent
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
let context = this.getContext();
|
|
548
|
-
|
|
549
|
-
context.beginPath();
|
|
550
|
-
context.roundRect(x, y, width, height, radius);
|
|
551
|
-
context[fill === true ? "fill" : "stroke"]();
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Draw a rounded filled rectangle at the specified coordinates
|
|
556
|
-
* @param {number} x
|
|
557
|
-
* @param {number} y
|
|
558
|
-
* @param {number} width
|
|
559
|
-
* @param {number} height
|
|
560
|
-
* @param {number} radius
|
|
561
|
-
*/
|
|
562
|
-
fillRoundRect(x, y, width, height, radius) {
|
|
563
|
-
this.strokeRoundRect(x, y, width, height, radius, true);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* Stroke a Point at the specified coordinates
|
|
568
|
-
* @param {number} x
|
|
569
|
-
* @param {number} y
|
|
570
|
-
*/
|
|
571
|
-
strokePoint(x, y) {
|
|
572
|
-
this.strokeLine(x, y, x + 1, y + 1);
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* Draw a a point at the specified coordinates
|
|
577
|
-
* @param {number} x
|
|
578
|
-
* @param {number} y
|
|
579
|
-
* @param {number} width
|
|
580
|
-
* @param {number} height
|
|
581
|
-
*/
|
|
582
|
-
fillPoint(x, y) {
|
|
583
|
-
this.strokePoint(x, y);
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* restores the most recently saved renderer state by popping the top entry in the drawing state stack
|
|
588
|
-
* @example
|
|
589
|
-
* // Save the current state
|
|
590
|
-
* renderer.save();
|
|
591
|
-
*
|
|
592
|
-
* // apply a transform and draw a rect
|
|
593
|
-
* renderer.tranform(matrix);
|
|
594
|
-
* renderer.fillRect(10, 10, 100, 100);
|
|
595
|
-
*
|
|
596
|
-
* // Restore to the state saved by the most recent call to save()
|
|
597
|
-
* renderer.restore();
|
|
598
|
-
*/
|
|
599
|
-
restore() {
|
|
600
|
-
const canvas = this.getCanvas();
|
|
601
|
-
this.getContext().restore();
|
|
602
|
-
this.currentColor.glArray[3] = this.getGlobalAlpha();
|
|
603
|
-
this.currentScissor[0] = 0;
|
|
604
|
-
this.currentScissor[1] = 0;
|
|
605
|
-
this.currentScissor[2] = canvas.width;
|
|
606
|
-
this.currentScissor[3] = canvas.height;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* saves the entire state of the renderer by pushing the current state onto a stack.
|
|
611
|
-
* @example
|
|
612
|
-
* // Save the current state
|
|
613
|
-
* renderer.save();
|
|
614
|
-
*
|
|
615
|
-
* // apply a transform and draw a rect
|
|
616
|
-
* renderer.tranform(matrix);
|
|
617
|
-
* renderer.fillRect(10, 10, 100, 100);
|
|
618
|
-
*
|
|
619
|
-
* // Restore to the state saved by the most recent call to save()
|
|
620
|
-
* renderer.restore();
|
|
621
|
-
*/
|
|
622
|
-
save() {
|
|
623
|
-
this.getContext().save();
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* adds a rotation to the transformation matrix.
|
|
628
|
-
* @param {number} angle - the rotation angle, clockwise in radians
|
|
629
|
-
* @example
|
|
630
|
-
* // Rotated rectangle
|
|
631
|
-
* renderer.rotate((45 * Math.PI) / 180);
|
|
632
|
-
* renderer.setColor("red");
|
|
633
|
-
* renderer.fillRect(10, 10, 100, 100);
|
|
634
|
-
*
|
|
635
|
-
* // Reset transformation matrix to the identity matrix
|
|
636
|
-
* renderer.setTransform(1, 0, 0, 1, 0, 0);
|
|
637
|
-
*/
|
|
638
|
-
rotate(angle) {
|
|
639
|
-
this.getContext().rotate(angle);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
/**
|
|
643
|
-
* adds a scaling transformation to the renderer units horizontally and/or vertically
|
|
644
|
-
* @param {number} x - Scaling factor in the horizontal direction. A negative value flips pixels across the vertical axis. A value of 1 results in no horizontal scaling.
|
|
645
|
-
* @param {number} y - Scaling factor in the vertical direction. A negative value flips pixels across the horizontal axis. A value of 1 results in no vertical scaling
|
|
646
|
-
*/
|
|
647
|
-
scale(x, y) {
|
|
648
|
-
this.getContext().scale(x, y);
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
* Set the current fill & stroke style color.
|
|
653
|
-
* By default, or upon reset, the value is set to #000000.
|
|
654
|
-
* @param {Color|string} color - css color value
|
|
655
|
-
*/
|
|
656
|
-
setColor(color) {
|
|
657
|
-
let currentColor = this.currentColor;
|
|
658
|
-
let context = this.getContext();
|
|
659
|
-
|
|
660
|
-
currentColor.copy(color);
|
|
661
|
-
// globalAlpha is applied at rendering time by the canvas
|
|
662
|
-
|
|
663
|
-
context.strokeStyle = context.fillStyle = currentColor.toRGBA();
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
/**
|
|
667
|
-
* Set the global alpha
|
|
668
|
-
* @param {number} alpha - 0.0 to 1.0 values accepted.
|
|
669
|
-
*/
|
|
670
|
-
setGlobalAlpha(alpha) {
|
|
671
|
-
this.getContext().globalAlpha = alpha;
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
/**
|
|
675
|
-
* Return the global alpha
|
|
676
|
-
* @returns {number} global alpha value
|
|
677
|
-
*/
|
|
678
|
-
getGlobalAlpha() {
|
|
679
|
-
return this.getContext().globalAlpha;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
* sets or returns the thickness of lines for shape drawing
|
|
684
|
-
* @type {number}
|
|
685
|
-
* @default 1
|
|
686
|
-
*/
|
|
687
|
-
get lineWidth() {
|
|
688
|
-
return this.getContext().lineWidth;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* @ignore
|
|
693
|
-
*/
|
|
694
|
-
set lineWidth(value) {
|
|
695
|
-
this.getContext().lineWidth = value;
|
|
696
|
-
return value;
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
/**
|
|
700
|
-
* sets or returns the shape used to join two line segments where they meet.
|
|
701
|
-
* There are three possible values for this property: "round", "bevel", and "miter"
|
|
702
|
-
* @type {string}
|
|
703
|
-
* @default "miter"
|
|
704
|
-
*/
|
|
705
|
-
get lineJoin() {
|
|
706
|
-
return this.getContext().lineJoin;
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* @ignore
|
|
711
|
-
*/
|
|
712
|
-
set lineJoin(value) {
|
|
713
|
-
let context = this.getContext();
|
|
714
|
-
context.lineJoin = value;
|
|
715
|
-
return context.lineJoin;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
/**
|
|
719
|
-
* Reset (overrides) the renderer transformation matrix to the
|
|
720
|
-
* identity one, and then apply the given transformation matrix.
|
|
721
|
-
* @param {Matrix2d|number} a - a matrix2d to transform by, or a the a component to multiply the current matrix by
|
|
722
|
-
* @param {number} b - the b component to multiply the current matrix by
|
|
723
|
-
* @param {number} c - the c component to multiply the current matrix by
|
|
724
|
-
* @param {number} d - the d component to multiply the current matrix by
|
|
725
|
-
* @param {number} e - the e component to multiply the current matrix by
|
|
726
|
-
* @param {number} f - the f component to multiply the current matrix by
|
|
727
|
-
*/
|
|
728
|
-
setTransform(a, b, c, d, e, f) {
|
|
729
|
-
this.resetTransform();
|
|
730
|
-
this.transform(a, b, c, d, e, f);
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
/**
|
|
734
|
-
* Multiply given matrix into the renderer tranformation matrix
|
|
735
|
-
* @see {@link CanvasRenderer.setTransform} which will reset the current transform matrix prior to performing the new transformation
|
|
736
|
-
* @param {Matrix2d|number} a - a matrix2d to transform by, or a the a component to multiply the current matrix by
|
|
737
|
-
* @param {number} b - the b component to multiply the current matrix by
|
|
738
|
-
* @param {number} c - the c component to multiply the current matrix by
|
|
739
|
-
* @param {number} d - the d component to multiply the current matrix by
|
|
740
|
-
* @param {number} e - the e component to multiply the current matrix by
|
|
741
|
-
* @param {number} f - the f component to multiply the current matrix by
|
|
742
|
-
*/
|
|
743
|
-
transform(a, b, c, d, e, f) {
|
|
744
|
-
if (typeof a === "object") {
|
|
745
|
-
let m = a.toArray();
|
|
746
|
-
a = m[0];
|
|
747
|
-
b = m[1];
|
|
748
|
-
c = m[3];
|
|
749
|
-
d = m[4];
|
|
750
|
-
e = m[6];
|
|
751
|
-
f = m[7];
|
|
752
|
-
}
|
|
753
|
-
// else individual components
|
|
754
|
-
|
|
755
|
-
if (this.settings.subPixel === false) {
|
|
756
|
-
e |= 0;
|
|
757
|
-
f |= 0;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
this.getContext().transform(a, b, c, d, e, f);
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
/**
|
|
764
|
-
* adds a translation transformation to the current matrix.
|
|
765
|
-
* @param {number} x - Distance to move in the horizontal direction. Positive values are to the right, and negative to the left.
|
|
766
|
-
* @param {number} y - Distance to move in the vertical direction. Positive values are down, and negative are up.
|
|
767
|
-
*/
|
|
768
|
-
translate(x, y) {
|
|
769
|
-
if (this.settings.subPixel === false) {
|
|
770
|
-
this.getContext().translate(~~x, ~~y);
|
|
771
|
-
} else {
|
|
772
|
-
this.getContext().translate(x, y);
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
/**
|
|
777
|
-
* clip the given region from the original canvas. Once a region is clipped,
|
|
778
|
-
* all future drawing will be limited to the clipped region.
|
|
779
|
-
* You can however save the current region using the save(),
|
|
780
|
-
* and restore it (with the restore() method) any time in the future.
|
|
781
|
-
* (<u>this is an experimental feature !</u>)
|
|
782
|
-
* @param {number} x
|
|
783
|
-
* @param {number} y
|
|
784
|
-
* @param {number} width
|
|
785
|
-
* @param {number} height
|
|
786
|
-
*/
|
|
787
|
-
clipRect(x, y, width, height) {
|
|
788
|
-
let canvas = this.getCanvas();
|
|
789
|
-
// if requested box is different from the current canvas size;
|
|
790
|
-
if (x !== 0 || y !== 0 || width !== canvas.width || height !== canvas.height) {
|
|
791
|
-
let currentScissor = this.currentScissor;
|
|
792
|
-
// if different from the current scissor box
|
|
793
|
-
if (currentScissor[0] !== x || currentScissor[1] !== y ||
|
|
794
|
-
currentScissor[2] !== width || currentScissor[3] !== height) {
|
|
795
|
-
let context = this.getContext();
|
|
796
|
-
context.beginPath();
|
|
797
|
-
context.rect(x, y, width, height);
|
|
798
|
-
context.clip();
|
|
799
|
-
// save the new currentScissor box
|
|
800
|
-
currentScissor[0] = x;
|
|
801
|
-
currentScissor[1] = y;
|
|
802
|
-
currentScissor[2] = width;
|
|
803
|
-
currentScissor[3] = height;
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
/**
|
|
809
|
-
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
810
|
-
* If the drawing or rendering area is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
811
|
-
* (Note Mask are not preserved through renderer context save and restore and need so be manually cleared)
|
|
812
|
-
* @see CanvasRenderer#clearMask
|
|
813
|
-
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] - the shape defining the mask to be applied
|
|
814
|
-
* @param {boolean} [invert=false] - either the given shape should define what is visible (default) or the opposite
|
|
815
|
-
*/
|
|
816
|
-
setMask(mask, invert = false) {
|
|
817
|
-
let context = this.getContext();
|
|
818
|
-
|
|
819
|
-
if (this.maskLevel === 0) {
|
|
820
|
-
// only save context on the first mask
|
|
821
|
-
context.save();
|
|
822
|
-
if (typeof mask !== "undefined") {
|
|
823
|
-
context.beginPath();
|
|
824
|
-
}
|
|
825
|
-
// else use the current path
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
if (typeof mask !== "undefined") {
|
|
829
|
-
switch (mask.type) {
|
|
830
|
-
// RoundRect
|
|
831
|
-
case "RoundRect":
|
|
832
|
-
context.roundRect(mask.top, mask.left, mask.width, mask.height, mask.radius);
|
|
833
|
-
break;
|
|
834
|
-
|
|
835
|
-
// Rect or Bounds
|
|
836
|
-
case "Rectangle":
|
|
837
|
-
case "Bounds":
|
|
838
|
-
context.rect(mask.top, mask.left, mask.width, mask.height);
|
|
839
|
-
break;
|
|
840
|
-
|
|
841
|
-
// Polygon or Line
|
|
842
|
-
case "Polygon":
|
|
843
|
-
{
|
|
844
|
-
// polygon
|
|
845
|
-
const _x = mask.pos.x, _y = mask.pos.y;
|
|
846
|
-
context.moveTo(_x + mask.points[0].x, _y + mask.points[0].y);
|
|
847
|
-
for (let i = 1; i < mask.points.length; i++) {
|
|
848
|
-
const point = mask.points[i];
|
|
849
|
-
context.lineTo(_x + point.x, _y + point.y);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
break;
|
|
853
|
-
|
|
854
|
-
case "Ellipse":
|
|
855
|
-
{
|
|
856
|
-
const _x = mask.pos.x, _y = mask.pos.y,
|
|
857
|
-
hw = mask.radiusV.x,
|
|
858
|
-
hh = mask.radiusV.y,
|
|
859
|
-
lx = _x - hw,
|
|
860
|
-
rx = _x + hw,
|
|
861
|
-
ty = _y - hh,
|
|
862
|
-
by = _y + hh;
|
|
863
|
-
|
|
864
|
-
let xmagic = hw * 0.551784,
|
|
865
|
-
ymagic = hh * 0.551784,
|
|
866
|
-
xmin = _x - xmagic,
|
|
867
|
-
xmax = _x + xmagic,
|
|
868
|
-
ymin = _y - ymagic,
|
|
869
|
-
ymax = _y + ymagic;
|
|
870
|
-
|
|
871
|
-
context.moveTo(_x, ty);
|
|
872
|
-
context.bezierCurveTo(xmax, ty, rx, ymin, rx, _y);
|
|
873
|
-
context.bezierCurveTo(rx, ymax, xmax, by, _x, by);
|
|
874
|
-
context.bezierCurveTo(xmin, by, lx, ymax, lx, _y);
|
|
875
|
-
context.bezierCurveTo(lx, ymin, xmin, ty, _x, ty);
|
|
876
|
-
}
|
|
877
|
-
break;
|
|
878
|
-
|
|
879
|
-
default:
|
|
880
|
-
throw new Error("Invalid geometry for setMask");
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
this.maskLevel++;
|
|
885
|
-
|
|
886
|
-
if (invert === true) {
|
|
887
|
-
context.closePath();
|
|
888
|
-
context.globalCompositeOperation = "destination-atop";
|
|
889
|
-
context.fill();
|
|
890
|
-
} else {
|
|
891
|
-
context.clip();
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
/**
|
|
896
|
-
* disable (remove) the rendering mask set through setMask.
|
|
897
|
-
* @see CanvasRenderer#setMask
|
|
898
|
-
*/
|
|
899
|
-
clearMask() {
|
|
900
|
-
if (this.maskLevel > 0) {
|
|
901
|
-
this.maskLevel = 0;
|
|
902
|
-
this.getContext().restore();
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
}
|