@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
|
@@ -26,36 +26,53 @@ import { textureFromCanvas } from './webgl/texture_util.js';
|
|
|
26
26
|
|
|
27
27
|
export class Graphics extends DisplayObject {
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @param {import('../core/game.js').Game} game -
|
|
31
|
-
* @param {number} x -
|
|
32
|
-
* @param {number} y -
|
|
29
|
+
* Creates a new Graphics object.
|
|
30
|
+
* @param {import('../core/game.js').Game} game - The game instance.
|
|
31
|
+
* @param {number} x - The x coordinate of the graphics object.
|
|
32
|
+
* @param {number} y - The y coordinate of the graphics object.
|
|
33
33
|
*/
|
|
34
34
|
constructor(game, x = 0, y = 0) {
|
|
35
35
|
super(game);
|
|
36
|
+
/** @type {number} */
|
|
36
37
|
this.type = GRAPHICS;
|
|
37
38
|
this.position.setTo(x, y);
|
|
39
|
+
/** @type {boolean} */
|
|
38
40
|
this.renderable = true;
|
|
41
|
+
/** @type {number} */
|
|
39
42
|
this.fillAlpha = 1;
|
|
43
|
+
/** @type {number} */
|
|
40
44
|
this.lineWidth = 0;
|
|
45
|
+
/** @type {number} */
|
|
41
46
|
this.lineColor = 0;
|
|
42
47
|
this.graphicsData = [];
|
|
48
|
+
/** @type {number} */
|
|
43
49
|
this.tint = 0xffffff;
|
|
50
|
+
/** @type {number} */
|
|
44
51
|
this.blendMode = BLEND_NORMAL;
|
|
52
|
+
/** @type {GraphicsData} */
|
|
45
53
|
this.currentPath = null;
|
|
54
|
+
/** @type {object[]} */
|
|
46
55
|
this._webGL = [];
|
|
56
|
+
/** @type {boolean} */
|
|
47
57
|
this.isMask = false;
|
|
58
|
+
/** @type {number} */
|
|
48
59
|
this.boundsPadding = 0;
|
|
60
|
+
/** @type {Rectangle} */
|
|
49
61
|
this._localBounds = new Rectangle(0, 0, 1, 1);
|
|
62
|
+
/** @type {boolean} */
|
|
50
63
|
this.dirty = true;
|
|
64
|
+
/** @type {boolean} */
|
|
51
65
|
this._boundsDirty = false;
|
|
66
|
+
/** @type {boolean} */
|
|
52
67
|
this._cacheAsBitmap = false;
|
|
68
|
+
/** @type {boolean} */
|
|
53
69
|
this.webGLDirty = false;
|
|
70
|
+
/** @type {boolean} */
|
|
54
71
|
this.cachedSpriteDirty = false;
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
/**
|
|
58
|
-
*
|
|
75
|
+
* Destroys the graphics object and clears all data.
|
|
59
76
|
*/
|
|
60
77
|
destroy() {
|
|
61
78
|
// TODO
|
|
@@ -64,11 +81,11 @@ export class Graphics extends DisplayObject {
|
|
|
64
81
|
}
|
|
65
82
|
|
|
66
83
|
/**
|
|
67
|
-
*
|
|
68
|
-
* @param {number} lineWidth -
|
|
69
|
-
* @param {number} color -
|
|
70
|
-
* @param {number} alpha -
|
|
71
|
-
* @returns {Graphics}
|
|
84
|
+
* Sets the line style for subsequent drawing operations.
|
|
85
|
+
* @param {number} lineWidth - The width of the line to draw.
|
|
86
|
+
* @param {number} color - The color of the line to draw.
|
|
87
|
+
* @param {number} alpha - The alpha (transparency) of the line to draw.
|
|
88
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
72
89
|
*/
|
|
73
90
|
lineStyle(lineWidth = 0, color = 0, alpha = 1) {
|
|
74
91
|
this.lineWidth = lineWidth || 0;
|
|
@@ -89,10 +106,10 @@ export class Graphics extends DisplayObject {
|
|
|
89
106
|
}
|
|
90
107
|
|
|
91
108
|
/**
|
|
92
|
-
*
|
|
93
|
-
* @param {number} x -
|
|
94
|
-
* @param {number} y -
|
|
95
|
-
* @returns {Graphics}
|
|
109
|
+
* Moves the drawing cursor to the specified point.
|
|
110
|
+
* @param {number} x - The x coordinate to move to.
|
|
111
|
+
* @param {number} y - The y coordinate to move to.
|
|
112
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
96
113
|
*/
|
|
97
114
|
moveTo(x, y) {
|
|
98
115
|
this.drawShape(new Polygon([x, y]));
|
|
@@ -100,10 +117,10 @@ export class Graphics extends DisplayObject {
|
|
|
100
117
|
}
|
|
101
118
|
|
|
102
119
|
/**
|
|
103
|
-
*
|
|
104
|
-
* @param {number} x -
|
|
105
|
-
* @param {number} y -
|
|
106
|
-
* @returns {Graphics}
|
|
120
|
+
* Draws a line from the current drawing position to the specified point.
|
|
121
|
+
* @param {number} x - The x coordinate to draw to.
|
|
122
|
+
* @param {number} y - The y coordinate to draw to.
|
|
123
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
107
124
|
*/
|
|
108
125
|
lineTo(x, y) {
|
|
109
126
|
if (!this.currentPath) {
|
|
@@ -116,12 +133,12 @@ export class Graphics extends DisplayObject {
|
|
|
116
133
|
}
|
|
117
134
|
|
|
118
135
|
/**
|
|
119
|
-
*
|
|
120
|
-
* @param {number} cpX -
|
|
121
|
-
* @param {number} cpY -
|
|
122
|
-
* @param {number} toX -
|
|
123
|
-
* @param {number} toY -
|
|
124
|
-
* @returns {Graphics}
|
|
136
|
+
* Draws a quadratic curve from the current position to the specified point.
|
|
137
|
+
* @param {number} cpX - The x coordinate of the control point.
|
|
138
|
+
* @param {number} cpY - The y coordinate of the control point.
|
|
139
|
+
* @param {number} toX - The x coordinate to draw to.
|
|
140
|
+
* @param {number} toY - The y coordinate to draw to.
|
|
141
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
125
142
|
*/
|
|
126
143
|
quadraticCurveTo(cpX, cpY, toX, toY) {
|
|
127
144
|
if (this.currentPath) {
|
|
@@ -153,14 +170,14 @@ export class Graphics extends DisplayObject {
|
|
|
153
170
|
}
|
|
154
171
|
|
|
155
172
|
/**
|
|
156
|
-
*
|
|
157
|
-
* @param {number} cpX -
|
|
158
|
-
* @param {number} cpY -
|
|
159
|
-
* @param {number} cpX2 -
|
|
160
|
-
* @param {number} cpY2 -
|
|
161
|
-
* @param {number} toX -
|
|
162
|
-
* @param {number} toY -
|
|
163
|
-
* @returns {Graphics}
|
|
173
|
+
* Draws a cubic Bezier curve from the current position to the specified point.
|
|
174
|
+
* @param {number} cpX - The x coordinate of the first control point.
|
|
175
|
+
* @param {number} cpY - The y coordinate of the first control point.
|
|
176
|
+
* @param {number} cpX2 - The x coordinate of the second control point.
|
|
177
|
+
* @param {number} cpY2 - The y coordinate of the second control point.
|
|
178
|
+
* @param {number} toX - The x coordinate to draw to.
|
|
179
|
+
* @param {number} toY - The y coordinate to draw to.
|
|
180
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
164
181
|
*/
|
|
165
182
|
bezierCurveTo(cpX, cpY, cpX2, cpY2, toX, toY) {
|
|
166
183
|
if (this.currentPath) {
|
|
@@ -198,13 +215,13 @@ export class Graphics extends DisplayObject {
|
|
|
198
215
|
}
|
|
199
216
|
|
|
200
217
|
/**
|
|
201
|
-
*
|
|
202
|
-
* @param {number} x1 -
|
|
203
|
-
* @param {number} y1 -
|
|
204
|
-
* @param {number} x2 -
|
|
205
|
-
* @param {number} y2 -
|
|
206
|
-
* @param {number} radius -
|
|
207
|
-
* @returns {Graphics}
|
|
218
|
+
* Draws an arc from the current position to the specified point.
|
|
219
|
+
* @param {number} x1 - The x coordinate of the starting point.
|
|
220
|
+
* @param {number} y1 - The y coordinate of the starting point.
|
|
221
|
+
* @param {number} x2 - The x coordinate of the end point.
|
|
222
|
+
* @param {number} y2 - The y coordinate of the end point.
|
|
223
|
+
* @param {number} radius - The radius of the arc.
|
|
224
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
208
225
|
*/
|
|
209
226
|
arcTo(x1, y1, x2, y2, radius) {
|
|
210
227
|
if (this.currentPath) {
|
|
@@ -250,15 +267,15 @@ export class Graphics extends DisplayObject {
|
|
|
250
267
|
}
|
|
251
268
|
|
|
252
269
|
/**
|
|
253
|
-
*
|
|
254
|
-
* @param {number} cx -
|
|
255
|
-
* @param {number} cy -
|
|
256
|
-
* @param {number} radius -
|
|
257
|
-
* @param {number} startAngle -
|
|
258
|
-
* @param {number} endAngle -
|
|
259
|
-
* @param {boolean} anticlockwise -
|
|
260
|
-
* @param {number} segments -
|
|
261
|
-
* @returns {Graphics}
|
|
270
|
+
* Draws an arc with the specified center, radius, and angles.
|
|
271
|
+
* @param {number} cx - The x coordinate of the center point.
|
|
272
|
+
* @param {number} cy - The y coordinate of the center point.
|
|
273
|
+
* @param {number} radius - The radius of the arc.
|
|
274
|
+
* @param {number} startAngle - The starting angle in radians.
|
|
275
|
+
* @param {number} endAngle - The ending angle in radians.
|
|
276
|
+
* @param {boolean} anticlockwise - Whether to draw the arc anticlockwise.
|
|
277
|
+
* @param {number} segments - The number of segments to use for drawing the arc.
|
|
278
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
262
279
|
*/
|
|
263
280
|
arc(cx, cy, radius, startAngle, endAngle, anticlockwise = false, segments = 40) {
|
|
264
281
|
// If we do this we can never draw a full circle
|
|
@@ -304,10 +321,10 @@ export class Graphics extends DisplayObject {
|
|
|
304
321
|
}
|
|
305
322
|
|
|
306
323
|
/**
|
|
307
|
-
*
|
|
308
|
-
* @param {number} color -
|
|
309
|
-
* @param {number} alpha -
|
|
310
|
-
* @returns {Graphics}
|
|
324
|
+
* Begins filling with the specified color and alpha.
|
|
325
|
+
* @param {number} color - The fill color to use.
|
|
326
|
+
* @param {number} alpha - The fill alpha (transparency) to use.
|
|
327
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
311
328
|
*/
|
|
312
329
|
beginFill(color = 0, alpha = 1) {
|
|
313
330
|
this.filling = true;
|
|
@@ -324,8 +341,8 @@ export class Graphics extends DisplayObject {
|
|
|
324
341
|
}
|
|
325
342
|
|
|
326
343
|
/**
|
|
327
|
-
*
|
|
328
|
-
* @returns {Graphics}
|
|
344
|
+
* Ends the current fill operation.
|
|
345
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
329
346
|
*/
|
|
330
347
|
endFill() {
|
|
331
348
|
this.filling = false;
|
|
@@ -335,12 +352,12 @@ export class Graphics extends DisplayObject {
|
|
|
335
352
|
}
|
|
336
353
|
|
|
337
354
|
/**
|
|
338
|
-
*
|
|
339
|
-
* @param {number} x -
|
|
340
|
-
* @param {number} y -
|
|
341
|
-
* @param {number} width -
|
|
342
|
-
* @param {number} height -
|
|
343
|
-
* @returns {Graphics}
|
|
355
|
+
* Draws a rectangle with the specified properties.
|
|
356
|
+
* @param {number} x - The x coordinate of the rectangle.
|
|
357
|
+
* @param {number} y - The y coordinate of the rectangle.
|
|
358
|
+
* @param {number} width - The width of the rectangle.
|
|
359
|
+
* @param {number} height - The height of the rectangle.
|
|
360
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
344
361
|
*/
|
|
345
362
|
drawRect(x, y, width, height) {
|
|
346
363
|
this.drawShape(new Rectangle(x, y, width, height));
|
|
@@ -348,13 +365,13 @@ export class Graphics extends DisplayObject {
|
|
|
348
365
|
}
|
|
349
366
|
|
|
350
367
|
/**
|
|
351
|
-
*
|
|
352
|
-
* @param {number} x -
|
|
353
|
-
* @param {number} y -
|
|
354
|
-
* @param {number} width -
|
|
355
|
-
* @param {number} height -
|
|
356
|
-
* @param {number} radius -
|
|
357
|
-
* @returns {Graphics}
|
|
368
|
+
* Draws a rounded rectangle with the specified properties.
|
|
369
|
+
* @param {number} x - The x coordinate of the rectangle.
|
|
370
|
+
* @param {number} y - The y coordinate of the rectangle.
|
|
371
|
+
* @param {number} width - The width of the rectangle.
|
|
372
|
+
* @param {number} height - The height of the rectangle.
|
|
373
|
+
* @param {number} radius - The radius of the rounded corners.
|
|
374
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
358
375
|
*/
|
|
359
376
|
drawRoundedRect(x, y, width, height, radius) {
|
|
360
377
|
this.drawShape(new RoundedRectangle(x, y, width, height, radius));
|
|
@@ -362,11 +379,11 @@ export class Graphics extends DisplayObject {
|
|
|
362
379
|
}
|
|
363
380
|
|
|
364
381
|
/**
|
|
365
|
-
*
|
|
366
|
-
* @param {number} x -
|
|
367
|
-
* @param {number} y -
|
|
368
|
-
* @param {number} diameter -
|
|
369
|
-
* @returns {Graphics}
|
|
382
|
+
* Draws a circle with the specified properties.
|
|
383
|
+
* @param {number} x - The x coordinate of the center point.
|
|
384
|
+
* @param {number} y - The y coordinate of the center point.
|
|
385
|
+
* @param {number} diameter - The diameter of the circle.
|
|
386
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
370
387
|
*/
|
|
371
388
|
drawCircle(x, y, diameter) {
|
|
372
389
|
this.drawShape(new Circle(x, y, diameter));
|
|
@@ -374,12 +391,12 @@ export class Graphics extends DisplayObject {
|
|
|
374
391
|
}
|
|
375
392
|
|
|
376
393
|
/**
|
|
377
|
-
*
|
|
378
|
-
* @param {number} x -
|
|
379
|
-
* @param {number} y -
|
|
380
|
-
* @param {number} width -
|
|
381
|
-
* @param {number} height -
|
|
382
|
-
* @returns {Graphics}
|
|
394
|
+
* Draws an ellipse with the specified properties.
|
|
395
|
+
* @param {number} x - The x coordinate of the center point.
|
|
396
|
+
* @param {number} y - The y coordinate of the center point.
|
|
397
|
+
* @param {number} width - The width of the ellipse.
|
|
398
|
+
* @param {number} height - The height of the ellipse.
|
|
399
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
383
400
|
*/
|
|
384
401
|
drawEllipse(x, y, width, height) {
|
|
385
402
|
this.drawShape(new Ellipse(x, y, width, height));
|
|
@@ -387,9 +404,9 @@ export class Graphics extends DisplayObject {
|
|
|
387
404
|
}
|
|
388
405
|
|
|
389
406
|
/**
|
|
390
|
-
*
|
|
391
|
-
* @param {Polygon} path -
|
|
392
|
-
* @returns {Graphics}
|
|
407
|
+
* Draws a polygon with the specified path.
|
|
408
|
+
* @param {Polygon} path - The polygon to draw.
|
|
409
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
393
410
|
*/
|
|
394
411
|
drawPolygon(path) {
|
|
395
412
|
let points;
|
|
@@ -412,8 +429,8 @@ export class Graphics extends DisplayObject {
|
|
|
412
429
|
}
|
|
413
430
|
|
|
414
431
|
/**
|
|
415
|
-
*
|
|
416
|
-
* @returns {Graphics}
|
|
432
|
+
* Clears all graphics data.
|
|
433
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
417
434
|
*/
|
|
418
435
|
clear() {
|
|
419
436
|
this.lineWidth = 0;
|
|
@@ -427,7 +444,7 @@ export class Graphics extends DisplayObject {
|
|
|
427
444
|
}
|
|
428
445
|
|
|
429
446
|
/**
|
|
430
|
-
*
|
|
447
|
+
* Generates a texture from the graphics object (not implemented).
|
|
431
448
|
*/
|
|
432
449
|
generateTexture() {
|
|
433
450
|
// TODO
|
|
@@ -435,8 +452,8 @@ export class Graphics extends DisplayObject {
|
|
|
435
452
|
}
|
|
436
453
|
|
|
437
454
|
/**
|
|
438
|
-
*
|
|
439
|
-
* @param {object} renderSession -
|
|
455
|
+
* Renders the graphics object using WebGL.
|
|
456
|
+
* @param {object} renderSession - The render session to use.
|
|
440
457
|
*/
|
|
441
458
|
renderWebGL(renderSession) {
|
|
442
459
|
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
|
@@ -495,8 +512,8 @@ export class Graphics extends DisplayObject {
|
|
|
495
512
|
}
|
|
496
513
|
|
|
497
514
|
/**
|
|
498
|
-
*
|
|
499
|
-
* @param {object} renderSession -
|
|
515
|
+
* Renders the graphics object using Canvas.
|
|
516
|
+
* @param {object} renderSession - The render session to use.
|
|
500
517
|
*/
|
|
501
518
|
renderCanvas(renderSession) {
|
|
502
519
|
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
|
@@ -551,9 +568,9 @@ export class Graphics extends DisplayObject {
|
|
|
551
568
|
}
|
|
552
569
|
|
|
553
570
|
/**
|
|
554
|
-
*
|
|
555
|
-
* @param {import('../geom/matrix.js').Matrix} matrix -
|
|
556
|
-
* @returns {Rectangle}
|
|
571
|
+
* Gets the bounds of the graphics object.
|
|
572
|
+
* @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
|
|
573
|
+
* @returns {Rectangle} The bounds rectangle of the graphics object.
|
|
557
574
|
*/
|
|
558
575
|
getBounds(matrix = null) {
|
|
559
576
|
if (!this.renderable) {
|
|
@@ -612,8 +629,8 @@ export class Graphics extends DisplayObject {
|
|
|
612
629
|
}
|
|
613
630
|
|
|
614
631
|
/**
|
|
615
|
-
*
|
|
616
|
-
* @returns {Rectangle}
|
|
632
|
+
* Gets the local bounds of the graphics object.
|
|
633
|
+
* @returns {Rectangle} The local bounds rectangle of the graphics object.
|
|
617
634
|
*/
|
|
618
635
|
getLocalBounds() {
|
|
619
636
|
const matrixCache = this.worldTransform;
|
|
@@ -630,10 +647,10 @@ export class Graphics extends DisplayObject {
|
|
|
630
647
|
}
|
|
631
648
|
|
|
632
649
|
/**
|
|
633
|
-
*
|
|
634
|
-
* @param {Point} point -
|
|
635
|
-
* @param {Point} tempPoint -
|
|
636
|
-
* @returns {boolean}
|
|
650
|
+
* Checks if the graphics object contains a point.
|
|
651
|
+
* @param {Point} point - The point to check.
|
|
652
|
+
* @param {Point} tempPoint - A temporary point object to use.
|
|
653
|
+
* @returns {boolean} True if the graphics object contains the point, otherwise false.
|
|
637
654
|
*/
|
|
638
655
|
containsPoint(point, tempPoint) {
|
|
639
656
|
this.worldTransform.applyInverse(point, tempPoint);
|
|
@@ -650,7 +667,7 @@ export class Graphics extends DisplayObject {
|
|
|
650
667
|
}
|
|
651
668
|
|
|
652
669
|
/**
|
|
653
|
-
*
|
|
670
|
+
* Updates the local bounds of the graphics object.
|
|
654
671
|
*/
|
|
655
672
|
updateLocalBounds() {
|
|
656
673
|
let minX = Infinity;
|
|
@@ -731,7 +748,7 @@ export class Graphics extends DisplayObject {
|
|
|
731
748
|
}
|
|
732
749
|
|
|
733
750
|
/**
|
|
734
|
-
*
|
|
751
|
+
* Generates a cached sprite representation of the graphics object.
|
|
735
752
|
*/
|
|
736
753
|
generateCachedSprite() {
|
|
737
754
|
const bounds = this.getLocalBounds();
|
|
@@ -757,7 +774,7 @@ export class Graphics extends DisplayObject {
|
|
|
757
774
|
}
|
|
758
775
|
|
|
759
776
|
/**
|
|
760
|
-
*
|
|
777
|
+
* Updates the cached sprite texture.
|
|
761
778
|
*/
|
|
762
779
|
updateCachedSpriteTexture() {
|
|
763
780
|
const cachedSprite = this._cachedSprite;
|
|
@@ -776,7 +793,7 @@ export class Graphics extends DisplayObject {
|
|
|
776
793
|
}
|
|
777
794
|
|
|
778
795
|
/**
|
|
779
|
-
*
|
|
796
|
+
* Destroys the cached sprite.
|
|
780
797
|
*/
|
|
781
798
|
destroyCachedSprite() {
|
|
782
799
|
if (!this._cachedSprite) {
|
|
@@ -787,9 +804,9 @@ export class Graphics extends DisplayObject {
|
|
|
787
804
|
}
|
|
788
805
|
|
|
789
806
|
/**
|
|
790
|
-
*
|
|
791
|
-
* @param {object} shape -
|
|
792
|
-
* @returns {GraphicsData}
|
|
807
|
+
* Draws a shape with the specified properties.
|
|
808
|
+
* @param {object} shape - The shape to draw.
|
|
809
|
+
* @returns {GraphicsData} The graphics data for the drawn shape.
|
|
793
810
|
*/
|
|
794
811
|
drawShape(shape) {
|
|
795
812
|
if (this.currentPath) {
|
|
@@ -824,7 +841,7 @@ export class Graphics extends DisplayObject {
|
|
|
824
841
|
}
|
|
825
842
|
|
|
826
843
|
/**
|
|
827
|
-
*
|
|
844
|
+
* Performs post-update operations for the graphics object.
|
|
828
845
|
*/
|
|
829
846
|
postUpdate() {
|
|
830
847
|
if (this._boundsDirty) {
|
|
@@ -837,9 +854,9 @@ export class Graphics extends DisplayObject {
|
|
|
837
854
|
}
|
|
838
855
|
|
|
839
856
|
/**
|
|
840
|
-
*
|
|
841
|
-
* @param {Point[]} points -
|
|
842
|
-
* @param {boolean} cull -
|
|
857
|
+
* Draws a triangle with the specified points and culling options.
|
|
858
|
+
* @param {Point[]} points - The points of the triangle.
|
|
859
|
+
* @param {boolean} cull - Whether to perform backface culling.
|
|
843
860
|
*/
|
|
844
861
|
drawTriangle(points, cull = false) {
|
|
845
862
|
const triangle = new Polygon(points);
|
|
@@ -857,10 +874,10 @@ export class Graphics extends DisplayObject {
|
|
|
857
874
|
}
|
|
858
875
|
|
|
859
876
|
/**
|
|
860
|
-
*
|
|
861
|
-
* @param {number[]|Point[]} vertices -
|
|
862
|
-
* @param {number[]} indices -
|
|
863
|
-
* @param {boolean} cull -
|
|
877
|
+
* Draws triangles with the specified vertices and indices.
|
|
878
|
+
* @param {number[]|Point[]} vertices - The vertices of the triangles.
|
|
879
|
+
* @param {number[]} indices - The indices of the vertices to use.
|
|
880
|
+
* @param {boolean} cull - Whether to perform backface culling.
|
|
864
881
|
*/
|
|
865
882
|
drawTriangles(vertices, indices, cull = false) {
|
|
866
883
|
const point1 = new Point();
|
|
@@ -2,14 +2,14 @@ import { clone } from './graphics_data_util.js';
|
|
|
2
2
|
|
|
3
3
|
export class GraphicsData {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {number} lineWidth -
|
|
7
|
-
* @param {number} lineColor -
|
|
8
|
-
* @param {number} lineAlpha -
|
|
9
|
-
* @param {number} fillColor -
|
|
10
|
-
* @param {number} fillAlpha -
|
|
11
|
-
* @param {boolean} fill -
|
|
12
|
-
* @param {object} shape -
|
|
5
|
+
* Creates a new GraphicsData object.
|
|
6
|
+
* @param {number} lineWidth - The line width.
|
|
7
|
+
* @param {number} lineColor - The line color.
|
|
8
|
+
* @param {number} lineAlpha - The line alpha.
|
|
9
|
+
* @param {number} fillColor - The fill color.
|
|
10
|
+
* @param {number} fillAlpha - The fill alpha.
|
|
11
|
+
* @param {boolean} fill - Whether to fill the shape.
|
|
12
|
+
* @param {object} shape - The shape to draw.
|
|
13
13
|
*/
|
|
14
14
|
constructor(lineWidth, lineColor, lineAlpha, fillColor, fillAlpha, fill, shape) {
|
|
15
15
|
this.lineWidth = lineWidth;
|
|
@@ -25,8 +25,8 @@ export class GraphicsData {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @returns {GraphicsData}
|
|
28
|
+
* Clones this GraphicsData object.
|
|
29
|
+
* @returns {GraphicsData} A new cloned GraphicsData object.
|
|
30
30
|
*/
|
|
31
31
|
clone() {
|
|
32
32
|
return clone(this);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { GraphicsData } from './graphics_data.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {GraphicsData} source -
|
|
6
|
-
* @returns {GraphicsData}
|
|
4
|
+
* Clones a GraphicsData object.
|
|
5
|
+
* @param {GraphicsData} source - The source GraphicsData to clone.
|
|
6
|
+
* @returns {GraphicsData} A new cloned GraphicsData object.
|
|
7
7
|
*/
|
|
8
8
|
export const clone = (source) => {
|
|
9
9
|
return new GraphicsData(
|