melonjs 10.2.2 → 10.4.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/README.md +6 -6
- package/dist/melonjs.js +2907 -3383
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3620 -4528
- package/dist/melonjs.module.js +3210 -3331
- package/package.json +19 -19
- package/src/audio/audio.js +30 -31
- package/src/camera/camera2d.js +47 -58
- package/src/entity/draggable.js +11 -21
- package/src/entity/droptarget.js +12 -22
- package/src/entity/entity.js +32 -38
- package/src/game.js +21 -22
- package/src/{shapes → geometries}/ellipse.js +40 -47
- package/src/{shapes → geometries}/line.js +9 -12
- package/src/{shapes → geometries}/poly.js +100 -53
- package/src/{shapes → geometries}/rectangle.js +42 -45
- package/src/index.js +9 -20
- package/src/input/gamepad.js +11 -10
- package/src/input/input.js +2 -3
- package/src/input/keyboard.js +113 -113
- package/src/input/pointer.js +61 -29
- package/src/input/pointerevent.js +92 -29
- package/src/lang/deprecated.js +44 -14
- package/src/level/level.js +23 -24
- package/src/level/tiled/TMXGroup.js +7 -9
- package/src/level/tiled/TMXLayer.js +30 -33
- package/src/level/tiled/TMXObject.js +59 -53
- package/src/level/tiled/TMXTile.js +18 -19
- package/src/level/tiled/TMXTileMap.js +38 -46
- package/src/level/tiled/TMXTileset.js +12 -16
- package/src/level/tiled/TMXTilesetGroup.js +9 -10
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -9
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -9
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -6
- package/src/level/tiled/renderer/TMXRenderer.js +24 -26
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -5
- package/src/loader/loader.js +17 -16
- package/src/loader/loadingscreen.js +8 -10
- package/src/math/color.js +47 -67
- package/src/math/math.js +15 -16
- package/src/math/matrix2.js +53 -59
- package/src/math/matrix3.js +56 -63
- package/src/math/observable_vector2.js +87 -77
- package/src/math/observable_vector3.js +97 -80
- package/src/math/vector2.js +107 -97
- package/src/math/vector3.js +116 -100
- package/src/particles/emitter.js +66 -76
- package/src/particles/particle.js +4 -6
- package/src/particles/particlecontainer.js +2 -4
- package/src/physics/body.js +47 -146
- package/src/physics/bounds.js +48 -50
- package/src/physics/collision.js +13 -14
- package/src/physics/detector.js +14 -14
- package/src/physics/quadtree.js +18 -21
- package/src/physics/sat.js +30 -30
- package/src/physics/world.js +24 -29
- package/src/plugin/plugin.js +11 -15
- package/src/renderable/GUI.js +41 -47
- package/src/renderable/collectable.js +5 -10
- package/src/renderable/colorlayer.js +10 -15
- package/src/renderable/container.js +87 -73
- package/src/renderable/imagelayer.js +25 -32
- package/src/renderable/nineslicesprite.js +41 -42
- package/src/renderable/renderable.js +113 -124
- package/src/renderable/sprite.js +62 -69
- package/src/renderable/trigger.js +26 -32
- package/src/state/stage.js +13 -18
- package/src/state/state.js +26 -27
- package/src/system/device.js +76 -133
- package/src/system/event.js +81 -70
- package/src/system/pooling.js +11 -12
- package/src/system/save.js +3 -4
- package/src/system/timer.js +19 -20
- package/src/text/bitmaptext.js +57 -55
- package/src/text/bitmaptextdata.js +10 -11
- package/src/text/glyph.js +3 -0
- package/src/text/text.js +49 -55
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +1 -1
- package/src/tweens/tween.js +44 -46
- package/src/utils/agent.js +3 -4
- package/src/utils/array.js +4 -5
- package/src/utils/file.js +3 -4
- package/src/utils/function.js +4 -5
- package/src/utils/string.js +7 -9
- package/src/utils/utils.js +4 -5
- package/src/video/canvas/canvas_renderer.js +60 -62
- package/src/video/renderer.js +53 -58
- package/src/video/texture.js +98 -112
- package/src/video/texture_cache.js +4 -6
- package/src/video/video.js +16 -17
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/glshader.js +37 -39
- package/src/video/webgl/webgl_compositor.js +128 -110
- package/src/video/webgl/webgl_renderer.js +126 -106
package/src/text/bitmaptext.js
CHANGED
|
@@ -34,41 +34,37 @@ var measureTextHeight = function(font) {
|
|
|
34
34
|
/**
|
|
35
35
|
* @classdesc
|
|
36
36
|
* a bitmap font object
|
|
37
|
-
* @
|
|
38
|
-
* @extends me.Renderable
|
|
39
|
-
* @memberOf me
|
|
40
|
-
* @constructor
|
|
41
|
-
* @param {number} x position of the text object
|
|
42
|
-
* @param {number} y position of the text object
|
|
43
|
-
* @param {object} settings the text configuration
|
|
44
|
-
* @param {string|Image} settings.font a font name to identify the corresponing source image
|
|
45
|
-
* @param {string} [settings.fontData=settings.font] the bitmap font data corresponding name, or the bitmap font data itself
|
|
46
|
-
* @param {number} [settings.size] size a scaling ratio
|
|
47
|
-
* @param {me.Color|string} [settings.fillStyle] a CSS color value used to tint the bitmapText (@see me.BitmapText.tint)
|
|
48
|
-
* @param {number} [settings.lineWidth=1] line width, in pixels, when drawing stroke
|
|
49
|
-
* @param {string} [settings.textAlign="left"] horizontal text alignment
|
|
50
|
-
* @param {string} [settings.textBaseline="top"] the text baseline
|
|
51
|
-
* @param {number} [settings.lineHeight=1.0] line spacing height
|
|
52
|
-
* @param {me.Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] anchor point to draw the text at
|
|
53
|
-
* @param {(string|string[])} [settings.text] a string, or an array of strings
|
|
54
|
-
* @example
|
|
55
|
-
* // Use me.loader.preload or me.loader.load to load assets
|
|
56
|
-
* me.loader.preload([
|
|
57
|
-
* { name: "arial", type: "binary" src: "data/font/arial.fnt" },
|
|
58
|
-
* { name: "arial", type: "image" src: "data/font/arial.png" },
|
|
59
|
-
* ])
|
|
60
|
-
* // Then create an instance of your bitmap font:
|
|
61
|
-
* var myFont = new me.BitmapText(x, y, {font:"arial", text:"Hello"});
|
|
62
|
-
* // two possibilities for using "myFont"
|
|
63
|
-
* // either call the draw function from your Renderable draw function
|
|
64
|
-
* myFont.draw(renderer, "Hello!", 0, 0);
|
|
65
|
-
* // or just add it to the word container
|
|
66
|
-
* me.game.world.addChild(myFont);
|
|
37
|
+
* @augments Renderable
|
|
67
38
|
*/
|
|
68
|
-
|
|
69
39
|
class BitmapText extends Renderable {
|
|
70
|
-
|
|
71
|
-
|
|
40
|
+
/**
|
|
41
|
+
* @param {number} x position of the text object
|
|
42
|
+
* @param {number} y position of the text object
|
|
43
|
+
* @param {object} settings the text configuration
|
|
44
|
+
* @param {string|Image} settings.font a font name to identify the corresponing source image
|
|
45
|
+
* @param {string} [settings.fontData=settings.font] the bitmap font data corresponding name, or the bitmap font data itself
|
|
46
|
+
* @param {number} [settings.size] size a scaling ratio
|
|
47
|
+
* @param {Color|string} [settings.fillStyle] a CSS color value used to tint the bitmapText (@see BitmapText.tint)
|
|
48
|
+
* @param {number} [settings.lineWidth=1] line width, in pixels, when drawing stroke
|
|
49
|
+
* @param {string} [settings.textAlign="left"] horizontal text alignment
|
|
50
|
+
* @param {string} [settings.textBaseline="top"] the text baseline
|
|
51
|
+
* @param {number} [settings.lineHeight=1.0] line spacing height
|
|
52
|
+
* @param {Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] anchor point to draw the text at
|
|
53
|
+
* @param {(string|string[])} [settings.text] a string, or an array of strings
|
|
54
|
+
* @example
|
|
55
|
+
* // Use me.loader.preload or me.loader.load to load assets
|
|
56
|
+
* me.loader.preload([
|
|
57
|
+
* { name: "arial", type: "binary" src: "data/font/arial.fnt" },
|
|
58
|
+
* { name: "arial", type: "image" src: "data/font/arial.png" },
|
|
59
|
+
* ])
|
|
60
|
+
* // Then create an instance of your bitmap font:
|
|
61
|
+
* var myFont = new me.BitmapText(x, y, {font:"arial", text:"Hello"});
|
|
62
|
+
* // two possibilities for using "myFont"
|
|
63
|
+
* // either call the draw function from your Renderable draw function
|
|
64
|
+
* myFont.draw(renderer, "Hello!", 0, 0);
|
|
65
|
+
* // or just add it to the word container
|
|
66
|
+
* me.game.world.addChild(myFont);
|
|
67
|
+
*/
|
|
72
68
|
constructor(x, y, settings) {
|
|
73
69
|
// call the parent constructor
|
|
74
70
|
super(x, y, settings.width || 0, settings.height || 0);
|
|
@@ -80,7 +76,7 @@ class BitmapText extends Renderable {
|
|
|
80
76
|
* @type {string}
|
|
81
77
|
* @default "left"
|
|
82
78
|
* @name textAlign
|
|
83
|
-
* @
|
|
79
|
+
* @memberof BitmapText
|
|
84
80
|
*/
|
|
85
81
|
this.textAlign = settings.textAlign || "left";
|
|
86
82
|
|
|
@@ -91,7 +87,7 @@ class BitmapText extends Renderable {
|
|
|
91
87
|
* @type {string}
|
|
92
88
|
* @default "top"
|
|
93
89
|
* @name textBaseline
|
|
94
|
-
* @
|
|
90
|
+
* @memberof BitmapText
|
|
95
91
|
*/
|
|
96
92
|
this.textBaseline = settings.textBaseline || "top";
|
|
97
93
|
|
|
@@ -102,27 +98,33 @@ class BitmapText extends Renderable {
|
|
|
102
98
|
* @type {number}
|
|
103
99
|
* @default 1.0
|
|
104
100
|
* @name lineHeight
|
|
105
|
-
* @
|
|
101
|
+
* @memberof BitmapText
|
|
106
102
|
*/
|
|
107
103
|
this.lineHeight = settings.lineHeight || 1.0;
|
|
108
104
|
|
|
109
105
|
/**
|
|
110
106
|
* the text to be displayed
|
|
111
107
|
* @private
|
|
112
|
-
* @type {string[]}
|
|
113
|
-
* @name _text
|
|
114
|
-
* @memberOf me.BitmapText
|
|
115
108
|
*/
|
|
116
109
|
this._text = [];
|
|
117
110
|
|
|
118
|
-
/**
|
|
119
|
-
|
|
111
|
+
/**
|
|
112
|
+
* scaled font size
|
|
113
|
+
* @private
|
|
114
|
+
*/
|
|
120
115
|
this.fontScale = pool.pull("Vector2d", 1.0, 1.0);
|
|
121
116
|
|
|
122
|
-
|
|
117
|
+
/**
|
|
118
|
+
* font image
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
123
121
|
this.fontImage = (typeof settings.font === "object") ? settings.font : loader.getImage(settings.font);
|
|
124
122
|
|
|
125
123
|
if (typeof settings.fontData !== "string") {
|
|
124
|
+
/**
|
|
125
|
+
* font data
|
|
126
|
+
* @private
|
|
127
|
+
*/
|
|
126
128
|
// use settings.font to retreive the data from the loader
|
|
127
129
|
this.fontData = pool.pull("BitmapTextData", loader.getBinary(settings.font));
|
|
128
130
|
} else {
|
|
@@ -166,11 +168,11 @@ class BitmapText extends Renderable {
|
|
|
166
168
|
/**
|
|
167
169
|
* change the font settings
|
|
168
170
|
* @name set
|
|
169
|
-
* @
|
|
171
|
+
* @memberof BitmapText.prototype
|
|
170
172
|
* @function
|
|
171
173
|
* @param {string} textAlign ("left", "center", "right")
|
|
172
174
|
* @param {number} [scale]
|
|
173
|
-
* @returns {
|
|
175
|
+
* @returns {BitmapText} this object for chaining
|
|
174
176
|
*/
|
|
175
177
|
set(textAlign, scale) {
|
|
176
178
|
this.textAlign = textAlign;
|
|
@@ -186,10 +188,10 @@ class BitmapText extends Renderable {
|
|
|
186
188
|
/**
|
|
187
189
|
* change the text to be displayed
|
|
188
190
|
* @name setText
|
|
189
|
-
* @
|
|
191
|
+
* @memberof BitmapText.prototype
|
|
190
192
|
* @function
|
|
191
193
|
* @param {number|string|string[]} value a string, or an array of strings
|
|
192
|
-
* @returns {
|
|
194
|
+
* @returns {BitmapText} this object for chaining
|
|
193
195
|
*/
|
|
194
196
|
setText(value) {
|
|
195
197
|
if (typeof value === "undefined") {
|
|
@@ -211,10 +213,10 @@ class BitmapText extends Renderable {
|
|
|
211
213
|
/**
|
|
212
214
|
* defines the color used to tint the bitmap text
|
|
213
215
|
* @public
|
|
214
|
-
* @type {
|
|
216
|
+
* @type {Color}
|
|
215
217
|
* @name fillStyle
|
|
216
|
-
* @see
|
|
217
|
-
* @
|
|
218
|
+
* @see Renderable#tint
|
|
219
|
+
* @memberof BitmapText
|
|
218
220
|
*/
|
|
219
221
|
get fillStyle() {
|
|
220
222
|
return this.tint;
|
|
@@ -226,10 +228,10 @@ class BitmapText extends Renderable {
|
|
|
226
228
|
/**
|
|
227
229
|
* change the font display size
|
|
228
230
|
* @name resize
|
|
229
|
-
* @
|
|
231
|
+
* @memberof BitmapText.prototype
|
|
230
232
|
* @function
|
|
231
233
|
* @param {number} scale ratio
|
|
232
|
-
* @returns {
|
|
234
|
+
* @returns {BitmapText} this object for chaining
|
|
233
235
|
*/
|
|
234
236
|
resize(scale) {
|
|
235
237
|
this.fontScale.set(scale, scale);
|
|
@@ -242,10 +244,10 @@ class BitmapText extends Renderable {
|
|
|
242
244
|
/**
|
|
243
245
|
* measure the given text size in pixels
|
|
244
246
|
* @name measureText
|
|
245
|
-
* @
|
|
247
|
+
* @memberof BitmapText.prototype
|
|
246
248
|
* @function
|
|
247
249
|
* @param {string} [text]
|
|
248
|
-
* @param {
|
|
250
|
+
* @param {Rect} [ret] a object in which to store the text metrics
|
|
249
251
|
* @returns {TextMetrics} a TextMetrics object with two properties: `width` and `height`, defining the output dimensions
|
|
250
252
|
*/
|
|
251
253
|
measureText(text, ret) {
|
|
@@ -277,9 +279,9 @@ class BitmapText extends Renderable {
|
|
|
277
279
|
/**
|
|
278
280
|
* draw the bitmap font
|
|
279
281
|
* @name draw
|
|
280
|
-
* @
|
|
282
|
+
* @memberof BitmapText.prototype
|
|
281
283
|
* @function
|
|
282
|
-
* @param {
|
|
284
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer Reference to the destination renderer instance
|
|
283
285
|
* @param {string} [text]
|
|
284
286
|
* @param {number} [x]
|
|
285
287
|
* @param {number} [y]
|
|
@@ -20,10 +20,10 @@ function getValueFromPair(string, pattern) {
|
|
|
20
20
|
* Gets the first glyph in the map that is not a space character
|
|
21
21
|
* @ignore
|
|
22
22
|
* @name _getFirstGlyph
|
|
23
|
-
* @
|
|
23
|
+
* @memberof BitmapTextData
|
|
24
24
|
* @function
|
|
25
25
|
* @param {object} glyphs the map of glyphs, each key is a char code
|
|
26
|
-
* @returns {
|
|
26
|
+
* @returns {Glyph}
|
|
27
27
|
*/
|
|
28
28
|
function getFirstGlyph(glyphs) {
|
|
29
29
|
var keys = Object.keys(glyphs);
|
|
@@ -39,7 +39,7 @@ function getFirstGlyph(glyphs) {
|
|
|
39
39
|
* Creates a glyph to use for the space character
|
|
40
40
|
* @ignore
|
|
41
41
|
* @name createSpaceGlyph
|
|
42
|
-
* @
|
|
42
|
+
* @memberof BitmapTextData
|
|
43
43
|
* @function
|
|
44
44
|
* @param {object} glyphs the map of glyphs, each key is a char code
|
|
45
45
|
*/
|
|
@@ -58,16 +58,15 @@ function createSpaceGlyph(glyphs) {
|
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Class for storing relevant data from the font file.
|
|
61
|
-
* @class me.BitmapTextData
|
|
62
|
-
* @memberOf me
|
|
63
61
|
* @ignore
|
|
64
|
-
* @param data {string} - The bitmap font data pulled from the resource loader using me.loader.getBinary()
|
|
65
|
-
* @constructor
|
|
66
62
|
*/
|
|
67
63
|
class BitmapTextData {
|
|
68
64
|
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
/**
|
|
66
|
+
* @param {string} data - The bitmap font data pulled from the resource loader using me.loader.getBinary()
|
|
67
|
+
*/
|
|
68
|
+
constructor(data) {
|
|
69
|
+
this.onResetEvent(data);
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
/**
|
|
@@ -89,7 +88,7 @@ class BitmapTextData {
|
|
|
89
88
|
* The map of glyphs, each key is a char code.
|
|
90
89
|
* @name glyphs
|
|
91
90
|
* @type {object}
|
|
92
|
-
* @
|
|
91
|
+
* @memberof BitmapTextData
|
|
93
92
|
*/
|
|
94
93
|
this.glyphs = {};
|
|
95
94
|
|
|
@@ -100,7 +99,7 @@ class BitmapTextData {
|
|
|
100
99
|
/**
|
|
101
100
|
* This parses the font data text and builds a map of glyphs containing the data for each character
|
|
102
101
|
* @name parse
|
|
103
|
-
* @
|
|
102
|
+
* @memberof BitmapTextData
|
|
104
103
|
* @function
|
|
105
104
|
* @param {string} fontData
|
|
106
105
|
*/
|
package/src/text/glyph.js
CHANGED
package/src/text/text.js
CHANGED
|
@@ -37,30 +37,27 @@ var setContextStyle = function(context, font, stroke = false) {
|
|
|
37
37
|
/**
|
|
38
38
|
* @classdesc
|
|
39
39
|
* a generic system font object.
|
|
40
|
-
* @
|
|
41
|
-
* @extends me.Renderable
|
|
42
|
-
* @memberOf me
|
|
43
|
-
* @constructor
|
|
44
|
-
* @param {number} x position of the text object
|
|
45
|
-
* @param {number} y position of the text object
|
|
46
|
-
* @param {object} settings the text configuration
|
|
47
|
-
* @param {string} settings.font a CSS family font name
|
|
48
|
-
* @param {number|string} settings.size size, or size + suffix (px, em, pt)
|
|
49
|
-
* @param {me.Color|string} [settings.fillStyle="#000000"] a CSS color value
|
|
50
|
-
* @param {me.Color|string} [settings.strokeStyle="#000000"] a CSS color value
|
|
51
|
-
* @param {number} [settings.lineWidth=1] line width, in pixels, when drawing stroke
|
|
52
|
-
* @param {string} [settings.textAlign="left"] horizontal text alignment
|
|
53
|
-
* @param {string} [settings.textBaseline="top"] the text baseline
|
|
54
|
-
* @param {number} [settings.lineHeight=1.0] line spacing height
|
|
55
|
-
* @param {me.Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] anchor point to draw the text at
|
|
56
|
-
* @param {boolean} [settings.offScreenCanvas=false] whether to draw the font to an individual "cache" texture first
|
|
57
|
-
* @param {(string|string[])} [settings.text=""] a string, or an array of strings
|
|
58
|
-
* @example
|
|
59
|
-
* var font = new me.Text(0, 0, {font: "Arial", size: 8, fillStyle: this.color});
|
|
40
|
+
* @augments Renderable
|
|
60
41
|
*/
|
|
61
42
|
class Text extends Renderable {
|
|
62
|
-
|
|
63
|
-
|
|
43
|
+
/**
|
|
44
|
+
* @param {number} x position of the text object
|
|
45
|
+
* @param {number} y position of the text object
|
|
46
|
+
* @param {object} settings the text configuration
|
|
47
|
+
* @param {string} settings.font a CSS family font name
|
|
48
|
+
* @param {number|string} settings.size size, or size + suffix (px, em, pt)
|
|
49
|
+
* @param {Color|string} [settings.fillStyle="#000000"] a CSS color value
|
|
50
|
+
* @param {Color|string} [settings.strokeStyle="#000000"] a CSS color value
|
|
51
|
+
* @param {number} [settings.lineWidth=1] line width, in pixels, when drawing stroke
|
|
52
|
+
* @param {string} [settings.textAlign="left"] horizontal text alignment
|
|
53
|
+
* @param {string} [settings.textBaseline="top"] the text baseline
|
|
54
|
+
* @param {number} [settings.lineHeight=1.0] line spacing height
|
|
55
|
+
* @param {Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] anchor point to draw the text at
|
|
56
|
+
* @param {boolean} [settings.offScreenCanvas=false] whether to draw the font to an individual "cache" texture first
|
|
57
|
+
* @param {(string|string[])} [settings.text=""] a string, or an array of strings
|
|
58
|
+
* @example
|
|
59
|
+
* var font = new me.Text(0, 0, {font: "Arial", size: 8, fillStyle: this.color});
|
|
60
|
+
*/
|
|
64
61
|
constructor(x, y, settings) {
|
|
65
62
|
// call the parent constructor
|
|
66
63
|
super(x, y, settings.width || 0, settings.height || 0);
|
|
@@ -73,9 +70,9 @@ class Text extends Renderable {
|
|
|
73
70
|
/**
|
|
74
71
|
* defines the color used to draw the font.<br>
|
|
75
72
|
* @public
|
|
76
|
-
* @type {
|
|
73
|
+
* @type {Color}
|
|
77
74
|
* @default black
|
|
78
|
-
* @name
|
|
75
|
+
* @name Text#fillStyle
|
|
79
76
|
*/
|
|
80
77
|
if (typeof settings.fillStyle !== "undefined") {
|
|
81
78
|
if (settings.fillStyle instanceof Color) {
|
|
@@ -91,9 +88,9 @@ class Text extends Renderable {
|
|
|
91
88
|
/**
|
|
92
89
|
* defines the color used to draw the font stroke.<br>
|
|
93
90
|
* @public
|
|
94
|
-
* @type {
|
|
91
|
+
* @type {Color}
|
|
95
92
|
* @default black
|
|
96
|
-
* @name
|
|
93
|
+
* @name Text#strokeStyle
|
|
97
94
|
*/
|
|
98
95
|
if (typeof settings.strokeStyle !== "undefined") {
|
|
99
96
|
if (settings.strokeStyle instanceof Color) {
|
|
@@ -111,7 +108,7 @@ class Text extends Renderable {
|
|
|
111
108
|
* @public
|
|
112
109
|
* @type {number}
|
|
113
110
|
* @default 1
|
|
114
|
-
* @name
|
|
111
|
+
* @name Text#lineWidth
|
|
115
112
|
*/
|
|
116
113
|
this.lineWidth = settings.lineWidth || 1;
|
|
117
114
|
|
|
@@ -121,7 +118,7 @@ class Text extends Renderable {
|
|
|
121
118
|
* @public
|
|
122
119
|
* @type {string}
|
|
123
120
|
* @default "left"
|
|
124
|
-
* @name
|
|
121
|
+
* @name Text#textAlign
|
|
125
122
|
*/
|
|
126
123
|
this.textAlign = settings.textAlign || "left";
|
|
127
124
|
|
|
@@ -131,7 +128,7 @@ class Text extends Renderable {
|
|
|
131
128
|
* @public
|
|
132
129
|
* @type {string}
|
|
133
130
|
* @default "top"
|
|
134
|
-
* @name
|
|
131
|
+
* @name Text#textBaseline
|
|
135
132
|
*/
|
|
136
133
|
this.textBaseline = settings.textBaseline || "top";
|
|
137
134
|
|
|
@@ -141,7 +138,7 @@ class Text extends Renderable {
|
|
|
141
138
|
* @public
|
|
142
139
|
* @type {number}
|
|
143
140
|
* @default 1.0
|
|
144
|
-
* @name
|
|
141
|
+
* @name Text#lineHeight
|
|
145
142
|
*/
|
|
146
143
|
this.lineHeight = settings.lineHeight || 1.0;
|
|
147
144
|
|
|
@@ -152,16 +149,13 @@ class Text extends Renderable {
|
|
|
152
149
|
* @public
|
|
153
150
|
* @type {boolean}
|
|
154
151
|
* @default false
|
|
155
|
-
* @name
|
|
152
|
+
* @name Text#offScreenCanvas
|
|
156
153
|
*/
|
|
157
154
|
this.offScreenCanvas = false;
|
|
158
155
|
|
|
159
156
|
/**
|
|
160
157
|
* the text to be displayed
|
|
161
158
|
* @private
|
|
162
|
-
* @type {string[]}
|
|
163
|
-
* @name _text
|
|
164
|
-
* @memberOf me.Text
|
|
165
159
|
*/
|
|
166
160
|
this._text = [];
|
|
167
161
|
|
|
@@ -171,7 +165,7 @@ class Text extends Renderable {
|
|
|
171
165
|
* @type {number}
|
|
172
166
|
* @name fontSize
|
|
173
167
|
* @default 10
|
|
174
|
-
* @
|
|
168
|
+
* @memberof Text
|
|
175
169
|
*/
|
|
176
170
|
this.fontSize = 10;
|
|
177
171
|
|
|
@@ -215,22 +209,21 @@ class Text extends Renderable {
|
|
|
215
209
|
onDeactivateEvent() {
|
|
216
210
|
// free the canvas and potential corresponding texture when deactivated
|
|
217
211
|
if (this.offScreenCanvas === true) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
renderer.cache.remove(this.canvas);
|
|
221
|
-
}
|
|
212
|
+
renderer.currentCompositor.deleteTexture2D(renderer.currentCompositor.getTexture2D(this.glTextureUnit));
|
|
213
|
+
renderer.cache.delete(this.canvas);
|
|
222
214
|
this.canvas.width = this.canvas.height = 0;
|
|
223
215
|
this.context = undefined;
|
|
224
216
|
this.canvas = undefined;
|
|
217
|
+
this.glTextureUnit = undefined;
|
|
225
218
|
}
|
|
226
219
|
}
|
|
227
220
|
|
|
228
221
|
/**
|
|
229
222
|
* make the font bold
|
|
230
223
|
* @name bold
|
|
231
|
-
* @
|
|
224
|
+
* @memberof Text.prototype
|
|
232
225
|
* @function
|
|
233
|
-
* @returns {
|
|
226
|
+
* @returns {Text} this object for chaining
|
|
234
227
|
*/
|
|
235
228
|
bold() {
|
|
236
229
|
this.font = "bold " + this.font;
|
|
@@ -241,9 +234,9 @@ class Text extends Renderable {
|
|
|
241
234
|
/**
|
|
242
235
|
* make the font italic
|
|
243
236
|
* @name italic
|
|
244
|
-
* @
|
|
237
|
+
* @memberof Text.prototype
|
|
245
238
|
* @function
|
|
246
|
-
* @returns {
|
|
239
|
+
* @returns {Text} this object for chaining
|
|
247
240
|
*/
|
|
248
241
|
italic() {
|
|
249
242
|
this.font = "italic " + this.font;
|
|
@@ -254,11 +247,11 @@ class Text extends Renderable {
|
|
|
254
247
|
/**
|
|
255
248
|
* set the font family and size
|
|
256
249
|
* @name setFont
|
|
257
|
-
* @
|
|
250
|
+
* @memberof Text.prototype
|
|
258
251
|
* @function
|
|
259
252
|
* @param {string} font a CSS font name
|
|
260
253
|
* @param {number|string} [size=10] size in px, or size + suffix (px, em, pt)
|
|
261
|
-
* @returns {
|
|
254
|
+
* @returns {Text} this object for chaining
|
|
262
255
|
* @example
|
|
263
256
|
* font.setFont("Arial", 20);
|
|
264
257
|
* font.setFont("Arial", "1.5em");
|
|
@@ -298,10 +291,10 @@ class Text extends Renderable {
|
|
|
298
291
|
/**
|
|
299
292
|
* change the text to be displayed
|
|
300
293
|
* @name setText
|
|
301
|
-
* @
|
|
294
|
+
* @memberof Text.prototype
|
|
302
295
|
* @function
|
|
303
296
|
* @param {number|string|string[]} value a string, or an array of strings
|
|
304
|
-
* @returns {
|
|
297
|
+
* @returns {Text} this object for chaining
|
|
305
298
|
*/
|
|
306
299
|
setText(value = "") {
|
|
307
300
|
if (this._text.toString() !== value.toString()) {
|
|
@@ -319,11 +312,11 @@ class Text extends Renderable {
|
|
|
319
312
|
/**
|
|
320
313
|
* measure the given text size in pixels
|
|
321
314
|
* @name measureText
|
|
322
|
-
* @
|
|
315
|
+
* @memberof Text.prototype
|
|
323
316
|
* @function
|
|
324
|
-
* @param {
|
|
317
|
+
* @param {CanvasRenderer|WebGLRenderer} [renderer] reference to the active renderer
|
|
325
318
|
* @param {string} [text] the text to be measured
|
|
326
|
-
* @param {
|
|
319
|
+
* @param {Rect|Bounds} [ret] a object in which to store the text metrics
|
|
327
320
|
* @returns {TextMetrics} a TextMetrics object with two properties: `width` and `height`, defining the output dimensions
|
|
328
321
|
*/
|
|
329
322
|
measureText(renderer, text, ret) {
|
|
@@ -380,7 +373,8 @@ class Text extends Renderable {
|
|
|
380
373
|
|
|
381
374
|
if (renderer instanceof WebGLRenderer) {
|
|
382
375
|
// invalidate the previous corresponding texture so that it can reuploaded once changed
|
|
383
|
-
renderer.
|
|
376
|
+
this.glTextureUnit = renderer.cache.getUnit(renderer.cache.get(this.canvas));
|
|
377
|
+
renderer.currentCompositor.unbindTexture2D(null, this.glTextureUnit);
|
|
384
378
|
|
|
385
379
|
if (renderer.WebGLVersion === 1) {
|
|
386
380
|
// round size to next Pow2
|
|
@@ -407,9 +401,9 @@ class Text extends Renderable {
|
|
|
407
401
|
/**
|
|
408
402
|
* draw a text at the specified coord
|
|
409
403
|
* @name draw
|
|
410
|
-
* @
|
|
404
|
+
* @memberof Text.prototype
|
|
411
405
|
* @function
|
|
412
|
-
* @param {
|
|
406
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer Reference to the destination renderer instance
|
|
413
407
|
* @param {string} [text]
|
|
414
408
|
* @param {number} [x]
|
|
415
409
|
* @param {number} [y]
|
|
@@ -473,9 +467,9 @@ class Text extends Renderable {
|
|
|
473
467
|
* by the `lineWidth` and `fillStroke` properties. <br>
|
|
474
468
|
* Note : using drawStroke is not recommended for performance reasons
|
|
475
469
|
* @name drawStroke
|
|
476
|
-
* @
|
|
470
|
+
* @memberof Text.prototype
|
|
477
471
|
* @function
|
|
478
|
-
* @param {
|
|
472
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer Reference to the destination renderer instance
|
|
479
473
|
* @param {string} text
|
|
480
474
|
* @param {number} x
|
|
481
475
|
* @param {number} y
|
package/src/tweens/easing.js
CHANGED