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
|
@@ -24,7 +24,7 @@ const offsetsStaggerY = [
|
|
|
24
24
|
* an Hexagonal Map Renderder
|
|
25
25
|
* @augments TMXRenderer
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
export default class TMXHexagonalRenderer extends TMXRenderer {
|
|
28
28
|
/**
|
|
29
29
|
* @param {TMXTileMap} map - the TMX map
|
|
30
30
|
*/
|
|
@@ -390,7 +390,7 @@ const offsetsStaggerY = [
|
|
|
390
390
|
let rowTile = startTile.clone();
|
|
391
391
|
let rowPos = startPos.clone();
|
|
392
392
|
|
|
393
|
-
|
|
393
|
+
/* Determine in which half of the tile the top-left corner of the area we
|
|
394
394
|
* need to draw is. If we're in the upper half, we need to start one row
|
|
395
395
|
* up due to those tiles being visible as well. How we go up one row
|
|
396
396
|
* depends on whether we're in the left or right half of the tile.
|
|
@@ -9,7 +9,7 @@ import TMXLayer from "./../TMXLayer.js";
|
|
|
9
9
|
* an Isometric Map Renderder
|
|
10
10
|
* @augments TMXRenderer
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
export default class TMXIsometricRenderer extends TMXRenderer {
|
|
13
13
|
/**
|
|
14
14
|
* @param {TMXTileMap} map - the TMX map
|
|
15
15
|
*/
|
|
@@ -7,7 +7,7 @@ import TMXRenderer from "./TMXRenderer.js";
|
|
|
7
7
|
* an Orthogonal Map Renderder
|
|
8
8
|
* @augments TMXRenderer
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
export default class TMXOrthogonalRenderer extends TMXRenderer {
|
|
11
11
|
/**
|
|
12
12
|
* @param {TMXTileMap} map - the TMX map
|
|
13
13
|
*/
|
|
@@ -8,7 +8,7 @@ import Bounds from "./../../../physics/bounds.js";
|
|
|
8
8
|
* @classdesc
|
|
9
9
|
* The map renderer base class
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
export default class TMXRenderer {
|
|
12
12
|
/**
|
|
13
13
|
* @param {number} cols - width of the tilemap in tiles
|
|
14
14
|
* @param {number} rows - height of the tilemap in tiles
|
|
@@ -9,7 +9,7 @@ import { degToRad } from "./../../../math/math.js";
|
|
|
9
9
|
* a Staggered Map Renderder
|
|
10
10
|
* @augments TMXHexagonalRenderer
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
export default class TMXStaggeredRenderer extends TMXHexagonalRenderer {
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* return true if the renderer can render the specified layer
|
package/src/loader/parser.js
CHANGED
|
@@ -125,7 +125,7 @@ export function preloadTMX(tmxData, onload, onerror) {
|
|
|
125
125
|
switch (format) {
|
|
126
126
|
case "xml":
|
|
127
127
|
case "tmx":
|
|
128
|
-
case "tsx":
|
|
128
|
+
case "tsx": {
|
|
129
129
|
// ie9 does not fully implement the responseXML
|
|
130
130
|
if (ua.match(/msie/i) || !xmlhttp.responseXML) {
|
|
131
131
|
if (globalThis.DOMParser) {
|
|
@@ -139,7 +139,7 @@ export function preloadTMX(tmxData, onload, onerror) {
|
|
|
139
139
|
result = xmlhttp.responseXML;
|
|
140
140
|
}
|
|
141
141
|
// converts to a JS object
|
|
142
|
-
|
|
142
|
+
const data = TMXUtils.parse(result);
|
|
143
143
|
switch (format) {
|
|
144
144
|
case "tmx":
|
|
145
145
|
result = data.map;
|
|
@@ -149,9 +149,8 @@ export function preloadTMX(tmxData, onload, onerror) {
|
|
|
149
149
|
result = data.tilesets[0];
|
|
150
150
|
break;
|
|
151
151
|
}
|
|
152
|
-
|
|
153
152
|
break;
|
|
154
|
-
|
|
153
|
+
}
|
|
155
154
|
case "json":
|
|
156
155
|
case "tmj":
|
|
157
156
|
case "tsj":
|
package/src/math/color.js
CHANGED
|
@@ -182,7 +182,7 @@ let cssToRGB = new Map();
|
|
|
182
182
|
* @classdesc
|
|
183
183
|
* A color manipulation object.
|
|
184
184
|
*/
|
|
185
|
-
|
|
185
|
+
export default class Color {
|
|
186
186
|
/**
|
|
187
187
|
* @param {number} [r=0] - red component or array of color components
|
|
188
188
|
* @param {number} [g=0] - green component
|
|
@@ -336,12 +336,12 @@ let cssToRGB = new Map();
|
|
|
336
336
|
* @returns {Color} Reference to this object for method chaining
|
|
337
337
|
*/
|
|
338
338
|
copy(color) {
|
|
339
|
-
if (color
|
|
339
|
+
if (typeof color === "string") {
|
|
340
|
+
return this.parseCSS(color);
|
|
341
|
+
} else {
|
|
340
342
|
this.glArray.set(color.glArray);
|
|
341
343
|
return this;
|
|
342
344
|
}
|
|
343
|
-
|
|
344
|
-
return this.parseCSS(color);
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
/**
|
package/src/math/matrix2.js
CHANGED
|
@@ -7,7 +7,7 @@ import Matrix3d from "./matrix3.js";
|
|
|
7
7
|
* the identity matrix and parameters position : <br>
|
|
8
8
|
* <img src="images/identity-matrix_2x.png"/>
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
export default class Matrix2d {
|
|
11
11
|
/**
|
|
12
12
|
* @param {(Matrix2d|Matrix3d|...number)} args - an instance of me.Matrix2d or me.Matrix3d to copy from, or individual matrix components (See {@link Matrix2d.setTransform}). If not arguments are given, the matrix will be set to Identity.
|
|
13
13
|
*/
|
|
@@ -40,11 +40,8 @@ import Matrix3d from "./matrix3.js";
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* tx component of the matrix
|
|
43
|
-
* @public
|
|
44
43
|
* @type {number}
|
|
45
44
|
* @see Matrix2d.translate
|
|
46
|
-
* @name tx
|
|
47
|
-
* @memberof Matrix2d
|
|
48
45
|
*/
|
|
49
46
|
get tx() {
|
|
50
47
|
return this.val[6];
|
|
@@ -52,11 +49,8 @@ import Matrix3d from "./matrix3.js";
|
|
|
52
49
|
|
|
53
50
|
/**
|
|
54
51
|
* ty component of the matrix
|
|
55
|
-
* @public
|
|
56
52
|
* @type {number}
|
|
57
53
|
* @see Matrix2d.translate
|
|
58
|
-
* @name ty
|
|
59
|
-
* @memberof Matrix2d
|
|
60
54
|
*/
|
|
61
55
|
get ty() {
|
|
62
56
|
return this.val[7];
|
|
@@ -66,8 +60,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
66
60
|
* reset the transformation matrix to the identity matrix (no transformation).<br>
|
|
67
61
|
* the identity matrix and parameters position : <br>
|
|
68
62
|
* <img src="images/identity-matrix_2x.png"/>
|
|
69
|
-
* @name identity
|
|
70
|
-
* @memberof Matrix2d
|
|
71
63
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
72
64
|
*/
|
|
73
65
|
identity() {
|
|
@@ -81,8 +73,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
81
73
|
|
|
82
74
|
/**
|
|
83
75
|
* set the matrix to the specified value
|
|
84
|
-
* @name setTransform
|
|
85
|
-
* @memberof Matrix2d
|
|
86
76
|
* @param {number} a
|
|
87
77
|
* @param {number} b
|
|
88
78
|
* @param {number} c
|
|
@@ -124,8 +114,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
124
114
|
|
|
125
115
|
/**
|
|
126
116
|
* Copies over the values from another me.Matrix2d.
|
|
127
|
-
* @name copy
|
|
128
|
-
* @memberof Matrix2d
|
|
129
117
|
* @param {Matrix2d} m - the matrix object to copy from
|
|
130
118
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
131
119
|
*/
|
|
@@ -136,8 +124,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
136
124
|
|
|
137
125
|
/**
|
|
138
126
|
* Copies over the upper-left 3x3 values from the given me.Matrix3d
|
|
139
|
-
* @name fromMat3d
|
|
140
|
-
* @memberof Matrix2d
|
|
141
127
|
* @param {Matrix3d} m - the matrix object to copy from
|
|
142
128
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
143
129
|
*/
|
|
@@ -160,8 +146,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
160
146
|
|
|
161
147
|
/**
|
|
162
148
|
* multiply both matrix
|
|
163
|
-
* @name multiply
|
|
164
|
-
* @memberof Matrix2d
|
|
165
149
|
* @param {Matrix2d} m - the other matrix
|
|
166
150
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
167
151
|
*/
|
|
@@ -191,8 +175,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
191
175
|
|
|
192
176
|
/**
|
|
193
177
|
* Transpose the value of this matrix.
|
|
194
|
-
* @name transpose
|
|
195
|
-
* @memberof Matrix2d
|
|
196
178
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
197
179
|
*/
|
|
198
180
|
transpose() {
|
|
@@ -213,8 +195,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
213
195
|
|
|
214
196
|
/**
|
|
215
197
|
* invert this matrix, causing it to apply the opposite transformation.
|
|
216
|
-
* @name invert
|
|
217
|
-
* @memberof Matrix2d
|
|
218
198
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
219
199
|
*/
|
|
220
200
|
invert() {
|
|
@@ -245,10 +225,8 @@ import Matrix3d from "./matrix3.js";
|
|
|
245
225
|
return this;
|
|
246
226
|
}
|
|
247
227
|
|
|
248
|
-
|
|
228
|
+
/**
|
|
249
229
|
* apply the current transform to the given 2d or 3d vector
|
|
250
|
-
* @name apply
|
|
251
|
-
* @memberof Matrix2d
|
|
252
230
|
* @param {Vector2d|Vector3d} v - the vector object to be transformed
|
|
253
231
|
* @returns {Vector2d|Vector3d} result vector object.
|
|
254
232
|
*/
|
|
@@ -270,8 +248,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
270
248
|
|
|
271
249
|
/**
|
|
272
250
|
* apply the inverted current transform to the given 2d vector
|
|
273
|
-
* @name applyInverse
|
|
274
|
-
* @memberof Matrix2d
|
|
275
251
|
* @param {Vector2d} v - the vector object to be transformed
|
|
276
252
|
* @returns {Vector2d} result vector object.
|
|
277
253
|
*/
|
|
@@ -290,8 +266,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
290
266
|
|
|
291
267
|
/**
|
|
292
268
|
* scale the matrix
|
|
293
|
-
* @name scale
|
|
294
|
-
* @memberof Matrix2d
|
|
295
269
|
* @param {number} x - a number representing the abscissa of the scaling vector.
|
|
296
270
|
* @param {number} [y=x] - a number representing the ordinate of the scaling vector.
|
|
297
271
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
@@ -309,8 +283,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
309
283
|
|
|
310
284
|
/**
|
|
311
285
|
* adds a 2D scaling transformation.
|
|
312
|
-
* @name scaleV
|
|
313
|
-
* @memberof Matrix2d
|
|
314
286
|
* @param {Vector2d} v - scaling vector
|
|
315
287
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
316
288
|
*/
|
|
@@ -320,8 +292,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
320
292
|
|
|
321
293
|
/**
|
|
322
294
|
* specifies a 2D scale operation using the [sx, 1] scaling vector
|
|
323
|
-
* @name scaleX
|
|
324
|
-
* @memberof Matrix2d
|
|
325
295
|
* @param {number} x - x scaling vector
|
|
326
296
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
327
297
|
*/
|
|
@@ -331,8 +301,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
331
301
|
|
|
332
302
|
/**
|
|
333
303
|
* specifies a 2D scale operation using the [1,sy] scaling vector
|
|
334
|
-
* @name scaleY
|
|
335
|
-
* @memberof Matrix2d
|
|
336
304
|
* @param {number} y - y scaling vector
|
|
337
305
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
338
306
|
*/
|
|
@@ -342,8 +310,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
342
310
|
|
|
343
311
|
/**
|
|
344
312
|
* rotate the matrix (counter-clockwise) by the specified angle (in radians).
|
|
345
|
-
* @name rotate
|
|
346
|
-
* @memberof Matrix2d
|
|
347
313
|
* @param {number} angle - Rotation angle in radians.
|
|
348
314
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
349
315
|
*/
|
|
@@ -372,18 +338,8 @@ import Matrix3d from "./matrix3.js";
|
|
|
372
338
|
|
|
373
339
|
/**
|
|
374
340
|
* translate the matrix position on the horizontal and vertical axis
|
|
375
|
-
* @
|
|
376
|
-
* @
|
|
377
|
-
* @method
|
|
378
|
-
* @param {number} x - the x coordindates to translate the matrix by
|
|
379
|
-
* @param {number} y - the y coordindates to translate the matrix by
|
|
380
|
-
* @returns {Matrix2d} Reference to this object for method chaining
|
|
381
|
-
*/
|
|
382
|
-
/**
|
|
383
|
-
* translate the matrix by a vector on the horizontal and vertical axis
|
|
384
|
-
* @name translateV
|
|
385
|
-
* @memberof Matrix2d
|
|
386
|
-
* @param {Vector2d} v - the vector to translate the matrix by
|
|
341
|
+
* @param {number|Vector2d} x - the x coordindates or a vector to translate the matrix by
|
|
342
|
+
* @param {number} [y] - the y coordindates to translate the matrix by
|
|
387
343
|
* @returns {Matrix2d} Reference to this object for method chaining
|
|
388
344
|
*/
|
|
389
345
|
translate() {
|
|
@@ -408,8 +364,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
408
364
|
|
|
409
365
|
/**
|
|
410
366
|
* returns true if the matrix is an identity matrix.
|
|
411
|
-
* @name isIdentity
|
|
412
|
-
* @memberof Matrix2d
|
|
413
367
|
* @returns {boolean}
|
|
414
368
|
*/
|
|
415
369
|
isIdentity() {
|
|
@@ -430,8 +384,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
430
384
|
|
|
431
385
|
/**
|
|
432
386
|
* return true if the two matrices are identical
|
|
433
|
-
* @name equals
|
|
434
|
-
* @memberof Matrix2d
|
|
435
387
|
* @param {Matrix2d} m - the other matrix
|
|
436
388
|
* @returns {boolean} true if both are equals
|
|
437
389
|
*/
|
|
@@ -454,8 +406,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
454
406
|
|
|
455
407
|
/**
|
|
456
408
|
* Clone the Matrix
|
|
457
|
-
* @name clone
|
|
458
|
-
* @memberof Matrix2d
|
|
459
409
|
* @returns {Matrix2d}
|
|
460
410
|
*/
|
|
461
411
|
clone() {
|
|
@@ -464,8 +414,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
464
414
|
|
|
465
415
|
/**
|
|
466
416
|
* return an array representation of this Matrix
|
|
467
|
-
* @name toArray
|
|
468
|
-
* @memberof Matrix2d
|
|
469
417
|
* @returns {Float32Array}
|
|
470
418
|
*/
|
|
471
419
|
toArray() {
|
|
@@ -474,8 +422,6 @@ import Matrix3d from "./matrix3.js";
|
|
|
474
422
|
|
|
475
423
|
/**
|
|
476
424
|
* convert the object to a string representation
|
|
477
|
-
* @name toString
|
|
478
|
-
* @memberof Matrix2d
|
|
479
425
|
* @returns {string}
|
|
480
426
|
*/
|
|
481
427
|
toString() {
|