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