melonjs 18.2.2 → 19.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/README.md +33 -27
- package/build/application/application.d.ts +85 -13
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +1 -1
- package/build/application/header.d.ts.map +1 -1
- package/build/application/settings.d.ts +20 -7
- package/build/application/settings.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +10 -11
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/geometries/earcut.d.ts.map +1 -1
- package/build/geometries/path2d.d.ts.map +1 -1
- package/build/geometries/rectangle.d.ts.map +1 -1
- package/build/index.d.ts +99 -92
- package/build/index.d.ts.map +1 -1
- package/build/index.js +16586 -13472
- package/build/index.js.map +4 -4
- package/build/input/gamepad.d.ts.map +1 -1
- package/build/input/keyboard.d.ts.map +1 -1
- package/build/input/pointer.d.ts.map +1 -1
- package/build/input/pointerevent.d.ts +6 -0
- package/build/input/pointerevent.d.ts.map +1 -1
- package/build/level/level.d.ts +5 -5
- package/build/level/level.d.ts.map +1 -1
- package/build/level/tiled/TMXGroup.d.ts +1 -1
- package/build/level/tiled/TMXLayer.d.ts +4 -4
- package/build/level/tiled/TMXLayer.d.ts.map +1 -1
- package/build/level/tiled/TMXObject.d.ts +1 -1
- package/build/level/tiled/TMXObjectFactory.d.ts +98 -0
- package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -0
- package/build/level/tiled/TMXTile.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts +7 -3
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/level/tiled/TMXTileset.d.ts.map +1 -1
- package/build/level/tiled/TMXUtils.d.ts +22 -0
- package/build/level/tiled/TMXUtils.d.ts.map +1 -1
- package/build/level/tiled/factories/shape.d.ts +9 -0
- package/build/level/tiled/factories/shape.d.ts.map +1 -0
- package/build/level/tiled/factories/text.d.ts +8 -0
- package/build/level/tiled/factories/text.d.ts.map +1 -0
- package/build/level/tiled/factories/tile.d.ts +8 -0
- package/build/level/tiled/factories/tile.d.ts.map +1 -0
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +1 -1
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +1 -1
- package/build/loader/cache.d.ts +2 -0
- package/build/loader/cache.d.ts.map +1 -1
- package/build/loader/loader.d.ts +60 -0
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/loadingscreen.d.ts +2 -2
- package/build/loader/loadingscreen.d.ts.map +1 -1
- package/build/loader/parsers/fetchdata.d.ts.map +1 -1
- package/build/loader/parsers/fontface.d.ts +2 -2
- package/build/loader/parsers/mtl.d.ts +11 -0
- package/build/loader/parsers/mtl.d.ts.map +1 -0
- package/build/loader/parsers/obj.d.ts +11 -0
- package/build/loader/parsers/obj.d.ts.map +1 -0
- package/build/loader/parsers/tmx.d.ts +0 -1
- package/build/loader/parsers/tmx.d.ts.map +1 -1
- package/build/loader/parsers/video.d.ts.map +1 -1
- package/build/math/color.d.ts.map +1 -1
- package/build/math/math.d.ts +12 -0
- package/build/math/math.d.ts.map +1 -1
- package/build/math/matrix2d.d.ts +2 -2
- package/build/math/matrix2d.d.ts.map +1 -1
- package/build/math/matrix3d.d.ts +19 -4
- package/build/math/matrix3d.d.ts.map +1 -1
- package/build/math/observableVector2d.d.ts +1 -1
- package/build/math/observableVector2d.d.ts.map +1 -1
- package/build/math/observableVector3d.d.ts +1 -1
- package/build/math/observableVector3d.d.ts.map +1 -1
- package/build/math/vertex.d.ts +42 -0
- package/build/math/vertex.d.ts.map +1 -0
- package/build/particles/emitter.d.ts +2 -2
- package/build/particles/particle.d.ts.map +1 -1
- package/build/physics/bounds.d.ts +4 -3
- package/build/physics/bounds.d.ts.map +1 -1
- package/build/physics/collision.d.ts +1 -1
- package/build/physics/detector.d.ts +1 -1
- package/build/physics/quadtree.d.ts.map +1 -1
- package/build/physics/world.d.ts +3 -3
- package/build/physics/world.d.ts.map +1 -1
- package/build/plugin/plugin.d.ts +3 -3
- package/build/renderable/container.d.ts +32 -8
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/draggable.d.ts.map +1 -1
- package/build/renderable/dragndrop.d.ts.map +1 -1
- package/build/renderable/entity/entity.d.ts +7 -0
- package/build/renderable/entity/entity.d.ts.map +1 -1
- package/build/renderable/imagelayer.d.ts +1 -4
- package/build/renderable/imagelayer.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +147 -0
- package/build/renderable/mesh.d.ts.map +1 -0
- package/build/renderable/renderable.d.ts +59 -33
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +2 -2
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/text/bitmaptext.d.ts +2 -11
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/bitmaptextdata.d.ts +2 -0
- package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
- package/build/renderable/text/glyph.d.ts +1 -1
- package/build/renderable/text/glyph.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts +2 -7
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/renderable/text/textmetrics.d.ts +2 -0
- package/build/renderable/text/textmetrics.d.ts.map +1 -1
- package/build/renderable/trail.d.ts +120 -0
- package/build/renderable/trail.d.ts.map +1 -0
- package/build/renderable/ui/uibaseelement.d.ts +0 -1
- package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
- package/build/renderable/ui/uitextbutton.d.ts +2 -6
- package/build/renderable/ui/uitextbutton.d.ts.map +1 -1
- package/build/state/stage.d.ts +39 -55
- package/build/state/stage.d.ts.map +1 -1
- package/build/state/state.d.ts +15 -29
- package/build/state/state.d.ts.map +1 -1
- package/build/system/bootstrap.d.ts +13 -0
- package/build/system/bootstrap.d.ts.map +1 -0
- package/build/system/device.d.ts +5 -4
- package/build/system/device.d.ts.map +1 -1
- package/build/system/event.d.ts +26 -6
- package/build/system/event.d.ts.map +1 -1
- package/build/system/eventEmitter.d.ts +4 -4
- package/build/system/eventEmitter.d.ts.map +1 -1
- package/build/system/legacy_pool.d.ts +32 -4
- package/build/system/legacy_pool.d.ts.map +1 -1
- package/build/system/platform.d.ts.map +1 -1
- package/build/system/timer.d.ts.map +1 -1
- package/build/tweens/easing.d.ts +23 -34
- package/build/tweens/easing.d.ts.map +1 -1
- package/build/tweens/interpolation.d.ts +32 -0
- package/build/tweens/interpolation.d.ts.map +1 -1
- package/build/tweens/tween.d.ts +80 -42
- package/build/tweens/tween.d.ts.map +1 -1
- package/build/utils/function.d.ts +1 -1
- package/build/utils/function.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +34 -10
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/gradient.d.ts +116 -0
- package/build/video/gradient.d.ts.map +1 -0
- package/build/video/renderer.d.ts +60 -6
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/renderstate.d.ts +22 -4
- package/build/video/renderstate.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts +3 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts +2 -1
- package/build/video/texture/cache.d.ts.map +1 -1
- package/build/video/utils/dash.d.ts +15 -0
- package/build/video/utils/dash.d.ts.map +1 -0
- package/build/video/utils/tessellation.d.ts +29 -0
- package/build/video/utils/tessellation.d.ts.map +1 -0
- package/build/video/video.d.ts +16 -2
- package/build/video/video.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +65 -0
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -0
- package/build/video/webgl/batchers/mesh_batcher.d.ts +20 -0
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -0
- package/build/video/webgl/batchers/quad_batcher.d.ts +2 -45
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +5 -0
- package/build/video/webgl/buffer/index.d.ts.map +1 -1
- package/build/video/webgl/buffer/vertex.d.ts +5 -0
- package/build/video/webgl/buffer/vertex.d.ts.map +1 -1
- package/build/video/webgl/effects/blur.d.ts +36 -0
- package/build/video/webgl/effects/blur.d.ts.map +1 -0
- package/build/video/webgl/effects/chromaticAberration.d.ts +39 -0
- package/build/video/webgl/effects/chromaticAberration.d.ts.map +1 -0
- package/build/video/webgl/effects/desaturate.d.ts +32 -0
- package/build/video/webgl/effects/desaturate.d.ts.map +1 -0
- package/build/video/webgl/effects/dissolve.d.ts +42 -0
- package/build/video/webgl/effects/dissolve.d.ts.map +1 -0
- package/build/video/webgl/effects/dropShadow.d.ts +47 -0
- package/build/video/webgl/effects/dropShadow.d.ts.map +1 -0
- package/build/video/webgl/effects/flash.d.ts +46 -0
- package/build/video/webgl/effects/flash.d.ts.map +1 -0
- package/build/video/webgl/effects/glow.d.ts +48 -0
- package/build/video/webgl/effects/glow.d.ts.map +1 -0
- package/build/video/webgl/effects/hologram.d.ts +37 -0
- package/build/video/webgl/effects/hologram.d.ts.map +1 -0
- package/build/video/webgl/effects/invert.d.ts +29 -0
- package/build/video/webgl/effects/invert.d.ts.map +1 -0
- package/build/video/webgl/effects/outline.d.ts +49 -0
- package/build/video/webgl/effects/outline.d.ts.map +1 -0
- package/build/video/webgl/effects/pixelate.d.ts +38 -0
- package/build/video/webgl/effects/pixelate.d.ts.map +1 -0
- package/build/video/webgl/effects/scanline.d.ts +47 -0
- package/build/video/webgl/effects/scanline.d.ts.map +1 -0
- package/build/video/webgl/effects/sepia.d.ts +28 -0
- package/build/video/webgl/effects/sepia.d.ts.map +1 -0
- package/build/video/webgl/effects/tintPulse.d.ts +43 -0
- package/build/video/webgl/effects/tintPulse.d.ts.map +1 -0
- package/build/video/webgl/effects/wave.d.ts +43 -0
- package/build/video/webgl/effects/wave.d.ts.map +1 -0
- package/build/video/webgl/utils/program.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts +40 -15
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/package.json +10 -10
- package/build/system/eventEmitter.spec.d.ts +0 -2
- package/build/system/eventEmitter.spec.d.ts.map +0 -1
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set a callback to be invoked whenever pool.register() is called.
|
|
3
|
+
* @param {Function} callback - function(className, classObj, poolInstance) called on each registration
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export function setPoolRegisterCallback(callback: Function): void;
|
|
1
7
|
export default pool;
|
|
2
8
|
/**
|
|
3
9
|
* a default global ObjectPool instance
|
|
@@ -32,9 +38,29 @@ declare class ObjectPool {
|
|
|
32
38
|
objectClass: {};
|
|
33
39
|
instance_counter: number;
|
|
34
40
|
/**
|
|
35
|
-
*
|
|
41
|
+
* When enabled, classes registered via {@link pool.register} are also
|
|
42
|
+
* automatically registered as Tiled object factories, so that objects
|
|
43
|
+
* placed in a Tiled map with a matching class or name will be
|
|
44
|
+
* instantiated using the registered constructor.
|
|
45
|
+
* Set to `false` to disable this behavior (e.g. for classes that should
|
|
46
|
+
* only be used programmatically and not from Tiled maps).
|
|
47
|
+
* @type {boolean}
|
|
48
|
+
* @default true
|
|
49
|
+
* @example
|
|
50
|
+
* // disable auto-registration for a specific class
|
|
51
|
+
* pool.autoRegisterTiled = false;
|
|
52
|
+
* pool.register("InternalHelper", HelperClass);
|
|
53
|
+
* pool.autoRegisterTiled = true; // re-enable for subsequent registrations
|
|
54
|
+
*/
|
|
55
|
+
autoRegisterTiled: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Register an object to the pool. <br>
|
|
36
58
|
* Pooling must be set to true if more than one such objects will be created. <br>
|
|
37
|
-
* (Note: for an object to be poolable, it must
|
|
59
|
+
* (Note: for an object to be poolable, it must implement an `onResetEvent` method) <br><br>
|
|
60
|
+
* Registered classes are also automatically available as Tiled object factories,
|
|
61
|
+
* meaning objects placed in a Tiled map with a matching class or name will be
|
|
62
|
+
* instantiated using the registered constructor. For more control, use
|
|
63
|
+
* {@link registerTiledObjectClass} or {@link registerTiledObjectFactory} instead.
|
|
38
64
|
* @param {string} className - as defined in the Name field of the Object Properties (in Tiled)
|
|
39
65
|
* @param {object} classObj - corresponding Class to be instantiated
|
|
40
66
|
* @param {boolean} [recycling=false] - enables object recycling for the specified class
|
|
@@ -47,6 +73,8 @@ declare class ObjectPool {
|
|
|
47
73
|
* }
|
|
48
74
|
* };
|
|
49
75
|
* // add our users defined entities in the object pool and enable object recycling
|
|
76
|
+
* // this also registers "cherrysprite" as a Tiled object factory, so any object
|
|
77
|
+
* // with class or name "cherrysprite" in a Tiled map will create a Cherry instance
|
|
50
78
|
* me.pool.register("cherrysprite", Cherry, true);
|
|
51
79
|
*/
|
|
52
80
|
register(className: string, classObj: object, recycling?: boolean): void;
|
|
@@ -68,8 +96,8 @@ declare class ObjectPool {
|
|
|
68
96
|
* // ...
|
|
69
97
|
* // when we want to destroy existing object, the remove
|
|
70
98
|
* // function will ensure the object can then be reallocated later
|
|
71
|
-
*
|
|
72
|
-
*
|
|
99
|
+
* app.world.removeChild(enemy);
|
|
100
|
+
* app.world.removeChild(bullet);
|
|
73
101
|
*/
|
|
74
102
|
pull(name: string, ...args?: any[]): object;
|
|
75
103
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy_pool.d.ts","sourceRoot":"","sources":["../../src/system/legacy_pool.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"legacy_pool.d.ts","sourceRoot":"","sources":["../../src/system/legacy_pool.js"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,kEAEC;;AAmND;;;;;;;;;;;;;;GAcG;AACH,+BAA8B;AAhO9B;;;;;;;;;;;;GAYG;AACH;IAEE,gBAAqB;IACrB,yBAAyB;IAEzB;;;;;;;;;;;;;;OAcG;IACH,mBARU,OAAO,CAQY;IAG9B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,oBAhBW,MAAM,YACN,MAAM,cACN,OAAO,QAsCjB;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAnBW,MAAM,YACH,GAAC,EAAA,GACF,MAAM,CAsClB;IAED;;;;OAIG;IACH,cAOC;IAED;;;;;;;;;OASG;IACH,UAJW,MAAM,iBACN,OAAO,GACL,OAAO,CAgBnB;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;;;;;;OAUG;IACH,cAPW,MAAM,GACJ,OAAO,CAcnB;IAED;;;OAGG;IACH,oBAFa,MAAM,CAIlB;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/system/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,eAAO,MAAM,EAAE,QAGT,CAAC;AACP,eAAO,MAAM,GAAG,SAA+B,CAAC;AAChD,eAAO,MAAM,OAAO,SAAsB,CAAC;AAC3C,eAAO,MAAM,QAAQ,SAAwB,CAAC;AAC9C,eAAO,MAAM,KAAK,SAAoB,CAAC;AACvC,eAAO,MAAM,QAAQ,SAAkB,CAAC;AACxC,eAAO,MAAM,EAAE,SAA4B,CAAC;AAC5C,eAAO,MAAM,UAAU,SAAyB,CAAC;AACjD,eAAO,MAAM,MAAM,SAAyC,CAAC;AAC7D,eAAO,MAAM,MAAM,SAAyB,CAAC;AAC7C,eAAO,MAAM,QAAQ,SAA6B,CAAC;AACnD,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/system/platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,eAAO,MAAM,EAAE,QAGT,CAAC;AACP,eAAO,MAAM,GAAG,SAA+B,CAAC;AAChD,eAAO,MAAM,OAAO,SAAsB,CAAC;AAC3C,eAAO,MAAM,QAAQ,SAAwB,CAAC;AAC9C,eAAO,MAAM,KAAK,SAAoB,CAAC;AACvC,eAAO,MAAM,QAAQ,SAAkB,CAAC;AACxC,eAAO,MAAM,EAAE,SAA4B,CAAC;AAC5C,eAAO,MAAM,UAAU,SAAyB,CAAC;AACjD,eAAO,MAAM,MAAM,SAAyC,CAAC;AAC7D,eAAO,MAAM,MAAM,SAAyB,CAAC;AAC7C,eAAO,MAAM,QAAQ,SAA6B,CAAC;AACnD,eAAO,MAAM,MAAM,SAMiB,CAAC;AACrC,eAAO,MAAM,QAAQ,SACqD,CAAC;AAC3E,eAAO,MAAM,MAAM,SAK2C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../../src/system/timer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../../src/system/timer.ts"],"names":[],"mappings":"AAaA;;;GAGG;AACH,cAAM,KAAK;IACV,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE;QACP,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;QAC5B,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,OAAO,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,OAAO,CAAC;QACnB,IAAI,EAAE,GAAG,EAAE,CAAC;KACZ,EAAE,CAAC;IACJ,OAAO,EAAE,MAAM,CAAC;;IAsEhB;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.Circular.InOut<br>
|
|
26
|
-
* Easing.Elastic.In<br>
|
|
27
|
-
* Easing.Elastic.Out<br>
|
|
28
|
-
* Easing.Elastic.InOut<br>
|
|
29
|
-
* Easing.Back.In<br>
|
|
30
|
-
* Easing.Back.Out<br>
|
|
31
|
-
* Easing.Back.InOut<br>
|
|
32
|
-
* Easing.Bounce.In<br>
|
|
33
|
-
* Easing.Bounce.Out<br>
|
|
34
|
-
* Easing.Bounce.InOut
|
|
35
|
-
* </p>
|
|
2
|
+
* Easing functions for use with {@link Tween}.
|
|
3
|
+
* Each family provides `In` (accelerate), `Out` (decelerate), and `InOut` (both) variants.
|
|
4
|
+
*
|
|
5
|
+
* Available families:
|
|
6
|
+
* - `Linear.None` — constant speed
|
|
7
|
+
* - `Quadratic` — power of 2
|
|
8
|
+
* - `Cubic` — power of 3
|
|
9
|
+
* - `Quartic` — power of 4
|
|
10
|
+
* - `Quintic` — power of 5
|
|
11
|
+
* - `Sinusoidal` — sine wave
|
|
12
|
+
* - `Exponential` — base-2 exponential
|
|
13
|
+
* - `Circular` — circular arc
|
|
14
|
+
* - `Elastic` — spring overshoot
|
|
15
|
+
* - `Back` — slight overshoot before settling
|
|
16
|
+
* - `Bounce` — bouncing ball effect
|
|
17
|
+
* @example
|
|
18
|
+
* // use with Tween
|
|
19
|
+
* new me.Tween(obj).to({ x: 100 }, {
|
|
20
|
+
* duration: 1000,
|
|
21
|
+
* easing: me.Tween.Easing.Bounce.Out,
|
|
22
|
+
* }).start();
|
|
23
|
+
* @see https://easings.net/ for visual reference
|
|
24
|
+
* @category Tweens
|
|
36
25
|
*/
|
|
37
26
|
export type EasingFunction = (t: number) => number;
|
|
38
27
|
export declare const Easing: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"easing.d.ts","sourceRoot":"","sources":["../../src/tweens/easing.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"easing.d.ts","sourceRoot":"","sources":["../../src/tweens/easing.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAEnD,eAAO,MAAM,MAAM;;kBAEP,MAAM;;;gBAMR,MAAM;iBAGL,MAAM;mBAGJ,MAAM;;;gBAST,MAAM;iBAGL,MAAM;mBAGJ,MAAM;;;gBAST,MAAM;iBAGL,MAAM;mBAGJ,MAAM;;;gBAST,MAAM;iBAGL,MAAM;mBAGJ,MAAM;;;gBAST,MAAM;iBAGL,MAAM;mBAGJ,MAAM;;;gBAMT,MAAM;iBAGL,MAAM;mBAGJ,MAAM;;;gBAeT,MAAM;iBAGL,MAAM;mBAGJ,MAAM;;;gBAST,MAAM;iBASL,MAAM;mBASJ,MAAM;;;gBAoBT,MAAM;iBAIL,MAAM;mBAIJ,MAAM;;;gBAUT,MAAM;iBAGL,MAAM;mBAWJ,MAAM;;CAOlB,CAAC"}
|
|
@@ -1,7 +1,39 @@
|
|
|
1
1
|
export type InterpolationFunction = (v: number[], k: number) => number;
|
|
2
|
+
/**
|
|
3
|
+
* Interpolation functions for tweening through arrays of values.
|
|
4
|
+
* Used when a tween target property is an array (e.g. a path of waypoints).
|
|
5
|
+
*
|
|
6
|
+
* Available functions:
|
|
7
|
+
* - `Linear` — straight-line interpolation between consecutive values
|
|
8
|
+
* - `Bezier` — smooth Bezier curve through all values
|
|
9
|
+
* - `CatmullRom` — smooth Catmull-Rom spline through all values (best for paths)
|
|
10
|
+
* @example
|
|
11
|
+
* // tween through waypoints using CatmullRom spline
|
|
12
|
+
* new me.Tween(obj).to({ x: [100, 200, 300, 400] }, {
|
|
13
|
+
* duration: 2000,
|
|
14
|
+
* interpolation: me.Tween.Interpolation.CatmullRom,
|
|
15
|
+
* }).start();
|
|
16
|
+
* @see {@link Tween}
|
|
17
|
+
* @category Tweens
|
|
18
|
+
*/
|
|
2
19
|
export declare const Interpolation: {
|
|
20
|
+
/**
|
|
21
|
+
* Piecewise linear interpolation between consecutive array values.
|
|
22
|
+
* @param v - array of values
|
|
23
|
+
* @param k - interpolation factor (0 to 1)
|
|
24
|
+
*/
|
|
3
25
|
Linear: (v: number[], k: number) => number;
|
|
26
|
+
/**
|
|
27
|
+
* Smooth Bezier curve interpolation through all array values.
|
|
28
|
+
* @param v - array of values
|
|
29
|
+
* @param k - interpolation factor (0 to 1)
|
|
30
|
+
*/
|
|
4
31
|
Bezier: (v: number[], k: number) => number;
|
|
32
|
+
/**
|
|
33
|
+
* Smooth Catmull-Rom spline interpolation — best for path-following tweens.
|
|
34
|
+
* @param v - array of values
|
|
35
|
+
* @param k - interpolation factor (0 to 1)
|
|
36
|
+
*/
|
|
5
37
|
CatmullRom: (v: number[], k: number) => number;
|
|
6
38
|
};
|
|
7
39
|
//# sourceMappingURL=interpolation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../src/tweens/interpolation.ts"],"names":[],"mappings":"AA8CA,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAEvE,eAAO,MAAM,aAAa;
|
|
1
|
+
{"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../src/tweens/interpolation.ts"],"names":[],"mappings":"AA8CA,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAEvE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa;IACzB;;;;OAIG;gBACS,MAAM,EAAE,KAAK,MAAM;IAc/B;;;;OAIG;gBACS,MAAM,EAAE,KAAK,MAAM;IAU/B;;;;OAIG;oBACa,MAAM,EAAE,KAAK,MAAM;CAoCnC,CAAC"}
|
package/build/tweens/tween.d.ts
CHANGED
|
@@ -7,21 +7,33 @@ type OnUpdateCallback<T> = (this: T, value: number) => void;
|
|
|
7
7
|
/** @ignore */
|
|
8
8
|
type OnCompleteCallback<T> = (this: T) => void;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
10
|
+
* A tweening engine for smoothly interpolating object properties over time.
|
|
11
|
+
* Based on <a href="https://github.com/sole/Tween.js">tween.js</a> with
|
|
12
|
+
* optimised Robert Penner's equations.
|
|
13
|
+
*
|
|
14
|
+
* Tweens use an event-based lifecycle — on `start()` the tween subscribes to
|
|
15
|
+
* the game loop events (`TICK`, `GAME_AFTER_UPDATE`, `STATE_PAUSE`,
|
|
16
|
+
* `STATE_RESUME`, `GAME_RESET`)
|
|
17
|
+
* and automatically unsubscribes on completion or `stop()`.
|
|
18
|
+
* They do not need to be added to a container.
|
|
19
|
+
* @example
|
|
20
|
+
* // basic usage
|
|
21
|
+
* new me.Tween(myObject.pos)
|
|
22
|
+
* .to({ x: 200, y: 200 }, { duration: 3000, easing: me.Tween.Easing.Bounce.Out })
|
|
23
|
+
* .onComplete(() => console.log("done!"))
|
|
24
|
+
* .start();
|
|
25
|
+
* @example
|
|
26
|
+
* // auto-start with options
|
|
27
|
+
* new me.Tween(myObject.pos).to({ x: 200 }, {
|
|
28
|
+
* duration: 1000,
|
|
29
|
+
* easing: me.Tween.Easing.Quadratic.InOut,
|
|
30
|
+
* yoyo: true,
|
|
31
|
+
* repeat: Infinity,
|
|
32
|
+
* autoStart: true,
|
|
33
|
+
* });
|
|
21
34
|
* @category Tweens
|
|
22
35
|
*/
|
|
23
36
|
export default class Tween {
|
|
24
|
-
#private;
|
|
25
37
|
_object: object;
|
|
26
38
|
_valuesStart: Record<string, unknown>;
|
|
27
39
|
_valuesEnd: Record<string, unknown>;
|
|
@@ -40,21 +52,22 @@ export default class Tween {
|
|
|
40
52
|
_onUpdateCallback: OnUpdateCallback<object> | null;
|
|
41
53
|
_onCompleteCallback: OnCompleteCallback<object> | null;
|
|
42
54
|
_tweenTimeTracker: number;
|
|
55
|
+
_lastUpdate: number;
|
|
56
|
+
_isRunning: boolean;
|
|
57
|
+
_isPaused: boolean;
|
|
58
|
+
_lastTick: number;
|
|
59
|
+
/**
|
|
60
|
+
* whether the tween should persist across state changes (not auto-stopped on game reset)
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
43
63
|
isPersistent: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* whether the tween should keep running when the game is paused
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
44
68
|
updateWhenPaused: boolean;
|
|
45
|
-
isRenderable: boolean;
|
|
46
69
|
/**
|
|
47
|
-
* @param object - object
|
|
48
|
-
* @example
|
|
49
|
-
* // add a tween to change the object pos.x and pos.y variable to 200 in 3 seconds
|
|
50
|
-
* tween = new me.Tween(myObject.pos).to({
|
|
51
|
-
* x: 200,
|
|
52
|
-
* y: 200,
|
|
53
|
-
* }, {
|
|
54
|
-
* duration: 3000,
|
|
55
|
-
* easing: me.Tween.Easing.Bounce.Out,
|
|
56
|
-
* autoStart : true
|
|
57
|
-
* }).onComplete(myFunc);
|
|
70
|
+
* @param object - the object whose properties will be tweened
|
|
58
71
|
*/
|
|
59
72
|
constructor(object: object);
|
|
60
73
|
/**
|
|
@@ -69,27 +82,35 @@ export default class Tween {
|
|
|
69
82
|
* @ignore
|
|
70
83
|
*/
|
|
71
84
|
_resumeCallback(elapsed: number): void;
|
|
85
|
+
/** @ignore */
|
|
86
|
+
_onAfterUpdate(lastUpdate: number): void;
|
|
87
|
+
/** @ignore */
|
|
88
|
+
_onTick(timestamp: number): void;
|
|
89
|
+
/** @ignore */
|
|
90
|
+
_onPause(): void;
|
|
91
|
+
/** @ignore */
|
|
92
|
+
_onReset(): void;
|
|
72
93
|
/**
|
|
73
|
-
*
|
|
94
|
+
* Subscribe to the game loop events
|
|
74
95
|
* @ignore
|
|
75
96
|
*/
|
|
76
|
-
|
|
97
|
+
_subscribe(): void;
|
|
77
98
|
/**
|
|
78
|
-
* Unsubscribe
|
|
99
|
+
* Unsubscribe from the game loop events
|
|
79
100
|
* @ignore
|
|
80
101
|
*/
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
* @param properties -
|
|
85
|
-
* @param [options] -
|
|
86
|
-
* @param [options.duration] - tween duration
|
|
87
|
-
* @param [options.easing] - easing function
|
|
88
|
-
* @param [options.delay] - delay
|
|
89
|
-
* @param [options.yoyo] -
|
|
90
|
-
* @param [options.repeat] -
|
|
91
|
-
* @param [options.interpolation] - interpolation function
|
|
92
|
-
* @param [options.autoStart] -
|
|
102
|
+
_unsubscribe(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Define the target property values and tween options.
|
|
105
|
+
* @param properties - target property values to tween to (e.g. `{ x: 200, y: 100 }`)
|
|
106
|
+
* @param [options] - tween configuration
|
|
107
|
+
* @param [options.duration] - tween duration in milliseconds
|
|
108
|
+
* @param [options.easing] - easing function (e.g. `Tween.Easing.Quadratic.InOut`)
|
|
109
|
+
* @param [options.delay] - delay before starting, in milliseconds
|
|
110
|
+
* @param [options.yoyo] - bounce back to original values when finished (use with `repeat`)
|
|
111
|
+
* @param [options.repeat] - number of times to repeat (use `Infinity` for endless loops)
|
|
112
|
+
* @param [options.interpolation] - interpolation function for array values
|
|
113
|
+
* @param [options.autoStart] - start the tween immediately without calling `start()`
|
|
93
114
|
* @returns this instance for object chaining
|
|
94
115
|
*/
|
|
95
116
|
to(properties: Record<string, unknown>, options?: {
|
|
@@ -102,13 +123,13 @@ export default class Tween {
|
|
|
102
123
|
autoStart?: boolean | undefined;
|
|
103
124
|
}): this;
|
|
104
125
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @param [time] - the
|
|
126
|
+
* Start the tween. Subscribes to game loop events and begins interpolation.
|
|
127
|
+
* @param [time] - the start time (defaults to current game time)
|
|
107
128
|
* @returns this instance for object chaining
|
|
108
129
|
*/
|
|
109
130
|
start(time?: number): this;
|
|
110
131
|
/**
|
|
111
|
-
*
|
|
132
|
+
* Stop the tween. Unsubscribes from all game loop events.
|
|
112
133
|
* @returns this instance for object chaining
|
|
113
134
|
*/
|
|
114
135
|
stop(): this;
|
|
@@ -169,6 +190,15 @@ export default class Tween {
|
|
|
169
190
|
onComplete(onCompleteCallback: OnCompleteCallback<object>): this;
|
|
170
191
|
/** @ignore */
|
|
171
192
|
update(dt: number): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Available easing functions, accessed via `Tween.Easing`.
|
|
195
|
+
* Each family provides `In`, `Out`, and `InOut` variants.
|
|
196
|
+
* @see {@link Easing} for the full list
|
|
197
|
+
* @example
|
|
198
|
+
* me.Tween.Easing.Quadratic.InOut
|
|
199
|
+
* me.Tween.Easing.Bounce.Out
|
|
200
|
+
* me.Tween.Easing.Elastic.In
|
|
201
|
+
*/
|
|
172
202
|
static get Easing(): {
|
|
173
203
|
Linear: {
|
|
174
204
|
None: (k: number) => number;
|
|
@@ -224,6 +254,14 @@ export default class Tween {
|
|
|
224
254
|
InOut: (k: number) => number;
|
|
225
255
|
};
|
|
226
256
|
};
|
|
257
|
+
/**
|
|
258
|
+
* Available interpolation functions for tweening array values.
|
|
259
|
+
* @see {@link Interpolation}
|
|
260
|
+
* @example
|
|
261
|
+
* me.Tween.Interpolation.Linear
|
|
262
|
+
* me.Tween.Interpolation.Bezier
|
|
263
|
+
* me.Tween.Interpolation.CatmullRom
|
|
264
|
+
*/
|
|
227
265
|
static get Interpolation(): {
|
|
228
266
|
Linear: (v: number[], k: number) => number;
|
|
229
267
|
Bezier: (v: number[], k: number) => number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tween.d.ts","sourceRoot":"","sources":["../../src/tweens/tween.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tween.d.ts","sourceRoot":"","sources":["../../src/tweens/tween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MAAM;IAKpB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM;IAKpB;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,OAAO;IAKlB;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,cAAc;IAK7B;;;;OAIG;IACH,aAAa,CAAC,aAAa,EAAE,qBAAqB;IAKlD;;;;OAIG;IACH,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,EAAE;IAKxB;;;;OAIG;IACH,OAAO,CAAC,eAAe,EAAE,eAAe,CAAC,MAAM,CAAC;IAKhD;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAKnD;;;;OAIG;IACH,UAAU,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,MAAM,CAAC;IAKzD,cAAc;IACd,MAAM,CAAC,EAAE,EAAE,MAAM;IAiHjB;;;;;;;;OAQG;IACH,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAEhB;IAED;;;;;;;OAOG;IACH,MAAM,KAAK,aAAa;;;;MAEvB;CACD;AAED,eAAO,MAAM,SAAS,wDASpB,CAAC"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* // with the current context and [1, 2, 3] as parameter
|
|
14
14
|
* me.utils.function.defer(myFunc, this, 1, 2, 3);
|
|
15
15
|
*/
|
|
16
|
-
export declare function defer(func: (...args: unknown[]) => unknown, thisArg: unknown, ...args: unknown[]):
|
|
16
|
+
export declare function defer(func: (...args: unknown[]) => unknown, thisArg: unknown, ...args: unknown[]): number;
|
|
17
17
|
/**
|
|
18
18
|
* returns a function that, when invoked will only be triggered at most once during a given window of time
|
|
19
19
|
* @param fn - the function to be throttled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/utils/function.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CACpB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EACrC,OAAO,EAAE,OAAO,EAChB,GAAG,IAAI,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/utils/function.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CACpB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EACrC,OAAO,EAAE,OAAO,EAChB,GAAG,IAAI,EAAE,OAAO,EAAE,UAGlB;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,MAAM,IAAI,EAAE,OAAM,MAAY,MAIlD,GAAG,MAAM,EAAE,SAkBnB,CAAC"}
|
|
@@ -117,6 +117,9 @@ export default class CanvasRenderer extends Renderer {
|
|
|
117
117
|
* @see CanvasRenderer#createPattern
|
|
118
118
|
*/
|
|
119
119
|
drawPattern(pattern: CanvasPattern, x: number, y: number, width: number, height: number): void;
|
|
120
|
+
_meshSortBuf: Float64Array<ArrayBuffer> | undefined;
|
|
121
|
+
_meshColorCanvas: HTMLCanvasElement | undefined;
|
|
122
|
+
_meshColorCtx: CanvasRenderingContext2D | null | undefined;
|
|
120
123
|
/**
|
|
121
124
|
* starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path
|
|
122
125
|
* @example
|
|
@@ -144,6 +147,33 @@ export default class CanvasRenderer extends Renderer {
|
|
|
144
147
|
* adds a straight line to the current sub-path by connecting the sub-path's last point to the specified (x, y) coordinates.
|
|
145
148
|
*/
|
|
146
149
|
lineTo(x: any, y: any): void;
|
|
150
|
+
/**
|
|
151
|
+
* Adds a quadratic Bezier curve to the current sub-path.
|
|
152
|
+
* @param {number} cpx - The x-axis coordinate of the control point.
|
|
153
|
+
* @param {number} cpy - The y-axis coordinate of the control point.
|
|
154
|
+
* @param {number} x - The x-axis coordinate of the end point.
|
|
155
|
+
* @param {number} y - The y-axis coordinate of the end point.
|
|
156
|
+
*/
|
|
157
|
+
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
|
|
158
|
+
/**
|
|
159
|
+
* Adds a cubic Bezier curve to the current sub-path.
|
|
160
|
+
* @param {number} cp1x - The x-axis coordinate of the first control point.
|
|
161
|
+
* @param {number} cp1y - The y-axis coordinate of the first control point.
|
|
162
|
+
* @param {number} cp2x - The x-axis coordinate of the second control point.
|
|
163
|
+
* @param {number} cp2y - The y-axis coordinate of the second control point.
|
|
164
|
+
* @param {number} x - The x-axis coordinate of the end point.
|
|
165
|
+
* @param {number} y - The y-axis coordinate of the end point.
|
|
166
|
+
*/
|
|
167
|
+
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
|
|
168
|
+
/**
|
|
169
|
+
* Adds a circular arc to the current sub-path, using the given control points and radius.
|
|
170
|
+
* @param {number} x1 - The x-axis coordinate of the first control point.
|
|
171
|
+
* @param {number} y1 - The y-axis coordinate of the first control point.
|
|
172
|
+
* @param {number} x2 - The x-axis coordinate of the second control point.
|
|
173
|
+
* @param {number} y2 - The y-axis coordinate of the second control point.
|
|
174
|
+
* @param {number} radius - The arc's radius. Must be non-negative.
|
|
175
|
+
*/
|
|
176
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
|
|
147
177
|
/**
|
|
148
178
|
* creates a rectangular path whose starting point is at (x, y) and whose size is specified by width and height.
|
|
149
179
|
* @param {number} x - The x axis of the coordinate for the rectangle starting point.
|
|
@@ -338,12 +368,6 @@ export default class CanvasRenderer extends Renderer {
|
|
|
338
368
|
* @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
|
|
339
369
|
*/
|
|
340
370
|
scale(x: number, y: number): void;
|
|
341
|
-
/**
|
|
342
|
-
* Set the current fill & stroke style color.
|
|
343
|
-
* By default, or upon reset, the value is set to #000000.
|
|
344
|
-
* @param {Color|string} color - css color value
|
|
345
|
-
*/
|
|
346
|
-
setColor(color: Color | string): void;
|
|
347
371
|
/**
|
|
348
372
|
* Set the global alpha
|
|
349
373
|
* @param {number} alpha - 0.0 to 1.0 values accepted.
|
|
@@ -378,25 +402,25 @@ export default class CanvasRenderer extends Renderer {
|
|
|
378
402
|
/**
|
|
379
403
|
* Reset (overrides) the renderer transformation matrix to the
|
|
380
404
|
* identity one, and then apply the given transformation matrix.
|
|
381
|
-
* @param {Matrix2d|number} a - a
|
|
405
|
+
* @param {Matrix2d|Matrix3d|number} a - a matrix to transform by, or the a component to multiply the current matrix by
|
|
382
406
|
* @param {number} b - the b component to multiply the current matrix by
|
|
383
407
|
* @param {number} c - the c component to multiply the current matrix by
|
|
384
408
|
* @param {number} d - the d component to multiply the current matrix by
|
|
385
409
|
* @param {number} e - the e component to multiply the current matrix by
|
|
386
410
|
* @param {number} f - the f component to multiply the current matrix by
|
|
387
411
|
*/
|
|
388
|
-
setTransform(a: Matrix2d | number, b: number, c: number, d: number, e: number, f: number): void;
|
|
412
|
+
setTransform(a: Matrix2d | Matrix3d | number, b: number, c: number, d: number, e: number, f: number): void;
|
|
389
413
|
/**
|
|
390
414
|
* Multiply given matrix into the renderer tranformation matrix
|
|
391
415
|
* @see {@link CanvasRenderer.setTransform} which will reset the current transform matrix prior to performing the new transformation
|
|
392
|
-
* @param {Matrix2d|number} a - a
|
|
416
|
+
* @param {Matrix2d|Matrix3d|number} a - a matrix to transform by, or the a component to multiply the current matrix by
|
|
393
417
|
* @param {number} b - the b component to multiply the current matrix by
|
|
394
418
|
* @param {number} c - the c component to multiply the current matrix by
|
|
395
419
|
* @param {number} d - the d component to multiply the current matrix by
|
|
396
420
|
* @param {number} e - the e component to multiply the current matrix by
|
|
397
421
|
* @param {number} f - the f component to multiply the current matrix by
|
|
398
422
|
*/
|
|
399
|
-
transform(a: Matrix2d | number, b: number, c: number, d: number, e: number, f: number): void;
|
|
423
|
+
transform(a: Matrix2d | Matrix3d | number, b: number, c: number, d: number, e: number, f: number): void;
|
|
400
424
|
/**
|
|
401
425
|
* adds a translation transformation to the current matrix.
|
|
402
426
|
* @param {number} x - Distance to move in the horizontal direction. Positive values are to the right, and negative to the left.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/canvas/canvas_renderer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"canvas_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/canvas/canvas_renderer.js"],"names":[],"mappings":"AAYA;;;;;;;;GAQG;AAEH;;;GAGG;AACH;IAcE,oBAAmC;IA4CpC;;OAEG;IACH,uBAEC;IAED;;;;;OAKG;IACH,sBAFW,QAAQ,QAclB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,oBAHW,MAAM,GACJ,MAAM,CAqClB;IAWD;;;;OAIG;IACH,mBAHW,KAAK,GAAC,MAAM,WACZ,OAAO,QAajB;IAED;;;;;;OAMG;IACH,aALW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,QAIhB;IAED;;;;;;;;;;;OAWG;IACH,qBAVW,gBAAgB,GAAC,eAAe,GAAC,gBAAgB,GAAC,iBAAiB,GAAC,WAAW,GAAC,eAAe,GAAC,UAAU,UAC1G,MAAM,GACJ,aAAa,CAUzB;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,iBAjBW,gBAAgB,GAAC,eAAe,GAAC,gBAAgB,GAAC,iBAAiB,GAAC,WAAW,GAAC,eAAe,GAAC,UAAU,MAC1G,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAgDhB;IAED;;;;;;;;OAQG;IACH,qBAPW,aAAa,KACb,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,QAiBhB;IAmCC,oDAAkD;IAqGhD,gDAAwD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,QA+BhB;IAED;;;;OAIG;IACH,aAHW,MAAM,KACN,MAAM,QAQhB;IAED;;;;;;;;;;OAUG;IACH,YALW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,QA8BhB;IAED;;;;;;;OAOG;IACH,eAHW,IAAI,GAAC,SAAS,GAAC,OAAO,GAAC,IAAI,GAAC,OAAO,WACnC,OAAO,QAuFjB;CAYD;qBAzsCoB,kBAAkB;yBACd,uBAAuB;sBAV1B,uBAAuB;0BActB,iCAAiC;+BAC5B,iCAAiC;6BACnC,6BAA6B;0BAChC,4BAA4B;6BACzB,+BAA+B;8BAC9B,wBAAwB"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Gradient object representing a linear or radial gradient fill.
|
|
3
|
+
* Created via {@link Renderer#createLinearGradient} or {@link Renderer#createRadialGradient}.
|
|
4
|
+
* Can be passed to {@link Renderer#setColor} as a fill style.
|
|
5
|
+
*/
|
|
6
|
+
export class Gradient {
|
|
7
|
+
/**
|
|
8
|
+
* @param {"linear"|"radial"} type - the gradient type
|
|
9
|
+
* @param {number[]} coords - gradient coordinates [x0, y0, x1, y1] for linear, [x0, y0, r0, x1, y1, r1] for radial
|
|
10
|
+
*/
|
|
11
|
+
constructor(type: "linear" | "radial", coords: number[]);
|
|
12
|
+
/**
|
|
13
|
+
* gradient type
|
|
14
|
+
* @type {"linear"|"radial"}
|
|
15
|
+
*/
|
|
16
|
+
/** @ignore */
|
|
17
|
+
_id: number;
|
|
18
|
+
type: "linear" | "radial";
|
|
19
|
+
/**
|
|
20
|
+
* gradient coordinates
|
|
21
|
+
* @type {number[]}
|
|
22
|
+
* @ignore
|
|
23
|
+
*/
|
|
24
|
+
coords: number[];
|
|
25
|
+
/**
|
|
26
|
+
* color stops
|
|
27
|
+
* @type {Array<{offset: number, color: string}>}
|
|
28
|
+
* @ignore
|
|
29
|
+
*/
|
|
30
|
+
colorStops: Array<{
|
|
31
|
+
offset: number;
|
|
32
|
+
color: string;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* cached canvas gradient (for Canvas renderer)
|
|
36
|
+
* @type {CanvasGradient|undefined}
|
|
37
|
+
* @ignore
|
|
38
|
+
*/
|
|
39
|
+
_canvasGradient: CanvasGradient | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* cached gradient render target (for WebGL renderer)
|
|
42
|
+
* @type {CanvasRenderTarget|undefined}
|
|
43
|
+
* @ignore
|
|
44
|
+
*/
|
|
45
|
+
_renderTarget: CanvasRenderTarget | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* whether the gradient needs to be regenerated
|
|
48
|
+
* @type {boolean}
|
|
49
|
+
* @ignore
|
|
50
|
+
*/
|
|
51
|
+
_dirty: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* cached parsed Color objects for sampling (lazily built)
|
|
54
|
+
* @type {{offset: number, color: Color}[]|null}
|
|
55
|
+
* @ignore
|
|
56
|
+
*/
|
|
57
|
+
_parsedStops: {
|
|
58
|
+
offset: number;
|
|
59
|
+
color: Color;
|
|
60
|
+
}[] | null;
|
|
61
|
+
/**
|
|
62
|
+
* Add a color stop to the gradient.
|
|
63
|
+
* @param {number} offset - value between 0.0 and 1.0
|
|
64
|
+
* @param {Color|string} color - a CSS color string or Color object
|
|
65
|
+
* @returns {Gradient} this gradient for chaining
|
|
66
|
+
* @example
|
|
67
|
+
* gradient.addColorStop(0, "#FF0000");
|
|
68
|
+
* gradient.addColorStop(0.5, "green");
|
|
69
|
+
* gradient.addColorStop(1, "blue");
|
|
70
|
+
*/
|
|
71
|
+
addColorStop(offset: number, color: Color | string): Gradient;
|
|
72
|
+
/**
|
|
73
|
+
* Get or create a native CanvasGradient for use with a 2D context.
|
|
74
|
+
* @param {CanvasRenderingContext2D} context - the 2D context to create the gradient on
|
|
75
|
+
* @returns {CanvasGradient}
|
|
76
|
+
* @ignore
|
|
77
|
+
*/
|
|
78
|
+
toCanvasGradient(context: CanvasRenderingContext2D): CanvasGradient;
|
|
79
|
+
/**
|
|
80
|
+
* Render the gradient onto a canvas matching the given draw rect.
|
|
81
|
+
* Uses the original gradient coordinates so the result matches Canvas 2D behavior.
|
|
82
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer - the active renderer (used to invalidate GPU texture)
|
|
83
|
+
* @param {number} x - draw rect x
|
|
84
|
+
* @param {number} y - draw rect y
|
|
85
|
+
* @param {number} width - draw rect width
|
|
86
|
+
* @param {number} height - draw rect height
|
|
87
|
+
* @returns {HTMLCanvasElement|OffscreenCanvas} the rendered gradient canvas
|
|
88
|
+
* @ignore
|
|
89
|
+
*/
|
|
90
|
+
toCanvas(renderer: CanvasRenderer | WebGLRenderer, x: number, y: number, width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
|
|
91
|
+
/**
|
|
92
|
+
* Get the interpolated color at a given position along the gradient.
|
|
93
|
+
* Useful for procedural effects like trails that need per-segment colors.
|
|
94
|
+
* @param {number} position - position along the gradient (0.0–1.0)
|
|
95
|
+
* @param {Color} out - output Color object to write into
|
|
96
|
+
* @returns {Color} the output Color object
|
|
97
|
+
* @example
|
|
98
|
+
* const gradient = new Gradient("linear", [0, 0, 1, 0]);
|
|
99
|
+
* gradient.addColorStop(0, "#ff0000");
|
|
100
|
+
* gradient.addColorStop(1, "#0000ff");
|
|
101
|
+
* gradient.getColorAt(0.5, myColor); // myColor is now purple
|
|
102
|
+
*/
|
|
103
|
+
getColorAt(position: number, out: Color): Color;
|
|
104
|
+
/**
|
|
105
|
+
* Build the parsed Color cache from colorStops strings.
|
|
106
|
+
* @ignore
|
|
107
|
+
*/
|
|
108
|
+
_buildParsedStops(): void;
|
|
109
|
+
/**
|
|
110
|
+
* Release pooled resources held by this gradient.
|
|
111
|
+
*/
|
|
112
|
+
destroy(): void;
|
|
113
|
+
}
|
|
114
|
+
import CanvasRenderTarget from "./rendertarget/canvasrendertarget.js";
|
|
115
|
+
import type { Color } from "../math/color.ts";
|
|
116
|
+
//# sourceMappingURL=gradient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gradient.d.ts","sourceRoot":"","sources":["../../src/video/gradient.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH;IACC;;;OAGG;IACH,kBAHW,QAAQ,GAAC,QAAQ,UACjB,MAAM,EAAE,EAqDlB;IAlDA;;;OAGG;IACH,cAAc;IACd,YAA2B;IAE3B,0BAAgB;IAEhB;;;;OAIG;IACH,QAHU,MAAM,EAAE,CAGE;IAEpB;;;;OAIG;IACH,YAHU,KAAK,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,CAG5B;IAEpB;;;;OAIG;IACH,iBAHU,cAAc,GAAC,SAAS,CAGF;IAEhC;;;;OAIG;IACH,eAHU,kBAAkB,GAAC,SAAS,CAGR;IAE9B;;;;OAIG;IACH,QAHU,OAAO,CAGC;IAElB;;;;OAIG;IACH,cAHU;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAC,EAAE,GAAC,IAAI,CAGvB;IAGzB;;;;;;;;;OASG;IACH,qBARW,MAAM,SACN,KAAK,GAAC,MAAM,GACV,QAAQ,CA0BpB;IAED;;;;;OAKG;IACH,0BAJW,wBAAwB,GACtB,cAAc,CAiC1B;IAED;;;;;;;;;;OAUG;IACH,mBARW,cAAc,GAAC,aAAa,KAC5B,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,GACJ,iBAAiB,GAAC,eAAe,CAwE7C;IAED;;;;;;;;;;;OAWG;IACH,qBATW,MAAM,OACN,KAAK,GACH,KAAK,CA+CjB;IAED;;;OAGG;IACH,0BAWC;IAED;;OAEG;IACH,gBAOC;CACD;+BAtT8B,sCAAsC;2BAH7C,kBAAkB"}
|