@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
|
@@ -27,11 +27,12 @@ import { getSmoothingPrefix } from './util.js';
|
|
|
27
27
|
|
|
28
28
|
export class CanvasRenderer {
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @param {import('../../core/game.js').Game} game -
|
|
30
|
+
* Creates a new CanvasRenderer instance.
|
|
31
|
+
* @param {import('../../core/game.js').Game} game - The game instance.
|
|
32
32
|
*/
|
|
33
33
|
constructor(game) {
|
|
34
34
|
detectCapabilities(game);
|
|
35
|
+
/** @type {number} */
|
|
35
36
|
this.type = RENDER_CANVAS;
|
|
36
37
|
this.resolution = game.config.resolution;
|
|
37
38
|
this.clearBeforeRender = game.config.clearBeforeRender;
|
|
@@ -61,8 +62,8 @@ export class CanvasRenderer {
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @param {import('../../core/stage.js').Stage} root -
|
|
65
|
+
* Renders the stage to canvas.
|
|
66
|
+
* @param {import('../../core/stage.js').Stage} root - The root stage to render.
|
|
66
67
|
*/
|
|
67
68
|
render(root) {
|
|
68
69
|
if (!this.context) {
|
|
@@ -86,8 +87,8 @@ export class CanvasRenderer {
|
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
/**
|
|
89
|
-
*
|
|
90
|
-
* @param {boolean} removeView -
|
|
90
|
+
* Destroys this renderer and cleans up resources.
|
|
91
|
+
* @param {boolean} removeView - Whether to remove the view from the DOM.
|
|
91
92
|
*/
|
|
92
93
|
destroy(removeView = true) {
|
|
93
94
|
if (removeView && this.view.parent) {
|
|
@@ -99,9 +100,9 @@ export class CanvasRenderer {
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
/**
|
|
102
|
-
*
|
|
103
|
-
* @param {number} width -
|
|
104
|
-
* @param {number} height -
|
|
103
|
+
* Resizes the canvas to the specified dimensions.
|
|
104
|
+
* @param {number} width - The new width of the canvas.
|
|
105
|
+
* @param {number} height - The new height of the canvas.
|
|
105
106
|
*/
|
|
106
107
|
resize(width, height) {
|
|
107
108
|
this.width = width * this.resolution;
|
|
@@ -118,10 +119,10 @@ export class CanvasRenderer {
|
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
/**
|
|
121
|
-
*
|
|
122
|
-
* @param {import('../../display/image.js').Image} displayObject -
|
|
123
|
-
* @param {CanvasRenderingContext2D} context -
|
|
124
|
-
* @param {import('../../geom/matrix.js').Matrix} matrix -
|
|
122
|
+
* Renders a display object to canvas.
|
|
123
|
+
* @param {import('../../display/image.js').Image} displayObject - The display object to render.
|
|
124
|
+
* @param {CanvasRenderingContext2D} context - The canvas rendering context.
|
|
125
|
+
* @param {import('../../geom/matrix.js').Matrix} matrix - The transformation matrix.
|
|
125
126
|
*/
|
|
126
127
|
renderDisplayObject(displayObject, context, matrix) {
|
|
127
128
|
this.renderSession.context = context || this.context;
|
|
@@ -130,7 +131,7 @@ export class CanvasRenderer {
|
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
/**
|
|
133
|
-
*
|
|
134
|
+
* Maps blend modes to canvas rendering operations.
|
|
134
135
|
*/
|
|
135
136
|
mapBlendModes() {
|
|
136
137
|
if (window.PhaserRegistry.blendModesCanvas) {
|
|
@@ -159,8 +160,8 @@ export class CanvasRenderer {
|
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
/**
|
|
162
|
-
*
|
|
163
|
-
* @param {import('../../core/game.js').Game} game -
|
|
163
|
+
* Initializes the WebGL context for rendering.
|
|
164
|
+
* @param {import('../../core/game.js').Game} game - The game instance.
|
|
164
165
|
*/
|
|
165
166
|
initContext(game) {
|
|
166
167
|
// stub
|
|
@@ -3,10 +3,10 @@ import { hex2rgb } from '../../util/math.js';
|
|
|
3
3
|
import { create, removeByCanvas } from './pool.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {object} sprite -
|
|
8
|
-
* @param {object} color -
|
|
9
|
-
* @returns {object}
|
|
6
|
+
* Tints a sprite with the given color.
|
|
7
|
+
* @param {object} sprite - The sprite to tint.
|
|
8
|
+
* @param {object} color - The color to tint with.
|
|
9
|
+
* @returns {object} The tinted sprite.
|
|
10
10
|
*/
|
|
11
11
|
export const getTintedTexture = (sprite, color) => {
|
|
12
12
|
const canvas = sprite.tintedTexture || create('CanvasTinter', 1, 1);
|
|
@@ -15,11 +15,11 @@ export const getTintedTexture = (sprite, color) => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param {object} texture -
|
|
20
|
-
* @param {object} color -
|
|
21
|
-
* @param {HTMLCanvasElement} canvas -
|
|
22
|
-
* @throws {Error}
|
|
18
|
+
* Tints a texture with the given color.
|
|
19
|
+
* @param {object} texture - The texture to tint.
|
|
20
|
+
* @param {object} color - The color to tint with.
|
|
21
|
+
* @param {HTMLCanvasElement} canvas - The canvas to render to.
|
|
22
|
+
* @throws {Error} If the operation fails.
|
|
23
23
|
*/
|
|
24
24
|
export const tintWithMultiply = (texture, color, canvas) => {
|
|
25
25
|
const context = canvas.getContext('2d', { willReadFrequently: false });
|
|
@@ -41,11 +41,11 @@ export const tintWithMultiply = (texture, color, canvas) => {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
* @param {object} texture -
|
|
46
|
-
* @param {object} color -
|
|
47
|
-
* @param {HTMLCanvasElement} canvas -
|
|
48
|
-
* @throws {Error}
|
|
44
|
+
* Tints a texture with the given color.
|
|
45
|
+
* @param {object} texture - The texture to tint.
|
|
46
|
+
* @param {object} color - The color to tint with.
|
|
47
|
+
* @param {HTMLCanvasElement} canvas - The canvas to render to.
|
|
48
|
+
* @throws {Error} If the operation fails.
|
|
49
49
|
*/
|
|
50
50
|
export const tintWithPerPixel = (texture, color, canvas) => {
|
|
51
51
|
const context = canvas.getContext('2d', { willReadFrequently: false });
|
|
@@ -79,9 +79,9 @@ export const tintWithPerPixel = (texture, color, canvas) => {
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
|
-
*
|
|
83
|
-
* @returns {boolean}
|
|
84
|
-
* @throws {Error}
|
|
82
|
+
* Checks if the tinter can handle the given texture.
|
|
83
|
+
* @returns {boolean} True if the tinter can handle the texture, false otherwise.
|
|
84
|
+
* @throws {Error} If the operation fails.
|
|
85
85
|
*/
|
|
86
86
|
export const checkInverseAlpha = () => {
|
|
87
87
|
// Check for DOM
|
|
@@ -121,9 +121,9 @@ export const checkInverseAlpha = () => {
|
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
|
-
*
|
|
125
|
-
* @returns {boolean}
|
|
126
|
-
* @throws {Error}
|
|
124
|
+
* Checks if the tinter can handle the given texture.
|
|
125
|
+
* @returns {boolean} True if the tinter can handle the texture, false otherwise.
|
|
126
|
+
* @throws {Error} If the operation fails.
|
|
127
127
|
*/
|
|
128
128
|
export const canUseNewCanvasBlendModes = () => {
|
|
129
129
|
// Check for DOM
|
|
@@ -163,8 +163,8 @@ export const canUseNewCanvasBlendModes = () => {
|
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
|
-
*
|
|
167
|
-
* @param {import('../../core/game.js').Game} game -
|
|
166
|
+
* Creates a new Tinter instance.
|
|
167
|
+
* @param {import('../../core/game.js').Game} game - The game instance.
|
|
168
168
|
*/
|
|
169
169
|
export const detectCapabilities = (game) => {
|
|
170
170
|
if (!window.PhaserRegistry) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { create as createCanvas } from './pool.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {object} parent -
|
|
6
|
-
* @param {number} width -
|
|
7
|
-
* @param {number} height -
|
|
8
|
-
* @param {string} id -
|
|
9
|
-
* @param {boolean} skipPool -
|
|
10
|
-
* @returns {HTMLCanvasElement}
|
|
4
|
+
* Creates a new HTML canvas element.
|
|
5
|
+
* @param {object} parent - The parent element to append the canvas to.
|
|
6
|
+
* @param {number} width - The width of the canvas.
|
|
7
|
+
* @param {number} height - The height of the canvas.
|
|
8
|
+
* @param {string} id - The ID to assign to the canvas.
|
|
9
|
+
* @param {boolean} skipPool - Whether to skip using the canvas pool.
|
|
10
|
+
* @returns {HTMLCanvasElement} The created HTML canvas element.
|
|
11
11
|
*/
|
|
12
12
|
export const create = (parent, width, height, id, skipPool) => {
|
|
13
13
|
width = width || 256;
|
|
@@ -23,10 +23,10 @@ export const create = (parent, width, height, id, skipPool) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @param {HTMLCanvasElement} canvas -
|
|
28
|
-
* @param {string} color -
|
|
29
|
-
* @returns {
|
|
26
|
+
* Sets the background color of a canvas element.
|
|
27
|
+
* @param {HTMLCanvasElement} canvas - The canvas element to modify.
|
|
28
|
+
* @param {string} color - The background color to set.
|
|
29
|
+
* @returns {HTMLCanvasElement} The modified canvas element.
|
|
30
30
|
*/
|
|
31
31
|
export const setBackgroundColor = (canvas, color) => {
|
|
32
32
|
color = color || 'rgb(0,0,0)';
|
|
@@ -35,10 +35,10 @@ export const setBackgroundColor = (canvas, color) => {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @param {HTMLCanvasElement} canvas -
|
|
40
|
-
* @param {string} value -
|
|
41
|
-
* @returns {
|
|
38
|
+
* Sets the touch action property of a canvas element.
|
|
39
|
+
* @param {HTMLCanvasElement} canvas - The canvas element to modify.
|
|
40
|
+
* @param {string} value - The touch action value to set.
|
|
41
|
+
* @returns {HTMLCanvasElement} The modified canvas element.
|
|
42
42
|
*/
|
|
43
43
|
export const setTouchAction = (canvas, value = 'none') => {
|
|
44
44
|
value = value || 'none';
|
|
@@ -50,10 +50,10 @@ export const setTouchAction = (canvas, value = 'none') => {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @param {HTMLCanvasElement} canvas -
|
|
55
|
-
* @param {string} value -
|
|
56
|
-
* @returns {
|
|
53
|
+
* Sets the user select property of a canvas element.
|
|
54
|
+
* @param {HTMLCanvasElement} canvas - The canvas element to modify.
|
|
55
|
+
* @param {string} value - The user select value to set.
|
|
56
|
+
* @returns {HTMLCanvasElement} The modified canvas element.
|
|
57
57
|
*/
|
|
58
58
|
export const setUserSelect = (canvas, value = 'none') => {
|
|
59
59
|
value = value || 'none';
|
|
@@ -68,11 +68,11 @@ export const setUserSelect = (canvas, value = 'none') => {
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
72
|
-
* @param {HTMLCanvasElement} canvas -
|
|
73
|
-
* @param {object} parent -
|
|
74
|
-
* @param {boolean} overflowHidden -
|
|
75
|
-
* @returns {
|
|
71
|
+
* Adds a canvas element to the DOM.
|
|
72
|
+
* @param {HTMLCanvasElement} canvas - The canvas element to add.
|
|
73
|
+
* @param {object} parent - The parent element to append the canvas to.
|
|
74
|
+
* @param {boolean} overflowHidden - Whether to set overflow hidden on the parent.
|
|
75
|
+
* @returns {HTMLCanvasElement} The added canvas element.
|
|
76
76
|
*/
|
|
77
77
|
export const addToDOM = (canvas, parent, overflowHidden = true) => {
|
|
78
78
|
let target;
|
|
@@ -97,8 +97,8 @@ export const addToDOM = (canvas, parent, overflowHidden = true) => {
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
101
|
-
* @param {HTMLCanvasElement} canvas -
|
|
100
|
+
* Removes a canvas element from the DOM.
|
|
101
|
+
* @param {HTMLCanvasElement} canvas - The canvas element to remove.
|
|
102
102
|
*/
|
|
103
103
|
export const removeFromDOM = (canvas) => {
|
|
104
104
|
if (canvas && canvas.parentNode) {
|
|
@@ -107,15 +107,15 @@ export const removeFromDOM = (canvas) => {
|
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param {
|
|
112
|
-
* @param {number} translateX -
|
|
113
|
-
* @param {number} translateY -
|
|
114
|
-
* @param {number} scaleX -
|
|
115
|
-
* @param {number} scaleY -
|
|
116
|
-
* @param {number} skewX -
|
|
117
|
-
* @param {number} skewY -
|
|
118
|
-
* @returns {
|
|
110
|
+
* Sets the transformation matrix on a canvas rendering context.
|
|
111
|
+
* @param {CanvasRenderingContext2D} context - The canvas rendering context.
|
|
112
|
+
* @param {number} translateX - The X translation value.
|
|
113
|
+
* @param {number} translateY - The Y translation value.
|
|
114
|
+
* @param {number} scaleX - The X scale value.
|
|
115
|
+
* @param {number} scaleY - The Y scale value.
|
|
116
|
+
* @param {number} skewX - The X skew value.
|
|
117
|
+
* @param {number} skewY - The Y skew value.
|
|
118
|
+
* @returns {CanvasRenderingContext2D} The modified rendering context.
|
|
119
119
|
*/
|
|
120
120
|
export const setTransform = (context, translateX, translateY, scaleX, scaleY, skewX, skewY) => {
|
|
121
121
|
context.setTransform(scaleX, skewX, skewY, scaleY, translateX, translateY);
|
|
@@ -123,9 +123,9 @@ export const setTransform = (context, translateX, translateY, scaleX, scaleY, sk
|
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
|
-
*
|
|
127
|
-
* @param {
|
|
128
|
-
* @returns {
|
|
126
|
+
* Gets the smoothing prefix for a canvas rendering context.
|
|
127
|
+
* @param {CanvasRenderingContext2D} context - The canvas rendering context.
|
|
128
|
+
* @returns {string | null} The smoothing property name or null if not found.
|
|
129
129
|
*/
|
|
130
130
|
export const getSmoothingPrefix = (context) => {
|
|
131
131
|
const VENDORS = ['i', 'webkitI', 'msI', 'mozI', 'oI'];
|
|
@@ -139,10 +139,10 @@ export const getSmoothingPrefix = (context) => {
|
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
/**
|
|
142
|
-
*
|
|
143
|
-
* @param {object} context -
|
|
144
|
-
* @param {number} value -
|
|
145
|
-
* @returns {object}
|
|
142
|
+
* Sets the smoothing enabled property on a canvas rendering context.
|
|
143
|
+
* @param {object} context - The canvas rendering context.
|
|
144
|
+
* @param {number} value - The smoothing enabled value to set.
|
|
145
|
+
* @returns {object} The modified rendering context.
|
|
146
146
|
*/
|
|
147
147
|
export const setSmoothingEnabled = (context, value) => {
|
|
148
148
|
const s = getSmoothingPrefix(context);
|