@vpmedia/phaser 1.11.0 → 1.13.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/package.json +8 -5
- package/src/index.js +19 -19
- package/src/phaser/core/animation.js +12 -9
- package/src/phaser/core/animation_manager.js +16 -6
- package/src/phaser/core/animation_parser.js +40 -17
- package/src/phaser/core/array_set.js +3 -5
- package/src/phaser/core/cache.js +12 -12
- package/src/phaser/core/const.js +1 -1
- package/src/phaser/core/device.js +2 -4
- package/src/phaser/core/device_util.js +50 -17
- package/src/phaser/core/dom.js +36 -27
- package/src/phaser/core/event_manager.js +47 -19
- package/src/phaser/core/factory.js +34 -12
- package/src/phaser/core/frame.js +3 -5
- package/src/phaser/core/frame_data.js +2 -4
- package/src/phaser/core/frame_util.js +11 -9
- package/src/phaser/core/game.js +22 -19
- package/src/phaser/core/input.js +24 -16
- package/src/phaser/core/input_handler.js +102 -28
- package/src/phaser/core/input_mouse.js +12 -16
- package/src/phaser/core/input_mspointer.js +11 -10
- package/src/phaser/core/input_pointer.js +61 -20
- package/src/phaser/core/input_touch.js +7 -9
- package/src/phaser/core/loader.js +171 -54
- package/src/phaser/core/loader_parser.js +29 -22
- package/src/phaser/core/raf.js +2 -4
- package/src/phaser/core/scale_manager.js +75 -31
- package/src/phaser/core/scene.js +2 -4
- package/src/phaser/core/scene_manager.js +9 -6
- package/src/phaser/core/signal.js +19 -11
- package/src/phaser/core/signal_binding.js +12 -7
- package/src/phaser/core/sound.js +23 -14
- package/src/phaser/core/sound_manager.js +62 -26
- package/src/phaser/core/sound_sprite.js +34 -34
- package/src/phaser/core/stage.js +4 -7
- package/src/phaser/core/time.js +3 -5
- package/src/phaser/core/timer.js +27 -10
- package/src/phaser/core/timer_event.js +1 -3
- package/src/phaser/core/tween.js +36 -12
- package/src/phaser/core/tween_data.js +17 -9
- package/src/phaser/core/tween_easing.js +87 -83
- package/src/phaser/core/tween_manager.js +34 -16
- package/src/phaser/core/world.js +3 -5
- package/src/phaser/display/bitmap_text.js +25 -14
- package/src/phaser/display/button.js +35 -8
- package/src/phaser/display/canvas/buffer.js +1 -3
- package/src/phaser/display/canvas/graphics.js +30 -15
- package/src/phaser/display/canvas/masker.js +7 -5
- package/src/phaser/display/canvas/pool.js +18 -11
- package/src/phaser/display/canvas/renderer.js +40 -20
- package/src/phaser/display/canvas/tinter.js +61 -19
- package/src/phaser/display/canvas/util.js +44 -35
- package/src/phaser/display/display_object.js +42 -24
- package/src/phaser/display/graphics.js +72 -39
- package/src/phaser/display/graphics_data.js +3 -4
- package/src/phaser/display/graphics_data_util.js +15 -5
- package/src/phaser/display/group.js +15 -9
- package/src/phaser/display/image.js +17 -9
- package/src/phaser/display/sprite_batch.js +8 -4
- package/src/phaser/display/sprite_util.js +67 -26
- package/src/phaser/display/text.js +92 -31
- package/src/phaser/display/webgl/abstract_filter.js +1 -3
- package/src/phaser/display/webgl/base_texture.js +8 -5
- package/src/phaser/display/webgl/blend_manager.js +1 -3
- package/src/phaser/display/webgl/earcut.js +170 -129
- package/src/phaser/display/webgl/earcut_node.js +1 -3
- package/src/phaser/display/webgl/fast_sprite_batch.js +48 -47
- package/src/phaser/display/webgl/filter_manager.js +1 -3
- package/src/phaser/display/webgl/filter_texture.js +17 -6
- package/src/phaser/display/webgl/graphics.js +72 -50
- package/src/phaser/display/webgl/graphics_data.js +2 -4
- package/src/phaser/display/webgl/mask_manager.js +17 -7
- package/src/phaser/display/webgl/render_texture.js +19 -10
- package/src/phaser/display/webgl/renderer.js +41 -9
- package/src/phaser/display/webgl/shader/complex.js +1 -3
- package/src/phaser/display/webgl/shader/fast.js +9 -4
- package/src/phaser/display/webgl/shader/normal.js +43 -15
- package/src/phaser/display/webgl/shader/primitive.js +1 -3
- package/src/phaser/display/webgl/shader/strip.js +1 -3
- package/src/phaser/display/webgl/shader_manager.js +1 -3
- package/src/phaser/display/webgl/sprite_batch.js +14 -15
- package/src/phaser/display/webgl/stencil_manager.js +19 -21
- package/src/phaser/display/webgl/texture.js +14 -10
- package/src/phaser/display/webgl/texture_util.js +11 -9
- package/src/phaser/display/webgl/util.js +21 -18
- package/src/phaser/geom/circle.js +27 -11
- package/src/phaser/geom/ellipse.js +26 -10
- package/src/phaser/geom/line.js +31 -13
- package/src/phaser/geom/matrix.js +14 -5
- package/src/phaser/geom/point.js +18 -13
- package/src/phaser/geom/polygon.js +13 -8
- package/src/phaser/geom/rectangle.js +57 -14
- package/src/phaser/geom/rounded_rectangle.js +12 -4
- package/src/phaser/geom/util/circle.js +40 -32
- package/src/phaser/geom/util/ellipse.js +10 -18
- package/src/phaser/geom/util/line.js +46 -37
- package/src/phaser/geom/util/matrix.js +11 -9
- package/src/phaser/geom/util/point.js +101 -79
- package/src/phaser/geom/util/polygon.js +7 -15
- package/src/phaser/geom/util/rectangle.js +95 -69
- package/src/phaser/geom/util/rounded_rectangle.js +7 -15
- package/src/phaser/util/math.js +123 -89
- package/types/global.d.ts +7 -0
- package/types/index.d.ts +22 -0
- package/types/index.d.ts.map +1 -0
- package/types/phaser/core/animation.d.ts +55 -0
- package/types/phaser/core/animation.d.ts.map +1 -0
- package/types/phaser/core/animation_manager.d.ts +35 -0
- package/types/phaser/core/animation_manager.d.ts.map +1 -0
- package/types/phaser/core/animation_parser.d.ts +22 -0
- package/types/phaser/core/animation_parser.d.ts.map +1 -0
- package/types/phaser/core/array_set.d.ts +23 -0
- package/types/phaser/core/array_set.d.ts.map +1 -0
- package/types/phaser/core/cache.d.ts +106 -0
- package/types/phaser/core/cache.d.ts.map +1 -0
- package/types/phaser/core/const.d.ts +81 -0
- package/types/phaser/core/const.d.ts.map +1 -0
- package/types/phaser/core/device.d.ts +36 -0
- package/types/phaser/core/device.d.ts.map +1 -0
- package/types/phaser/core/device_util.d.ts +58 -0
- package/types/phaser/core/device_util.d.ts.map +1 -0
- package/types/phaser/core/dom.d.ts +63 -0
- package/types/phaser/core/dom.d.ts.map +1 -0
- package/types/phaser/core/event_manager.d.ts +53 -0
- package/types/phaser/core/event_manager.d.ts.map +1 -0
- package/types/phaser/core/factory.d.ts +12 -0
- package/types/phaser/core/factory.d.ts.map +1 -0
- package/types/phaser/core/frame.d.ts +30 -0
- package/types/phaser/core/frame.d.ts.map +1 -0
- package/types/phaser/core/frame_data.d.ts +14 -0
- package/types/phaser/core/frame_data.d.ts.map +1 -0
- package/types/phaser/core/frame_util.d.ts +17 -0
- package/types/phaser/core/frame_util.d.ts.map +1 -0
- package/types/phaser/core/game.d.ts +57 -0
- package/types/phaser/core/game.d.ts.map +1 -0
- package/types/phaser/core/input.d.ts +92 -0
- package/types/phaser/core/input.d.ts.map +1 -0
- package/types/phaser/core/input_handler.d.ts +111 -0
- package/types/phaser/core/input_handler.d.ts.map +1 -0
- package/types/phaser/core/input_mouse.d.ts +39 -0
- package/types/phaser/core/input_mouse.d.ts.map +1 -0
- package/types/phaser/core/input_mspointer.d.ts +34 -0
- package/types/phaser/core/input_mspointer.d.ts.map +1 -0
- package/types/phaser/core/input_pointer.d.ts +68 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -0
- package/types/phaser/core/input_touch.d.ts +37 -0
- package/types/phaser/core/input_touch.d.ts.map +1 -0
- package/types/phaser/core/loader.d.ts +94 -0
- package/types/phaser/core/loader.d.ts.map +1 -0
- package/types/phaser/core/loader_parser.d.ts +39 -0
- package/types/phaser/core/loader_parser.d.ts.map +1 -0
- package/types/phaser/core/raf.d.ts +15 -0
- package/types/phaser/core/raf.d.ts.map +1 -0
- package/types/phaser/core/scale_manager.d.ts +137 -0
- package/types/phaser/core/scale_manager.d.ts.map +1 -0
- package/types/phaser/core/scene.d.ts +17 -0
- package/types/phaser/core/scene.d.ts.map +1 -0
- package/types/phaser/core/scene_manager.d.ts +39 -0
- package/types/phaser/core/scene_manager.d.ts.map +1 -0
- package/types/phaser/core/signal.d.ts +25 -0
- package/types/phaser/core/signal.d.ts.map +1 -0
- package/types/phaser/core/signal_binding.d.ts +26 -0
- package/types/phaser/core/signal_binding.d.ts.map +1 -0
- package/types/phaser/core/sound.d.ts +72 -0
- package/types/phaser/core/sound.d.ts.map +1 -0
- package/types/phaser/core/sound_manager.d.ts +50 -0
- package/types/phaser/core/sound_manager.d.ts.map +1 -0
- package/types/phaser/core/sound_sprite.d.ts +18 -0
- package/types/phaser/core/sound_sprite.d.ts.map +1 -0
- package/types/phaser/core/stage.d.ts +23 -0
- package/types/phaser/core/stage.d.ts.map +1 -0
- package/types/phaser/core/time.d.ts +49 -0
- package/types/phaser/core/time.d.ts.map +1 -0
- package/types/phaser/core/timer.d.ts +49 -0
- package/types/phaser/core/timer.d.ts.map +1 -0
- package/types/phaser/core/timer_event.d.ts +18 -0
- package/types/phaser/core/timer_event.d.ts.map +1 -0
- package/types/phaser/core/tween.d.ts +52 -0
- package/types/phaser/core/tween.d.ts.map +1 -0
- package/types/phaser/core/tween_data.d.ts +37 -0
- package/types/phaser/core/tween_data.d.ts.map +1 -0
- package/types/phaser/core/tween_easing.d.ts +192 -0
- package/types/phaser/core/tween_easing.d.ts.map +1 -0
- package/types/phaser/core/tween_manager.d.ts +94 -0
- package/types/phaser/core/tween_manager.d.ts.map +1 -0
- package/types/phaser/core/world.d.ts +6 -0
- package/types/phaser/core/world.d.ts.map +1 -0
- package/types/phaser/display/bitmap_text.d.ts +59 -0
- package/types/phaser/display/bitmap_text.d.ts.map +1 -0
- package/types/phaser/display/button.d.ts +47 -0
- package/types/phaser/display/button.d.ts.map +1 -0
- package/types/phaser/display/canvas/buffer.d.ts +11 -0
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -0
- package/types/phaser/display/canvas/graphics.d.ts +21 -0
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -0
- package/types/phaser/display/canvas/masker.d.ts +14 -0
- package/types/phaser/display/canvas/masker.d.ts.map +1 -0
- package/types/phaser/display/canvas/pool.d.ts +52 -0
- package/types/phaser/display/canvas/pool.d.ts.map +1 -0
- package/types/phaser/display/canvas/renderer.d.ts +28 -0
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -0
- package/types/phaser/display/canvas/tinter.d.ts +41 -0
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -0
- package/types/phaser/display/canvas/util.d.ts +79 -0
- package/types/phaser/display/canvas/util.d.ts.map +1 -0
- package/types/phaser/display/display_object.d.ts +83 -0
- package/types/phaser/display/display_object.d.ts.map +1 -0
- package/types/phaser/display/graphics.d.ts +60 -0
- package/types/phaser/display/graphics.d.ts.map +1 -0
- package/types/phaser/display/graphics_data.d.ts +15 -0
- package/types/phaser/display/graphics_data.d.ts.map +1 -0
- package/types/phaser/display/graphics_data_util.d.ts +8 -0
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -0
- package/types/phaser/display/group.d.ts +49 -0
- package/types/phaser/display/group.d.ts.map +1 -0
- package/types/phaser/display/image.d.ts +52 -0
- package/types/phaser/display/image.d.ts.map +1 -0
- package/types/phaser/display/sprite_batch.d.ts +11 -0
- package/types/phaser/display/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/sprite_util.d.ts +40 -0
- package/types/phaser/display/sprite_util.d.ts.map +1 -0
- package/types/phaser/display/text.d.ts +125 -0
- package/types/phaser/display/text.d.ts.map +1 -0
- package/types/phaser/display/webgl/abstract_filter.d.ts +17 -0
- package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -0
- package/types/phaser/display/webgl/base_texture.d.ts +20 -0
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/blend_manager.d.ts +14 -0
- package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/earcut.d.ts +215 -0
- package/types/phaser/display/webgl/earcut.d.ts.map +1 -0
- package/types/phaser/display/webgl/earcut_node.d.ts +19 -0
- package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -0
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +34 -0
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/webgl/filter_manager.d.ts +21 -0
- package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/filter_texture.d.ts +13 -0
- package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/graphics.d.ts +80 -0
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -0
- package/types/phaser/display/webgl/graphics_data.d.ts +23 -0
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -0
- package/types/phaser/display/webgl/mask_manager.d.ts +15 -0
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/render_texture.d.ts +25 -0
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/renderer.d.ts +44 -0
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/complex.d.ts +22 -0
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/fast.d.ts +25 -0
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/normal.d.ts +25 -0
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts +21 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/strip.d.ts +22 -0
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader_manager.d.ts +24 -0
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts +36 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts +12 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/texture.d.ts +30 -0
- package/types/phaser/display/webgl/texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/texture_util.d.ts +17 -0
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -0
- package/types/phaser/display/webgl/util.d.ts +45 -0
- package/types/phaser/display/webgl/util.d.ts.map +1 -0
- package/types/phaser/geom/circle.d.ts +46 -0
- package/types/phaser/geom/circle.d.ts.map +1 -0
- package/types/phaser/geom/ellipse.d.ts +26 -0
- package/types/phaser/geom/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/line.d.ts +45 -0
- package/types/phaser/geom/line.d.ts.map +1 -0
- package/types/phaser/geom/matrix.d.ts +35 -0
- package/types/phaser/geom/matrix.d.ts.map +1 -0
- package/types/phaser/geom/point.d.ts +43 -0
- package/types/phaser/geom/point.d.ts.map +1 -0
- package/types/phaser/geom/polygon.d.ts +17 -0
- package/types/phaser/geom/polygon.d.ts.map +1 -0
- package/types/phaser/geom/rectangle.d.ts +71 -0
- package/types/phaser/geom/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/rounded_rectangle.d.ts +21 -0
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/circle.d.ts +64 -0
- package/types/phaser/geom/util/circle.d.ts.map +1 -0
- package/types/phaser/geom/util/ellipse.d.ts +16 -0
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/util/line.d.ts +49 -0
- package/types/phaser/geom/util/line.d.ts.map +1 -0
- package/types/phaser/geom/util/matrix.d.ts +22 -0
- package/types/phaser/geom/util/matrix.d.ts.map +1 -0
- package/types/phaser/geom/util/point.d.ts +179 -0
- package/types/phaser/geom/util/point.d.ts.map +1 -0
- package/types/phaser/geom/util/polygon.d.ts +10 -0
- package/types/phaser/geom/util/polygon.d.ts.map +1 -0
- package/types/phaser/geom/util/rectangle.d.ts +141 -0
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts +10 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/util/math.d.ts +182 -0
- package/types/phaser/util/math.d.ts.map +1 -0
|
@@ -1,35 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
GEOM_POLYGON,
|
|
9
|
+
GEOM_RECTANGLE,
|
|
10
|
+
GEOM_CIRCLE,
|
|
11
|
+
GEOM_ELLIPSE,
|
|
12
|
+
GEOM_ROUNDED_RECTANGLE,
|
|
13
|
+
} from '../../core/const';
|
|
8
14
|
|
|
9
15
|
/**
|
|
16
|
+
* TBD.
|
|
10
17
|
*
|
|
11
|
-
* @param {object} graphics TBD
|
|
18
|
+
* @param {object} graphics - TBD.
|
|
12
19
|
*/
|
|
13
20
|
export function updateGraphicsTint(graphics) {
|
|
14
|
-
if (graphics.tint ===
|
|
21
|
+
if (graphics.tint === 0xffffff) {
|
|
15
22
|
return;
|
|
16
23
|
}
|
|
17
|
-
const tintR = (graphics.tint >> 16 &
|
|
18
|
-
const tintG = (graphics.tint >> 8 &
|
|
19
|
-
const tintB = (graphics.tint &
|
|
24
|
+
const tintR = ((graphics.tint >> 16) & 0xff) / 255;
|
|
25
|
+
const tintG = ((graphics.tint >> 8) & 0xff) / 255;
|
|
26
|
+
const tintB = (graphics.tint & 0xff) / 255;
|
|
20
27
|
for (let i = 0; i < graphics.graphicsData.length; i += 1) {
|
|
21
28
|
const data = graphics.graphicsData[i];
|
|
22
29
|
const fillColor = data.fillColor | 0;
|
|
23
30
|
const lineColor = data.lineColor | 0;
|
|
24
|
-
data._fillTint =
|
|
25
|
-
|
|
31
|
+
data._fillTint =
|
|
32
|
+
(((((fillColor >> 16) & 0xff) / 255) * tintR * 255) << 16) +
|
|
33
|
+
(((((fillColor >> 8) & 0xff) / 255) * tintG * 255) << 8) +
|
|
34
|
+
((fillColor & 0xff) / 255) * tintB * 255;
|
|
35
|
+
data._lineTint =
|
|
36
|
+
(((((lineColor >> 16) & 0xff) / 255) * tintR * 255) << 16) +
|
|
37
|
+
(((((lineColor >> 8) & 0xff) / 255) * tintG * 255) << 8) +
|
|
38
|
+
((lineColor & 0xff) / 255) * tintB * 255;
|
|
26
39
|
}
|
|
27
40
|
}
|
|
28
41
|
|
|
29
42
|
/**
|
|
43
|
+
* TBD.
|
|
30
44
|
*
|
|
31
|
-
* @param {object} graphics TBD
|
|
32
|
-
* @param {object} context TBD
|
|
45
|
+
* @param {object} graphics - TBD.
|
|
46
|
+
* @param {object} context - TBD.
|
|
33
47
|
*/
|
|
34
48
|
export function renderGraphics(graphics, context) {
|
|
35
49
|
const worldAlpha = graphics.worldAlpha;
|
|
@@ -128,7 +142,7 @@ export function renderGraphics(graphics, context) {
|
|
|
128
142
|
const width = shape.width;
|
|
129
143
|
const height = shape.height;
|
|
130
144
|
let radius = shape.radius;
|
|
131
|
-
const maxRadius = Math.min(width, height) / 2 | 0;
|
|
145
|
+
const maxRadius = (Math.min(width, height) / 2) | 0;
|
|
132
146
|
radius = radius > maxRadius ? maxRadius : radius;
|
|
133
147
|
context.beginPath();
|
|
134
148
|
context.moveTo(rx, ry + radius);
|
|
@@ -156,9 +170,10 @@ export function renderGraphics(graphics, context) {
|
|
|
156
170
|
}
|
|
157
171
|
|
|
158
172
|
/**
|
|
173
|
+
* TBD.
|
|
159
174
|
*
|
|
160
|
-
* @param {object} graphics TBD
|
|
161
|
-
* @param {object} context TBD
|
|
175
|
+
* @param {object} graphics - TBD.
|
|
176
|
+
* @param {object} context - TBD.
|
|
162
177
|
*/
|
|
163
178
|
export function renderGraphicsMask(graphics, context) {
|
|
164
179
|
const len = graphics.graphicsData.length;
|
|
@@ -210,7 +225,7 @@ export function renderGraphicsMask(graphics, context) {
|
|
|
210
225
|
const width = shape.width;
|
|
211
226
|
const height = shape.height;
|
|
212
227
|
let radius = shape.radius;
|
|
213
|
-
const maxRadius = Math.min(width, height) / 2 | 0;
|
|
228
|
+
const maxRadius = (Math.min(width, height) / 2) | 0;
|
|
214
229
|
radius = radius > maxRadius ? maxRadius : radius;
|
|
215
230
|
context.moveTo(rx, ry + radius);
|
|
216
231
|
context.lineTo(rx, ry + height - radius);
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
7
|
import { renderGraphicsMask } from './graphics';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* TBD.
|
|
10
11
|
*
|
|
11
|
-
* @param {object} maskData TBD
|
|
12
|
-
* @param {object} renderSession TBD
|
|
12
|
+
* @param {object} maskData - TBD.
|
|
13
|
+
* @param {object} renderSession - TBD.
|
|
13
14
|
*/
|
|
14
15
|
export function pushMask(maskData, renderSession) {
|
|
15
16
|
const context = renderSession.context;
|
|
@@ -23,7 +24,7 @@ export function pushMask(maskData, renderSession) {
|
|
|
23
24
|
transform.c * resolution,
|
|
24
25
|
transform.d * resolution,
|
|
25
26
|
transform.tx * resolution,
|
|
26
|
-
transform.ty * resolution
|
|
27
|
+
transform.ty * resolution
|
|
27
28
|
);
|
|
28
29
|
renderGraphicsMask(maskData, context);
|
|
29
30
|
context.clip();
|
|
@@ -31,8 +32,9 @@ export function pushMask(maskData, renderSession) {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
/**
|
|
35
|
+
* TBD.
|
|
34
36
|
*
|
|
35
|
-
* @param {object} renderSession TBD
|
|
37
|
+
* @param {object} renderSession - TBD.
|
|
36
38
|
*/
|
|
37
39
|
export function popMask(renderSession) {
|
|
38
40
|
renderSession.context.restore();
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
+
* TBD.
|
|
9
10
|
*
|
|
10
|
-
* @returns {object} TBD
|
|
11
|
+
* @returns {object[]} TBD.
|
|
11
12
|
*/
|
|
12
13
|
export function getPool() {
|
|
13
14
|
if (!window.PhaserRegistry) {
|
|
@@ -20,8 +21,9 @@ export function getPool() {
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
/**
|
|
24
|
+
* TBD.
|
|
23
25
|
*
|
|
24
|
-
* @returns {object} TBD
|
|
26
|
+
* @returns {object} TBD.
|
|
25
27
|
*/
|
|
26
28
|
export function getFirst() {
|
|
27
29
|
const pool = getPool();
|
|
@@ -34,8 +36,9 @@ export function getFirst() {
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
/**
|
|
39
|
+
* TBD.
|
|
37
40
|
*
|
|
38
|
-
* @param {object} parent TBD
|
|
41
|
+
* @param {object} parent - TBD.
|
|
39
42
|
*/
|
|
40
43
|
export function remove(parent) {
|
|
41
44
|
const pool = getPool();
|
|
@@ -49,8 +52,9 @@ export function remove(parent) {
|
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
/**
|
|
55
|
+
* TBD.
|
|
52
56
|
*
|
|
53
|
-
* @param {
|
|
57
|
+
* @param {HTMLCanvasElement} canvas - TBD.
|
|
54
58
|
*/
|
|
55
59
|
export function removeByCanvas(canvas) {
|
|
56
60
|
const pool = getPool();
|
|
@@ -64,8 +68,9 @@ export function removeByCanvas(canvas) {
|
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
/**
|
|
71
|
+
* TBD.
|
|
67
72
|
*
|
|
68
|
-
* @returns {number} TBD
|
|
73
|
+
* @returns {number} TBD.
|
|
69
74
|
*/
|
|
70
75
|
export function getTotal() {
|
|
71
76
|
const pool = getPool();
|
|
@@ -79,8 +84,9 @@ export function getTotal() {
|
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
/**
|
|
87
|
+
* TBD.
|
|
82
88
|
*
|
|
83
|
-
* @returns {number} TBD
|
|
89
|
+
* @returns {number} TBD.
|
|
84
90
|
*/
|
|
85
91
|
export function getFree() {
|
|
86
92
|
const pool = getPool();
|
|
@@ -94,11 +100,12 @@ export function getFree() {
|
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
/**
|
|
103
|
+
* TBD.
|
|
97
104
|
*
|
|
98
|
-
* @param {object} parent TBD
|
|
99
|
-
* @param {number} width TBD
|
|
100
|
-
* @param {number} height TBD
|
|
101
|
-
* @returns {object} TBD
|
|
105
|
+
* @param {object} parent - TBD.
|
|
106
|
+
* @param {number} width - TBD.
|
|
107
|
+
* @param {number} height - TBD.
|
|
108
|
+
* @returns {object} TBD.
|
|
102
109
|
*/
|
|
103
110
|
export function create(parent, width, height) {
|
|
104
111
|
if (parent === undefined) {
|
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
RENDER_CANVAS,
|
|
9
|
+
SCALE_LINEAR,
|
|
10
|
+
BLEND_NORMAL,
|
|
11
|
+
BLEND_ADD,
|
|
12
|
+
BLEND_MULTIPLY,
|
|
13
|
+
BLEND_SCREEN,
|
|
14
|
+
BLEND_OVERLAY,
|
|
15
|
+
BLEND_DARKEN,
|
|
16
|
+
BLEND_LIGHTEN,
|
|
17
|
+
BLEND_COLOR_DODGE,
|
|
18
|
+
BLEND_COLOR_BURN,
|
|
19
|
+
BLEND_HARD_LIGHT,
|
|
20
|
+
BLEND_SOFT_LIGHT,
|
|
21
|
+
BLEND_DIFFERENCE,
|
|
22
|
+
BLEND_EXCLUSION,
|
|
23
|
+
BLEND_HUE,
|
|
24
|
+
BLEND_SATURATION,
|
|
25
|
+
BLEND_COLOR,
|
|
26
|
+
BLEND_LUMINOSITY,
|
|
27
|
+
SCALE_NEAREST,
|
|
28
|
+
} from '../../core/const';
|
|
8
29
|
import { getSmoothingPrefix } from './util';
|
|
9
30
|
import { detectCapabilities } from './tinter';
|
|
10
31
|
import * as CanvasMaskManager from './masker';
|
|
11
32
|
|
|
12
33
|
export default class {
|
|
13
|
-
|
|
14
34
|
constructor(game) {
|
|
15
35
|
detectCapabilities();
|
|
16
36
|
this.type = RENDER_CANVAS;
|
|
@@ -78,7 +98,8 @@ export default class {
|
|
|
78
98
|
this.view.style.height = this.height / this.resolution + 'px';
|
|
79
99
|
}
|
|
80
100
|
if (this.renderSession.smoothProperty) {
|
|
81
|
-
this.context[this.renderSession.smoothProperty] =
|
|
101
|
+
this.context[this.renderSession.smoothProperty] =
|
|
102
|
+
this.renderSession.scaleMode === SCALE_LINEAR;
|
|
82
103
|
}
|
|
83
104
|
}
|
|
84
105
|
|
|
@@ -96,22 +117,21 @@ export default class {
|
|
|
96
117
|
const useNew = window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY;
|
|
97
118
|
b[BLEND_NORMAL] = 'source-over';
|
|
98
119
|
b[BLEND_ADD] = 'lighter';
|
|
99
|
-
b[BLEND_MULTIPLY] =
|
|
100
|
-
b[BLEND_SCREEN] =
|
|
101
|
-
b[BLEND_OVERLAY] =
|
|
102
|
-
b[BLEND_DARKEN] =
|
|
103
|
-
b[BLEND_LIGHTEN] =
|
|
104
|
-
b[BLEND_COLOR_DODGE] =
|
|
105
|
-
b[BLEND_COLOR_BURN] =
|
|
106
|
-
b[BLEND_HARD_LIGHT] =
|
|
107
|
-
b[BLEND_SOFT_LIGHT] =
|
|
108
|
-
b[BLEND_DIFFERENCE] =
|
|
109
|
-
b[BLEND_EXCLUSION] =
|
|
110
|
-
b[BLEND_HUE] =
|
|
111
|
-
b[BLEND_SATURATION] =
|
|
112
|
-
b[BLEND_COLOR] =
|
|
113
|
-
b[BLEND_LUMINOSITY] =
|
|
120
|
+
b[BLEND_MULTIPLY] = useNew ? 'multiply' : 'source-over';
|
|
121
|
+
b[BLEND_SCREEN] = useNew ? 'screen' : 'source-over';
|
|
122
|
+
b[BLEND_OVERLAY] = useNew ? 'overlay' : 'source-over';
|
|
123
|
+
b[BLEND_DARKEN] = useNew ? 'darken' : 'source-over';
|
|
124
|
+
b[BLEND_LIGHTEN] = useNew ? 'lighten' : 'source-over';
|
|
125
|
+
b[BLEND_COLOR_DODGE] = useNew ? 'color-dodge' : 'source-over';
|
|
126
|
+
b[BLEND_COLOR_BURN] = useNew ? 'color-burn' : 'source-over';
|
|
127
|
+
b[BLEND_HARD_LIGHT] = useNew ? 'hard-light' : 'source-over';
|
|
128
|
+
b[BLEND_SOFT_LIGHT] = useNew ? 'soft-light' : 'source-over';
|
|
129
|
+
b[BLEND_DIFFERENCE] = useNew ? 'difference' : 'source-over';
|
|
130
|
+
b[BLEND_EXCLUSION] = useNew ? 'exclusion' : 'source-over';
|
|
131
|
+
b[BLEND_HUE] = useNew ? 'hue' : 'source-over';
|
|
132
|
+
b[BLEND_SATURATION] = useNew ? 'saturation' : 'source-over';
|
|
133
|
+
b[BLEND_COLOR] = useNew ? 'color' : 'source-over';
|
|
134
|
+
b[BLEND_LUMINOSITY] = useNew ? 'luminosity' : 'source-over';
|
|
114
135
|
window.PhaserRegistry.blendModesCanvas = b;
|
|
115
136
|
}
|
|
116
|
-
|
|
117
137
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
7
|
import CanvasBuffer from './buffer';
|
|
8
8
|
import { create, removeByCanvas } from './pool';
|
|
9
9
|
import { hex2rgb } from '../../util/math';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
+
* TBD.
|
|
12
13
|
*
|
|
13
|
-
* @param {object} sprite TBD
|
|
14
|
-
* @param {object} color TBD
|
|
15
|
-
* @returns {object} TBD
|
|
14
|
+
* @param {object} sprite - TBD.
|
|
15
|
+
* @param {object} color - TBD.
|
|
16
|
+
* @returns {object} TBD.
|
|
16
17
|
*/
|
|
17
18
|
export function getTintedTexture(sprite, color) {
|
|
18
19
|
const canvas = sprite.tintedTexture || create('CanvasTinter');
|
|
@@ -21,10 +22,11 @@ export function getTintedTexture(sprite, color) {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
25
|
+
* TBD.
|
|
24
26
|
*
|
|
25
|
-
* @param {object} texture TBD
|
|
26
|
-
* @param {object} color TBD
|
|
27
|
-
* @param {
|
|
27
|
+
* @param {object} texture - TBD.
|
|
28
|
+
* @param {object} color - TBD.
|
|
29
|
+
* @param {HTMLCanvasElement} canvas - TBD.
|
|
28
30
|
*/
|
|
29
31
|
export function tintWithMultiply(texture, color, canvas) {
|
|
30
32
|
const context = canvas.getContext('2d');
|
|
@@ -37,16 +39,37 @@ export function tintWithMultiply(texture, color, canvas) {
|
|
|
37
39
|
context.fillStyle = '#' + ('00000' + (color | 0).toString(16)).substr(-6);
|
|
38
40
|
context.fillRect(0, 0, crop.width, crop.height);
|
|
39
41
|
context.globalCompositeOperation = 'multiply';
|
|
40
|
-
context.drawImage(
|
|
42
|
+
context.drawImage(
|
|
43
|
+
texture.baseTexture.source,
|
|
44
|
+
crop.x,
|
|
45
|
+
crop.y,
|
|
46
|
+
crop.width,
|
|
47
|
+
crop.height,
|
|
48
|
+
0,
|
|
49
|
+
0,
|
|
50
|
+
crop.width,
|
|
51
|
+
crop.height
|
|
52
|
+
);
|
|
41
53
|
context.globalCompositeOperation = 'destination-atop';
|
|
42
|
-
context.drawImage(
|
|
54
|
+
context.drawImage(
|
|
55
|
+
texture.baseTexture.source,
|
|
56
|
+
crop.x,
|
|
57
|
+
crop.y,
|
|
58
|
+
crop.width,
|
|
59
|
+
crop.height,
|
|
60
|
+
0,
|
|
61
|
+
0,
|
|
62
|
+
crop.width,
|
|
63
|
+
crop.height
|
|
64
|
+
);
|
|
43
65
|
}
|
|
44
66
|
|
|
45
67
|
/**
|
|
68
|
+
* TBD.
|
|
46
69
|
*
|
|
47
|
-
* @param {object} texture TBD
|
|
48
|
-
* @param {object} color TBD
|
|
49
|
-
* @param {
|
|
70
|
+
* @param {object} texture - TBD.
|
|
71
|
+
* @param {object} color - TBD.
|
|
72
|
+
* @param {HTMLCanvasElement} canvas - TBD.
|
|
50
73
|
*/
|
|
51
74
|
export function tintWithPerPixel(texture, color, canvas) {
|
|
52
75
|
const context = canvas.getContext('2d');
|
|
@@ -54,7 +77,17 @@ export function tintWithPerPixel(texture, color, canvas) {
|
|
|
54
77
|
canvas.width = crop.width;
|
|
55
78
|
canvas.height = crop.height;
|
|
56
79
|
context.globalCompositeOperation = 'copy';
|
|
57
|
-
context.drawImage(
|
|
80
|
+
context.drawImage(
|
|
81
|
+
texture.baseTexture.source,
|
|
82
|
+
crop.x,
|
|
83
|
+
crop.y,
|
|
84
|
+
crop.width,
|
|
85
|
+
crop.height,
|
|
86
|
+
0,
|
|
87
|
+
0,
|
|
88
|
+
crop.width,
|
|
89
|
+
crop.height
|
|
90
|
+
);
|
|
58
91
|
const rgbValues = hex2rgb(color);
|
|
59
92
|
const r = rgbValues[0];
|
|
60
93
|
const g = rgbValues[1];
|
|
@@ -77,8 +110,9 @@ export function tintWithPerPixel(texture, color, canvas) {
|
|
|
77
110
|
}
|
|
78
111
|
|
|
79
112
|
/**
|
|
113
|
+
* TBD.
|
|
80
114
|
*
|
|
81
|
-
* @returns {boolean} TBD
|
|
115
|
+
* @returns {boolean} TBD.
|
|
82
116
|
*/
|
|
83
117
|
export function checkInverseAlpha() {
|
|
84
118
|
const canvas = new CanvasBuffer(2, 1);
|
|
@@ -95,12 +129,18 @@ export function checkInverseAlpha() {
|
|
|
95
129
|
// Get those values
|
|
96
130
|
const s2 = canvas.context.getImageData(1, 0, 1, 1);
|
|
97
131
|
// Compare and return
|
|
98
|
-
return (
|
|
132
|
+
return (
|
|
133
|
+
s2.data[0] === s1.data[0] &&
|
|
134
|
+
s2.data[1] === s1.data[1] &&
|
|
135
|
+
s2.data[2] === s1.data[2] &&
|
|
136
|
+
s2.data[3] === s1.data[3]
|
|
137
|
+
);
|
|
99
138
|
}
|
|
100
139
|
|
|
101
140
|
/**
|
|
141
|
+
* TBD.
|
|
102
142
|
*
|
|
103
|
-
* @returns {boolean} TBD
|
|
143
|
+
* @returns {boolean} TBD.
|
|
104
144
|
*/
|
|
105
145
|
export function canUseNewCanvasBlendModes() {
|
|
106
146
|
if (document === undefined) {
|
|
@@ -122,11 +162,11 @@ export function canUseNewCanvasBlendModes() {
|
|
|
122
162
|
}
|
|
123
163
|
const data = context.getImageData(2, 0, 1, 1).data;
|
|
124
164
|
removeByCanvas(canvas);
|
|
125
|
-
return
|
|
165
|
+
return data[0] === 255 && data[1] === 0 && data[2] === 0;
|
|
126
166
|
}
|
|
127
167
|
|
|
128
168
|
/**
|
|
129
|
-
* TBD
|
|
169
|
+
* TBD.
|
|
130
170
|
*/
|
|
131
171
|
export function detectCapabilities() {
|
|
132
172
|
if (!window.PhaserRegistry) {
|
|
@@ -139,6 +179,8 @@ export function detectCapabilities() {
|
|
|
139
179
|
window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY = canUseNewCanvasBlendModes();
|
|
140
180
|
}
|
|
141
181
|
if (!window.PhaserRegistry.CANVAS_TINT_METHOD) {
|
|
142
|
-
window.PhaserRegistry.CANVAS_TINT_METHOD = window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY
|
|
182
|
+
window.PhaserRegistry.CANVAS_TINT_METHOD = window.PhaserRegistry.CAN_CANVAS_USE_MULTIPLY
|
|
183
|
+
? tintWithMultiply
|
|
184
|
+
: tintWithPerPixel;
|
|
143
185
|
}
|
|
144
186
|
}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
7
|
import { create as createCanvas } from './pool';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* TBD.
|
|
10
11
|
*
|
|
11
|
-
* @param {object} parent TBD
|
|
12
|
-
* @param {number} width TBD
|
|
13
|
-
* @param {number} height TBD
|
|
14
|
-
* @param {string} id TBD
|
|
15
|
-
* @param {boolean} skipPool TBD
|
|
16
|
-
* @returns {object} TBD
|
|
12
|
+
* @param {object} parent - TBD.
|
|
13
|
+
* @param {number} width - TBD.
|
|
14
|
+
* @param {number} height - TBD.
|
|
15
|
+
* @param {string} id - TBD.
|
|
16
|
+
* @param {boolean} skipPool - TBD.
|
|
17
|
+
* @returns {object} TBD.
|
|
17
18
|
*/
|
|
18
19
|
export function create(parent, width, height, id, skipPool) {
|
|
19
20
|
width = width || 256;
|
|
20
21
|
height = height || 256;
|
|
21
|
-
const canvas =
|
|
22
|
+
const canvas = skipPool ? document.createElement('canvas') : createCanvas(parent, width, height);
|
|
22
23
|
if (typeof id === 'string' && id !== '') {
|
|
23
24
|
canvas.id = id;
|
|
24
25
|
}
|
|
@@ -29,10 +30,11 @@ export function create(parent, width, height, id, skipPool) {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
33
|
+
* TBD.
|
|
32
34
|
*
|
|
33
|
-
* @param {
|
|
34
|
-
* @param {string} color TBD
|
|
35
|
-
* @returns {object} TBD
|
|
35
|
+
* @param {HTMLCanvasElement} canvas - TBD.
|
|
36
|
+
* @param {string} color - TBD.
|
|
37
|
+
* @returns {object} TBD.
|
|
36
38
|
*/
|
|
37
39
|
export function setBackgroundColor(canvas, color) {
|
|
38
40
|
color = color || 'rgb(0,0,0)';
|
|
@@ -41,10 +43,11 @@ export function setBackgroundColor(canvas, color) {
|
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
/**
|
|
46
|
+
* TBD.
|
|
44
47
|
*
|
|
45
|
-
* @param {
|
|
46
|
-
* @param {string} value TBD
|
|
47
|
-
* @returns {object} TBD
|
|
48
|
+
* @param {HTMLCanvasElement} canvas - TBD.
|
|
49
|
+
* @param {string} value - TBD.
|
|
50
|
+
* @returns {object} TBD.
|
|
48
51
|
*/
|
|
49
52
|
export function setTouchAction(canvas, value) {
|
|
50
53
|
value = value || 'none';
|
|
@@ -55,10 +58,11 @@ export function setTouchAction(canvas, value) {
|
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
/**
|
|
61
|
+
* TBD.
|
|
58
62
|
*
|
|
59
|
-
* @param {
|
|
60
|
-
* @param {string} value TBD
|
|
61
|
-
* @returns {object} TBD
|
|
63
|
+
* @param {HTMLCanvasElement} canvas - TBD.
|
|
64
|
+
* @param {string} value - TBD.
|
|
65
|
+
* @returns {object} TBD.
|
|
62
66
|
*/
|
|
63
67
|
export function setUserSelect(canvas, value) {
|
|
64
68
|
value = value || 'none';
|
|
@@ -73,11 +77,12 @@ export function setUserSelect(canvas, value) {
|
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
/**
|
|
80
|
+
* TBD.
|
|
76
81
|
*
|
|
77
|
-
* @param {
|
|
78
|
-
* @param {object} parent TBD
|
|
79
|
-
* @param {boolean} overflowHidden TBD
|
|
80
|
-
* @returns {object} TBD
|
|
82
|
+
* @param {HTMLCanvasElement} canvas - TBD.
|
|
83
|
+
* @param {object} parent - TBD.
|
|
84
|
+
* @param {boolean} overflowHidden - TBD.
|
|
85
|
+
* @returns {object} TBD.
|
|
81
86
|
*/
|
|
82
87
|
export function addToDOM(canvas, parent, overflowHidden = true) {
|
|
83
88
|
let target;
|
|
@@ -102,8 +107,9 @@ export function addToDOM(canvas, parent, overflowHidden = true) {
|
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
/**
|
|
110
|
+
* TBD.
|
|
105
111
|
*
|
|
106
|
-
* @param {
|
|
112
|
+
* @param {HTMLCanvasElement} canvas - TBD.
|
|
107
113
|
*/
|
|
108
114
|
export function removeFromDOM(canvas) {
|
|
109
115
|
if (canvas.parentNode) {
|
|
@@ -112,15 +118,16 @@ export function removeFromDOM(canvas) {
|
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
/**
|
|
121
|
+
* TBD.
|
|
115
122
|
*
|
|
116
|
-
* @param {object} context TBD
|
|
117
|
-
* @param {number} translateX TBD
|
|
118
|
-
* @param {number} translateY TBD
|
|
119
|
-
* @param {number} scaleX TBD
|
|
120
|
-
* @param {number} scaleY TBD
|
|
121
|
-
* @param {number} skewX TBD
|
|
122
|
-
* @param {number} skewY TBD
|
|
123
|
-
* @returns {object} TBD
|
|
123
|
+
* @param {object} context - TBD.
|
|
124
|
+
* @param {number} translateX - TBD.
|
|
125
|
+
* @param {number} translateY - TBD.
|
|
126
|
+
* @param {number} scaleX - TBD.
|
|
127
|
+
* @param {number} scaleY - TBD.
|
|
128
|
+
* @param {number} skewX - TBD.
|
|
129
|
+
* @param {number} skewY - TBD.
|
|
130
|
+
* @returns {object} TBD.
|
|
124
131
|
*/
|
|
125
132
|
export function setTransform(context, translateX, translateY, scaleX, scaleY, skewX, skewY) {
|
|
126
133
|
context.setTransform(scaleX, skewX, skewY, scaleY, translateX, translateY);
|
|
@@ -128,9 +135,10 @@ export function setTransform(context, translateX, translateY, scaleX, scaleY, sk
|
|
|
128
135
|
}
|
|
129
136
|
|
|
130
137
|
/**
|
|
138
|
+
* TBD.
|
|
131
139
|
*
|
|
132
|
-
* @param {object} context TBD
|
|
133
|
-
* @returns {object} TBD
|
|
140
|
+
* @param {object} context - TBD.
|
|
141
|
+
* @returns {object} TBD.
|
|
134
142
|
*/
|
|
135
143
|
export function getSmoothingPrefix(context) {
|
|
136
144
|
const VENDORS = ['i', 'webkitI', 'msI', 'mozI', 'oI'];
|
|
@@ -144,10 +152,11 @@ export function getSmoothingPrefix(context) {
|
|
|
144
152
|
}
|
|
145
153
|
|
|
146
154
|
/**
|
|
155
|
+
* TBD.
|
|
147
156
|
*
|
|
148
|
-
* @param {object} context TBD
|
|
149
|
-
* @param {number} value TBD
|
|
150
|
-
* @returns {object} TBD
|
|
157
|
+
* @param {object} context - TBD.
|
|
158
|
+
* @param {number} value - TBD.
|
|
159
|
+
* @returns {object} TBD.
|
|
151
160
|
*/
|
|
152
161
|
export function setSmoothingEnabled(context, value) {
|
|
153
162
|
const s = getSmoothingPrefix(context);
|