@vpmedia/phaser 1.112.0 → 1.113.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1261 -1314
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +14 -10
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +10 -8
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +5 -4
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +4 -3
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/const.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +3 -2
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +1 -1
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +8 -6
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +40 -30
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +3 -2
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +3 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +6 -4
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +3 -2
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +4 -3
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +9 -8
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts +3 -2
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/registry.d.ts +7 -0
- package/dist/phaser/core/registry.d.ts.map +1 -0
- package/dist/phaser/core/scale_manager.d.ts +1 -1
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +0 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +1 -1
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts +0 -1
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts +4 -3
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +6 -4
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +3 -2
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +5 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +3 -2
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +1 -1
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +1 -1
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +10 -7
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +3 -2
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_easing.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +3 -2
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts +3 -2
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +3 -2
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +3 -2
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/graphics.d.ts +7 -6
- package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts +2 -2
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +10 -8
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts +3 -2
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts +2 -2
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +14 -12
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +8 -5
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +4 -3
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +13 -10
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_batch.d.ts +3 -2
- package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +18 -15
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +11 -9
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +0 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +4 -3
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +7 -6
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +4 -2
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +16 -11
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +16 -6
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +19 -7
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +33 -12
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +15 -6
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +15 -6
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +16 -11
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +29 -20
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +12 -10
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +3 -2
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts +4 -1
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts +1 -1
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/point.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts +3 -2
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts +2 -2
- package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/phaser/core/animation.ts +64 -60
- package/src/phaser/core/animation_manager.ts +50 -53
- package/src/phaser/core/animation_parser.ts +9 -9
- package/src/phaser/core/array_set.ts +16 -17
- package/src/phaser/core/cache.ts +92 -93
- package/src/phaser/core/const.ts +1 -1
- package/src/phaser/core/device.ts +24 -29
- package/src/phaser/core/device_util.ts +22 -26
- package/src/phaser/core/dom.ts +54 -65
- package/src/phaser/core/event_manager.ts +64 -94
- package/src/phaser/core/factory.ts +14 -14
- package/src/phaser/core/frame.ts +28 -28
- package/src/phaser/core/frame_data.test.ts +100 -0
- package/src/phaser/core/frame_data.ts +24 -24
- package/src/phaser/core/frame_util.ts +2 -2
- package/src/phaser/core/game.ts +47 -48
- package/src/phaser/core/input.ts +104 -110
- package/src/phaser/core/input_handler.test.ts +113 -0
- package/src/phaser/core/input_handler.ts +199 -218
- package/src/phaser/core/input_mouse.ts +71 -54
- package/src/phaser/core/input_mspointer.ts +52 -39
- package/src/phaser/core/input_pointer.ts +81 -80
- package/src/phaser/core/input_touch.ts +49 -36
- package/src/phaser/core/loader.ts +173 -152
- package/src/phaser/core/loader_parser.ts +39 -57
- package/src/phaser/core/raf.ts +8 -7
- package/src/phaser/core/registry.test.ts +31 -0
- package/src/phaser/core/registry.ts +9 -0
- package/src/phaser/core/scale_manager.ts +156 -152
- package/src/phaser/core/scene.ts +9 -13
- package/src/phaser/core/scene_manager.ts +47 -47
- package/src/phaser/core/signal.test.ts +4 -4
- package/src/phaser/core/signal.ts +41 -52
- package/src/phaser/core/signal_binding.ts +26 -25
- package/src/phaser/core/signal_dispatch.test.ts +180 -0
- package/src/phaser/core/sound.ts +75 -83
- package/src/phaser/core/sound_manager.ts +52 -51
- package/src/phaser/core/sound_sprite.ts +17 -16
- package/src/phaser/core/stage.ts +25 -24
- package/src/phaser/core/time.ts +52 -52
- package/src/phaser/core/timer.test.ts +187 -0
- package/src/phaser/core/timer.ts +82 -69
- package/src/phaser/core/timer_event.ts +10 -10
- package/src/phaser/core/tween.ts +90 -93
- package/src/phaser/core/tween_data.ts +45 -51
- package/src/phaser/core/tween_easing.test.ts +106 -0
- package/src/phaser/core/tween_easing.ts +151 -123
- package/src/phaser/core/tween_manager.ts +19 -18
- package/src/phaser/core/world.ts +4 -3
- package/src/phaser/display/bitmap_text.ts +56 -64
- package/src/phaser/display/button.ts +33 -32
- package/src/phaser/display/canvas/buffer.ts +8 -8
- package/src/phaser/display/canvas/graphics.ts +36 -37
- package/src/phaser/display/canvas/masker.ts +2 -2
- package/src/phaser/display/canvas/pool.test.ts +106 -0
- package/src/phaser/display/canvas/pool.ts +25 -27
- package/src/phaser/display/canvas/renderer.ts +32 -31
- package/src/phaser/display/canvas/tinter.ts +25 -25
- package/src/phaser/display/canvas/util.ts +7 -10
- package/src/phaser/display/display_object.ts +114 -118
- package/src/phaser/display/graphics.ts +121 -119
- package/src/phaser/display/graphics_data.ts +12 -12
- package/src/phaser/display/graphics_data_util.ts +2 -3
- package/src/phaser/display/group.ts +50 -57
- package/src/phaser/display/image.ts +55 -52
- package/src/phaser/display/sprite_batch.ts +3 -2
- package/src/phaser/display/sprite_util.ts +48 -54
- package/src/phaser/display/text.ts +199 -204
- package/src/phaser/display/webgl/abstract_filter.ts +9 -9
- package/src/phaser/display/webgl/base_texture.ts +21 -24
- package/src/phaser/display/webgl/blend_manager.ts +6 -10
- package/src/phaser/display/webgl/earcut.ts +73 -37
- package/src/phaser/display/webgl/earcut_node.ts +10 -10
- package/src/phaser/display/webgl/fast_sprite_batch.ts +34 -34
- package/src/phaser/display/webgl/filter_manager.ts +13 -12
- package/src/phaser/display/webgl/filter_texture.ts +14 -13
- package/src/phaser/display/webgl/graphics.ts +51 -57
- package/src/phaser/display/webgl/graphics_data.ts +15 -14
- package/src/phaser/display/webgl/mask_manager.ts +2 -2
- package/src/phaser/display/webgl/render_texture.ts +26 -25
- package/src/phaser/display/webgl/renderer.ts +57 -62
- package/src/phaser/display/webgl/shader/complex.ts +28 -12
- package/src/phaser/display/webgl/shader/fast.ts +30 -12
- package/src/phaser/display/webgl/shader/normal.ts +70 -57
- package/src/phaser/display/webgl/shader/primitive.ts +26 -11
- package/src/phaser/display/webgl/shader/shader.test.ts +148 -0
- package/src/phaser/display/webgl/shader/strip.ts +27 -12
- package/src/phaser/display/webgl/shader_manager.test.ts +124 -0
- package/src/phaser/display/webgl/shader_manager.ts +26 -34
- package/src/phaser/display/webgl/sprite_batch.ts +67 -61
- package/src/phaser/display/webgl/stencil_manager.ts +23 -34
- package/src/phaser/display/webgl/texture.ts +43 -50
- package/src/phaser/display/webgl/texture_util.ts +2 -3
- package/src/phaser/display/webgl/util.ts +26 -25
- package/src/phaser/geom/circle.test.ts +2 -3
- package/src/phaser/geom/circle.ts +36 -36
- package/src/phaser/geom/ellipse.test.ts +73 -71
- package/src/phaser/geom/ellipse.ts +14 -14
- package/src/phaser/geom/line.test.ts +5 -5
- package/src/phaser/geom/line.ts +35 -35
- package/src/phaser/geom/matrix.test.ts +1 -1
- package/src/phaser/geom/matrix.ts +27 -27
- package/src/phaser/geom/point.test.ts +1 -2
- package/src/phaser/geom/point.ts +35 -35
- package/src/phaser/geom/polygon.test.ts +82 -0
- package/src/phaser/geom/polygon.ts +16 -16
- package/src/phaser/geom/rectangle.test.ts +14 -14
- package/src/phaser/geom/rectangle.ts +83 -75
- package/src/phaser/geom/rounded_rectangle.test.ts +1 -7
- package/src/phaser/geom/rounded_rectangle.ts +9 -9
- package/src/phaser/geom/util/circle.test.ts +25 -23
- package/src/phaser/geom/util/circle.ts +9 -18
- package/src/phaser/geom/util/ellipse.test.ts +7 -5
- package/src/phaser/geom/util/ellipse.ts +3 -2
- package/src/phaser/geom/util/line.test.ts +10 -8
- package/src/phaser/geom/util/line.ts +6 -16
- package/src/phaser/geom/util/matrix.test.ts +20 -18
- package/src/phaser/geom/util/matrix.ts +8 -15
- package/src/phaser/geom/util/point.test.ts +8 -6
- package/src/phaser/geom/util/point.ts +24 -28
- package/src/phaser/geom/util/polygon.test.ts +12 -10
- package/src/phaser/geom/util/polygon.ts +2 -2
- package/src/phaser/geom/util/rectangle.test.ts +10 -8
- package/src/phaser/geom/util/rectangle.ts +18 -37
- package/src/phaser/geom/util/rounded_rectangle.test.ts +11 -9
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
- package/src/phaser/util/math.test.ts +11 -11
- package/src/phaser/util/math.ts +29 -46
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TEXT } from '../core/const.js';
|
|
2
|
+
import { ENGINE_ERROR_CREATING_CANVAS_2D_CONTEXT } from '../core/error_code.js';
|
|
2
3
|
import { Point } from '../geom/point.js';
|
|
3
4
|
import { Rectangle } from '../geom/rectangle.js';
|
|
4
5
|
import { snapToCeil } from '../util/math.js';
|
|
@@ -6,37 +7,39 @@ import { create, remove } from './canvas/pool.js';
|
|
|
6
7
|
import { Image } from './image.js';
|
|
7
8
|
import { getBounds, renderCanvas, renderWebGL } from './sprite_util.js';
|
|
8
9
|
import { textureFromCanvas } from './webgl/texture_util.js';
|
|
10
|
+
import type { Game } from '../core/game.js';
|
|
11
|
+
import type { Matrix } from '../geom/matrix.js';
|
|
9
12
|
|
|
10
13
|
export class Text extends Image {
|
|
11
|
-
declare type: number;
|
|
12
|
-
canvas!: any;
|
|
13
|
-
context!: any;
|
|
14
|
-
padding!: Point;
|
|
15
|
-
textBounds!: Rectangle | null;
|
|
16
|
-
style!: any;
|
|
17
|
-
colors!: any;
|
|
18
|
-
strokeColors!: any;
|
|
19
|
-
fontStyles!: any;
|
|
20
|
-
fontWeights!: any;
|
|
21
|
-
autoRound!: boolean;
|
|
22
|
-
useAdvancedWrap!: boolean;
|
|
23
|
-
_res!: number;
|
|
24
|
-
_text!: string;
|
|
25
|
-
_fontComponents!: any;
|
|
26
|
-
_lineSpacing!: number;
|
|
27
|
-
_charCount!: number;
|
|
28
|
-
declare _width: any;
|
|
29
|
-
declare _height: any;
|
|
30
|
-
dirty!: boolean;
|
|
14
|
+
declare public type: number;
|
|
15
|
+
public canvas!: any;
|
|
16
|
+
public context!: any;
|
|
17
|
+
public padding!: Point;
|
|
18
|
+
public textBounds!: Rectangle | null;
|
|
19
|
+
public style!: any;
|
|
20
|
+
public colors!: any;
|
|
21
|
+
public strokeColors!: any;
|
|
22
|
+
public fontStyles!: any;
|
|
23
|
+
public fontWeights!: any;
|
|
24
|
+
public autoRound!: boolean;
|
|
25
|
+
public useAdvancedWrap!: boolean;
|
|
26
|
+
public _res!: number;
|
|
27
|
+
public _text!: string;
|
|
28
|
+
public _fontComponents!: any;
|
|
29
|
+
public _lineSpacing!: number;
|
|
30
|
+
public _charCount!: number;
|
|
31
|
+
declare public _width: any;
|
|
32
|
+
declare public _height: any;
|
|
33
|
+
public dirty!: boolean;
|
|
31
34
|
/**
|
|
32
35
|
* Creates a new Text object.
|
|
33
|
-
* @param {
|
|
36
|
+
* @param {Game} game - The game instance this text belongs to.
|
|
34
37
|
* @param {number} x - The x position of the text.
|
|
35
38
|
* @param {number} y - The y position of the text.
|
|
36
39
|
* @param {string} text - The text content to display.
|
|
37
40
|
* @param {object} style - The style settings for the text.
|
|
38
41
|
*/
|
|
39
|
-
constructor(game:
|
|
42
|
+
public constructor(game: Game, x: number, y: number, text = '', style: any = {}) {
|
|
40
43
|
super(game, x, y, null);
|
|
41
44
|
this.game = game;
|
|
42
45
|
/** @type {number} */
|
|
@@ -57,7 +60,7 @@ export class Text extends Image {
|
|
|
57
60
|
this.autoRound = false;
|
|
58
61
|
this.useAdvancedWrap = false;
|
|
59
62
|
this._res = game.renderer.resolution;
|
|
60
|
-
this._text = text
|
|
63
|
+
this._text = text;
|
|
61
64
|
this._fontComponents = null;
|
|
62
65
|
/** @type {number} */
|
|
63
66
|
this._lineSpacing = 0;
|
|
@@ -77,7 +80,7 @@ export class Text extends Image {
|
|
|
77
80
|
/**
|
|
78
81
|
* Destroys this text object and cleans up resources.
|
|
79
82
|
*/
|
|
80
|
-
override destroy() {
|
|
83
|
+
public override destroy() {
|
|
81
84
|
this.texture.destroy(true);
|
|
82
85
|
remove(this);
|
|
83
86
|
this.canvas = null;
|
|
@@ -104,14 +107,7 @@ export class Text extends Image {
|
|
|
104
107
|
* @param {boolean} shadowFill - Whether to apply the shadow to the fill.
|
|
105
108
|
* @returns {Text} This Text object for chaining.
|
|
106
109
|
*/
|
|
107
|
-
setShadow(
|
|
108
|
-
x: number = 0,
|
|
109
|
-
y: number = 0,
|
|
110
|
-
color: string = 'rgba(0, 0, 0, 1)',
|
|
111
|
-
blur: number = 0,
|
|
112
|
-
shadowStroke: boolean = true,
|
|
113
|
-
shadowFill: boolean = true
|
|
114
|
-
) {
|
|
110
|
+
public setShadow(x = 0, y = 0, color = 'rgba(0, 0, 0, 1)', blur = 0, shadowStroke = true, shadowFill = true) {
|
|
115
111
|
this.style.shadowOffsetX = x;
|
|
116
112
|
this.style.shadowOffsetY = y;
|
|
117
113
|
this.style.shadowColor = color;
|
|
@@ -128,24 +124,24 @@ export class Text extends Image {
|
|
|
128
124
|
* @param {boolean} update - Whether to update the text immediately.
|
|
129
125
|
* @returns {Text} This Text object for chaining.
|
|
130
126
|
*/
|
|
131
|
-
setStyle(style: any | null = null, update
|
|
132
|
-
style =
|
|
133
|
-
style.font = style.font
|
|
134
|
-
style.backgroundColor = style.backgroundColor
|
|
135
|
-
style.fill = style.fill
|
|
136
|
-
style.align = style.align
|
|
137
|
-
style.boundsAlignH = style.boundsAlignH
|
|
138
|
-
style.boundsAlignV = style.boundsAlignV
|
|
139
|
-
style.stroke = style.stroke
|
|
140
|
-
style.strokeThickness = style.strokeThickness
|
|
141
|
-
style.wordWrap = style.wordWrap
|
|
142
|
-
style.wordWrapWidth = style.wordWrapWidth
|
|
143
|
-
style.maxLines = style.maxLines
|
|
144
|
-
style.shadowOffsetX = style.shadowOffsetX
|
|
145
|
-
style.shadowOffsetY = style.shadowOffsetY
|
|
146
|
-
style.shadowColor = style.shadowColor
|
|
147
|
-
style.shadowBlur = style.shadowBlur
|
|
148
|
-
style.tabs = style.tabs
|
|
127
|
+
public setStyle(style: any | null = null, update = false) {
|
|
128
|
+
style = structuredClone(style) ?? {};
|
|
129
|
+
style.font = style.font ?? 'bold 20pt Arial';
|
|
130
|
+
style.backgroundColor = style.backgroundColor ?? null;
|
|
131
|
+
style.fill = style.fill ?? 'black';
|
|
132
|
+
style.align = style.align ?? 'left';
|
|
133
|
+
style.boundsAlignH = style.boundsAlignH ?? 'left';
|
|
134
|
+
style.boundsAlignV = style.boundsAlignV ?? 'top';
|
|
135
|
+
style.stroke = style.stroke ?? 'black'; // provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
|
136
|
+
style.strokeThickness = style.strokeThickness ?? 0;
|
|
137
|
+
style.wordWrap = style.wordWrap ?? false;
|
|
138
|
+
style.wordWrapWidth = style.wordWrapWidth ?? 100;
|
|
139
|
+
style.maxLines = style.maxLines ?? 0;
|
|
140
|
+
style.shadowOffsetX = style.shadowOffsetX ?? 0;
|
|
141
|
+
style.shadowOffsetY = style.shadowOffsetY ?? 0;
|
|
142
|
+
style.shadowColor = style.shadowColor ?? 'rgba(0,0,0,0)';
|
|
143
|
+
style.shadowBlur = style.shadowBlur ?? 0;
|
|
144
|
+
style.tabs = style.tabs ?? 0;
|
|
149
145
|
const components = this.fontToComponents(style.font);
|
|
150
146
|
if (style.fontStyle) {
|
|
151
147
|
components.fontStyle = style.fontStyle;
|
|
@@ -175,7 +171,7 @@ export class Text extends Image {
|
|
|
175
171
|
/**
|
|
176
172
|
* Updates the text content and renders it to the canvas.
|
|
177
173
|
*/
|
|
178
|
-
updateText() {
|
|
174
|
+
public updateText() {
|
|
179
175
|
this.texture.baseTexture.resolution = this._res;
|
|
180
176
|
this.context.font = this.style.font;
|
|
181
177
|
let outputText: any = this.text;
|
|
@@ -185,7 +181,7 @@ export class Text extends Image {
|
|
|
185
181
|
// Split text into lines
|
|
186
182
|
const lines = outputText.split(/(?:\r\n|\r|\n)/);
|
|
187
183
|
// Calculate text width
|
|
188
|
-
const tabs = this.style
|
|
184
|
+
const { tabs } = this.style;
|
|
189
185
|
const lineWidths = [];
|
|
190
186
|
let lineWidth = 0;
|
|
191
187
|
let maxLineWidth = 0;
|
|
@@ -258,7 +254,7 @@ export class Text extends Image {
|
|
|
258
254
|
}
|
|
259
255
|
}
|
|
260
256
|
lineWidths[i] = Math.ceil(lineWidth);
|
|
261
|
-
maxLineWidth = Math.max(maxLineWidth, lineWidths[i]);
|
|
257
|
+
maxLineWidth = Math.max(maxLineWidth, lineWidths[i]!);
|
|
262
258
|
}
|
|
263
259
|
this.canvas.width = maxLineWidth * this._res;
|
|
264
260
|
// Calculate text height
|
|
@@ -297,9 +293,9 @@ export class Text extends Image {
|
|
|
297
293
|
linePositionY += lineSpacing * i;
|
|
298
294
|
}
|
|
299
295
|
if (this.style.align === 'right') {
|
|
300
|
-
linePositionX += maxLineWidth - lineWidths[i]
|
|
296
|
+
linePositionX += maxLineWidth - lineWidths[i]!;
|
|
301
297
|
} else if (this.style.align === 'center') {
|
|
302
|
-
linePositionX += (maxLineWidth - lineWidths[i]) / 2;
|
|
298
|
+
linePositionX += (maxLineWidth - lineWidths[i]!) / 2;
|
|
303
299
|
}
|
|
304
300
|
if (this.autoRound) {
|
|
305
301
|
linePositionX = Math.round(linePositionX);
|
|
@@ -342,9 +338,9 @@ export class Text extends Image {
|
|
|
342
338
|
* @param {number} y - The y position to start rendering from.
|
|
343
339
|
* @param {boolean} fill - True to fill the text, false to stroke it.
|
|
344
340
|
*/
|
|
345
|
-
renderTabLine(line: string, x: number, y: number, fill: boolean) {
|
|
341
|
+
public renderTabLine(line: string, x: number, y: number, fill: boolean) {
|
|
346
342
|
const text = line.split(/(?:\t)/);
|
|
347
|
-
const tabs = this.style
|
|
343
|
+
const { tabs } = this.style;
|
|
348
344
|
let snap = 0;
|
|
349
345
|
if (Array.isArray(tabs)) {
|
|
350
346
|
let tab = 0;
|
|
@@ -378,7 +374,7 @@ export class Text extends Image {
|
|
|
378
374
|
* Updates the shadow properties for this text.
|
|
379
375
|
* @param {string} state - The shadow state to update ('stroke' or 'fill').
|
|
380
376
|
*/
|
|
381
|
-
updateShadow(state: string) {
|
|
377
|
+
public updateShadow(state: string) {
|
|
382
378
|
if (state) {
|
|
383
379
|
this.context.shadowOffsetX = this.style.shadowOffsetX;
|
|
384
380
|
this.context.shadowOffsetY = this.style.shadowOffsetY;
|
|
@@ -397,10 +393,9 @@ export class Text extends Image {
|
|
|
397
393
|
* @param {string} line - The line of text to measure.
|
|
398
394
|
* @returns {number} The width of the line in pixels.
|
|
399
395
|
*/
|
|
400
|
-
measureLine(line: string) {
|
|
396
|
+
public measureLine(line: string) {
|
|
401
397
|
let lineLength = 0;
|
|
402
|
-
for (
|
|
403
|
-
const letter = line[i];
|
|
398
|
+
for (const letter of line) {
|
|
404
399
|
if (this.fontWeights.length > 0 || this.fontStyles.length > 0) {
|
|
405
400
|
const components = this.fontToComponents(this.context.font);
|
|
406
401
|
if (this.fontStyles[this._charCount]) {
|
|
@@ -435,9 +430,8 @@ export class Text extends Image {
|
|
|
435
430
|
* @param {number} x - The x position to start updating from.
|
|
436
431
|
* @param {number} y - The y position to start updating from.
|
|
437
432
|
*/
|
|
438
|
-
updateLine(line: string, x: number, y: number) {
|
|
439
|
-
for (
|
|
440
|
-
const letter = line[i];
|
|
433
|
+
public updateLine(line: string, x: number, y: number) {
|
|
434
|
+
for (const letter of line) {
|
|
441
435
|
if (this.fontWeights.length > 0 || this.fontStyles.length > 0) {
|
|
442
436
|
const components = this.fontToComponents(this.context.font);
|
|
443
437
|
if (this.fontStyles[this._charCount]) {
|
|
@@ -471,7 +465,7 @@ export class Text extends Image {
|
|
|
471
465
|
* Clears all color values from this text object.
|
|
472
466
|
* @returns {Text} This Text object for chaining.
|
|
473
467
|
*/
|
|
474
|
-
clearColors() {
|
|
468
|
+
public clearColors() {
|
|
475
469
|
this.colors = [];
|
|
476
470
|
this.strokeColors = [];
|
|
477
471
|
this.dirty = true;
|
|
@@ -482,7 +476,7 @@ export class Text extends Image {
|
|
|
482
476
|
* Clears all font style values from this text object.
|
|
483
477
|
* @returns {Text} This Text object for chaining.
|
|
484
478
|
*/
|
|
485
|
-
clearFontValues() {
|
|
479
|
+
public clearFontValues() {
|
|
486
480
|
this.fontStyles = [];
|
|
487
481
|
this.fontWeights = [];
|
|
488
482
|
this.dirty = true;
|
|
@@ -495,7 +489,7 @@ export class Text extends Image {
|
|
|
495
489
|
* @param {number} position - The character position to apply the color at.
|
|
496
490
|
* @returns {Text} This Text object for chaining.
|
|
497
491
|
*/
|
|
498
|
-
addColor(color: string, position: number) {
|
|
492
|
+
public addColor(color: string, position: number) {
|
|
499
493
|
this.colors[position] = color;
|
|
500
494
|
this.dirty = true;
|
|
501
495
|
return this;
|
|
@@ -507,7 +501,7 @@ export class Text extends Image {
|
|
|
507
501
|
* @param {number} position - The character position to apply the stroke color at.
|
|
508
502
|
* @returns {Text} This Text object for chaining.
|
|
509
503
|
*/
|
|
510
|
-
addStrokeColor(color: number, position: number) {
|
|
504
|
+
public addStrokeColor(color: number, position: number) {
|
|
511
505
|
this.strokeColors[position] = color;
|
|
512
506
|
this.dirty = true;
|
|
513
507
|
return this;
|
|
@@ -519,7 +513,7 @@ export class Text extends Image {
|
|
|
519
513
|
* @param {number} position - The character position to apply the font style at.
|
|
520
514
|
* @returns {Text} This Text object for chaining.
|
|
521
515
|
*/
|
|
522
|
-
addFontStyle(style: any, position: number) {
|
|
516
|
+
public addFontStyle(style: any, position: number) {
|
|
523
517
|
this.fontStyles[position] = style;
|
|
524
518
|
this.dirty = true;
|
|
525
519
|
return this;
|
|
@@ -531,7 +525,7 @@ export class Text extends Image {
|
|
|
531
525
|
* @param {number} position - The character position to apply the font weight at.
|
|
532
526
|
* @returns {Text} This Text object for chaining.
|
|
533
527
|
*/
|
|
534
|
-
addFontWeight(weight: number, position: number) {
|
|
528
|
+
public addFontWeight(weight: number, position: number) {
|
|
535
529
|
this.fontWeights[position] = weight;
|
|
536
530
|
this.dirty = true;
|
|
537
531
|
return this;
|
|
@@ -542,7 +536,7 @@ export class Text extends Image {
|
|
|
542
536
|
* @param {string} text - The text to precalculate word wrap for.
|
|
543
537
|
* @returns {string[]} The wrapped lines of text.
|
|
544
538
|
*/
|
|
545
|
-
precalculateWordWrap(text: string) {
|
|
539
|
+
public precalculateWordWrap(text: string) {
|
|
546
540
|
this.texture.baseTexture.resolution = this._res;
|
|
547
541
|
this.context.font = this.style.font;
|
|
548
542
|
const wrappedLines = this.runWordWrap(text);
|
|
@@ -554,7 +548,7 @@ export class Text extends Image {
|
|
|
554
548
|
* @param {string} text - The text to run word wrap on.
|
|
555
549
|
* @returns {string} The wrapped text.
|
|
556
550
|
*/
|
|
557
|
-
runWordWrap(text: any) {
|
|
551
|
+
public runWordWrap(text: any) {
|
|
558
552
|
if (this.useAdvancedWrap) {
|
|
559
553
|
return this.advancedWordWrap(text);
|
|
560
554
|
}
|
|
@@ -567,16 +561,16 @@ export class Text extends Image {
|
|
|
567
561
|
* @returns {string} The wrapped text.
|
|
568
562
|
* @throws {Error} If the wordWrapWidth setting is less than a single character.
|
|
569
563
|
*/
|
|
570
|
-
advancedWordWrap(text: string) {
|
|
571
|
-
const context = this
|
|
572
|
-
const wordWrapWidth = this.style
|
|
564
|
+
public advancedWordWrap(text: string) {
|
|
565
|
+
const { context } = this;
|
|
566
|
+
const { wordWrapWidth } = this.style;
|
|
573
567
|
let output = '';
|
|
574
568
|
// (1) condense whitespace
|
|
575
569
|
// (2) split into lines
|
|
576
570
|
const lines = text.replace(/ +/gi, ' ').split(/\r?\n/gi);
|
|
577
571
|
let linesCount = lines.length;
|
|
578
572
|
for (let i = 0; i < linesCount; i += 1) {
|
|
579
|
-
let line = lines[i]
|
|
573
|
+
let line = lines[i]!;
|
|
580
574
|
let out = '';
|
|
581
575
|
// trim whitespace
|
|
582
576
|
line = line.replace(/^ *|\s*$/gi, '');
|
|
@@ -599,7 +593,7 @@ export class Text extends Image {
|
|
|
599
593
|
if (j === 0) {
|
|
600
594
|
// shave off letters from word until it's small enough
|
|
601
595
|
let newWord = wordWithSpace;
|
|
602
|
-
while (newWord.length) {
|
|
596
|
+
while (newWord.length > 0) {
|
|
603
597
|
newWord = newWord.slice(0, -1);
|
|
604
598
|
wordWidth = context.measureText(newWord).width;
|
|
605
599
|
if (wordWidth <= currentLineWidth) {
|
|
@@ -608,17 +602,17 @@ export class Text extends Image {
|
|
|
608
602
|
}
|
|
609
603
|
// if wordWrapWidth is too small for even a single
|
|
610
604
|
// letter, shame user failure with a fatal error
|
|
611
|
-
if (
|
|
605
|
+
if (newWord.length === 0) {
|
|
612
606
|
throw new Error("This text's wordWrapWidth setting is less than a single character!");
|
|
613
607
|
}
|
|
614
608
|
// replace current word in array with remainder
|
|
615
|
-
const secondPart = word
|
|
609
|
+
const secondPart = word!.slice(newWord.length);
|
|
616
610
|
words[j] = secondPart;
|
|
617
611
|
// append first piece to output
|
|
618
612
|
out += newWord;
|
|
619
613
|
}
|
|
620
614
|
// if existing word length is 0, don't include it
|
|
621
|
-
const offset = words[j]
|
|
615
|
+
const offset = words[j]!.length > 0 ? j : j + 1;
|
|
622
616
|
// collapse rest of sentence
|
|
623
617
|
// remove any trailing white space
|
|
624
618
|
const remainder = words
|
|
@@ -626,7 +620,7 @@ export class Text extends Image {
|
|
|
626
620
|
.join(' ')
|
|
627
621
|
.replace(/[ \n]*$/gi, '');
|
|
628
622
|
// prepend remainder to next line
|
|
629
|
-
lines[i + 1] = `${remainder} ${lines[i + 1]
|
|
623
|
+
lines[i + 1] = `${remainder} ${lines[i + 1] ?? ''}`;
|
|
630
624
|
linesCount = lines.length;
|
|
631
625
|
break; // processing on this line
|
|
632
626
|
// append word with space to output
|
|
@@ -649,14 +643,14 @@ export class Text extends Image {
|
|
|
649
643
|
* @param {string} text - The text to run basic word wrap on.
|
|
650
644
|
* @returns {string} The wrapped text.
|
|
651
645
|
*/
|
|
652
|
-
basicWordWrap(text: string) {
|
|
646
|
+
public basicWordWrap(text: string) {
|
|
653
647
|
let result = '';
|
|
654
648
|
const lines = text.split('\n');
|
|
655
649
|
for (let i = 0; i < lines.length; i += 1) {
|
|
656
650
|
let spaceLeft = this.style.wordWrapWidth;
|
|
657
|
-
const words = lines[i]
|
|
651
|
+
const words = lines[i]!.split(' ');
|
|
658
652
|
for (let j = 0; j < words.length; j += 1) {
|
|
659
|
-
const wordWidth = this.context.measureText(words[j]).width;
|
|
653
|
+
const wordWidth = this.context.measureText(words[j]!).width;
|
|
660
654
|
const wordWidthWithSpace = wordWidth + this.context.measureText(' ').width;
|
|
661
655
|
if (wordWidthWithSpace > spaceLeft) {
|
|
662
656
|
// Skip printing the newline if it's the first word of the line that is greater than the word wrap width.
|
|
@@ -681,7 +675,7 @@ export class Text extends Image {
|
|
|
681
675
|
* Updates the font properties based on the given components.
|
|
682
676
|
* @param {object} components - The font components to update from.
|
|
683
677
|
*/
|
|
684
|
-
updateFont(components: any) {
|
|
678
|
+
public updateFont(components: any) {
|
|
685
679
|
const font = this.componentsToFont(components);
|
|
686
680
|
if (this.style.font !== font) {
|
|
687
681
|
this.style.font = font;
|
|
@@ -697,7 +691,7 @@ export class Text extends Image {
|
|
|
697
691
|
* @param {string} font - The font string to convert.
|
|
698
692
|
* @returns {{ font: string, fontStyle?: string, fontVariant?: string, fontWeight?: string, fontSize?: string, fontFamily?: string }} The font components.
|
|
699
693
|
*/
|
|
700
|
-
fontToComponents(font: string) {
|
|
694
|
+
public fontToComponents(font: string) {
|
|
701
695
|
// The format is specified in http://www.w3.org/TR/CSS2/fonts.html#font-shorthand:
|
|
702
696
|
// style - normal | italic | oblique | inherit
|
|
703
697
|
// variant - normal | small-caps | inherit
|
|
@@ -706,21 +700,22 @@ export class Text extends Image {
|
|
|
706
700
|
// larger | smaller
|
|
707
701
|
// {number} (em | ex | ch | rem | vh | vw | vmin | vmax | px | mm | cm | in | pt | pc | %)
|
|
708
702
|
// font-family - rest (but identifiers or quoted with comma separation)
|
|
709
|
-
const m =
|
|
710
|
-
/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s
|
|
711
|
-
|
|
703
|
+
const m =
|
|
704
|
+
/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/.exec(
|
|
705
|
+
font
|
|
706
|
+
);
|
|
712
707
|
if (m) {
|
|
713
|
-
let family = m[5]
|
|
708
|
+
let family = m[5]!.trim();
|
|
714
709
|
// If it looks like the value should be quoted, but isn't, then quote it.
|
|
715
|
-
if (!/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.
|
|
710
|
+
if (!/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.test(family) && !/['",]/.test(family)) {
|
|
716
711
|
family = `'${family}'`;
|
|
717
712
|
}
|
|
718
713
|
return {
|
|
719
714
|
font,
|
|
720
|
-
fontStyle: m[1]
|
|
721
|
-
fontVariant: m[2]
|
|
722
|
-
fontWeight: m[3]
|
|
723
|
-
fontSize: m[4]
|
|
715
|
+
fontStyle: m[1] ?? 'normal',
|
|
716
|
+
fontVariant: m[2] ?? 'normal',
|
|
717
|
+
fontWeight: m[3] ?? 'normal',
|
|
718
|
+
fontSize: m[4] ?? 'medium',
|
|
724
719
|
fontFamily: family,
|
|
725
720
|
};
|
|
726
721
|
}
|
|
@@ -733,7 +728,7 @@ export class Text extends Image {
|
|
|
733
728
|
* @param {object} components - The font components to convert.
|
|
734
729
|
* @returns {string} The font string.
|
|
735
730
|
*/
|
|
736
|
-
componentsToFont(components: any) {
|
|
731
|
+
public componentsToFont(components: any) {
|
|
737
732
|
const parts = [];
|
|
738
733
|
let v;
|
|
739
734
|
v = components.fontStyle;
|
|
@@ -756,7 +751,7 @@ export class Text extends Image {
|
|
|
756
751
|
if (v) {
|
|
757
752
|
parts.push(v);
|
|
758
753
|
}
|
|
759
|
-
if (
|
|
754
|
+
if (parts.length === 0) {
|
|
760
755
|
// Fallback to whatever value the 'font' was
|
|
761
756
|
parts.push(components.font);
|
|
762
757
|
}
|
|
@@ -769,8 +764,8 @@ export class Text extends Image {
|
|
|
769
764
|
* @param {boolean} immediate - If true, updates the text immediately.
|
|
770
765
|
* @returns {Text} This Text object for chaining.
|
|
771
766
|
*/
|
|
772
|
-
setText(text: any, immediate
|
|
773
|
-
this.text = text.toString()
|
|
767
|
+
public setText(text: any, immediate = false) {
|
|
768
|
+
this.text = text.toString() ?? '';
|
|
774
769
|
if (immediate) {
|
|
775
770
|
this.updateText();
|
|
776
771
|
} else {
|
|
@@ -784,7 +779,7 @@ export class Text extends Image {
|
|
|
784
779
|
* @param {string[]|string[][]} list - The list of text to parse.
|
|
785
780
|
* @returns {Text} This Text object for chaining.
|
|
786
781
|
*/
|
|
787
|
-
parseList(list: any) {
|
|
782
|
+
public parseList(list: any) {
|
|
788
783
|
if (!Array.isArray(list)) {
|
|
789
784
|
return this;
|
|
790
785
|
}
|
|
@@ -815,7 +810,7 @@ export class Text extends Image {
|
|
|
815
810
|
* @param {number} height - The height of the bounds.
|
|
816
811
|
* @returns {Text} This Text object for chaining.
|
|
817
812
|
*/
|
|
818
|
-
setTextBounds(x: number, y: number, width: number, height: number) {
|
|
813
|
+
public setTextBounds(x: number, y: number, width: number, height: number) {
|
|
819
814
|
if (x === undefined) {
|
|
820
815
|
this.textBounds = null;
|
|
821
816
|
} else {
|
|
@@ -835,10 +830,10 @@ export class Text extends Image {
|
|
|
835
830
|
/**
|
|
836
831
|
* Updates the texture of this object.
|
|
837
832
|
*/
|
|
838
|
-
updateTexture() {
|
|
833
|
+
public updateTexture() {
|
|
839
834
|
const base = this.texture.baseTexture;
|
|
840
|
-
const crop = this.texture
|
|
841
|
-
const frame = this.texture
|
|
835
|
+
const { crop } = this.texture;
|
|
836
|
+
const { frame } = this.texture;
|
|
842
837
|
const w = this.canvas.width;
|
|
843
838
|
const h = this.canvas.height;
|
|
844
839
|
base.width = w;
|
|
@@ -852,8 +847,8 @@ export class Text extends Image {
|
|
|
852
847
|
this._width = w;
|
|
853
848
|
this._height = h;
|
|
854
849
|
if (this.textBounds) {
|
|
855
|
-
let x = this.textBounds
|
|
856
|
-
let y = this.textBounds
|
|
850
|
+
let { x } = this.textBounds;
|
|
851
|
+
let { y } = this.textBounds;
|
|
857
852
|
// Align the canvas based on the bounds
|
|
858
853
|
if (this.style.boundsAlignH === 'right') {
|
|
859
854
|
x += this.textBounds.width - this.canvas.width / this.resolution;
|
|
@@ -878,7 +873,7 @@ export class Text extends Image {
|
|
|
878
873
|
* Renders this text object using WebGL.
|
|
879
874
|
* @param {object} renderSession - The render session to use.
|
|
880
875
|
*/
|
|
881
|
-
override renderWebGL(renderSession: any) {
|
|
876
|
+
public override renderWebGL(renderSession: any) {
|
|
882
877
|
if (this.dirty) {
|
|
883
878
|
this.updateText();
|
|
884
879
|
this.dirty = false;
|
|
@@ -890,7 +885,7 @@ export class Text extends Image {
|
|
|
890
885
|
* Renders this text object using Canvas.
|
|
891
886
|
* @param {object} renderSession - The render session to use.
|
|
892
887
|
*/
|
|
893
|
-
override renderCanvas(renderSession: any) {
|
|
888
|
+
public override renderCanvas(renderSession: any) {
|
|
894
889
|
if (this.dirty) {
|
|
895
890
|
this.updateText();
|
|
896
891
|
this.dirty = false;
|
|
@@ -902,35 +897,34 @@ export class Text extends Image {
|
|
|
902
897
|
* Gets the font properties cache object.
|
|
903
898
|
* @returns {{[key: string]: {ascent: number, descent: number, fontSize: number}}} The font properties cache.
|
|
904
899
|
*/
|
|
905
|
-
getFontPropertiesCache() {
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
}
|
|
909
|
-
return window.PhaserRegistry.fontPropertiesCache;
|
|
900
|
+
public getFontPropertiesCache() {
|
|
901
|
+
globalThis.PhaserRegistry.fontPropertiesCache ??= {};
|
|
902
|
+
return globalThis.PhaserRegistry.fontPropertiesCache;
|
|
910
903
|
}
|
|
911
904
|
|
|
912
905
|
/**
|
|
913
906
|
* Gets the font properties canvas element.
|
|
914
907
|
* @returns {HTMLCanvasElement} The font properties canvas element.
|
|
915
908
|
*/
|
|
916
|
-
getFontPropertiesCanvas() {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
}
|
|
920
|
-
return window.PhaserRegistry.fontPropertiesCanvas;
|
|
909
|
+
public getFontPropertiesCanvas() {
|
|
910
|
+
globalThis.PhaserRegistry.fontPropertiesCanvas ??= document.createElement('canvas');
|
|
911
|
+
return globalThis.PhaserRegistry.fontPropertiesCanvas;
|
|
921
912
|
}
|
|
922
913
|
|
|
923
914
|
/**
|
|
924
915
|
* Gets the font properties canvas context.
|
|
925
916
|
* @returns {CanvasRenderingContext2D} The font properties canvas context.
|
|
926
917
|
*/
|
|
927
|
-
getFontPropertiesContext() {
|
|
928
|
-
if (!
|
|
918
|
+
public getFontPropertiesContext() {
|
|
919
|
+
if (!globalThis.PhaserRegistry.fontPropertiesContext) {
|
|
929
920
|
const canvas = this.getFontPropertiesCanvas();
|
|
930
921
|
const context = canvas.getContext('2d', { willReadFrequently: true });
|
|
931
|
-
|
|
922
|
+
if (!context) {
|
|
923
|
+
throw new Error(ENGINE_ERROR_CREATING_CANVAS_2D_CONTEXT);
|
|
924
|
+
}
|
|
925
|
+
globalThis.PhaserRegistry.fontPropertiesContext = context;
|
|
932
926
|
}
|
|
933
|
-
return
|
|
927
|
+
return globalThis.PhaserRegistry.fontPropertiesContext;
|
|
934
928
|
}
|
|
935
929
|
|
|
936
930
|
/**
|
|
@@ -938,11 +932,11 @@ export class Text extends Image {
|
|
|
938
932
|
* @param {string} font - The font to determine properties for.
|
|
939
933
|
* @returns {object} The font properties.
|
|
940
934
|
*/
|
|
941
|
-
determineFontProperties(font: string) {
|
|
935
|
+
public determineFontProperties(font: string) {
|
|
942
936
|
const fontPropertiesCache = this.getFontPropertiesCache();
|
|
943
|
-
|
|
944
|
-
if (
|
|
945
|
-
return
|
|
937
|
+
const cached = fontPropertiesCache[font];
|
|
938
|
+
if (cached) {
|
|
939
|
+
return cached;
|
|
946
940
|
}
|
|
947
941
|
const METRICS_STRING = '|ÉqÅ';
|
|
948
942
|
const BASELINE_SYMBOL = 'M';
|
|
@@ -950,7 +944,7 @@ export class Text extends Image {
|
|
|
950
944
|
const context = this.getFontPropertiesContext();
|
|
951
945
|
context.font = font;
|
|
952
946
|
const metrics = context.measureText(METRICS_STRING + BASELINE_SYMBOL);
|
|
953
|
-
properties = {
|
|
947
|
+
const properties: FontProperties = {
|
|
954
948
|
ascent: Math.ceil(metrics.actualBoundingBoxAscent),
|
|
955
949
|
descent: Math.ceil(metrics.actualBoundingBoxDescent),
|
|
956
950
|
fontSize: Math.ceil(metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent),
|
|
@@ -963,18 +957,17 @@ export class Text extends Image {
|
|
|
963
957
|
* @param {string} fontStyle - The font style to determine properties for.
|
|
964
958
|
* @returns {{ascent: number, descent: number, fontSize: number}} The font properties.
|
|
965
959
|
*/
|
|
966
|
-
determineFontPropertiesFallback(fontStyle: string) {
|
|
960
|
+
public determineFontPropertiesFallback(fontStyle: string) {
|
|
967
961
|
const fontPropertiesCache = this.getFontPropertiesCache();
|
|
968
|
-
|
|
969
|
-
if (!
|
|
970
|
-
properties = {};
|
|
962
|
+
const cached = fontPropertiesCache[fontStyle];
|
|
963
|
+
if (!cached) {
|
|
971
964
|
const canvas = this.getFontPropertiesCanvas();
|
|
972
965
|
const context = this.getFontPropertiesContext();
|
|
973
966
|
context.font = fontStyle;
|
|
974
967
|
const width = Math.ceil(context.measureText('|MÉq').width);
|
|
975
968
|
let baseline = Math.ceil(context.measureText('|MÉq').width);
|
|
976
969
|
const height = 2 * baseline;
|
|
977
|
-
baseline = (baseline * 1.4)
|
|
970
|
+
baseline = Math.trunc(baseline * 1.4);
|
|
978
971
|
canvas.width = width;
|
|
979
972
|
canvas.height = height;
|
|
980
973
|
context.fillStyle = '#f00';
|
|
@@ -984,11 +977,13 @@ export class Text extends Image {
|
|
|
984
977
|
context.fillStyle = '#000';
|
|
985
978
|
context.fillText('|MÉq', 0, baseline);
|
|
986
979
|
if (!context.getImageData(0, 0, width, height)) {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
980
|
+
const fallback: FontProperties = {
|
|
981
|
+
ascent: baseline,
|
|
982
|
+
descent: baseline + 6,
|
|
983
|
+
fontSize: baseline + baseline + 6,
|
|
984
|
+
};
|
|
985
|
+
fontPropertiesCache[fontStyle] = fallback;
|
|
986
|
+
return fallback;
|
|
992
987
|
}
|
|
993
988
|
const imagedata = context.getImageData(0, 0, width, height).data;
|
|
994
989
|
const pixels = imagedata.length;
|
|
@@ -1001,7 +996,7 @@ export class Text extends Image {
|
|
|
1001
996
|
for (i = 0; i < baseline; i += 1) {
|
|
1002
997
|
for (j = 0; j < line; j += 4) {
|
|
1003
998
|
// firefox returns 253 for red pixel
|
|
1004
|
-
if (imagedata[idx + j] < 253) {
|
|
999
|
+
if (imagedata[idx + j]! < 253) {
|
|
1005
1000
|
stop = true;
|
|
1006
1001
|
break;
|
|
1007
1002
|
}
|
|
@@ -1012,14 +1007,14 @@ export class Text extends Image {
|
|
|
1012
1007
|
break;
|
|
1013
1008
|
}
|
|
1014
1009
|
}
|
|
1015
|
-
|
|
1010
|
+
const ascent = baseline - i;
|
|
1016
1011
|
idx = pixels - line;
|
|
1017
1012
|
stop = false;
|
|
1018
1013
|
// descent. scan from bottom to top until we find a non red pixel
|
|
1019
1014
|
for (i = height; i > baseline; i -= 1) {
|
|
1020
1015
|
for (j = 0; j < line; j += 4) {
|
|
1021
1016
|
// firefox returns 253 for red pixel
|
|
1022
|
-
if (imagedata[idx + j] < 253) {
|
|
1017
|
+
if (imagedata[idx + j]! < 253) {
|
|
1023
1018
|
stop = true;
|
|
1024
1019
|
break;
|
|
1025
1020
|
}
|
|
@@ -1030,21 +1025,21 @@ export class Text extends Image {
|
|
|
1030
1025
|
break;
|
|
1031
1026
|
}
|
|
1032
1027
|
}
|
|
1033
|
-
properties.descent = i - baseline;
|
|
1034
1028
|
// TODO might need a tweak. kind of a temp fix!
|
|
1035
|
-
|
|
1036
|
-
properties
|
|
1029
|
+
const descent = i - baseline + 6;
|
|
1030
|
+
const properties: FontProperties = { ascent, descent, fontSize: ascent + descent };
|
|
1037
1031
|
fontPropertiesCache[fontStyle] = properties;
|
|
1032
|
+
return properties;
|
|
1038
1033
|
}
|
|
1039
|
-
return
|
|
1034
|
+
return cached;
|
|
1040
1035
|
}
|
|
1041
1036
|
|
|
1042
1037
|
/**
|
|
1043
1038
|
* Gets the bounds of this text object.
|
|
1044
|
-
* @param {
|
|
1039
|
+
* @param {Matrix} matrix - The transformation matrix to use.
|
|
1045
1040
|
* @returns {Rectangle} The bounds of this text object.
|
|
1046
1041
|
*/
|
|
1047
|
-
override getBounds(matrix:
|
|
1042
|
+
public override getBounds(matrix: Matrix | null = null) {
|
|
1048
1043
|
if (this.dirty) {
|
|
1049
1044
|
this.updateText();
|
|
1050
1045
|
this.dirty = false;
|
|
@@ -1056,7 +1051,7 @@ export class Text extends Image {
|
|
|
1056
1051
|
* Gets the text content of this object.
|
|
1057
1052
|
* @returns {string} The current text content.
|
|
1058
1053
|
*/
|
|
1059
|
-
get text(): string {
|
|
1054
|
+
public get text(): string {
|
|
1060
1055
|
return this._text;
|
|
1061
1056
|
}
|
|
1062
1057
|
|
|
@@ -1064,7 +1059,7 @@ export class Text extends Image {
|
|
|
1064
1059
|
* Sets the text content of this object.
|
|
1065
1060
|
* @param {string | number | boolean | Date} value - The new text content to set.
|
|
1066
1061
|
*/
|
|
1067
|
-
set text(value: string | number) {
|
|
1062
|
+
public set text(value: string | number) {
|
|
1068
1063
|
if (value !== this._text) {
|
|
1069
1064
|
this._text = value.toString() || '';
|
|
1070
1065
|
this.dirty = true;
|
|
@@ -1078,7 +1073,7 @@ export class Text extends Image {
|
|
|
1078
1073
|
* Gets the CSS font string for this object.
|
|
1079
1074
|
* @returns {string} The CSS font string.
|
|
1080
1075
|
*/
|
|
1081
|
-
get cssFont() {
|
|
1076
|
+
public get cssFont() {
|
|
1082
1077
|
return this.componentsToFont(this._fontComponents);
|
|
1083
1078
|
}
|
|
1084
1079
|
|
|
@@ -1086,7 +1081,7 @@ export class Text extends Image {
|
|
|
1086
1081
|
* Sets the CSS font string for this object.
|
|
1087
1082
|
* @param {string} value - The new CSS font string to set.
|
|
1088
1083
|
*/
|
|
1089
|
-
set cssFont(value: string) {
|
|
1084
|
+
public set cssFont(value: string) {
|
|
1090
1085
|
this._fontComponents = this.fontToComponents(value || 'bold 20pt Arial');
|
|
1091
1086
|
this.updateFont(this._fontComponents);
|
|
1092
1087
|
}
|
|
@@ -1095,7 +1090,7 @@ export class Text extends Image {
|
|
|
1095
1090
|
* Gets the font family of this object.
|
|
1096
1091
|
* @returns {number} The font family.
|
|
1097
1092
|
*/
|
|
1098
|
-
get font() {
|
|
1093
|
+
public get font() {
|
|
1099
1094
|
return this._fontComponents.fontFamily;
|
|
1100
1095
|
}
|
|
1101
1096
|
|
|
@@ -1103,11 +1098,11 @@ export class Text extends Image {
|
|
|
1103
1098
|
* Sets the font family of this object.
|
|
1104
1099
|
* @param {string} value - The new font family to set.
|
|
1105
1100
|
*/
|
|
1106
|
-
set font(value: string) {
|
|
1101
|
+
public set font(value: string) {
|
|
1107
1102
|
let mutatedValue = value || 'Arial';
|
|
1108
1103
|
mutatedValue = mutatedValue.trim();
|
|
1109
1104
|
// If it looks like the value should be quoted, but isn't, then quote it.
|
|
1110
|
-
if (!/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.
|
|
1105
|
+
if (!/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.test(mutatedValue) && !/['",]/.test(mutatedValue)) {
|
|
1111
1106
|
mutatedValue = `'${mutatedValue}'`;
|
|
1112
1107
|
}
|
|
1113
1108
|
|
|
@@ -1119,10 +1114,10 @@ export class Text extends Image {
|
|
|
1119
1114
|
* Gets the font size of this object.
|
|
1120
1115
|
* @returns {number} The font size.
|
|
1121
1116
|
*/
|
|
1122
|
-
get fontSize() {
|
|
1117
|
+
public get fontSize() {
|
|
1123
1118
|
const size = this._fontComponents.fontSize;
|
|
1124
1119
|
if (size && /(?:^0$|px$)/.exec(size)) {
|
|
1125
|
-
return
|
|
1120
|
+
return Math.trunc(Number(size));
|
|
1126
1121
|
}
|
|
1127
1122
|
return size;
|
|
1128
1123
|
}
|
|
@@ -1131,7 +1126,7 @@ export class Text extends Image {
|
|
|
1131
1126
|
* Sets the font size of this object.
|
|
1132
1127
|
* @param {number} value - The new font size to set.
|
|
1133
1128
|
*/
|
|
1134
|
-
set fontSize(value: number) {
|
|
1129
|
+
public set fontSize(value: number) {
|
|
1135
1130
|
let mutatedValue: any = value || '0';
|
|
1136
1131
|
if (typeof mutatedValue === 'number') {
|
|
1137
1132
|
mutatedValue = `${mutatedValue}px`;
|
|
@@ -1144,15 +1139,15 @@ export class Text extends Image {
|
|
|
1144
1139
|
* Gets the font weight of this object.
|
|
1145
1140
|
* @returns {string} The font weight.
|
|
1146
1141
|
*/
|
|
1147
|
-
get fontWeight() {
|
|
1148
|
-
return this._fontComponents.fontWeight
|
|
1142
|
+
public get fontWeight() {
|
|
1143
|
+
return this._fontComponents.fontWeight ?? 'normal';
|
|
1149
1144
|
}
|
|
1150
1145
|
|
|
1151
1146
|
/**
|
|
1152
1147
|
* Sets the font weight of this object.
|
|
1153
1148
|
* @param {string} value - The new font weight to set.
|
|
1154
1149
|
*/
|
|
1155
|
-
set fontWeight(value: string) {
|
|
1150
|
+
public set fontWeight(value: string) {
|
|
1156
1151
|
this._fontComponents.fontWeight = value || 'normal';
|
|
1157
1152
|
this.updateFont(this._fontComponents);
|
|
1158
1153
|
}
|
|
@@ -1161,15 +1156,15 @@ export class Text extends Image {
|
|
|
1161
1156
|
* Gets the font style of this object.
|
|
1162
1157
|
* @returns {string} The font style.
|
|
1163
1158
|
*/
|
|
1164
|
-
get fontStyle() {
|
|
1165
|
-
return this._fontComponents.fontStyle
|
|
1159
|
+
public get fontStyle() {
|
|
1160
|
+
return this._fontComponents.fontStyle ?? 'normal';
|
|
1166
1161
|
}
|
|
1167
1162
|
|
|
1168
1163
|
/**
|
|
1169
1164
|
* Sets the font style of this object.
|
|
1170
1165
|
* @param {string} value - The new font style to set.
|
|
1171
1166
|
*/
|
|
1172
|
-
set fontStyle(value: string) {
|
|
1167
|
+
public set fontStyle(value: string) {
|
|
1173
1168
|
this._fontComponents.fontStyle = value || 'normal';
|
|
1174
1169
|
this.updateFont(this._fontComponents);
|
|
1175
1170
|
}
|
|
@@ -1178,15 +1173,15 @@ export class Text extends Image {
|
|
|
1178
1173
|
* Gets the font variant of this object.
|
|
1179
1174
|
* @returns {string} The font variant.
|
|
1180
1175
|
*/
|
|
1181
|
-
get fontVariant() {
|
|
1182
|
-
return this._fontComponents.fontVariant
|
|
1176
|
+
public get fontVariant() {
|
|
1177
|
+
return this._fontComponents.fontVariant ?? 'normal';
|
|
1183
1178
|
}
|
|
1184
1179
|
|
|
1185
1180
|
/**
|
|
1186
1181
|
* Sets the font variant of this object.
|
|
1187
1182
|
* @param {string} value - The new font variant to set.
|
|
1188
1183
|
*/
|
|
1189
|
-
set fontVariant(value: string) {
|
|
1184
|
+
public set fontVariant(value: string) {
|
|
1190
1185
|
this._fontComponents.fontVariant = value || 'normal';
|
|
1191
1186
|
this.updateFont(this._fontComponents);
|
|
1192
1187
|
}
|
|
@@ -1195,7 +1190,7 @@ export class Text extends Image {
|
|
|
1195
1190
|
* Gets the fill color of this object.
|
|
1196
1191
|
* @returns {number} The fill color.
|
|
1197
1192
|
*/
|
|
1198
|
-
get fill() {
|
|
1193
|
+
public get fill() {
|
|
1199
1194
|
return this.style.fill;
|
|
1200
1195
|
}
|
|
1201
1196
|
|
|
@@ -1203,7 +1198,7 @@ export class Text extends Image {
|
|
|
1203
1198
|
* Sets the fill color of this object.
|
|
1204
1199
|
* @param {string} value - The new fill color to set.
|
|
1205
1200
|
*/
|
|
1206
|
-
set fill(value: string) {
|
|
1201
|
+
public set fill(value: string) {
|
|
1207
1202
|
if (value !== this.style.fill) {
|
|
1208
1203
|
this.style.fill = value;
|
|
1209
1204
|
this.dirty = true;
|
|
@@ -1214,7 +1209,7 @@ export class Text extends Image {
|
|
|
1214
1209
|
* Gets the alignment of this object.
|
|
1215
1210
|
* @returns {string} The text alignment.
|
|
1216
1211
|
*/
|
|
1217
|
-
get align() {
|
|
1212
|
+
public get align() {
|
|
1218
1213
|
return this.style.align;
|
|
1219
1214
|
}
|
|
1220
1215
|
|
|
@@ -1222,7 +1217,7 @@ export class Text extends Image {
|
|
|
1222
1217
|
* Sets the alignment of this object.
|
|
1223
1218
|
* @param {string} value - The new text alignment to set.
|
|
1224
1219
|
*/
|
|
1225
|
-
set align(value: string) {
|
|
1220
|
+
public set align(value: string) {
|
|
1226
1221
|
if (value !== this.style.align) {
|
|
1227
1222
|
this.style.align = value;
|
|
1228
1223
|
this.dirty = true;
|
|
@@ -1233,7 +1228,7 @@ export class Text extends Image {
|
|
|
1233
1228
|
* Gets the resolution of this object.
|
|
1234
1229
|
* @returns {number} The resolution.
|
|
1235
1230
|
*/
|
|
1236
|
-
get resolution() {
|
|
1231
|
+
public get resolution() {
|
|
1237
1232
|
return this._res;
|
|
1238
1233
|
}
|
|
1239
1234
|
|
|
@@ -1241,7 +1236,7 @@ export class Text extends Image {
|
|
|
1241
1236
|
* Sets the resolution of this object.
|
|
1242
1237
|
* @param {number} value - The new resolution to set.
|
|
1243
1238
|
*/
|
|
1244
|
-
set resolution(value: number) {
|
|
1239
|
+
public set resolution(value: number) {
|
|
1245
1240
|
if (value !== this._res) {
|
|
1246
1241
|
this._res = value;
|
|
1247
1242
|
this.dirty = true;
|
|
@@ -1252,7 +1247,7 @@ export class Text extends Image {
|
|
|
1252
1247
|
* Gets the tabs setting of this object.
|
|
1253
1248
|
* @returns {number} The tabs setting.
|
|
1254
1249
|
*/
|
|
1255
|
-
get tabs() {
|
|
1250
|
+
public get tabs() {
|
|
1256
1251
|
return this.style.tabs;
|
|
1257
1252
|
}
|
|
1258
1253
|
|
|
@@ -1260,7 +1255,7 @@ export class Text extends Image {
|
|
|
1260
1255
|
* Sets the tabs setting of this object.
|
|
1261
1256
|
* @param {number} value - The new tabs setting to set.
|
|
1262
1257
|
*/
|
|
1263
|
-
set tabs(value: number) {
|
|
1258
|
+
public set tabs(value: number) {
|
|
1264
1259
|
if (value !== this.style.tabs) {
|
|
1265
1260
|
this.style.tabs = value;
|
|
1266
1261
|
this.dirty = true;
|
|
@@ -1271,7 +1266,7 @@ export class Text extends Image {
|
|
|
1271
1266
|
* Gets the horizontal bounds alignment of this object.
|
|
1272
1267
|
* @returns {number} The horizontal bounds alignment.
|
|
1273
1268
|
*/
|
|
1274
|
-
get boundsAlignH() {
|
|
1269
|
+
public get boundsAlignH() {
|
|
1275
1270
|
return this.style.boundsAlignH;
|
|
1276
1271
|
}
|
|
1277
1272
|
|
|
@@ -1279,7 +1274,7 @@ export class Text extends Image {
|
|
|
1279
1274
|
* Sets the horizontal bounds alignment of this object.
|
|
1280
1275
|
* @param {number} value - The new horizontal bounds alignment to set.
|
|
1281
1276
|
*/
|
|
1282
|
-
set boundsAlignH(value: number) {
|
|
1277
|
+
public set boundsAlignH(value: number) {
|
|
1283
1278
|
if (value !== this.style.boundsAlignH) {
|
|
1284
1279
|
this.style.boundsAlignH = value;
|
|
1285
1280
|
this.dirty = true;
|
|
@@ -1290,7 +1285,7 @@ export class Text extends Image {
|
|
|
1290
1285
|
* Gets the vertical bounds alignment of this object.
|
|
1291
1286
|
* @returns {number} The vertical bounds alignment.
|
|
1292
1287
|
*/
|
|
1293
|
-
get boundsAlignV() {
|
|
1288
|
+
public get boundsAlignV() {
|
|
1294
1289
|
return this.style.boundsAlignV;
|
|
1295
1290
|
}
|
|
1296
1291
|
|
|
@@ -1298,7 +1293,7 @@ export class Text extends Image {
|
|
|
1298
1293
|
* Sets the vertical bounds alignment of this object.
|
|
1299
1294
|
* @param {number} value - The new vertical bounds alignment to set.
|
|
1300
1295
|
*/
|
|
1301
|
-
set boundsAlignV(value: number) {
|
|
1296
|
+
public set boundsAlignV(value: number) {
|
|
1302
1297
|
if (value !== this.style.boundsAlignV) {
|
|
1303
1298
|
this.style.boundsAlignV = value;
|
|
1304
1299
|
this.dirty = true;
|
|
@@ -1309,7 +1304,7 @@ export class Text extends Image {
|
|
|
1309
1304
|
* Gets the stroke color of this object.
|
|
1310
1305
|
* @returns {number} The stroke color.
|
|
1311
1306
|
*/
|
|
1312
|
-
get stroke() {
|
|
1307
|
+
public get stroke() {
|
|
1313
1308
|
return this.style.stroke;
|
|
1314
1309
|
}
|
|
1315
1310
|
|
|
@@ -1317,7 +1312,7 @@ export class Text extends Image {
|
|
|
1317
1312
|
* Sets the stroke color of this object.
|
|
1318
1313
|
* @param {string} value - The new stroke color to set.
|
|
1319
1314
|
*/
|
|
1320
|
-
set stroke(value: string) {
|
|
1315
|
+
public set stroke(value: string) {
|
|
1321
1316
|
if (value !== this.style.stroke) {
|
|
1322
1317
|
this.style.stroke = value;
|
|
1323
1318
|
this.dirty = true;
|
|
@@ -1328,7 +1323,7 @@ export class Text extends Image {
|
|
|
1328
1323
|
* Gets the stroke thickness of this object.
|
|
1329
1324
|
* @returns {number} The stroke thickness.
|
|
1330
1325
|
*/
|
|
1331
|
-
get strokeThickness() {
|
|
1326
|
+
public get strokeThickness() {
|
|
1332
1327
|
return this.style.strokeThickness;
|
|
1333
1328
|
}
|
|
1334
1329
|
|
|
@@ -1336,7 +1331,7 @@ export class Text extends Image {
|
|
|
1336
1331
|
* Sets the stroke thickness of this object.
|
|
1337
1332
|
* @param {number} value - The new stroke thickness to set.
|
|
1338
1333
|
*/
|
|
1339
|
-
set strokeThickness(value: number) {
|
|
1334
|
+
public set strokeThickness(value: number) {
|
|
1340
1335
|
if (value !== this.style.strokeThickness) {
|
|
1341
1336
|
this.style.strokeThickness = value;
|
|
1342
1337
|
this.dirty = true;
|
|
@@ -1347,7 +1342,7 @@ export class Text extends Image {
|
|
|
1347
1342
|
* Gets the word wrap setting of this object.
|
|
1348
1343
|
* @returns {number} The word wrap setting.
|
|
1349
1344
|
*/
|
|
1350
|
-
get wordWrap() {
|
|
1345
|
+
public get wordWrap() {
|
|
1351
1346
|
return this.style.wordWrap;
|
|
1352
1347
|
}
|
|
1353
1348
|
|
|
@@ -1355,7 +1350,7 @@ export class Text extends Image {
|
|
|
1355
1350
|
* Sets the word wrap setting of this object.
|
|
1356
1351
|
* @param {boolean} value - The new word wrap setting to set.
|
|
1357
1352
|
*/
|
|
1358
|
-
set wordWrap(value: boolean) {
|
|
1353
|
+
public set wordWrap(value: boolean) {
|
|
1359
1354
|
if (value !== this.style.wordWrap) {
|
|
1360
1355
|
this.style.wordWrap = value;
|
|
1361
1356
|
this.dirty = true;
|
|
@@ -1366,7 +1361,7 @@ export class Text extends Image {
|
|
|
1366
1361
|
* Gets the word wrap width of this object.
|
|
1367
1362
|
* @returns {number} The word wrap width.
|
|
1368
1363
|
*/
|
|
1369
|
-
get wordWrapWidth() {
|
|
1364
|
+
public get wordWrapWidth() {
|
|
1370
1365
|
return this.style.wordWrapWidth;
|
|
1371
1366
|
}
|
|
1372
1367
|
|
|
@@ -1374,7 +1369,7 @@ export class Text extends Image {
|
|
|
1374
1369
|
* Sets the word wrap width of this object.
|
|
1375
1370
|
* @param {number} value - The new word wrap width to set.
|
|
1376
1371
|
*/
|
|
1377
|
-
set wordWrapWidth(value: number) {
|
|
1372
|
+
public set wordWrapWidth(value: number) {
|
|
1378
1373
|
if (value !== this.style.wordWrapWidth) {
|
|
1379
1374
|
this.style.wordWrapWidth = value;
|
|
1380
1375
|
this.dirty = true;
|
|
@@ -1385,7 +1380,7 @@ export class Text extends Image {
|
|
|
1385
1380
|
* Gets the line spacing of this object.
|
|
1386
1381
|
* @returns {number} The line spacing.
|
|
1387
1382
|
*/
|
|
1388
|
-
get lineSpacing() {
|
|
1383
|
+
public get lineSpacing() {
|
|
1389
1384
|
return this._lineSpacing;
|
|
1390
1385
|
}
|
|
1391
1386
|
|
|
@@ -1393,9 +1388,9 @@ export class Text extends Image {
|
|
|
1393
1388
|
* Sets the line spacing of this object.
|
|
1394
1389
|
* @param {number} value - The new line spacing to set.
|
|
1395
1390
|
*/
|
|
1396
|
-
set lineSpacing(value: any) {
|
|
1391
|
+
public set lineSpacing(value: any) {
|
|
1397
1392
|
if (value !== this._lineSpacing) {
|
|
1398
|
-
this._lineSpacing = Number
|
|
1393
|
+
this._lineSpacing = Number(value);
|
|
1399
1394
|
this.dirty = true;
|
|
1400
1395
|
if (this.parent) {
|
|
1401
1396
|
this.updateTransform();
|
|
@@ -1407,7 +1402,7 @@ export class Text extends Image {
|
|
|
1407
1402
|
* Gets the shadow offset X of this object.
|
|
1408
1403
|
* @returns {number} The shadow offset X.
|
|
1409
1404
|
*/
|
|
1410
|
-
get shadowOffsetX() {
|
|
1405
|
+
public get shadowOffsetX() {
|
|
1411
1406
|
return this.style.shadowOffsetX;
|
|
1412
1407
|
}
|
|
1413
1408
|
|
|
@@ -1415,7 +1410,7 @@ export class Text extends Image {
|
|
|
1415
1410
|
* Sets the shadow offset X of this object.
|
|
1416
1411
|
* @param {number} value - The new shadow offset X to set.
|
|
1417
1412
|
*/
|
|
1418
|
-
set shadowOffsetX(value: number) {
|
|
1413
|
+
public set shadowOffsetX(value: number) {
|
|
1419
1414
|
if (value !== this.style.shadowOffsetX) {
|
|
1420
1415
|
this.style.shadowOffsetX = value;
|
|
1421
1416
|
this.dirty = true;
|
|
@@ -1426,7 +1421,7 @@ export class Text extends Image {
|
|
|
1426
1421
|
* Gets the shadow offset Y of this object.
|
|
1427
1422
|
* @returns {number} The shadow offset Y.
|
|
1428
1423
|
*/
|
|
1429
|
-
get shadowOffsetY() {
|
|
1424
|
+
public get shadowOffsetY() {
|
|
1430
1425
|
return this.style.shadowOffsetY;
|
|
1431
1426
|
}
|
|
1432
1427
|
|
|
@@ -1434,7 +1429,7 @@ export class Text extends Image {
|
|
|
1434
1429
|
* Sets the shadow offset Y of this object.
|
|
1435
1430
|
* @param {number} value - The new shadow offset Y to set.
|
|
1436
1431
|
*/
|
|
1437
|
-
set shadowOffsetY(value: number) {
|
|
1432
|
+
public set shadowOffsetY(value: number) {
|
|
1438
1433
|
if (value !== this.style.shadowOffsetY) {
|
|
1439
1434
|
this.style.shadowOffsetY = value;
|
|
1440
1435
|
this.dirty = true;
|
|
@@ -1445,7 +1440,7 @@ export class Text extends Image {
|
|
|
1445
1440
|
* Gets the shadow color of this object.
|
|
1446
1441
|
* @returns {number} The shadow color.
|
|
1447
1442
|
*/
|
|
1448
|
-
get shadowColor() {
|
|
1443
|
+
public get shadowColor() {
|
|
1449
1444
|
return this.style.shadowColor;
|
|
1450
1445
|
}
|
|
1451
1446
|
|
|
@@ -1453,7 +1448,7 @@ export class Text extends Image {
|
|
|
1453
1448
|
* Sets the shadow color of this object.
|
|
1454
1449
|
* @param {string} value - The new shadow color to set.
|
|
1455
1450
|
*/
|
|
1456
|
-
set shadowColor(value: string) {
|
|
1451
|
+
public set shadowColor(value: string) {
|
|
1457
1452
|
if (value !== this.style.shadowColor) {
|
|
1458
1453
|
this.style.shadowColor = value;
|
|
1459
1454
|
this.dirty = true;
|
|
@@ -1464,7 +1459,7 @@ export class Text extends Image {
|
|
|
1464
1459
|
* Gets the shadow blur of this object.
|
|
1465
1460
|
* @returns {number} The shadow blur.
|
|
1466
1461
|
*/
|
|
1467
|
-
get shadowBlur() {
|
|
1462
|
+
public get shadowBlur() {
|
|
1468
1463
|
return this.style.shadowBlur;
|
|
1469
1464
|
}
|
|
1470
1465
|
|
|
@@ -1472,7 +1467,7 @@ export class Text extends Image {
|
|
|
1472
1467
|
* Sets the shadow blur of this object.
|
|
1473
1468
|
* @param {number} value - The new shadow blur to set.
|
|
1474
1469
|
*/
|
|
1475
|
-
set shadowBlur(value: number) {
|
|
1470
|
+
public set shadowBlur(value: number) {
|
|
1476
1471
|
if (value !== this.style.shadowBlur) {
|
|
1477
1472
|
this.style.shadowBlur = value;
|
|
1478
1473
|
this.dirty = true;
|
|
@@ -1483,7 +1478,7 @@ export class Text extends Image {
|
|
|
1483
1478
|
* Gets the shadow stroke setting of this object.
|
|
1484
1479
|
* @returns {number} The shadow stroke setting.
|
|
1485
1480
|
*/
|
|
1486
|
-
get shadowStroke() {
|
|
1481
|
+
public get shadowStroke() {
|
|
1487
1482
|
return this.style.shadowStroke;
|
|
1488
1483
|
}
|
|
1489
1484
|
|
|
@@ -1491,7 +1486,7 @@ export class Text extends Image {
|
|
|
1491
1486
|
* Sets the shadow stroke setting of this object.
|
|
1492
1487
|
* @param {boolean} value - The new shadow stroke setting to set.
|
|
1493
1488
|
*/
|
|
1494
|
-
set shadowStroke(value: boolean) {
|
|
1489
|
+
public set shadowStroke(value: boolean) {
|
|
1495
1490
|
if (value !== this.style.shadowStroke) {
|
|
1496
1491
|
this.style.shadowStroke = value;
|
|
1497
1492
|
this.dirty = true;
|
|
@@ -1502,7 +1497,7 @@ export class Text extends Image {
|
|
|
1502
1497
|
* Gets the shadow fill setting of this object.
|
|
1503
1498
|
* @returns {number} The shadow fill setting.
|
|
1504
1499
|
*/
|
|
1505
|
-
get shadowFill() {
|
|
1500
|
+
public get shadowFill() {
|
|
1506
1501
|
return this.style.shadowFill;
|
|
1507
1502
|
}
|
|
1508
1503
|
|
|
@@ -1510,7 +1505,7 @@ export class Text extends Image {
|
|
|
1510
1505
|
* Sets the shadow fill setting of this object.
|
|
1511
1506
|
* @param {boolean} value - The new shadow fill setting to set.
|
|
1512
1507
|
*/
|
|
1513
|
-
set shadowFill(value: boolean) {
|
|
1508
|
+
public set shadowFill(value: boolean) {
|
|
1514
1509
|
if (value !== this.style.shadowFill) {
|
|
1515
1510
|
this.style.shadowFill = value;
|
|
1516
1511
|
this.dirty = true;
|
|
@@ -1521,7 +1516,7 @@ export class Text extends Image {
|
|
|
1521
1516
|
* Gets the width of this object.
|
|
1522
1517
|
* @returns {number} The width in pixels.
|
|
1523
1518
|
*/
|
|
1524
|
-
override get width() {
|
|
1519
|
+
public override get width() {
|
|
1525
1520
|
if (this.dirty) {
|
|
1526
1521
|
this.updateText();
|
|
1527
1522
|
this.dirty = false;
|
|
@@ -1533,7 +1528,7 @@ export class Text extends Image {
|
|
|
1533
1528
|
* Sets the width of this object.
|
|
1534
1529
|
* @param {number} value - The new width to set in pixels.
|
|
1535
1530
|
*/
|
|
1536
|
-
override set width(value: number) {
|
|
1531
|
+
public override set width(value: number) {
|
|
1537
1532
|
this.scale.x = value / this.texture.frame.width;
|
|
1538
1533
|
this._width = value;
|
|
1539
1534
|
}
|
|
@@ -1542,7 +1537,7 @@ export class Text extends Image {
|
|
|
1542
1537
|
* Gets the height of this object.
|
|
1543
1538
|
* @returns {number} The height in pixels.
|
|
1544
1539
|
*/
|
|
1545
|
-
override get height() {
|
|
1540
|
+
public override get height() {
|
|
1546
1541
|
if (this.dirty) {
|
|
1547
1542
|
this.updateText();
|
|
1548
1543
|
this.dirty = false;
|
|
@@ -1554,7 +1549,7 @@ export class Text extends Image {
|
|
|
1554
1549
|
* Sets the height of this object.
|
|
1555
1550
|
* @param {number} value - The new height to set in pixels.
|
|
1556
1551
|
*/
|
|
1557
|
-
override set height(value: number) {
|
|
1552
|
+
public override set height(value: number) {
|
|
1558
1553
|
this.scale.y = value / this.texture.frame.height;
|
|
1559
1554
|
this._height = value;
|
|
1560
1555
|
}
|