Class: Text

me. Text

new Text(x, y, settings)

a generic system font object.
Parameters:
Name Type Description
x Number position of the text object
y Number position of the text object
settings Object the text configuration
Properties
Name Type Argument Default Description
font String a CSS family font name
size Number | String size, or size + suffix (px, em, pt)
fillStyle me.Color | String <optional>
"#000000" a CSS color value
strokeStyle me.Color | String <optional>
"#000000" a CSS color value
lineWidth Number <optional>
1 line width, in pixels, when drawing stroke
textAlign String <optional>
"left" horizontal text alignment
textBaseline String <optional>
"top" the text baseline
lineHeight Number <optional>
1.0 line spacing height
anchorPoint me.Vector2d <optional>
{x:0.0, y:0.0} anchor point to draw the text at
text String | Array.<String> <optional>
a string, or an array of strings
Source:
text.js, line 54

Extends

Members

alpha :Number

Define the renderable opacity
Set to zero if you do not wish an object to be drawn
Type:
  • Number
Inherited From:
Default Value:
  • 1.0
Source:
renderable.js, line 213
See:
  • me.Renderable#setOpacity
  • me.Renderable#getOpacity

ancestor :me.Container|me.Entity

a reference to the parent object that contains this renderable
Type:
Inherited From:
Default Value:
  • undefined
Source:
renderable.js, line 225

Methods

<static> bold()

make the font bold
Source:
text.js, line 170
Returns:
this object for chaining

<static> draw(renderer, text, x, y)

draw a text at the specified coord
Parameters:
Name Type Argument Description
renderer me.CanvasRenderer | me.WebGLRenderer Reference to the destination renderer instance
text String <optional>
x Number <optional>
y Number <optional>
Source:
text.js, line 329

<static> drawStroke(renderer, text, x, y)

draw a stroke text at the specified coord, as defined
by the `lineWidth` and `fillStroke` properties.
Note : using drawStroke is not recommended for performance reasons
Parameters:
Name Type Description
renderer me.CanvasRenderer | me.WebGLRenderer Reference to the destination renderer instance
text String
x Number
y Number
Source:
text.js, line 386

<static> italic()

make the font italic
Source:
text.js, line 183
Returns:
this object for chaining

<static> measureText(renderer, text, ret) → {TextMetrics}

measure the given text size in pixels
Parameters:
Name Type Argument Description
renderer me.CanvasRenderer | me.WebGLRenderer <optional>
reference a renderer instance
text String <optional>
the text to be measured
ret me.Rect <optional>
a object in which to store the text metrics
Source:
text.js, line 261
Returns:
a TextMetrics object with two properties: `width` and `height`, defining the output dimensions
Type
TextMetrics

<static> setFont(font, size)

set the font family and size
Parameters:
Name Type Description
font String a CSS font name
size Number | String size, or size + suffix (px, em, pt)
Source:
text.js, line 196
Returns:
this object for chaining
Example
font.setFont("Arial", 20);
font.setFont("Arial", "1.5em");

<static> setText(})

change the text to be displayed
Parameters:
Name Type Description
} Number | String | Array.<String> value a string, or an array of strings
Source:
text.js, line 240
Returns:
this object for chaining