@vpmedia/phaser 1.94.0 → 1.96.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/CHANGELOG.md +41 -0
- package/package.json +11 -11
- package/src/phaser/core/animation.js +79 -56
- package/src/phaser/core/animation_manager.js +55 -55
- package/src/phaser/core/animation_parser.js +2 -2
- package/src/phaser/core/cache.js +154 -154
- package/src/phaser/core/device.js +2 -1
- package/src/phaser/core/device_util.js +27 -27
- package/src/phaser/core/dom.js +43 -43
- package/src/phaser/core/event_manager.js +63 -63
- package/src/phaser/core/factory.js +47 -47
- package/src/phaser/core/frame.js +30 -30
- package/src/phaser/core/frame_data.js +30 -28
- package/src/phaser/core/frame_util.js +8 -8
- package/src/phaser/core/game.js +35 -19
- package/src/phaser/core/input_pointer.js +18 -0
- package/src/phaser/core/loader.js +171 -171
- package/src/phaser/core/loader_parser.js +22 -22
- package/src/phaser/core/raf.js +1 -1
- package/src/phaser/core/scale_manager.js +3 -2
- package/src/phaser/core/scene.js +16 -10
- package/src/phaser/core/scene_manager.js +51 -43
- package/src/phaser/core/signal.js +56 -52
- package/src/phaser/core/sound.js +54 -54
- package/src/phaser/core/sound_manager.js +49 -49
- package/src/phaser/core/stage.js +16 -16
- package/src/phaser/core/time.js +54 -30
- package/src/phaser/core/timer.js +82 -64
- package/src/phaser/core/timer_event.js +9 -9
- package/src/phaser/core/tween.js +106 -90
- package/src/phaser/core/tween_data.js +30 -30
- package/src/phaser/core/tween_manager.js +32 -24
- package/src/phaser/core/world.js +4 -3
- package/src/phaser/display/bitmap_text.js +72 -54
- package/src/phaser/display/button.js +48 -47
- package/src/phaser/display/canvas/buffer.js +8 -8
- package/src/phaser/display/canvas/graphics.js +8 -8
- package/src/phaser/display/canvas/masker.js +5 -5
- package/src/phaser/display/canvas/pool.js +18 -18
- package/src/phaser/display/canvas/renderer.js +17 -16
- package/src/phaser/display/canvas/tinter.js +22 -22
- package/src/phaser/display/canvas/util.js +42 -42
- package/src/phaser/display/display_object.js +119 -108
- package/src/phaser/display/graphics.js +129 -112
- package/src/phaser/display/graphics_data.js +10 -10
- package/src/phaser/display/graphics_data_util.js +3 -3
- package/src/phaser/display/group.js +63 -50
- package/src/phaser/display/image.js +68 -50
- package/src/phaser/display/sprite_batch.js +2 -2
- package/src/phaser/display/sprite_util.js +19 -19
- package/src/phaser/display/text.js +217 -187
- package/src/phaser/display/webgl/abstract_filter.js +4 -4
- package/src/phaser/display/webgl/base_texture.js +9 -9
- package/src/phaser/display/webgl/blend_manager.js +7 -7
- package/src/phaser/display/webgl/earcut.js +95 -95
- package/src/phaser/display/webgl/earcut_node.js +4 -4
- package/src/phaser/display/webgl/fast_sprite_batch.js +15 -15
- package/src/phaser/display/webgl/filter_manager.js +9 -9
- package/src/phaser/display/webgl/filter_texture.js +10 -10
- package/src/phaser/display/webgl/graphics.js +37 -37
- package/src/phaser/display/webgl/graphics_data.js +4 -4
- package/src/phaser/display/webgl/mask_manager.js +6 -6
- package/src/phaser/display/webgl/render_texture.js +16 -16
- package/src/phaser/display/webgl/renderer.js +21 -20
- package/src/phaser/display/webgl/shader/complex.js +4 -4
- package/src/phaser/display/webgl/shader/fast.js +4 -4
- package/src/phaser/display/webgl/shader/normal.js +8 -8
- package/src/phaser/display/webgl/shader/primitive.js +4 -4
- package/src/phaser/display/webgl/shader/strip.js +4 -4
- package/src/phaser/display/webgl/shader_manager.js +9 -9
- package/src/phaser/display/webgl/sprite_batch.js +18 -18
- package/src/phaser/display/webgl/stencil_manager.js +16 -16
- package/src/phaser/display/webgl/texture.js +13 -13
- package/src/phaser/display/webgl/texture_util.js +8 -8
- package/src/phaser/display/webgl/util.js +25 -25
- package/src/phaser/geom/circle.js +74 -69
- package/src/phaser/geom/ellipse.js +33 -28
- package/src/phaser/geom/line.js +96 -93
- package/src/phaser/geom/matrix.js +61 -54
- package/src/phaser/geom/point.js +99 -96
- package/src/phaser/geom/polygon.js +27 -22
- package/src/phaser/geom/rectangle.js +137 -132
- package/src/phaser/geom/rounded_rectangle.js +12 -12
- package/src/phaser/geom/util/circle.js +33 -33
- package/src/phaser/geom/util/ellipse.js +5 -5
- package/src/phaser/geom/util/line.js +26 -26
- package/src/phaser/geom/util/matrix.js +8 -8
- package/src/phaser/geom/util/point.js +97 -97
- package/src/phaser/geom/util/polygon.js +4 -4
- package/src/phaser/geom/util/rectangle.js +74 -74
- package/src/phaser/geom/util/rounded_rectangle.js +4 -4
- package/src/phaser/util/math.js +81 -81
- package/types/phaser/core/animation.d.ts +79 -56
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +55 -55
- package/types/phaser/core/animation_parser.d.ts +3 -2
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +154 -154
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +51 -44
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +63 -63
- package/types/phaser/core/factory.d.ts +47 -47
- package/types/phaser/core/frame.d.ts +30 -30
- package/types/phaser/core/frame_data.d.ts +28 -27
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +54 -21
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +18 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +175 -172
- 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 +1 -1
- package/types/phaser/core/scale_manager.d.ts +6 -5
- package/types/phaser/core/scale_manager.d.ts.map +1 -1
- package/types/phaser/core/scene.d.ts +15 -9
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +51 -43
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +54 -51
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +54 -54
- package/types/phaser/core/sound_manager.d.ts +49 -49
- package/types/phaser/core/stage.d.ts +10 -10
- package/types/phaser/core/time.d.ts +54 -30
- package/types/phaser/core/time.d.ts.map +1 -1
- package/types/phaser/core/timer.d.ts +82 -64
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +9 -9
- package/types/phaser/core/tween.d.ts +106 -90
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +30 -30
- package/types/phaser/core/tween_manager.d.ts +35 -67
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +4 -3
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +76 -53
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +47 -46
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +8 -8
- package/types/phaser/display/canvas/graphics.d.ts +3 -3
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +6 -3
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +18 -17
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts +6 -6
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +119 -108
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +118 -102
- package/types/phaser/display/graphics.d.ts.map +1 -1
- package/types/phaser/display/graphics_data.d.ts +10 -10
- package/types/phaser/display/group.d.ts +59 -47
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +58 -45
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +237 -188
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +4 -4
- package/types/phaser/display/webgl/base_texture.d.ts +10 -10
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/blend_manager.d.ts +6 -6
- package/types/phaser/display/webgl/earcut.d.ts +95 -95
- package/types/phaser/display/webgl/earcut_node.d.ts +4 -4
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +15 -15
- package/types/phaser/display/webgl/filter_manager.d.ts +8 -8
- package/types/phaser/display/webgl/filter_texture.d.ts +10 -10
- package/types/phaser/display/webgl/graphics.d.ts +2 -2
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +4 -4
- package/types/phaser/display/webgl/render_texture.d.ts +16 -16
- package/types/phaser/display/webgl/renderer.d.ts +21 -20
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +4 -4
- package/types/phaser/display/webgl/shader/fast.d.ts +4 -4
- package/types/phaser/display/webgl/shader/normal.d.ts +8 -8
- package/types/phaser/display/webgl/shader/primitive.d.ts +4 -4
- package/types/phaser/display/webgl/shader/strip.d.ts +4 -4
- package/types/phaser/display/webgl/shader_manager.d.ts +8 -8
- package/types/phaser/display/webgl/sprite_batch.d.ts +17 -17
- package/types/phaser/display/webgl/stencil_manager.d.ts +15 -15
- package/types/phaser/display/webgl/texture.d.ts +12 -12
- package/types/phaser/display/webgl/texture_util.d.ts +4 -2
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +74 -69
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +33 -28
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +96 -93
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +61 -54
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +99 -96
- package/types/phaser/geom/point.d.ts.map +1 -1
- package/types/phaser/geom/polygon.d.ts +29 -23
- package/types/phaser/geom/polygon.d.ts.map +1 -1
- package/types/phaser/geom/rectangle.d.ts +137 -132
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
- package/types/phaser/geom/util/point.d.ts +1 -1
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/pnpm-workspace.yaml +0 -4
|
@@ -9,16 +9,17 @@ import { textureFromCanvas } from './webgl/texture_util.js';
|
|
|
9
9
|
|
|
10
10
|
export class Text extends Image {
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @param {import('../core/game.js').Game} game -
|
|
14
|
-
* @param {number} x -
|
|
15
|
-
* @param {number} y -
|
|
16
|
-
* @param {string} text -
|
|
17
|
-
* @param {object} style -
|
|
12
|
+
* Creates a new Text object.
|
|
13
|
+
* @param {import('../core/game.js').Game} game - The game instance this text belongs to.
|
|
14
|
+
* @param {number} x - The x position of the text.
|
|
15
|
+
* @param {number} y - The y position of the text.
|
|
16
|
+
* @param {string} text - The text content to display.
|
|
17
|
+
* @param {object} style - The style settings for the text.
|
|
18
18
|
*/
|
|
19
19
|
constructor(game, x, y, text = '', style = {}) {
|
|
20
20
|
super(game, x, y, null);
|
|
21
21
|
this.game = game;
|
|
22
|
+
/** @type {number} */
|
|
22
23
|
this.type = TEXT;
|
|
23
24
|
this.canvas = create(this);
|
|
24
25
|
this.context = this.canvas.getContext('2d', { willReadFrequently: false });
|
|
@@ -38,9 +39,13 @@ export class Text extends Image {
|
|
|
38
39
|
this._res = game.renderer.resolution;
|
|
39
40
|
this._text = text.toString();
|
|
40
41
|
this._fontComponents = null;
|
|
42
|
+
/** @type {number} */
|
|
41
43
|
this._lineSpacing = 0;
|
|
44
|
+
/** @type {number} */
|
|
42
45
|
this._charCount = 0;
|
|
46
|
+
/** @type {number} */
|
|
43
47
|
this._width = 0;
|
|
48
|
+
/** @type {number} */
|
|
44
49
|
this._height = 0;
|
|
45
50
|
this.loadTexture(textureFromCanvas(this.canvas));
|
|
46
51
|
this.setStyle(style);
|
|
@@ -50,7 +55,7 @@ export class Text extends Image {
|
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
/**
|
|
53
|
-
*
|
|
58
|
+
* Destroys this text object and cleans up resources.
|
|
54
59
|
*/
|
|
55
60
|
destroy() {
|
|
56
61
|
this.texture.destroy(true);
|
|
@@ -70,14 +75,14 @@ export class Text extends Image {
|
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
/**
|
|
73
|
-
*
|
|
74
|
-
* @param {number} x -
|
|
75
|
-
* @param {number} y -
|
|
76
|
-
* @param {string} color -
|
|
77
|
-
* @param {number} blur -
|
|
78
|
-
* @param {boolean} shadowStroke -
|
|
79
|
-
* @param {boolean} shadowFill -
|
|
80
|
-
* @returns {Text}
|
|
78
|
+
* Sets the drop shadow properties for this text.
|
|
79
|
+
* @param {number} x - The horizontal offset of the shadow.
|
|
80
|
+
* @param {number} y - The vertical offset of the shadow.
|
|
81
|
+
* @param {string} color - The color of the shadow.
|
|
82
|
+
* @param {number} blur - The blur radius of the shadow.
|
|
83
|
+
* @param {boolean} shadowStroke - Whether to apply the shadow to the stroke.
|
|
84
|
+
* @param {boolean} shadowFill - Whether to apply the shadow to the fill.
|
|
85
|
+
* @returns {Text} This Text object for chaining.
|
|
81
86
|
*/
|
|
82
87
|
setShadow(x = 0, y = 0, color = 'rgba(0, 0, 0, 1)', blur = 0, shadowStroke = true, shadowFill = true) {
|
|
83
88
|
this.style.shadowOffsetX = x;
|
|
@@ -91,10 +96,10 @@ export class Text extends Image {
|
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
/**
|
|
94
|
-
*
|
|
95
|
-
* @param {object} style -
|
|
96
|
-
* @param {boolean} update -
|
|
97
|
-
* @returns {Text}
|
|
99
|
+
* Sets the style properties for this text.
|
|
100
|
+
* @param {object} style - The style settings to apply.
|
|
101
|
+
* @param {boolean} update - Whether to update the text immediately.
|
|
102
|
+
* @returns {Text} This Text object for chaining.
|
|
98
103
|
*/
|
|
99
104
|
setStyle(style = null, update = false) {
|
|
100
105
|
style = JSON.parse(JSON.stringify(style)) || {};
|
|
@@ -141,7 +146,7 @@ export class Text extends Image {
|
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
/**
|
|
144
|
-
*
|
|
149
|
+
* Updates the text content and renders it to the canvas.
|
|
145
150
|
*/
|
|
146
151
|
updateText() {
|
|
147
152
|
this.texture.baseTexture.resolution = this._res;
|
|
@@ -304,11 +309,11 @@ export class Text extends Image {
|
|
|
304
309
|
}
|
|
305
310
|
|
|
306
311
|
/**
|
|
307
|
-
*
|
|
308
|
-
* @param {string} line -
|
|
309
|
-
* @param {number} x -
|
|
310
|
-
* @param {number} y -
|
|
311
|
-
* @param {boolean} fill -
|
|
312
|
+
* Renders a tabbed line of text to the canvas.
|
|
313
|
+
* @param {string} line - The line of text to render.
|
|
314
|
+
* @param {number} x - The x position to start rendering from.
|
|
315
|
+
* @param {number} y - The y position to start rendering from.
|
|
316
|
+
* @param {boolean} fill - True to fill the text, false to stroke it.
|
|
312
317
|
*/
|
|
313
318
|
renderTabLine(line, x, y, fill) {
|
|
314
319
|
const text = line.split(/(?:\t)/);
|
|
@@ -343,8 +348,8 @@ export class Text extends Image {
|
|
|
343
348
|
}
|
|
344
349
|
|
|
345
350
|
/**
|
|
346
|
-
*
|
|
347
|
-
* @param {string} state -
|
|
351
|
+
* Updates the shadow properties for this text.
|
|
352
|
+
* @param {string} state - The shadow state to update ('stroke' or 'fill').
|
|
348
353
|
*/
|
|
349
354
|
updateShadow(state) {
|
|
350
355
|
if (state) {
|
|
@@ -361,9 +366,9 @@ export class Text extends Image {
|
|
|
361
366
|
}
|
|
362
367
|
|
|
363
368
|
/**
|
|
364
|
-
*
|
|
365
|
-
* @param {string} line -
|
|
366
|
-
* @returns {number}
|
|
369
|
+
* Measures the width of a line of text.
|
|
370
|
+
* @param {string} line - The line of text to measure.
|
|
371
|
+
* @returns {number} The width of the line in pixels.
|
|
367
372
|
*/
|
|
368
373
|
measureLine(line) {
|
|
369
374
|
let lineLength = 0;
|
|
@@ -398,10 +403,10 @@ export class Text extends Image {
|
|
|
398
403
|
}
|
|
399
404
|
|
|
400
405
|
/**
|
|
401
|
-
*
|
|
402
|
-
* @param {string} line -
|
|
403
|
-
* @param {number} x -
|
|
404
|
-
* @param {number} y -
|
|
406
|
+
* Updates a line of text to the canvas.
|
|
407
|
+
* @param {string} line - The line of text to update.
|
|
408
|
+
* @param {number} x - The x position to start updating from.
|
|
409
|
+
* @param {number} y - The y position to start updating from.
|
|
405
410
|
*/
|
|
406
411
|
updateLine(line, x, y) {
|
|
407
412
|
for (let i = 0; i < line.length; i += 1) {
|
|
@@ -436,8 +441,8 @@ export class Text extends Image {
|
|
|
436
441
|
}
|
|
437
442
|
|
|
438
443
|
/**
|
|
439
|
-
*
|
|
440
|
-
* @returns {Text}
|
|
444
|
+
* Clears all color values from this text object.
|
|
445
|
+
* @returns {Text} This Text object for chaining.
|
|
441
446
|
*/
|
|
442
447
|
clearColors() {
|
|
443
448
|
this.colors = [];
|
|
@@ -447,8 +452,8 @@ export class Text extends Image {
|
|
|
447
452
|
}
|
|
448
453
|
|
|
449
454
|
/**
|
|
450
|
-
*
|
|
451
|
-
* @returns {Text}
|
|
455
|
+
* Clears all font style values from this text object.
|
|
456
|
+
* @returns {Text} This Text object for chaining.
|
|
452
457
|
*/
|
|
453
458
|
clearFontValues() {
|
|
454
459
|
this.fontStyles = [];
|
|
@@ -458,10 +463,10 @@ export class Text extends Image {
|
|
|
458
463
|
}
|
|
459
464
|
|
|
460
465
|
/**
|
|
461
|
-
*
|
|
462
|
-
* @param {string} color -
|
|
463
|
-
* @param {number} position -
|
|
464
|
-
* @returns {Text}
|
|
466
|
+
* Adds a color to this text object at the specified position.
|
|
467
|
+
* @param {string} color - The color to apply.
|
|
468
|
+
* @param {number} position - The character position to apply the color at.
|
|
469
|
+
* @returns {Text} This Text object for chaining.
|
|
465
470
|
*/
|
|
466
471
|
addColor(color, position) {
|
|
467
472
|
this.colors[position] = color;
|
|
@@ -470,10 +475,10 @@ export class Text extends Image {
|
|
|
470
475
|
}
|
|
471
476
|
|
|
472
477
|
/**
|
|
473
|
-
*
|
|
474
|
-
* @param {number} color -
|
|
475
|
-
* @param {number} position -
|
|
476
|
-
* @returns {Text}
|
|
478
|
+
* Adds a stroke color to this text object at the specified position.
|
|
479
|
+
* @param {number} color - The stroke color to apply.
|
|
480
|
+
* @param {number} position - The character position to apply the stroke color at.
|
|
481
|
+
* @returns {Text} This Text object for chaining.
|
|
477
482
|
*/
|
|
478
483
|
addStrokeColor(color, position) {
|
|
479
484
|
this.strokeColors[position] = color;
|
|
@@ -482,10 +487,10 @@ export class Text extends Image {
|
|
|
482
487
|
}
|
|
483
488
|
|
|
484
489
|
/**
|
|
485
|
-
*
|
|
486
|
-
* @param {object} style -
|
|
487
|
-
* @param {number} position -
|
|
488
|
-
* @returns {Text}
|
|
490
|
+
* Adds a font style to this text object at the specified position.
|
|
491
|
+
* @param {object} style - The font style to apply.
|
|
492
|
+
* @param {number} position - The character position to apply the font style at.
|
|
493
|
+
* @returns {Text} This Text object for chaining.
|
|
489
494
|
*/
|
|
490
495
|
addFontStyle(style, position) {
|
|
491
496
|
this.fontStyles[position] = style;
|
|
@@ -494,10 +499,10 @@ export class Text extends Image {
|
|
|
494
499
|
}
|
|
495
500
|
|
|
496
501
|
/**
|
|
497
|
-
*
|
|
498
|
-
* @param {number} weight -
|
|
499
|
-
* @param {number} position -
|
|
500
|
-
* @returns {Text}
|
|
502
|
+
* Adds a font weight to this text object at the specified position.
|
|
503
|
+
* @param {number} weight - The font weight to apply.
|
|
504
|
+
* @param {number} position - The character position to apply the font weight at.
|
|
505
|
+
* @returns {Text} This Text object for chaining.
|
|
501
506
|
*/
|
|
502
507
|
addFontWeight(weight, position) {
|
|
503
508
|
this.fontWeights[position] = weight;
|
|
@@ -506,9 +511,9 @@ export class Text extends Image {
|
|
|
506
511
|
}
|
|
507
512
|
|
|
508
513
|
/**
|
|
509
|
-
*
|
|
510
|
-
* @param {string} text -
|
|
511
|
-
* @returns {string[]}
|
|
514
|
+
* Precalculates word wrap for the given text.
|
|
515
|
+
* @param {string} text - The text to precalculate word wrap for.
|
|
516
|
+
* @returns {string[]} The wrapped lines of text.
|
|
512
517
|
*/
|
|
513
518
|
precalculateWordWrap(text) {
|
|
514
519
|
this.texture.baseTexture.resolution = this._res;
|
|
@@ -518,9 +523,9 @@ export class Text extends Image {
|
|
|
518
523
|
}
|
|
519
524
|
|
|
520
525
|
/**
|
|
521
|
-
*
|
|
522
|
-
* @param {string} text -
|
|
523
|
-
* @returns {string}
|
|
526
|
+
* Runs word wrap on the given text.
|
|
527
|
+
* @param {string} text - The text to run word wrap on.
|
|
528
|
+
* @returns {string} The wrapped text.
|
|
524
529
|
*/
|
|
525
530
|
runWordWrap(text) {
|
|
526
531
|
if (this.useAdvancedWrap) {
|
|
@@ -530,10 +535,10 @@ export class Text extends Image {
|
|
|
530
535
|
}
|
|
531
536
|
|
|
532
537
|
/**
|
|
533
|
-
*
|
|
534
|
-
* @param {string} text -
|
|
535
|
-
* @returns {string}
|
|
536
|
-
* @throws {Error}
|
|
538
|
+
* Runs advanced word wrap on the given text.
|
|
539
|
+
* @param {string} text - The text to run advanced word wrap on.
|
|
540
|
+
* @returns {string} The wrapped text.
|
|
541
|
+
* @throws {Error} If the wordWrapWidth setting is less than a single character.
|
|
537
542
|
*/
|
|
538
543
|
advancedWordWrap(text) {
|
|
539
544
|
const context = this.context;
|
|
@@ -613,9 +618,9 @@ export class Text extends Image {
|
|
|
613
618
|
}
|
|
614
619
|
|
|
615
620
|
/**
|
|
616
|
-
*
|
|
617
|
-
* @param {string} text -
|
|
618
|
-
* @returns {string}
|
|
621
|
+
* Runs basic word wrap on the given text.
|
|
622
|
+
* @param {string} text - The text to run basic word wrap on.
|
|
623
|
+
* @returns {string} The wrapped text.
|
|
619
624
|
*/
|
|
620
625
|
basicWordWrap(text) {
|
|
621
626
|
let result = '';
|
|
@@ -646,8 +651,8 @@ export class Text extends Image {
|
|
|
646
651
|
}
|
|
647
652
|
|
|
648
653
|
/**
|
|
649
|
-
*
|
|
650
|
-
* @param {object} components -
|
|
654
|
+
* Updates the font properties based on the given components.
|
|
655
|
+
* @param {object} components - The font components to update from.
|
|
651
656
|
*/
|
|
652
657
|
updateFont(components) {
|
|
653
658
|
const font = this.componentsToFont(components);
|
|
@@ -661,9 +666,9 @@ export class Text extends Image {
|
|
|
661
666
|
}
|
|
662
667
|
|
|
663
668
|
/**
|
|
664
|
-
*
|
|
665
|
-
* @param {string} font -
|
|
666
|
-
* @returns {
|
|
669
|
+
* Converts a font string to components.
|
|
670
|
+
* @param {string} font - The font string to convert.
|
|
671
|
+
* @returns {{ font: string, fontStyle?: string, fontVariant?: string, fontWeight?: string, fontSize?: string, fontFamily?: string }} The font components.
|
|
667
672
|
*/
|
|
668
673
|
fontToComponents(font) {
|
|
669
674
|
// The format is specified in http://www.w3.org/TR/CSS2/fonts.html#font-shorthand:
|
|
@@ -697,9 +702,9 @@ export class Text extends Image {
|
|
|
697
702
|
}
|
|
698
703
|
|
|
699
704
|
/**
|
|
700
|
-
*
|
|
701
|
-
* @param {object} components -
|
|
702
|
-
* @returns {string}
|
|
705
|
+
* Converts font components to a font string.
|
|
706
|
+
* @param {object} components - The font components to convert.
|
|
707
|
+
* @returns {string} The font string.
|
|
703
708
|
*/
|
|
704
709
|
componentsToFont(components) {
|
|
705
710
|
const parts = [];
|
|
@@ -732,10 +737,10 @@ export class Text extends Image {
|
|
|
732
737
|
}
|
|
733
738
|
|
|
734
739
|
/**
|
|
735
|
-
*
|
|
736
|
-
* @param {string} text -
|
|
737
|
-
* @param {boolean} immediate -
|
|
738
|
-
* @returns {Text}
|
|
740
|
+
* Sets the text content of this object.
|
|
741
|
+
* @param {string} text - The new text to set.
|
|
742
|
+
* @param {boolean} immediate - If true, updates the text immediately.
|
|
743
|
+
* @returns {Text} This Text object for chaining.
|
|
739
744
|
*/
|
|
740
745
|
setText(text, immediate = false) {
|
|
741
746
|
this.text = text.toString() || '';
|
|
@@ -748,9 +753,9 @@ export class Text extends Image {
|
|
|
748
753
|
}
|
|
749
754
|
|
|
750
755
|
/**
|
|
751
|
-
*
|
|
752
|
-
* @param {string[]|string[][]} list -
|
|
753
|
-
* @returns {Text}
|
|
756
|
+
* Parses a list of text into this object.
|
|
757
|
+
* @param {string[]|string[][]} list - The list of text to parse.
|
|
758
|
+
* @returns {Text} This Text object for chaining.
|
|
754
759
|
*/
|
|
755
760
|
parseList(list) {
|
|
756
761
|
if (!Array.isArray(list)) {
|
|
@@ -776,12 +781,12 @@ export class Text extends Image {
|
|
|
776
781
|
}
|
|
777
782
|
|
|
778
783
|
/**
|
|
779
|
-
*
|
|
780
|
-
* @param {number} x -
|
|
781
|
-
* @param {number} y -
|
|
782
|
-
* @param {number} width -
|
|
783
|
-
* @param {number} height -
|
|
784
|
-
* @returns {Text}
|
|
784
|
+
* Sets the text bounds for this object.
|
|
785
|
+
* @param {number} x - The x position of the bounds.
|
|
786
|
+
* @param {number} y - The y position of the bounds.
|
|
787
|
+
* @param {number} width - The width of the bounds.
|
|
788
|
+
* @param {number} height - The height of the bounds.
|
|
789
|
+
* @returns {Text} This Text object for chaining.
|
|
785
790
|
*/
|
|
786
791
|
setTextBounds(x, y, width, height) {
|
|
787
792
|
if (x === undefined) {
|
|
@@ -801,7 +806,7 @@ export class Text extends Image {
|
|
|
801
806
|
}
|
|
802
807
|
|
|
803
808
|
/**
|
|
804
|
-
*
|
|
809
|
+
* Updates the texture of this object.
|
|
805
810
|
*/
|
|
806
811
|
updateTexture() {
|
|
807
812
|
const base = this.texture.baseTexture;
|
|
@@ -843,8 +848,8 @@ export class Text extends Image {
|
|
|
843
848
|
}
|
|
844
849
|
|
|
845
850
|
/**
|
|
846
|
-
*
|
|
847
|
-
* @param {object} renderSession -
|
|
851
|
+
* Renders this text object using WebGL.
|
|
852
|
+
* @param {object} renderSession - The render session to use.
|
|
848
853
|
*/
|
|
849
854
|
renderWebGL(renderSession) {
|
|
850
855
|
if (this.dirty) {
|
|
@@ -855,8 +860,8 @@ export class Text extends Image {
|
|
|
855
860
|
}
|
|
856
861
|
|
|
857
862
|
/**
|
|
858
|
-
*
|
|
859
|
-
* @param {object} renderSession -
|
|
863
|
+
* Renders this text object using Canvas.
|
|
864
|
+
* @param {object} renderSession - The render session to use.
|
|
860
865
|
*/
|
|
861
866
|
renderCanvas(renderSession) {
|
|
862
867
|
if (this.dirty) {
|
|
@@ -867,8 +872,8 @@ export class Text extends Image {
|
|
|
867
872
|
}
|
|
868
873
|
|
|
869
874
|
/**
|
|
870
|
-
*
|
|
871
|
-
* @returns {
|
|
875
|
+
* Gets the font properties cache object.
|
|
876
|
+
* @returns {{[key: string]: {ascent: number, descent: number, fontSize: number}}} The font properties cache.
|
|
872
877
|
*/
|
|
873
878
|
getFontPropertiesCache() {
|
|
874
879
|
if (!window.PhaserRegistry.fontPropertiesCache) {
|
|
@@ -878,8 +883,8 @@ export class Text extends Image {
|
|
|
878
883
|
}
|
|
879
884
|
|
|
880
885
|
/**
|
|
881
|
-
*
|
|
882
|
-
* @returns {HTMLCanvasElement}
|
|
886
|
+
* Gets the font properties canvas element.
|
|
887
|
+
* @returns {HTMLCanvasElement} The font properties canvas element.
|
|
883
888
|
*/
|
|
884
889
|
getFontPropertiesCanvas() {
|
|
885
890
|
if (!window.PhaserRegistry.fontPropertiesCanvas) {
|
|
@@ -889,8 +894,8 @@ export class Text extends Image {
|
|
|
889
894
|
}
|
|
890
895
|
|
|
891
896
|
/**
|
|
892
|
-
*
|
|
893
|
-
* @returns {CanvasRenderingContext2D}
|
|
897
|
+
* Gets the font properties canvas context.
|
|
898
|
+
* @returns {CanvasRenderingContext2D} The font properties canvas context.
|
|
894
899
|
*/
|
|
895
900
|
getFontPropertiesContext() {
|
|
896
901
|
if (!window.PhaserRegistry.fontPropertiesContext) {
|
|
@@ -902,9 +907,9 @@ export class Text extends Image {
|
|
|
902
907
|
}
|
|
903
908
|
|
|
904
909
|
/**
|
|
905
|
-
*
|
|
906
|
-
* @param {string} font -
|
|
907
|
-
* @returns {object}
|
|
910
|
+
* Determines the font properties for a given font.
|
|
911
|
+
* @param {string} font - The font to determine properties for.
|
|
912
|
+
* @returns {object} The font properties.
|
|
908
913
|
*/
|
|
909
914
|
determineFontProperties(font) {
|
|
910
915
|
const fontPropertiesCache = this.getFontPropertiesCache();
|
|
@@ -927,9 +932,9 @@ export class Text extends Image {
|
|
|
927
932
|
}
|
|
928
933
|
|
|
929
934
|
/**
|
|
930
|
-
*
|
|
931
|
-
* @param {string} fontStyle -
|
|
932
|
-
* @returns {
|
|
935
|
+
* Determines font properties using a fallback method.
|
|
936
|
+
* @param {string} fontStyle - The font style to determine properties for.
|
|
937
|
+
* @returns {{ascent: number, descent: number, fontSize: number}} The font properties.
|
|
933
938
|
*/
|
|
934
939
|
determineFontPropertiesFallback(fontStyle) {
|
|
935
940
|
const fontPropertiesCache = this.getFontPropertiesCache();
|
|
@@ -1008,9 +1013,9 @@ export class Text extends Image {
|
|
|
1008
1013
|
}
|
|
1009
1014
|
|
|
1010
1015
|
/**
|
|
1011
|
-
*
|
|
1012
|
-
* @param {import('../geom/matrix.js').Matrix} matrix -
|
|
1013
|
-
* @returns {Rectangle}
|
|
1016
|
+
* Gets the bounds of this text object.
|
|
1017
|
+
* @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
|
|
1018
|
+
* @returns {Rectangle} The bounds of this text object.
|
|
1014
1019
|
*/
|
|
1015
1020
|
getBounds(matrix = null) {
|
|
1016
1021
|
if (this.dirty) {
|
|
@@ -1021,16 +1026,16 @@ export class Text extends Image {
|
|
|
1021
1026
|
}
|
|
1022
1027
|
|
|
1023
1028
|
/**
|
|
1024
|
-
*
|
|
1025
|
-
* @returns {string}
|
|
1029
|
+
* Gets the text content of this object.
|
|
1030
|
+
* @returns {string} The current text content.
|
|
1026
1031
|
*/
|
|
1027
1032
|
get text() {
|
|
1028
1033
|
return this._text;
|
|
1029
1034
|
}
|
|
1030
1035
|
|
|
1031
1036
|
/**
|
|
1032
|
-
*
|
|
1033
|
-
* @param {string | number | boolean | Date} value -
|
|
1037
|
+
* Sets the text content of this object.
|
|
1038
|
+
* @param {string | number | boolean | Date} value - The new text content to set.
|
|
1034
1039
|
*/
|
|
1035
1040
|
set text(value) {
|
|
1036
1041
|
if (value !== this._text) {
|
|
@@ -1043,15 +1048,16 @@ export class Text extends Image {
|
|
|
1043
1048
|
}
|
|
1044
1049
|
|
|
1045
1050
|
/**
|
|
1046
|
-
*
|
|
1047
|
-
* @returns {string}
|
|
1051
|
+
* Gets the CSS font string for this object.
|
|
1052
|
+
* @returns {string} The CSS font string.
|
|
1048
1053
|
*/
|
|
1049
1054
|
get cssFont() {
|
|
1050
1055
|
return this.componentsToFont(this._fontComponents);
|
|
1051
1056
|
}
|
|
1052
1057
|
|
|
1053
1058
|
/**
|
|
1054
|
-
*
|
|
1059
|
+
* Sets the CSS font string for this object.
|
|
1060
|
+
* @param {string} value - The new CSS font string to set.
|
|
1055
1061
|
*/
|
|
1056
1062
|
set cssFont(value) {
|
|
1057
1063
|
this._fontComponents = this.fontToComponents(value || 'bold 20pt Arial');
|
|
@@ -1059,15 +1065,16 @@ export class Text extends Image {
|
|
|
1059
1065
|
}
|
|
1060
1066
|
|
|
1061
1067
|
/**
|
|
1062
|
-
*
|
|
1063
|
-
* @returns {number}
|
|
1068
|
+
* Gets the font family of this object.
|
|
1069
|
+
* @returns {number} The font family.
|
|
1064
1070
|
*/
|
|
1065
1071
|
get font() {
|
|
1066
1072
|
return this._fontComponents.fontFamily;
|
|
1067
1073
|
}
|
|
1068
1074
|
|
|
1069
1075
|
/**
|
|
1070
|
-
*
|
|
1076
|
+
* Sets the font family of this object.
|
|
1077
|
+
* @param {string} value - The new font family to set.
|
|
1071
1078
|
*/
|
|
1072
1079
|
set font(value) {
|
|
1073
1080
|
let mutatedValue = value || 'Arial';
|
|
@@ -1082,8 +1089,8 @@ export class Text extends Image {
|
|
|
1082
1089
|
}
|
|
1083
1090
|
|
|
1084
1091
|
/**
|
|
1085
|
-
*
|
|
1086
|
-
* @returns {number}
|
|
1092
|
+
* Gets the font size of this object.
|
|
1093
|
+
* @returns {number} The font size.
|
|
1087
1094
|
*/
|
|
1088
1095
|
get fontSize() {
|
|
1089
1096
|
const size = this._fontComponents.fontSize;
|
|
@@ -1094,7 +1101,8 @@ export class Text extends Image {
|
|
|
1094
1101
|
}
|
|
1095
1102
|
|
|
1096
1103
|
/**
|
|
1097
|
-
*
|
|
1104
|
+
* Sets the font size of this object.
|
|
1105
|
+
* @param {number} value - The new font size to set.
|
|
1098
1106
|
*/
|
|
1099
1107
|
set fontSize(value) {
|
|
1100
1108
|
let mutatedValue = value || '0';
|
|
@@ -1106,15 +1114,16 @@ export class Text extends Image {
|
|
|
1106
1114
|
}
|
|
1107
1115
|
|
|
1108
1116
|
/**
|
|
1109
|
-
*
|
|
1110
|
-
* @returns {string}
|
|
1117
|
+
* Gets the font weight of this object.
|
|
1118
|
+
* @returns {string} The font weight.
|
|
1111
1119
|
*/
|
|
1112
1120
|
get fontWeight() {
|
|
1113
1121
|
return this._fontComponents.fontWeight || 'normal';
|
|
1114
1122
|
}
|
|
1115
1123
|
|
|
1116
1124
|
/**
|
|
1117
|
-
*
|
|
1125
|
+
* Sets the font weight of this object.
|
|
1126
|
+
* @param {string} value - The new font weight to set.
|
|
1118
1127
|
*/
|
|
1119
1128
|
set fontWeight(value) {
|
|
1120
1129
|
this._fontComponents.fontWeight = value || 'normal';
|
|
@@ -1122,15 +1131,16 @@ export class Text extends Image {
|
|
|
1122
1131
|
}
|
|
1123
1132
|
|
|
1124
1133
|
/**
|
|
1125
|
-
*
|
|
1126
|
-
* @returns {string}
|
|
1134
|
+
* Gets the font style of this object.
|
|
1135
|
+
* @returns {string} The font style.
|
|
1127
1136
|
*/
|
|
1128
1137
|
get fontStyle() {
|
|
1129
1138
|
return this._fontComponents.fontStyle || 'normal';
|
|
1130
1139
|
}
|
|
1131
1140
|
|
|
1132
1141
|
/**
|
|
1133
|
-
*
|
|
1142
|
+
* Sets the font style of this object.
|
|
1143
|
+
* @param {string} value - The new font style to set.
|
|
1134
1144
|
*/
|
|
1135
1145
|
set fontStyle(value) {
|
|
1136
1146
|
this._fontComponents.fontStyle = value || 'normal';
|
|
@@ -1138,15 +1148,16 @@ export class Text extends Image {
|
|
|
1138
1148
|
}
|
|
1139
1149
|
|
|
1140
1150
|
/**
|
|
1141
|
-
*
|
|
1142
|
-
* @returns {string}
|
|
1151
|
+
* Gets the font variant of this object.
|
|
1152
|
+
* @returns {string} The font variant.
|
|
1143
1153
|
*/
|
|
1144
1154
|
get fontVariant() {
|
|
1145
1155
|
return this._fontComponents.fontVariant || 'normal';
|
|
1146
1156
|
}
|
|
1147
1157
|
|
|
1148
1158
|
/**
|
|
1149
|
-
*
|
|
1159
|
+
* Sets the font variant of this object.
|
|
1160
|
+
* @param {string} value - The new font variant to set.
|
|
1150
1161
|
*/
|
|
1151
1162
|
set fontVariant(value) {
|
|
1152
1163
|
this._fontComponents.fontVariant = value || 'normal';
|
|
@@ -1154,15 +1165,16 @@ export class Text extends Image {
|
|
|
1154
1165
|
}
|
|
1155
1166
|
|
|
1156
1167
|
/**
|
|
1157
|
-
*
|
|
1158
|
-
* @returns {number}
|
|
1168
|
+
* Gets the fill color of this object.
|
|
1169
|
+
* @returns {number} The fill color.
|
|
1159
1170
|
*/
|
|
1160
1171
|
get fill() {
|
|
1161
1172
|
return this.style.fill;
|
|
1162
1173
|
}
|
|
1163
1174
|
|
|
1164
1175
|
/**
|
|
1165
|
-
*
|
|
1176
|
+
* Sets the fill color of this object.
|
|
1177
|
+
* @param {string} value - The new fill color to set.
|
|
1166
1178
|
*/
|
|
1167
1179
|
set fill(value) {
|
|
1168
1180
|
if (value !== this.style.fill) {
|
|
@@ -1172,15 +1184,16 @@ export class Text extends Image {
|
|
|
1172
1184
|
}
|
|
1173
1185
|
|
|
1174
1186
|
/**
|
|
1175
|
-
*
|
|
1176
|
-
* @returns {string}
|
|
1187
|
+
* Gets the alignment of this object.
|
|
1188
|
+
* @returns {string} The text alignment.
|
|
1177
1189
|
*/
|
|
1178
1190
|
get align() {
|
|
1179
1191
|
return this.style.align;
|
|
1180
1192
|
}
|
|
1181
1193
|
|
|
1182
1194
|
/**
|
|
1183
|
-
*
|
|
1195
|
+
* Sets the alignment of this object.
|
|
1196
|
+
* @param {string} value - The new text alignment to set.
|
|
1184
1197
|
*/
|
|
1185
1198
|
set align(value) {
|
|
1186
1199
|
if (value !== this.style.align) {
|
|
@@ -1190,15 +1203,16 @@ export class Text extends Image {
|
|
|
1190
1203
|
}
|
|
1191
1204
|
|
|
1192
1205
|
/**
|
|
1193
|
-
*
|
|
1194
|
-
* @returns {number}
|
|
1206
|
+
* Gets the resolution of this object.
|
|
1207
|
+
* @returns {number} The resolution.
|
|
1195
1208
|
*/
|
|
1196
1209
|
get resolution() {
|
|
1197
1210
|
return this._res;
|
|
1198
1211
|
}
|
|
1199
1212
|
|
|
1200
1213
|
/**
|
|
1201
|
-
*
|
|
1214
|
+
* Sets the resolution of this object.
|
|
1215
|
+
* @param {number} value - The new resolution to set.
|
|
1202
1216
|
*/
|
|
1203
1217
|
set resolution(value) {
|
|
1204
1218
|
if (value !== this._res) {
|
|
@@ -1208,15 +1222,16 @@ export class Text extends Image {
|
|
|
1208
1222
|
}
|
|
1209
1223
|
|
|
1210
1224
|
/**
|
|
1211
|
-
*
|
|
1212
|
-
* @returns {number}
|
|
1225
|
+
* Gets the tabs setting of this object.
|
|
1226
|
+
* @returns {number} The tabs setting.
|
|
1213
1227
|
*/
|
|
1214
1228
|
get tabs() {
|
|
1215
1229
|
return this.style.tabs;
|
|
1216
1230
|
}
|
|
1217
1231
|
|
|
1218
1232
|
/**
|
|
1219
|
-
*
|
|
1233
|
+
* Sets the tabs setting of this object.
|
|
1234
|
+
* @param {number} value - The new tabs setting to set.
|
|
1220
1235
|
*/
|
|
1221
1236
|
set tabs(value) {
|
|
1222
1237
|
if (value !== this.style.tabs) {
|
|
@@ -1226,15 +1241,16 @@ export class Text extends Image {
|
|
|
1226
1241
|
}
|
|
1227
1242
|
|
|
1228
1243
|
/**
|
|
1229
|
-
*
|
|
1230
|
-
* @returns {number}
|
|
1244
|
+
* Gets the horizontal bounds alignment of this object.
|
|
1245
|
+
* @returns {number} The horizontal bounds alignment.
|
|
1231
1246
|
*/
|
|
1232
1247
|
get boundsAlignH() {
|
|
1233
1248
|
return this.style.boundsAlignH;
|
|
1234
1249
|
}
|
|
1235
1250
|
|
|
1236
1251
|
/**
|
|
1237
|
-
*
|
|
1252
|
+
* Sets the horizontal bounds alignment of this object.
|
|
1253
|
+
* @param {number} value - The new horizontal bounds alignment to set.
|
|
1238
1254
|
*/
|
|
1239
1255
|
set boundsAlignH(value) {
|
|
1240
1256
|
if (value !== this.style.boundsAlignH) {
|
|
@@ -1244,15 +1260,16 @@ export class Text extends Image {
|
|
|
1244
1260
|
}
|
|
1245
1261
|
|
|
1246
1262
|
/**
|
|
1247
|
-
*
|
|
1248
|
-
* @returns {number}
|
|
1263
|
+
* Gets the vertical bounds alignment of this object.
|
|
1264
|
+
* @returns {number} The vertical bounds alignment.
|
|
1249
1265
|
*/
|
|
1250
1266
|
get boundsAlignV() {
|
|
1251
1267
|
return this.style.boundsAlignV;
|
|
1252
1268
|
}
|
|
1253
1269
|
|
|
1254
1270
|
/**
|
|
1255
|
-
*
|
|
1271
|
+
* Sets the vertical bounds alignment of this object.
|
|
1272
|
+
* @param {number} value - The new vertical bounds alignment to set.
|
|
1256
1273
|
*/
|
|
1257
1274
|
set boundsAlignV(value) {
|
|
1258
1275
|
if (value !== this.style.boundsAlignV) {
|
|
@@ -1262,15 +1279,16 @@ export class Text extends Image {
|
|
|
1262
1279
|
}
|
|
1263
1280
|
|
|
1264
1281
|
/**
|
|
1265
|
-
*
|
|
1266
|
-
* @returns {number}
|
|
1282
|
+
* Gets the stroke color of this object.
|
|
1283
|
+
* @returns {number} The stroke color.
|
|
1267
1284
|
*/
|
|
1268
1285
|
get stroke() {
|
|
1269
1286
|
return this.style.stroke;
|
|
1270
1287
|
}
|
|
1271
1288
|
|
|
1272
1289
|
/**
|
|
1273
|
-
*
|
|
1290
|
+
* Sets the stroke color of this object.
|
|
1291
|
+
* @param {string} value - The new stroke color to set.
|
|
1274
1292
|
*/
|
|
1275
1293
|
set stroke(value) {
|
|
1276
1294
|
if (value !== this.style.stroke) {
|
|
@@ -1280,15 +1298,16 @@ export class Text extends Image {
|
|
|
1280
1298
|
}
|
|
1281
1299
|
|
|
1282
1300
|
/**
|
|
1283
|
-
*
|
|
1284
|
-
* @returns {number}
|
|
1301
|
+
* Gets the stroke thickness of this object.
|
|
1302
|
+
* @returns {number} The stroke thickness.
|
|
1285
1303
|
*/
|
|
1286
1304
|
get strokeThickness() {
|
|
1287
1305
|
return this.style.strokeThickness;
|
|
1288
1306
|
}
|
|
1289
1307
|
|
|
1290
1308
|
/**
|
|
1291
|
-
*
|
|
1309
|
+
* Sets the stroke thickness of this object.
|
|
1310
|
+
* @param {number} value - The new stroke thickness to set.
|
|
1292
1311
|
*/
|
|
1293
1312
|
set strokeThickness(value) {
|
|
1294
1313
|
if (value !== this.style.strokeThickness) {
|
|
@@ -1298,15 +1317,16 @@ export class Text extends Image {
|
|
|
1298
1317
|
}
|
|
1299
1318
|
|
|
1300
1319
|
/**
|
|
1301
|
-
*
|
|
1302
|
-
* @returns {number}
|
|
1320
|
+
* Gets the word wrap setting of this object.
|
|
1321
|
+
* @returns {number} The word wrap setting.
|
|
1303
1322
|
*/
|
|
1304
1323
|
get wordWrap() {
|
|
1305
1324
|
return this.style.wordWrap;
|
|
1306
1325
|
}
|
|
1307
1326
|
|
|
1308
1327
|
/**
|
|
1309
|
-
*
|
|
1328
|
+
* Sets the word wrap setting of this object.
|
|
1329
|
+
* @param {boolean} value - The new word wrap setting to set.
|
|
1310
1330
|
*/
|
|
1311
1331
|
set wordWrap(value) {
|
|
1312
1332
|
if (value !== this.style.wordWrap) {
|
|
@@ -1316,15 +1336,16 @@ export class Text extends Image {
|
|
|
1316
1336
|
}
|
|
1317
1337
|
|
|
1318
1338
|
/**
|
|
1319
|
-
*
|
|
1320
|
-
* @returns {number}
|
|
1339
|
+
* Gets the word wrap width of this object.
|
|
1340
|
+
* @returns {number} The word wrap width.
|
|
1321
1341
|
*/
|
|
1322
1342
|
get wordWrapWidth() {
|
|
1323
1343
|
return this.style.wordWrapWidth;
|
|
1324
1344
|
}
|
|
1325
1345
|
|
|
1326
1346
|
/**
|
|
1327
|
-
*
|
|
1347
|
+
* Sets the word wrap width of this object.
|
|
1348
|
+
* @param {number} value - The new word wrap width to set.
|
|
1328
1349
|
*/
|
|
1329
1350
|
set wordWrapWidth(value) {
|
|
1330
1351
|
if (value !== this.style.wordWrapWidth) {
|
|
@@ -1334,15 +1355,16 @@ export class Text extends Image {
|
|
|
1334
1355
|
}
|
|
1335
1356
|
|
|
1336
1357
|
/**
|
|
1337
|
-
*
|
|
1338
|
-
* @returns {number}
|
|
1358
|
+
* Gets the line spacing of this object.
|
|
1359
|
+
* @returns {number} The line spacing.
|
|
1339
1360
|
*/
|
|
1340
1361
|
get lineSpacing() {
|
|
1341
1362
|
return this._lineSpacing;
|
|
1342
1363
|
}
|
|
1343
1364
|
|
|
1344
1365
|
/**
|
|
1345
|
-
*
|
|
1366
|
+
* Sets the line spacing of this object.
|
|
1367
|
+
* @param {number} value - The new line spacing to set.
|
|
1346
1368
|
*/
|
|
1347
1369
|
set lineSpacing(value) {
|
|
1348
1370
|
if (value !== this._lineSpacing) {
|
|
@@ -1355,15 +1377,16 @@ export class Text extends Image {
|
|
|
1355
1377
|
}
|
|
1356
1378
|
|
|
1357
1379
|
/**
|
|
1358
|
-
*
|
|
1359
|
-
* @returns {number}
|
|
1380
|
+
* Gets the shadow offset X of this object.
|
|
1381
|
+
* @returns {number} The shadow offset X.
|
|
1360
1382
|
*/
|
|
1361
1383
|
get shadowOffsetX() {
|
|
1362
1384
|
return this.style.shadowOffsetX;
|
|
1363
1385
|
}
|
|
1364
1386
|
|
|
1365
1387
|
/**
|
|
1366
|
-
*
|
|
1388
|
+
* Sets the shadow offset X of this object.
|
|
1389
|
+
* @param {number} value - The new shadow offset X to set.
|
|
1367
1390
|
*/
|
|
1368
1391
|
set shadowOffsetX(value) {
|
|
1369
1392
|
if (value !== this.style.shadowOffsetX) {
|
|
@@ -1373,15 +1396,16 @@ export class Text extends Image {
|
|
|
1373
1396
|
}
|
|
1374
1397
|
|
|
1375
1398
|
/**
|
|
1376
|
-
*
|
|
1377
|
-
* @returns {number}
|
|
1399
|
+
* Gets the shadow offset Y of this object.
|
|
1400
|
+
* @returns {number} The shadow offset Y.
|
|
1378
1401
|
*/
|
|
1379
1402
|
get shadowOffsetY() {
|
|
1380
1403
|
return this.style.shadowOffsetY;
|
|
1381
1404
|
}
|
|
1382
1405
|
|
|
1383
1406
|
/**
|
|
1384
|
-
*
|
|
1407
|
+
* Sets the shadow offset Y of this object.
|
|
1408
|
+
* @param {number} value - The new shadow offset Y to set.
|
|
1385
1409
|
*/
|
|
1386
1410
|
set shadowOffsetY(value) {
|
|
1387
1411
|
if (value !== this.style.shadowOffsetY) {
|
|
@@ -1391,15 +1415,16 @@ export class Text extends Image {
|
|
|
1391
1415
|
}
|
|
1392
1416
|
|
|
1393
1417
|
/**
|
|
1394
|
-
*
|
|
1395
|
-
* @returns {number}
|
|
1418
|
+
* Gets the shadow color of this object.
|
|
1419
|
+
* @returns {number} The shadow color.
|
|
1396
1420
|
*/
|
|
1397
1421
|
get shadowColor() {
|
|
1398
1422
|
return this.style.shadowColor;
|
|
1399
1423
|
}
|
|
1400
1424
|
|
|
1401
1425
|
/**
|
|
1402
|
-
*
|
|
1426
|
+
* Sets the shadow color of this object.
|
|
1427
|
+
* @param {string} value - The new shadow color to set.
|
|
1403
1428
|
*/
|
|
1404
1429
|
set shadowColor(value) {
|
|
1405
1430
|
if (value !== this.style.shadowColor) {
|
|
@@ -1409,15 +1434,16 @@ export class Text extends Image {
|
|
|
1409
1434
|
}
|
|
1410
1435
|
|
|
1411
1436
|
/**
|
|
1412
|
-
*
|
|
1413
|
-
* @returns {number}
|
|
1437
|
+
* Gets the shadow blur of this object.
|
|
1438
|
+
* @returns {number} The shadow blur.
|
|
1414
1439
|
*/
|
|
1415
1440
|
get shadowBlur() {
|
|
1416
1441
|
return this.style.shadowBlur;
|
|
1417
1442
|
}
|
|
1418
1443
|
|
|
1419
1444
|
/**
|
|
1420
|
-
*
|
|
1445
|
+
* Sets the shadow blur of this object.
|
|
1446
|
+
* @param {number} value - The new shadow blur to set.
|
|
1421
1447
|
*/
|
|
1422
1448
|
set shadowBlur(value) {
|
|
1423
1449
|
if (value !== this.style.shadowBlur) {
|
|
@@ -1427,15 +1453,16 @@ export class Text extends Image {
|
|
|
1427
1453
|
}
|
|
1428
1454
|
|
|
1429
1455
|
/**
|
|
1430
|
-
*
|
|
1431
|
-
* @returns {number}
|
|
1456
|
+
* Gets the shadow stroke setting of this object.
|
|
1457
|
+
* @returns {number} The shadow stroke setting.
|
|
1432
1458
|
*/
|
|
1433
1459
|
get shadowStroke() {
|
|
1434
1460
|
return this.style.shadowStroke;
|
|
1435
1461
|
}
|
|
1436
1462
|
|
|
1437
1463
|
/**
|
|
1438
|
-
*
|
|
1464
|
+
* Sets the shadow stroke setting of this object.
|
|
1465
|
+
* @param {boolean} value - The new shadow stroke setting to set.
|
|
1439
1466
|
*/
|
|
1440
1467
|
set shadowStroke(value) {
|
|
1441
1468
|
if (value !== this.style.shadowStroke) {
|
|
@@ -1445,15 +1472,16 @@ export class Text extends Image {
|
|
|
1445
1472
|
}
|
|
1446
1473
|
|
|
1447
1474
|
/**
|
|
1448
|
-
*
|
|
1449
|
-
* @returns {number}
|
|
1475
|
+
* Gets the shadow fill setting of this object.
|
|
1476
|
+
* @returns {number} The shadow fill setting.
|
|
1450
1477
|
*/
|
|
1451
1478
|
get shadowFill() {
|
|
1452
1479
|
return this.style.shadowFill;
|
|
1453
1480
|
}
|
|
1454
1481
|
|
|
1455
1482
|
/**
|
|
1456
|
-
*
|
|
1483
|
+
* Sets the shadow fill setting of this object.
|
|
1484
|
+
* @param {boolean} value - The new shadow fill setting to set.
|
|
1457
1485
|
*/
|
|
1458
1486
|
set shadowFill(value) {
|
|
1459
1487
|
if (value !== this.style.shadowFill) {
|
|
@@ -1463,8 +1491,8 @@ export class Text extends Image {
|
|
|
1463
1491
|
}
|
|
1464
1492
|
|
|
1465
1493
|
/**
|
|
1466
|
-
*
|
|
1467
|
-
* @returns {number}
|
|
1494
|
+
* Gets the width of this object.
|
|
1495
|
+
* @returns {number} The width in pixels.
|
|
1468
1496
|
*/
|
|
1469
1497
|
get width() {
|
|
1470
1498
|
if (this.dirty) {
|
|
@@ -1475,7 +1503,8 @@ export class Text extends Image {
|
|
|
1475
1503
|
}
|
|
1476
1504
|
|
|
1477
1505
|
/**
|
|
1478
|
-
*
|
|
1506
|
+
* Sets the width of this object.
|
|
1507
|
+
* @param {number} value - The new width to set in pixels.
|
|
1479
1508
|
*/
|
|
1480
1509
|
set width(value) {
|
|
1481
1510
|
this.scale.x = value / this.texture.frame.width;
|
|
@@ -1483,8 +1512,8 @@ export class Text extends Image {
|
|
|
1483
1512
|
}
|
|
1484
1513
|
|
|
1485
1514
|
/**
|
|
1486
|
-
*
|
|
1487
|
-
* @returns {number}
|
|
1515
|
+
* Gets the height of this object.
|
|
1516
|
+
* @returns {number} The height in pixels.
|
|
1488
1517
|
*/
|
|
1489
1518
|
get height() {
|
|
1490
1519
|
if (this.dirty) {
|
|
@@ -1495,7 +1524,8 @@ export class Text extends Image {
|
|
|
1495
1524
|
}
|
|
1496
1525
|
|
|
1497
1526
|
/**
|
|
1498
|
-
*
|
|
1527
|
+
* Sets the height of this object.
|
|
1528
|
+
* @param {number} value - The new height to set in pixels.
|
|
1499
1529
|
*/
|
|
1500
1530
|
set height(value) {
|
|
1501
1531
|
this.scale.y = value / this.texture.frame.height;
|