@vpmedia/phaser 1.15.0 → 1.16.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 +3 -3
- package/package.json +6 -5
- package/src/index.js +15 -18
- package/src/phaser/core/animation.js +102 -6
- package/src/phaser/core/animation_manager.js +88 -10
- package/src/phaser/core/animation_parser.js +5 -18
- package/src/phaser/core/array_set.js +51 -5
- package/src/phaser/core/cache.js +291 -6
- package/src/phaser/core/const.js +107 -4
- package/src/phaser/core/device.js +3 -6
- package/src/phaser/core/device_util.js +3 -16
- package/src/phaser/core/dom.js +127 -29
- package/src/phaser/core/event_manager.js +128 -6
- package/src/phaser/core/factory.js +69 -34
- package/src/phaser/core/frame.js +43 -6
- package/src/phaser/core/frame_data.js +55 -5
- package/src/phaser/core/frame_util.js +7 -12
- package/src/phaser/core/game.js +35 -7
- package/src/phaser/core/input.js +116 -17
- package/src/phaser/core/input_handler.js +242 -42
- package/src/phaser/core/input_mouse.js +66 -5
- package/src/phaser/core/input_mspointer.js +40 -9
- package/src/phaser/core/input_pointer.js +79 -17
- package/src/phaser/core/input_touch.js +42 -5
- package/src/phaser/core/loader.js +274 -101
- package/src/phaser/core/loader_parser.js +2 -10
- package/src/phaser/core/raf.js +16 -5
- package/src/phaser/core/scale_manager.js +204 -39
- package/src/phaser/core/scene.js +24 -5
- package/src/phaser/core/scene_manager.js +81 -11
- package/src/phaser/core/signal.js +88 -11
- package/src/phaser/core/signal_binding.js +35 -15
- package/src/phaser/core/sound.js +99 -10
- package/src/phaser/core/sound_manager.js +89 -13
- package/src/phaser/core/sound_sprite.js +20 -5
- package/src/phaser/core/stage.js +43 -7
- package/src/phaser/core/time.js +67 -5
- package/src/phaser/core/timer.js +107 -30
- package/src/phaser/core/timer_event.js +11 -6
- package/src/phaser/core/tween.js +124 -30
- package/src/phaser/core/tween_data.js +42 -18
- package/src/phaser/core/tween_easing.js +1 -8
- package/src/phaser/core/tween_manager.js +47 -5
- package/src/phaser/core/world.js +9 -6
- package/src/phaser/display/bitmap_text.js +91 -10
- package/src/phaser/display/button.js +63 -12
- package/src/phaser/display/canvas/buffer.js +16 -6
- package/src/phaser/display/canvas/graphics.js +1 -13
- package/src/phaser/display/canvas/masker.js +0 -6
- package/src/phaser/display/canvas/pool.js +0 -7
- package/src/phaser/display/canvas/renderer.js +28 -8
- package/src/phaser/display/canvas/tinter.js +4 -43
- package/src/phaser/display/canvas/util.js +0 -6
- package/src/phaser/display/display_object.js +192 -20
- package/src/phaser/display/graphics.js +161 -26
- package/src/phaser/display/graphics_data.js +14 -6
- package/src/phaser/display/graphics_data_util.js +2 -8
- package/src/phaser/display/group.js +74 -9
- package/src/phaser/display/image.js +85 -9
- package/src/phaser/display/sprite_batch.js +3 -8
- package/src/phaser/display/sprite_util.js +3 -23
- package/src/phaser/display/text.js +331 -31
- package/src/phaser/display/webgl/abstract_filter.js +8 -7
- package/src/phaser/display/webgl/base_texture.js +20 -12
- package/src/phaser/display/webgl/blend_manager.js +14 -7
- package/src/phaser/display/webgl/earcut.js +4 -23
- package/src/phaser/display/webgl/earcut_node.js +6 -7
- package/src/phaser/display/webgl/fast_sprite_batch.js +34 -11
- package/src/phaser/display/webgl/filter_manager.js +25 -7
- package/src/phaser/display/webgl/filter_texture.js +21 -22
- package/src/phaser/display/webgl/graphics.js +5 -28
- package/src/phaser/display/webgl/graphics_data.js +10 -7
- package/src/phaser/display/webgl/mask_manager.js +0 -6
- package/src/phaser/display/webgl/render_texture.js +33 -21
- package/src/phaser/display/webgl/renderer.js +38 -11
- package/src/phaser/display/webgl/shader/complex.js +10 -6
- package/src/phaser/display/webgl/shader/fast.js +10 -6
- package/src/phaser/display/webgl/shader/normal.js +23 -32
- package/src/phaser/display/webgl/shader/primitive.js +10 -6
- package/src/phaser/display/webgl/shader/strip.js +10 -6
- package/src/phaser/display/webgl/shader_manager.js +18 -6
- package/src/phaser/display/webgl/sprite_batch.js +41 -8
- package/src/phaser/display/webgl/stencil_manager.js +28 -6
- package/src/phaser/display/webgl/texture.js +28 -15
- package/src/phaser/display/webgl/texture_util.js +0 -6
- package/src/phaser/display/webgl/util.js +0 -7
- package/src/phaser/geom/circle.js +123 -18
- package/src/phaser/geom/ellipse.js +39 -18
- package/src/phaser/geom/line.js +148 -16
- package/src/phaser/geom/matrix.js +73 -6
- package/src/phaser/geom/point.js +152 -6
- package/src/phaser/geom/polygon.js +42 -14
- package/src/phaser/geom/rectangle.js +233 -6
- package/src/phaser/geom/rounded_rectangle.js +10 -6
- package/src/phaser/geom/util/circle.js +3 -9
- package/src/phaser/geom/util/ellipse.js +0 -7
- package/src/phaser/geom/util/line.js +5 -14
- package/src/phaser/geom/util/matrix.js +1 -7
- package/src/phaser/geom/util/point.js +0 -6
- package/src/phaser/geom/util/polygon.js +1 -7
- package/src/phaser/geom/util/rectangle.js +1 -7
- package/src/phaser/geom/util/rounded_rectangle.js +1 -7
- package/src/phaser/util/math.js +3 -21
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/phaser/core/animation.d.ts +105 -4
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +87 -0
- package/types/phaser/core/animation_manager.d.ts.map +1 -1
- package/types/phaser/core/animation_parser.d.ts +5 -4
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/array_set.d.ts +53 -7
- package/types/phaser/core/array_set.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +346 -56
- package/types/phaser/core/cache.d.ts.map +1 -1
- package/types/phaser/core/const.d.ts +143 -40
- package/types/phaser/core/const.d.ts.map +1 -1
- package/types/phaser/core/device.d.ts +0 -5
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/device_util.d.ts +1 -1
- package/types/phaser/core/device_util.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +119 -0
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +127 -0
- package/types/phaser/core/event_manager.d.ts.map +1 -1
- package/types/phaser/core/factory.d.ts +74 -7
- package/types/phaser/core/factory.d.ts.map +1 -1
- package/types/phaser/core/frame.d.ts +64 -21
- package/types/phaser/core/frame.d.ts.map +1 -1
- package/types/phaser/core/frame_data.d.ts +61 -9
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/frame_util.d.ts +10 -8
- package/types/phaser/core/frame_util.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +40 -6
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input.d.ts +114 -3
- package/types/phaser/core/input.d.ts.map +1 -1
- package/types/phaser/core/input_handler.d.ts +257 -24
- package/types/phaser/core/input_handler.d.ts.map +1 -1
- package/types/phaser/core/input_mouse.d.ts +51 -4
- package/types/phaser/core/input_mouse.d.ts.map +1 -1
- package/types/phaser/core/input_mspointer.d.ts +43 -9
- package/types/phaser/core/input_mspointer.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +78 -2
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/input_touch.d.ts +45 -8
- package/types/phaser/core/input_touch.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +264 -19
- package/types/phaser/core/loader.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +17 -7
- package/types/phaser/core/raf.d.ts.map +1 -1
- package/types/phaser/core/scale_manager.d.ts +201 -6
- package/types/phaser/core/scale_manager.d.ts.map +1 -1
- package/types/phaser/core/scene.d.ts +21 -5
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +90 -10
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +93 -9
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/signal_binding.d.ts +34 -5
- package/types/phaser/core/signal_binding.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +111 -14
- package/types/phaser/core/sound.d.ts.map +1 -1
- package/types/phaser/core/sound_manager.d.ts +93 -7
- package/types/phaser/core/sound_manager.d.ts.map +1 -1
- package/types/phaser/core/sound_sprite.d.ts +22 -8
- package/types/phaser/core/sound_sprite.d.ts.map +1 -1
- package/types/phaser/core/stage.d.ts +32 -3
- package/types/phaser/core/stage.d.ts.map +1 -1
- package/types/phaser/core/time.d.ts +73 -6
- package/types/phaser/core/time.d.ts.map +1 -1
- package/types/phaser/core/timer.d.ts +103 -2
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +11 -5
- package/types/phaser/core/timer_event.d.ts.map +1 -1
- package/types/phaser/core/tween.d.ts +122 -2
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +41 -2
- package/types/phaser/core/tween_data.d.ts.map +1 -1
- package/types/phaser/core/tween_easing.d.ts +0 -5
- package/types/phaser/core/tween_easing.d.ts.map +1 -1
- package/types/phaser/core/tween_manager.d.ts +49 -2
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +9 -1
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +84 -7
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +65 -8
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +20 -4
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/masker.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +0 -6
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +29 -2
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +195 -8
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +132 -6
- package/types/phaser/display/graphics.d.ts.map +1 -1
- package/types/phaser/display/graphics_data.d.ts +15 -1
- package/types/phaser/display/graphics_data.d.ts.map +1 -1
- package/types/phaser/display/graphics_data_util.d.ts +3 -2
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/types/phaser/display/group.d.ts +62 -0
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +66 -2
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/sprite_batch.d.ts +4 -3
- package/types/phaser/display/sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/sprite_util.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +366 -46
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +8 -6
- package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/types/phaser/display/webgl/base_texture.d.ts +20 -1
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/blend_manager.d.ts +11 -6
- package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/types/phaser/display/webgl/earcut_node.d.ts +9 -9
- package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +33 -6
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/webgl/filter_manager.d.ts +22 -6
- package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/filter_texture.d.ts +21 -3
- package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +10 -6
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/render_texture.d.ts +30 -3
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/renderer.d.ts +41 -4
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +10 -0
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/fast.d.ts +10 -0
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/normal.d.ts +20 -0
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/primitive.d.ts +10 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/strip.d.ts +10 -0
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader_manager.d.ts +15 -0
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/sprite_batch.d.ts +37 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/webgl/stencil_manager.d.ts +25 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture.d.ts +21 -0
- package/types/phaser/display/webgl/texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/display/webgl/util.d.ts +0 -6
- package/types/phaser/display/webgl/util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +131 -9
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +43 -5
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +159 -13
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +85 -11
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +170 -18
- package/types/phaser/geom/point.d.ts.map +1 -1
- package/types/phaser/geom/polygon.d.ts +45 -5
- package/types/phaser/geom/polygon.d.ts.map +1 -1
- package/types/phaser/geom/rectangle.d.ts +253 -20
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +11 -1
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/circle.d.ts +3 -3
- package/types/phaser/geom/util/circle.d.ts.map +1 -1
- package/types/phaser/geom/util/ellipse.d.ts +0 -6
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/util/line.d.ts +5 -5
- package/types/phaser/geom/util/line.d.ts.map +1 -1
- package/types/phaser/geom/util/matrix.d.ts.map +1 -1
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/types/phaser/geom/util/polygon.d.ts.map +1 -1
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/util/math.d.ts +0 -5
- package/types/phaser/util/math.d.ts.map +1 -1
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
* @module display/bitmap_text
|
|
3
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
4
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
5
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
6
|
-
*/
|
|
7
|
-
import { DisplayObject } from './display_object';
|
|
1
|
+
import { DisplayObject } from './display_object';
|
|
8
2
|
import { Image } from './image';
|
|
9
|
-
import { Game } from
|
|
3
|
+
import { Game } from '../core/game';
|
|
10
4
|
import { Point } from '../geom/point';
|
|
11
5
|
import { BITMAP_TEXT, SCALE_LINEAR, SCALE_NEAREST } from '../core/const';
|
|
12
6
|
|
|
@@ -41,6 +35,9 @@ export class BitmapText extends DisplayObject {
|
|
|
41
35
|
this.dirty = false;
|
|
42
36
|
}
|
|
43
37
|
|
|
38
|
+
/**
|
|
39
|
+
* TBD.
|
|
40
|
+
*/
|
|
44
41
|
destroy() {
|
|
45
42
|
this._prevAnchor = null;
|
|
46
43
|
this._glyphs = null;
|
|
@@ -49,6 +46,9 @@ export class BitmapText extends DisplayObject {
|
|
|
49
46
|
super.destroy();
|
|
50
47
|
}
|
|
51
48
|
|
|
49
|
+
/**
|
|
50
|
+
* TBD.
|
|
51
|
+
*/
|
|
52
52
|
preUpdate() {
|
|
53
53
|
if (this.pendingDestroy) {
|
|
54
54
|
this.destroy();
|
|
@@ -68,10 +68,21 @@ export class BitmapText extends DisplayObject {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* TBD.
|
|
73
|
+
* @param text - TBD.
|
|
74
|
+
*/
|
|
71
75
|
setText(text) {
|
|
72
76
|
this.text = text;
|
|
73
77
|
}
|
|
74
78
|
|
|
79
|
+
/**
|
|
80
|
+
* TBD.
|
|
81
|
+
* @param data - TBD.
|
|
82
|
+
* @param scale - TBD.
|
|
83
|
+
* @param text - TBD.
|
|
84
|
+
* @returns {object} TBD.
|
|
85
|
+
*/
|
|
75
86
|
scanLine(data, scale, text) {
|
|
76
87
|
let x = 0;
|
|
77
88
|
let w = 0;
|
|
@@ -102,8 +113,7 @@ export class BitmapText extends DisplayObject {
|
|
|
102
113
|
charData = data.chars[charCode];
|
|
103
114
|
}
|
|
104
115
|
// Adjust for kerning from previous character to this one
|
|
105
|
-
const kerning =
|
|
106
|
-
prevCharCode && charData.kerning[prevCharCode] ? charData.kerning[prevCharCode] : 0;
|
|
116
|
+
const kerning = prevCharCode && charData.kerning[prevCharCode] ? charData.kerning[prevCharCode] : 0;
|
|
107
117
|
// Record the last space in the string and the current width
|
|
108
118
|
if (/(\s)/.test(text.charAt(i))) {
|
|
109
119
|
lastSpace = i;
|
|
@@ -134,6 +144,12 @@ export class BitmapText extends DisplayObject {
|
|
|
134
144
|
};
|
|
135
145
|
}
|
|
136
146
|
|
|
147
|
+
/**
|
|
148
|
+
* TBD.
|
|
149
|
+
* @param text - TBD.
|
|
150
|
+
* @param replace - TBD.
|
|
151
|
+
* @returns {string} TBD.
|
|
152
|
+
*/
|
|
137
153
|
cleanText(text, replace = '') {
|
|
138
154
|
const data = this._data.font;
|
|
139
155
|
if (!data) {
|
|
@@ -156,6 +172,9 @@ export class BitmapText extends DisplayObject {
|
|
|
156
172
|
return lines.join('\n');
|
|
157
173
|
}
|
|
158
174
|
|
|
175
|
+
/**
|
|
176
|
+
* TBD.
|
|
177
|
+
*/
|
|
159
178
|
updateText() {
|
|
160
179
|
const data = this._data.font;
|
|
161
180
|
if (!data) {
|
|
@@ -224,6 +243,10 @@ export class BitmapText extends DisplayObject {
|
|
|
224
243
|
}
|
|
225
244
|
}
|
|
226
245
|
|
|
246
|
+
/**
|
|
247
|
+
* TBD.
|
|
248
|
+
* @returns {number} TBD.
|
|
249
|
+
*/
|
|
227
250
|
purgeGlyphs() {
|
|
228
251
|
const len = this._glyphs.length;
|
|
229
252
|
const kept = [];
|
|
@@ -240,6 +263,9 @@ export class BitmapText extends DisplayObject {
|
|
|
240
263
|
return len - kept.length;
|
|
241
264
|
}
|
|
242
265
|
|
|
266
|
+
/**
|
|
267
|
+
* TBD.
|
|
268
|
+
*/
|
|
243
269
|
updateTransform() {
|
|
244
270
|
if (this.dirty || !this.anchor.equals(this._prevAnchor)) {
|
|
245
271
|
this.updateText();
|
|
@@ -249,10 +275,17 @@ export class BitmapText extends DisplayObject {
|
|
|
249
275
|
super.updateTransform();
|
|
250
276
|
}
|
|
251
277
|
|
|
278
|
+
/**
|
|
279
|
+
* TBD.
|
|
280
|
+
* @returns {string} TBD.
|
|
281
|
+
*/
|
|
252
282
|
get align() {
|
|
253
283
|
return this._align;
|
|
254
284
|
}
|
|
255
285
|
|
|
286
|
+
/**
|
|
287
|
+
* TBD.
|
|
288
|
+
*/
|
|
256
289
|
set align(value) {
|
|
257
290
|
if (value !== this._align && (value === 'left' || value === 'center' || value === 'right')) {
|
|
258
291
|
this._align = value;
|
|
@@ -260,10 +293,17 @@ export class BitmapText extends DisplayObject {
|
|
|
260
293
|
}
|
|
261
294
|
}
|
|
262
295
|
|
|
296
|
+
/**
|
|
297
|
+
* TBD.
|
|
298
|
+
* @returns {number} TBD.
|
|
299
|
+
*/
|
|
263
300
|
get tint() {
|
|
264
301
|
return this._tint;
|
|
265
302
|
}
|
|
266
303
|
|
|
304
|
+
/**
|
|
305
|
+
* TBD.
|
|
306
|
+
*/
|
|
267
307
|
set tint(value) {
|
|
268
308
|
if (value !== this._tint) {
|
|
269
309
|
this._tint = value;
|
|
@@ -271,6 +311,10 @@ export class BitmapText extends DisplayObject {
|
|
|
271
311
|
}
|
|
272
312
|
}
|
|
273
313
|
|
|
314
|
+
/**
|
|
315
|
+
* TBD.
|
|
316
|
+
* @returns {string} TBD.
|
|
317
|
+
*/
|
|
274
318
|
get fill() {
|
|
275
319
|
if (typeof this.tint === 'number') {
|
|
276
320
|
let colorStr = this.tint.toString(16);
|
|
@@ -282,14 +326,24 @@ export class BitmapText extends DisplayObject {
|
|
|
282
326
|
return this.tint;
|
|
283
327
|
}
|
|
284
328
|
|
|
329
|
+
/**
|
|
330
|
+
* TBD.
|
|
331
|
+
*/
|
|
285
332
|
set fill(value) {
|
|
286
333
|
this.tint = typeof value === 'string' ? parseInt(value.replace('#', ''), 16) : value;
|
|
287
334
|
}
|
|
288
335
|
|
|
336
|
+
/**
|
|
337
|
+
* TBD.
|
|
338
|
+
* @returns {string} TBD.
|
|
339
|
+
*/
|
|
289
340
|
get font() {
|
|
290
341
|
return this._font;
|
|
291
342
|
}
|
|
292
343
|
|
|
344
|
+
/**
|
|
345
|
+
* TBD.
|
|
346
|
+
*/
|
|
293
347
|
set font(value) {
|
|
294
348
|
const trimmedValue = value.trim();
|
|
295
349
|
if (trimmedValue !== this._font) {
|
|
@@ -299,10 +353,17 @@ export class BitmapText extends DisplayObject {
|
|
|
299
353
|
}
|
|
300
354
|
}
|
|
301
355
|
|
|
356
|
+
/**
|
|
357
|
+
* TBD.
|
|
358
|
+
* @returns {number} TBD.
|
|
359
|
+
*/
|
|
302
360
|
get fontSize() {
|
|
303
361
|
return this._fontSize;
|
|
304
362
|
}
|
|
305
363
|
|
|
364
|
+
/**
|
|
365
|
+
* TBD.
|
|
366
|
+
*/
|
|
306
367
|
set fontSize(value) {
|
|
307
368
|
value = parseInt(value, 10);
|
|
308
369
|
if (value !== this._fontSize && value > 0) {
|
|
@@ -311,10 +372,17 @@ export class BitmapText extends DisplayObject {
|
|
|
311
372
|
}
|
|
312
373
|
}
|
|
313
374
|
|
|
375
|
+
/**
|
|
376
|
+
* TBD.
|
|
377
|
+
* @returns {string} TBD.
|
|
378
|
+
*/
|
|
314
379
|
get text() {
|
|
315
380
|
return this._text;
|
|
316
381
|
}
|
|
317
382
|
|
|
383
|
+
/**
|
|
384
|
+
* TBD.
|
|
385
|
+
*/
|
|
318
386
|
set text(value) {
|
|
319
387
|
const typedValue = value.toString();
|
|
320
388
|
if (typedValue !== this._text) {
|
|
@@ -323,10 +391,16 @@ export class BitmapText extends DisplayObject {
|
|
|
323
391
|
}
|
|
324
392
|
}
|
|
325
393
|
|
|
394
|
+
/**
|
|
395
|
+
* TBD.
|
|
396
|
+
*/
|
|
326
397
|
get maxWidth() {
|
|
327
398
|
return this._maxWidth;
|
|
328
399
|
}
|
|
329
400
|
|
|
401
|
+
/**
|
|
402
|
+
* TBD.
|
|
403
|
+
*/
|
|
330
404
|
set maxWidth(value) {
|
|
331
405
|
if (value !== this._maxWidth) {
|
|
332
406
|
this._maxWidth = value;
|
|
@@ -334,10 +408,17 @@ export class BitmapText extends DisplayObject {
|
|
|
334
408
|
}
|
|
335
409
|
}
|
|
336
410
|
|
|
411
|
+
/**
|
|
412
|
+
* TBD.
|
|
413
|
+
* @returns {boolean} TBD.
|
|
414
|
+
*/
|
|
337
415
|
get smoothed() {
|
|
338
416
|
return !this._data.base.scaleMode;
|
|
339
417
|
}
|
|
340
418
|
|
|
419
|
+
/**
|
|
420
|
+
* TBD.
|
|
421
|
+
*/
|
|
341
422
|
set smoothed(value) {
|
|
342
423
|
if (value) {
|
|
343
424
|
this._data.base.scaleMode = SCALE_LINEAR;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module display/button
|
|
3
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
4
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
5
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
6
|
-
*/
|
|
7
1
|
import { Image } from './image';
|
|
8
|
-
import { Signal } from
|
|
9
|
-
import { Game } from
|
|
2
|
+
import { Signal } from '../core/signal';
|
|
3
|
+
import { Game } from '../core/game';
|
|
10
4
|
import { InputHandler } from '../core/input_handler';
|
|
11
5
|
import { BUTTON, POINTER_CONTACT } from '../core/const';
|
|
12
6
|
|
|
@@ -71,6 +65,9 @@ export class Button extends Image {
|
|
|
71
65
|
this.events.onInputUp.add(this.onInputUpHandler, this);
|
|
72
66
|
}
|
|
73
67
|
|
|
68
|
+
/**
|
|
69
|
+
* TBD.
|
|
70
|
+
*/
|
|
74
71
|
destroy() {
|
|
75
72
|
this._onOverFrame = null;
|
|
76
73
|
this._onOutFrame = null;
|
|
@@ -94,6 +91,11 @@ export class Button extends Image {
|
|
|
94
91
|
super.destroy();
|
|
95
92
|
}
|
|
96
93
|
|
|
94
|
+
/**
|
|
95
|
+
* TBD.
|
|
96
|
+
* @param {boolean} isEnabled - TBD.
|
|
97
|
+
* @param {boolean} isImmediate - TBD.
|
|
98
|
+
*/
|
|
97
99
|
setEnabled(isEnabled, isImmediate) {
|
|
98
100
|
this.input.enabled = isEnabled;
|
|
99
101
|
if (isImmediate) {
|
|
@@ -105,14 +107,26 @@ export class Button extends Image {
|
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
|
|
110
|
+
/**
|
|
111
|
+
* TBD.
|
|
112
|
+
*/
|
|
108
113
|
clearFrames() {
|
|
109
114
|
this.setFrames(null, null, null, null);
|
|
110
115
|
}
|
|
111
116
|
|
|
117
|
+
/**
|
|
118
|
+
* TBD.
|
|
119
|
+
*/
|
|
112
120
|
removedFromWorld() {
|
|
113
121
|
this.inputEnabled = false;
|
|
114
122
|
}
|
|
115
123
|
|
|
124
|
+
/**
|
|
125
|
+
* TBD.
|
|
126
|
+
* @param {string} state - TBD.
|
|
127
|
+
* @param {string} frame - TBD.
|
|
128
|
+
* @param {boolean} switchImmediately - TBD.
|
|
129
|
+
*/
|
|
116
130
|
setStateFrame(state, frame, switchImmediately = false) {
|
|
117
131
|
const frameKey = '_on' + state + 'Frame';
|
|
118
132
|
if (frame) {
|
|
@@ -125,6 +139,11 @@ export class Button extends Image {
|
|
|
125
139
|
}
|
|
126
140
|
}
|
|
127
141
|
|
|
142
|
+
/**
|
|
143
|
+
* TBD.
|
|
144
|
+
* @param {string} newState - TBD.
|
|
145
|
+
* @returns {boolean} TBD.
|
|
146
|
+
*/
|
|
128
147
|
changeStateFrame(newState) {
|
|
129
148
|
if (this.freezeFrames) {
|
|
130
149
|
return false;
|
|
@@ -142,6 +161,13 @@ export class Button extends Image {
|
|
|
142
161
|
return false;
|
|
143
162
|
}
|
|
144
163
|
|
|
164
|
+
/**
|
|
165
|
+
* TBD.
|
|
166
|
+
* @param {string} overFrame - TBD.
|
|
167
|
+
* @param {string} outFrame - TBD.
|
|
168
|
+
* @param {string} downFrame - TBD.
|
|
169
|
+
* @param {string} upFrame - TBD.
|
|
170
|
+
*/
|
|
145
171
|
setFrames(overFrame, outFrame, downFrame, upFrame) {
|
|
146
172
|
this.setStateFrame(STATE_OVER, overFrame, this.input.pointerOver());
|
|
147
173
|
this.setStateFrame(STATE_OUT, outFrame, !this.input.pointerOver());
|
|
@@ -149,11 +175,13 @@ export class Button extends Image {
|
|
|
149
175
|
this.setStateFrame(STATE_UP, upFrame, this.input.pointerUp());
|
|
150
176
|
}
|
|
151
177
|
|
|
178
|
+
/**
|
|
179
|
+
* TBD.
|
|
180
|
+
* @param {object} sprite - TBD.
|
|
181
|
+
* @param {object} pointer - TBD.
|
|
182
|
+
*/
|
|
152
183
|
onInputOverHandler(sprite, pointer) {
|
|
153
|
-
if (
|
|
154
|
-
pointer.justReleased() &&
|
|
155
|
-
(this.justReleasedPreventsOver & pointer.pointerMode) === pointer.pointerMode
|
|
156
|
-
) {
|
|
184
|
+
if (pointer.justReleased() && (this.justReleasedPreventsOver & pointer.pointerMode) === pointer.pointerMode) {
|
|
157
185
|
// If the Pointer was only just released then we don't fire an over event
|
|
158
186
|
return;
|
|
159
187
|
}
|
|
@@ -166,6 +194,11 @@ export class Button extends Image {
|
|
|
166
194
|
}
|
|
167
195
|
}
|
|
168
196
|
|
|
197
|
+
/**
|
|
198
|
+
* TBD.
|
|
199
|
+
* @param {object} sprite - TBD.
|
|
200
|
+
* @param {object} pointer - TBD.
|
|
201
|
+
*/
|
|
169
202
|
onInputOutHandler(sprite, pointer) {
|
|
170
203
|
this.changeStateFrame(STATE_OUT);
|
|
171
204
|
if (this.onInputOut) {
|
|
@@ -173,6 +206,11 @@ export class Button extends Image {
|
|
|
173
206
|
}
|
|
174
207
|
}
|
|
175
208
|
|
|
209
|
+
/**
|
|
210
|
+
* TBD.
|
|
211
|
+
* @param {object} sprite - TBD.
|
|
212
|
+
* @param {object} pointer - TBD.
|
|
213
|
+
*/
|
|
176
214
|
onInputDownHandler(sprite, pointer) {
|
|
177
215
|
this.changeStateFrame(STATE_DOWN);
|
|
178
216
|
if (this.onInputDown) {
|
|
@@ -180,6 +218,12 @@ export class Button extends Image {
|
|
|
180
218
|
}
|
|
181
219
|
}
|
|
182
220
|
|
|
221
|
+
/**
|
|
222
|
+
* TBD.
|
|
223
|
+
* @param {object} sprite - TBD.
|
|
224
|
+
* @param {object} pointer - TBD.
|
|
225
|
+
* @param {boolean} isOver - TBD.
|
|
226
|
+
*/
|
|
183
227
|
onInputUpHandler(sprite, pointer, isOver) {
|
|
184
228
|
if (this.onInputUp) {
|
|
185
229
|
this.onInputUp.dispatch(this, pointer, isOver);
|
|
@@ -202,10 +246,17 @@ export class Button extends Image {
|
|
|
202
246
|
}
|
|
203
247
|
}
|
|
204
248
|
|
|
249
|
+
/**
|
|
250
|
+
* TBD.
|
|
251
|
+
* @returns {boolean} TBD.
|
|
252
|
+
*/
|
|
205
253
|
get inputEnabled() {
|
|
206
254
|
return this.input && this.input.enabled;
|
|
207
255
|
}
|
|
208
256
|
|
|
257
|
+
/**
|
|
258
|
+
* TBD.
|
|
259
|
+
*/
|
|
209
260
|
set inputEnabled(value) {
|
|
210
261
|
if (value) {
|
|
211
262
|
if (this.input === null) {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
1
|
import { create, removeByCanvas } from './pool';
|
|
8
2
|
|
|
9
3
|
export class CanvasBuffer {
|
|
4
|
+
/**
|
|
5
|
+
* TBD.
|
|
6
|
+
* @param {number} width - TBD.
|
|
7
|
+
* @param {number} height - TBD.
|
|
8
|
+
*/
|
|
10
9
|
constructor(width, height) {
|
|
11
10
|
this.width = width;
|
|
12
11
|
this.height = height;
|
|
@@ -16,11 +15,19 @@ export class CanvasBuffer {
|
|
|
16
15
|
this.canvas.height = height;
|
|
17
16
|
}
|
|
18
17
|
|
|
18
|
+
/**
|
|
19
|
+
* TBD.
|
|
20
|
+
*/
|
|
19
21
|
clear() {
|
|
20
22
|
this.context.setTransform(1, 0, 0, 1, 0, 0);
|
|
21
23
|
this.context.clearRect(0, 0, this.width, this.height);
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
/**
|
|
27
|
+
* TBD.
|
|
28
|
+
* @param {number} width - TBD.
|
|
29
|
+
* @param {number} height - TBD.
|
|
30
|
+
*/
|
|
24
31
|
resize(width, height) {
|
|
25
32
|
this.width = width;
|
|
26
33
|
this.height = height;
|
|
@@ -28,6 +35,9 @@ export class CanvasBuffer {
|
|
|
28
35
|
this.canvas.height = height;
|
|
29
36
|
}
|
|
30
37
|
|
|
38
|
+
/**
|
|
39
|
+
* TBD.
|
|
40
|
+
*/
|
|
31
41
|
destroy() {
|
|
32
42
|
removeByCanvas(this.canvas);
|
|
33
43
|
}
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
|
-
import {
|
|
8
|
-
GEOM_POLYGON,
|
|
9
|
-
GEOM_RECTANGLE,
|
|
10
|
-
GEOM_CIRCLE,
|
|
11
|
-
GEOM_ELLIPSE,
|
|
12
|
-
GEOM_ROUNDED_RECTANGLE,
|
|
13
|
-
} from '../../core/const';
|
|
1
|
+
import { GEOM_POLYGON, GEOM_RECTANGLE, GEOM_CIRCLE, GEOM_ELLIPSE, GEOM_ROUNDED_RECTANGLE } from '../../core/const';
|
|
14
2
|
|
|
15
3
|
/**
|
|
16
4
|
* TBD.
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
1
|
import { renderGraphicsMask } from './graphics';
|
|
8
2
|
|
|
9
3
|
/**
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
/**
|
|
9
2
|
* TBD.
|
|
10
3
|
* @returns {object[]} TBD.
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
1
|
import {
|
|
8
2
|
RENDER_CANVAS,
|
|
9
3
|
SCALE_LINEAR,
|
|
@@ -29,8 +23,13 @@ import {
|
|
|
29
23
|
import { getSmoothingPrefix } from './util';
|
|
30
24
|
import { detectCapabilities } from './tinter';
|
|
31
25
|
import * as CanvasMaskManager from './masker';
|
|
26
|
+
import { Game } from '../../core/game';
|
|
32
27
|
|
|
33
28
|
export class CanvasRenderer {
|
|
29
|
+
/**
|
|
30
|
+
* TBD.
|
|
31
|
+
* @param {Game} game - TBD.
|
|
32
|
+
*/
|
|
34
33
|
constructor(game) {
|
|
35
34
|
detectCapabilities();
|
|
36
35
|
this.type = RENDER_CANVAS;
|
|
@@ -58,6 +57,10 @@ export class CanvasRenderer {
|
|
|
58
57
|
this.resize(this.width, this.height);
|
|
59
58
|
}
|
|
60
59
|
|
|
60
|
+
/**
|
|
61
|
+
* TBD.
|
|
62
|
+
* @param root
|
|
63
|
+
*/
|
|
61
64
|
render(root) {
|
|
62
65
|
if (!this.context) {
|
|
63
66
|
return;
|
|
@@ -79,6 +82,10 @@ export class CanvasRenderer {
|
|
|
79
82
|
this.renderDisplayObject(root);
|
|
80
83
|
}
|
|
81
84
|
|
|
85
|
+
/**
|
|
86
|
+
* TBD.
|
|
87
|
+
* @param removeView
|
|
88
|
+
*/
|
|
82
89
|
destroy(removeView = true) {
|
|
83
90
|
if (removeView && this.view.parent) {
|
|
84
91
|
this.view.parent.removeChild(this.view);
|
|
@@ -88,6 +95,11 @@ export class CanvasRenderer {
|
|
|
88
95
|
this.renderSession = null;
|
|
89
96
|
}
|
|
90
97
|
|
|
98
|
+
/**
|
|
99
|
+
* TBD.
|
|
100
|
+
* @param {number} width - TBD.
|
|
101
|
+
* @param {number} height - TBD.
|
|
102
|
+
*/
|
|
91
103
|
resize(width, height) {
|
|
92
104
|
this.width = width * this.resolution;
|
|
93
105
|
this.height = height * this.resolution;
|
|
@@ -98,17 +110,25 @@ export class CanvasRenderer {
|
|
|
98
110
|
this.view.style.height = this.height / this.resolution + 'px';
|
|
99
111
|
}
|
|
100
112
|
if (this.renderSession.smoothProperty) {
|
|
101
|
-
this.context[this.renderSession.smoothProperty] =
|
|
102
|
-
this.renderSession.scaleMode === SCALE_LINEAR;
|
|
113
|
+
this.context[this.renderSession.smoothProperty] = this.renderSession.scaleMode === SCALE_LINEAR;
|
|
103
114
|
}
|
|
104
115
|
}
|
|
105
116
|
|
|
117
|
+
/**
|
|
118
|
+
* TBD.
|
|
119
|
+
* @param displayObject
|
|
120
|
+
* @param context
|
|
121
|
+
* @param matrix - TBD.
|
|
122
|
+
*/
|
|
106
123
|
renderDisplayObject(displayObject, context, matrix) {
|
|
107
124
|
this.renderSession.context = context || this.context;
|
|
108
125
|
this.renderSession.resolution = this.resolution;
|
|
109
126
|
displayObject.renderCanvas(this.renderSession, matrix);
|
|
110
127
|
}
|
|
111
128
|
|
|
129
|
+
/**
|
|
130
|
+
* TBD.
|
|
131
|
+
*/
|
|
112
132
|
mapBlendModes() {
|
|
113
133
|
if (window.PhaserRegistry.blendModesCanvas) {
|
|
114
134
|
return;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
1
|
import { CanvasBuffer } from './buffer';
|
|
8
2
|
import { create, removeByCanvas } from './pool';
|
|
9
3
|
import { hex2rgb } from '../../util/math';
|
|
@@ -37,29 +31,9 @@ export function tintWithMultiply(texture, color, canvas) {
|
|
|
37
31
|
context.fillStyle = '#' + ('00000' + (color | 0).toString(16)).substr(-6);
|
|
38
32
|
context.fillRect(0, 0, crop.width, crop.height);
|
|
39
33
|
context.globalCompositeOperation = 'multiply';
|
|
40
|
-
context.drawImage(
|
|
41
|
-
texture.baseTexture.source,
|
|
42
|
-
crop.x,
|
|
43
|
-
crop.y,
|
|
44
|
-
crop.width,
|
|
45
|
-
crop.height,
|
|
46
|
-
0,
|
|
47
|
-
0,
|
|
48
|
-
crop.width,
|
|
49
|
-
crop.height
|
|
50
|
-
);
|
|
34
|
+
context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height);
|
|
51
35
|
context.globalCompositeOperation = 'destination-atop';
|
|
52
|
-
context.drawImage(
|
|
53
|
-
texture.baseTexture.source,
|
|
54
|
-
crop.x,
|
|
55
|
-
crop.y,
|
|
56
|
-
crop.width,
|
|
57
|
-
crop.height,
|
|
58
|
-
0,
|
|
59
|
-
0,
|
|
60
|
-
crop.width,
|
|
61
|
-
crop.height
|
|
62
|
-
);
|
|
36
|
+
context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height);
|
|
63
37
|
}
|
|
64
38
|
|
|
65
39
|
/**
|
|
@@ -74,17 +48,7 @@ export function tintWithPerPixel(texture, color, canvas) {
|
|
|
74
48
|
canvas.width = crop.width;
|
|
75
49
|
canvas.height = crop.height;
|
|
76
50
|
context.globalCompositeOperation = 'copy';
|
|
77
|
-
context.drawImage(
|
|
78
|
-
texture.baseTexture.source,
|
|
79
|
-
crop.x,
|
|
80
|
-
crop.y,
|
|
81
|
-
crop.width,
|
|
82
|
-
crop.height,
|
|
83
|
-
0,
|
|
84
|
-
0,
|
|
85
|
-
crop.width,
|
|
86
|
-
crop.height
|
|
87
|
-
);
|
|
51
|
+
context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height);
|
|
88
52
|
const rgbValues = hex2rgb(color);
|
|
89
53
|
const r = rgbValues[0];
|
|
90
54
|
const g = rgbValues[1];
|
|
@@ -126,10 +90,7 @@ export function checkInverseAlpha() {
|
|
|
126
90
|
const s2 = canvas.context.getImageData(1, 0, 1, 1);
|
|
127
91
|
// Compare and return
|
|
128
92
|
return (
|
|
129
|
-
s2.data[0] === s1.data[0] &&
|
|
130
|
-
s2.data[1] === s1.data[1] &&
|
|
131
|
-
s2.data[2] === s1.data[2] &&
|
|
132
|
-
s2.data[3] === s1.data[3]
|
|
93
|
+
s2.data[0] === s1.data[0] && s2.data[1] === s1.data[1] && s2.data[2] === s1.data[2] && s2.data[3] === s1.data[3]
|
|
133
94
|
);
|
|
134
95
|
}
|
|
135
96
|
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
1
|
import { create as createCanvas } from './pool';
|
|
8
2
|
|
|
9
3
|
/**
|