@vpmedia/phaser 1.95.0 → 1.97.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 +51 -0
- package/package.json +10 -10
- package/src/phaser/core/animation.js +61 -56
- package/src/phaser/core/animation_manager.js +55 -55
- 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 +34 -18
- package/src/phaser/core/loader.js +170 -170
- package/src/phaser/core/loader_parser.js +22 -22
- package/src/phaser/core/raf.js +1 -1
- package/src/phaser/core/scene.js +16 -10
- package/src/phaser/core/scene_manager.js +51 -43
- package/src/phaser/core/signal.js +68 -52
- package/src/phaser/core/signal.test.js +37 -0
- 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 +30 -30
- package/src/phaser/core/timer.js +79 -64
- package/src/phaser/core/timer_event.js +9 -9
- package/src/phaser/core/tween.js +90 -90
- package/src/phaser/core/tween_data.js +30 -30
- package/src/phaser/core/tween_manager.js +29 -24
- package/src/phaser/core/world.js +4 -3
- package/src/phaser/display/bitmap_text.js +61 -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 +16 -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 +112 -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 +50 -50
- package/src/phaser/display/image.js +54 -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 +212 -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 +20 -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 +69 -69
- package/src/phaser/geom/circle.test.js +1 -0
- package/src/phaser/geom/ellipse.js +28 -28
- package/src/phaser/geom/ellipse.test.js +1 -0
- package/src/phaser/geom/line.js +93 -93
- package/src/phaser/geom/line.test.js +1 -0
- package/src/phaser/geom/matrix.js +54 -54
- package/src/phaser/geom/matrix.test.js +1 -0
- package/src/phaser/geom/point.js +96 -96
- package/src/phaser/geom/point.test.js +1 -0
- package/src/phaser/geom/polygon.js +22 -22
- package/src/phaser/geom/rectangle.js +132 -132
- package/src/phaser/geom/rectangle.test.js +1 -0
- package/src/phaser/geom/rounded_rectangle.js +12 -12
- package/src/phaser/geom/rounded_rectangle.test.js +1 -0
- package/src/phaser/geom/util/circle.js +33 -33
- package/src/phaser/geom/util/circle.test.js +1 -0
- package/src/phaser/geom/util/ellipse.js +5 -5
- package/src/phaser/geom/util/ellipse.test.js +1 -0
- package/src/phaser/geom/util/line.js +26 -26
- package/src/phaser/geom/util/line.test.js +1 -0
- package/src/phaser/geom/util/matrix.js +8 -8
- package/src/phaser/geom/util/matrix.test.js +1 -0
- package/src/phaser/geom/util/point.js +97 -97
- package/src/phaser/geom/util/point.test.js +1 -0
- package/src/phaser/geom/util/polygon.js +4 -4
- package/src/phaser/geom/util/polygon.test.js +1 -0
- package/src/phaser/geom/util/rectangle.js +74 -74
- package/src/phaser/geom/util/rectangle.test.js +1 -0
- package/src/phaser/geom/util/rounded_rectangle.js +4 -4
- package/src/phaser/geom/util/rounded_rectangle.test.js +1 -0
- package/src/phaser/util/math.js +81 -81
- package/src/phaser/util/math.test.js +1 -0
- package/types/phaser/core/animation.d.ts +61 -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/cache.d.ts +154 -154
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +43 -43
- 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 +52 -19
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +170 -170
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +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 +30 -30
- package/types/phaser/core/timer.d.ts +64 -64
- package/types/phaser/core/timer_event.d.ts +9 -9
- package/types/phaser/core/tween.d.ts +90 -90
- package/types/phaser/core/tween_data.d.ts +30 -30
- package/types/phaser/core/tween_manager.d.ts +29 -24
- 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 +59 -52
- 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/renderer.d.ts +16 -16
- 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 +101 -101
- package/types/phaser/display/graphics_data.d.ts +10 -10
- package/types/phaser/display/group.d.ts +47 -47
- package/types/phaser/display/image.d.ts +42 -40
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +207 -184
- 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 +9 -9
- 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_data.d.ts +4 -4
- package/types/phaser/display/webgl/render_texture.d.ts +16 -16
- package/types/phaser/display/webgl/renderer.d.ts +20 -20
- 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/geom/circle.d.ts +69 -69
- package/types/phaser/geom/ellipse.d.ts +28 -28
- package/types/phaser/geom/line.d.ts +93 -93
- package/types/phaser/geom/matrix.d.ts +54 -54
- package/types/phaser/geom/point.d.ts +96 -96
- package/types/phaser/geom/polygon.d.ts +22 -22
- package/types/phaser/geom/rectangle.d.ts +132 -132
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
- package/pnpm-workspace.yaml +0 -4
|
@@ -26,10 +26,10 @@ 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);
|
|
@@ -72,7 +72,7 @@ export class Graphics extends DisplayObject {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
75
|
+
* Destroys the graphics object and clears all data.
|
|
76
76
|
*/
|
|
77
77
|
destroy() {
|
|
78
78
|
// TODO
|
|
@@ -81,11 +81,11 @@ export class Graphics extends DisplayObject {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
85
|
-
* @param {number} lineWidth -
|
|
86
|
-
* @param {number} color -
|
|
87
|
-
* @param {number} alpha -
|
|
88
|
-
* @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.
|
|
89
89
|
*/
|
|
90
90
|
lineStyle(lineWidth = 0, color = 0, alpha = 1) {
|
|
91
91
|
this.lineWidth = lineWidth || 0;
|
|
@@ -106,10 +106,10 @@ export class Graphics extends DisplayObject {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
*
|
|
110
|
-
* @param {number} x -
|
|
111
|
-
* @param {number} y -
|
|
112
|
-
* @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.
|
|
113
113
|
*/
|
|
114
114
|
moveTo(x, y) {
|
|
115
115
|
this.drawShape(new Polygon([x, y]));
|
|
@@ -117,10 +117,10 @@ export class Graphics extends DisplayObject {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
|
-
*
|
|
121
|
-
* @param {number} x -
|
|
122
|
-
* @param {number} y -
|
|
123
|
-
* @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.
|
|
124
124
|
*/
|
|
125
125
|
lineTo(x, y) {
|
|
126
126
|
if (!this.currentPath) {
|
|
@@ -133,12 +133,12 @@ export class Graphics extends DisplayObject {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
|
-
*
|
|
137
|
-
* @param {number} cpX -
|
|
138
|
-
* @param {number} cpY -
|
|
139
|
-
* @param {number} toX -
|
|
140
|
-
* @param {number} toY -
|
|
141
|
-
* @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.
|
|
142
142
|
*/
|
|
143
143
|
quadraticCurveTo(cpX, cpY, toX, toY) {
|
|
144
144
|
if (this.currentPath) {
|
|
@@ -170,14 +170,14 @@ export class Graphics extends DisplayObject {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
|
-
*
|
|
174
|
-
* @param {number} cpX -
|
|
175
|
-
* @param {number} cpY -
|
|
176
|
-
* @param {number} cpX2 -
|
|
177
|
-
* @param {number} cpY2 -
|
|
178
|
-
* @param {number} toX -
|
|
179
|
-
* @param {number} toY -
|
|
180
|
-
* @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.
|
|
181
181
|
*/
|
|
182
182
|
bezierCurveTo(cpX, cpY, cpX2, cpY2, toX, toY) {
|
|
183
183
|
if (this.currentPath) {
|
|
@@ -215,13 +215,13 @@ export class Graphics extends DisplayObject {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
|
-
*
|
|
219
|
-
* @param {number} x1 -
|
|
220
|
-
* @param {number} y1 -
|
|
221
|
-
* @param {number} x2 -
|
|
222
|
-
* @param {number} y2 -
|
|
223
|
-
* @param {number} radius -
|
|
224
|
-
* @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.
|
|
225
225
|
*/
|
|
226
226
|
arcTo(x1, y1, x2, y2, radius) {
|
|
227
227
|
if (this.currentPath) {
|
|
@@ -267,15 +267,15 @@ export class Graphics extends DisplayObject {
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
/**
|
|
270
|
-
*
|
|
271
|
-
* @param {number} cx -
|
|
272
|
-
* @param {number} cy -
|
|
273
|
-
* @param {number} radius -
|
|
274
|
-
* @param {number} startAngle -
|
|
275
|
-
* @param {number} endAngle -
|
|
276
|
-
* @param {boolean} anticlockwise -
|
|
277
|
-
* @param {number} segments -
|
|
278
|
-
* @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.
|
|
279
279
|
*/
|
|
280
280
|
arc(cx, cy, radius, startAngle, endAngle, anticlockwise = false, segments = 40) {
|
|
281
281
|
// If we do this we can never draw a full circle
|
|
@@ -321,10 +321,10 @@ export class Graphics extends DisplayObject {
|
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
/**
|
|
324
|
-
*
|
|
325
|
-
* @param {number} color -
|
|
326
|
-
* @param {number} alpha -
|
|
327
|
-
* @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.
|
|
328
328
|
*/
|
|
329
329
|
beginFill(color = 0, alpha = 1) {
|
|
330
330
|
this.filling = true;
|
|
@@ -341,8 +341,8 @@ export class Graphics extends DisplayObject {
|
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
/**
|
|
344
|
-
*
|
|
345
|
-
* @returns {Graphics}
|
|
344
|
+
* Ends the current fill operation.
|
|
345
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
346
346
|
*/
|
|
347
347
|
endFill() {
|
|
348
348
|
this.filling = false;
|
|
@@ -352,12 +352,12 @@ export class Graphics extends DisplayObject {
|
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
/**
|
|
355
|
-
*
|
|
356
|
-
* @param {number} x -
|
|
357
|
-
* @param {number} y -
|
|
358
|
-
* @param {number} width -
|
|
359
|
-
* @param {number} height -
|
|
360
|
-
* @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.
|
|
361
361
|
*/
|
|
362
362
|
drawRect(x, y, width, height) {
|
|
363
363
|
this.drawShape(new Rectangle(x, y, width, height));
|
|
@@ -365,13 +365,13 @@ export class Graphics extends DisplayObject {
|
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
/**
|
|
368
|
-
*
|
|
369
|
-
* @param {number} x -
|
|
370
|
-
* @param {number} y -
|
|
371
|
-
* @param {number} width -
|
|
372
|
-
* @param {number} height -
|
|
373
|
-
* @param {number} radius -
|
|
374
|
-
* @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.
|
|
375
375
|
*/
|
|
376
376
|
drawRoundedRect(x, y, width, height, radius) {
|
|
377
377
|
this.drawShape(new RoundedRectangle(x, y, width, height, radius));
|
|
@@ -379,11 +379,11 @@ export class Graphics extends DisplayObject {
|
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
/**
|
|
382
|
-
*
|
|
383
|
-
* @param {number} x -
|
|
384
|
-
* @param {number} y -
|
|
385
|
-
* @param {number} diameter -
|
|
386
|
-
* @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.
|
|
387
387
|
*/
|
|
388
388
|
drawCircle(x, y, diameter) {
|
|
389
389
|
this.drawShape(new Circle(x, y, diameter));
|
|
@@ -391,12 +391,12 @@ export class Graphics extends DisplayObject {
|
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
/**
|
|
394
|
-
*
|
|
395
|
-
* @param {number} x -
|
|
396
|
-
* @param {number} y -
|
|
397
|
-
* @param {number} width -
|
|
398
|
-
* @param {number} height -
|
|
399
|
-
* @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.
|
|
400
400
|
*/
|
|
401
401
|
drawEllipse(x, y, width, height) {
|
|
402
402
|
this.drawShape(new Ellipse(x, y, width, height));
|
|
@@ -404,9 +404,9 @@ export class Graphics extends DisplayObject {
|
|
|
404
404
|
}
|
|
405
405
|
|
|
406
406
|
/**
|
|
407
|
-
*
|
|
408
|
-
* @param {Polygon} path -
|
|
409
|
-
* @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.
|
|
410
410
|
*/
|
|
411
411
|
drawPolygon(path) {
|
|
412
412
|
let points;
|
|
@@ -429,8 +429,8 @@ export class Graphics extends DisplayObject {
|
|
|
429
429
|
}
|
|
430
430
|
|
|
431
431
|
/**
|
|
432
|
-
*
|
|
433
|
-
* @returns {Graphics}
|
|
432
|
+
* Clears all graphics data.
|
|
433
|
+
* @returns {Graphics} This Graphics object for chaining.
|
|
434
434
|
*/
|
|
435
435
|
clear() {
|
|
436
436
|
this.lineWidth = 0;
|
|
@@ -444,7 +444,7 @@ export class Graphics extends DisplayObject {
|
|
|
444
444
|
}
|
|
445
445
|
|
|
446
446
|
/**
|
|
447
|
-
*
|
|
447
|
+
* Generates a texture from the graphics object (not implemented).
|
|
448
448
|
*/
|
|
449
449
|
generateTexture() {
|
|
450
450
|
// TODO
|
|
@@ -452,8 +452,8 @@ export class Graphics extends DisplayObject {
|
|
|
452
452
|
}
|
|
453
453
|
|
|
454
454
|
/**
|
|
455
|
-
*
|
|
456
|
-
* @param {object} renderSession -
|
|
455
|
+
* Renders the graphics object using WebGL.
|
|
456
|
+
* @param {object} renderSession - The render session to use.
|
|
457
457
|
*/
|
|
458
458
|
renderWebGL(renderSession) {
|
|
459
459
|
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
|
@@ -512,8 +512,8 @@ export class Graphics extends DisplayObject {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
/**
|
|
515
|
-
*
|
|
516
|
-
* @param {object} renderSession -
|
|
515
|
+
* Renders the graphics object using Canvas.
|
|
516
|
+
* @param {object} renderSession - The render session to use.
|
|
517
517
|
*/
|
|
518
518
|
renderCanvas(renderSession) {
|
|
519
519
|
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
|
@@ -568,9 +568,9 @@ export class Graphics extends DisplayObject {
|
|
|
568
568
|
}
|
|
569
569
|
|
|
570
570
|
/**
|
|
571
|
-
*
|
|
572
|
-
* @param {import('../geom/matrix.js').Matrix} matrix -
|
|
573
|
-
* @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.
|
|
574
574
|
*/
|
|
575
575
|
getBounds(matrix = null) {
|
|
576
576
|
if (!this.renderable) {
|
|
@@ -629,8 +629,8 @@ export class Graphics extends DisplayObject {
|
|
|
629
629
|
}
|
|
630
630
|
|
|
631
631
|
/**
|
|
632
|
-
*
|
|
633
|
-
* @returns {Rectangle}
|
|
632
|
+
* Gets the local bounds of the graphics object.
|
|
633
|
+
* @returns {Rectangle} The local bounds rectangle of the graphics object.
|
|
634
634
|
*/
|
|
635
635
|
getLocalBounds() {
|
|
636
636
|
const matrixCache = this.worldTransform;
|
|
@@ -647,10 +647,10 @@ export class Graphics extends DisplayObject {
|
|
|
647
647
|
}
|
|
648
648
|
|
|
649
649
|
/**
|
|
650
|
-
*
|
|
651
|
-
* @param {Point} point -
|
|
652
|
-
* @param {Point} tempPoint -
|
|
653
|
-
* @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.
|
|
654
654
|
*/
|
|
655
655
|
containsPoint(point, tempPoint) {
|
|
656
656
|
this.worldTransform.applyInverse(point, tempPoint);
|
|
@@ -667,7 +667,7 @@ export class Graphics extends DisplayObject {
|
|
|
667
667
|
}
|
|
668
668
|
|
|
669
669
|
/**
|
|
670
|
-
*
|
|
670
|
+
* Updates the local bounds of the graphics object.
|
|
671
671
|
*/
|
|
672
672
|
updateLocalBounds() {
|
|
673
673
|
let minX = Infinity;
|
|
@@ -748,7 +748,7 @@ export class Graphics extends DisplayObject {
|
|
|
748
748
|
}
|
|
749
749
|
|
|
750
750
|
/**
|
|
751
|
-
*
|
|
751
|
+
* Generates a cached sprite representation of the graphics object.
|
|
752
752
|
*/
|
|
753
753
|
generateCachedSprite() {
|
|
754
754
|
const bounds = this.getLocalBounds();
|
|
@@ -774,7 +774,7 @@ export class Graphics extends DisplayObject {
|
|
|
774
774
|
}
|
|
775
775
|
|
|
776
776
|
/**
|
|
777
|
-
*
|
|
777
|
+
* Updates the cached sprite texture.
|
|
778
778
|
*/
|
|
779
779
|
updateCachedSpriteTexture() {
|
|
780
780
|
const cachedSprite = this._cachedSprite;
|
|
@@ -793,7 +793,7 @@ export class Graphics extends DisplayObject {
|
|
|
793
793
|
}
|
|
794
794
|
|
|
795
795
|
/**
|
|
796
|
-
*
|
|
796
|
+
* Destroys the cached sprite.
|
|
797
797
|
*/
|
|
798
798
|
destroyCachedSprite() {
|
|
799
799
|
if (!this._cachedSprite) {
|
|
@@ -804,9 +804,9 @@ export class Graphics extends DisplayObject {
|
|
|
804
804
|
}
|
|
805
805
|
|
|
806
806
|
/**
|
|
807
|
-
*
|
|
808
|
-
* @param {object} shape -
|
|
809
|
-
* @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.
|
|
810
810
|
*/
|
|
811
811
|
drawShape(shape) {
|
|
812
812
|
if (this.currentPath) {
|
|
@@ -841,7 +841,7 @@ export class Graphics extends DisplayObject {
|
|
|
841
841
|
}
|
|
842
842
|
|
|
843
843
|
/**
|
|
844
|
-
*
|
|
844
|
+
* Performs post-update operations for the graphics object.
|
|
845
845
|
*/
|
|
846
846
|
postUpdate() {
|
|
847
847
|
if (this._boundsDirty) {
|
|
@@ -854,9 +854,9 @@ export class Graphics extends DisplayObject {
|
|
|
854
854
|
}
|
|
855
855
|
|
|
856
856
|
/**
|
|
857
|
-
*
|
|
858
|
-
* @param {Point[]} points -
|
|
859
|
-
* @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.
|
|
860
860
|
*/
|
|
861
861
|
drawTriangle(points, cull = false) {
|
|
862
862
|
const triangle = new Polygon(points);
|
|
@@ -874,10 +874,10 @@ export class Graphics extends DisplayObject {
|
|
|
874
874
|
}
|
|
875
875
|
|
|
876
876
|
/**
|
|
877
|
-
*
|
|
878
|
-
* @param {number[]|Point[]} vertices -
|
|
879
|
-
* @param {number[]} indices -
|
|
880
|
-
* @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.
|
|
881
881
|
*/
|
|
882
882
|
drawTriangles(vertices, indices, cull = false) {
|
|
883
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(
|