EaselJS

EaselJS  0.3.2

EaselJS > EaselJS > Text
Search:
 
Filters

Class Text - extends DisplayObject

Allows you to display one or more lines of dynamic text (not user editable) in the display list. Line wrapping support (using the lineWidth is very basic, wrapping on spaces and tabs only. Note that as an alternative to Text, you can position HTML text above or below the canvas relative to items in the display list using the localToGlobal() method.

Constructor

Text ( text , font , color )
Parameters:
text <String> Optional. The text to display.
font <String> Optional. The font style to use. Any valid value for the CSS font attribute is acceptable (ex. "36px bold Arial").
color <String> Optional. The color to draw the text in. Any valid value for the CSS color attribute is acceptable (ex. "#F00").

Properties

color - String

The color to draw the text in. Any valid value for the CSS color attribute is acceptable (ex. "#F00").

font - String

The font style to use. Any valid value for the CSS font attribute is acceptable (ex. "bold 36px Arial").

lineHeight - Number

Indicates the line height (vertical distance between baselines) for multi-line text. If null, the value of getMeasuredLineHeight is used.

lineWidth - Number

Indicates the maximum width for a line of text before it is wrapped to multiple lines. If null, the text will not be wrapped.

maxWidth - Number

The maximum width to draw the text. If maxWidth is specified (not null), the text will be condensed or shrunk to make it fit in this width. For detailed information view the whatwg spec.

outline - Boolean

If true, the text will be drawn as a stroke (outline). If false, the text will be drawn as a fill.

text - String

The text to display.

textAlign - String

The horizontal text alignment. Any of "start", "end", "left", "right", and "center". For detailed information view the whatwg spec.

textBaseline - String

The vertical alignment point on the font. Any of "top", "hanging", "middle", "alphabetic", "ideographic", or "bottom". For detailed information view the whatwg spec.

Methods

_drawTextLine

protected void _drawTextLine ( ctx , text , y )
Parameters:
ctx <CanvasRenderingContext2D>
text <Text>
y <Number>
Returns: void

_getWorkingContext

protected void _getWorkingContext ( )
Returns: void

clone

Point clone ( )
Returns a clone of the Point instance.
Returns: Point
a clone of the Point instance.

cloneProps

protected void cloneProps ( o )
Parameters:
o <Text>
Returns: void

draw

void draw ( ctx , ignoreCache )
Draws the Text into the specified context ignoring it's visible, alpha, shadow, and transform. Returns true if the draw was handled (useful for overriding functionality). NOTE: This method is mainly for internal use, though it may be useful for advanced uses.
Parameters:
ctx <CanvasRenderingContext2D> The canvas 2D context object to draw into.
ignoreCache <Boolean> Indicates whether the draw operation should ignore any current cache. For example, used for drawing the cache (to prevent it from simply drawing an existing cache back into itself).
Returns: void

getMeasuredLineHeight

Number getMeasuredLineHeight ( )
Returns an approximate line height of the text, ignoring the lineHeight property. This is based on the measured width of a "M" character multiplied by 1.2, which approximates em for most fonts.
Returns: Number
an approximate line height of the text, ignoring the lineHeight property. This is based on the measured width of a "M" character multiplied by 1.2, which approximates em for most fonts.

getMeasuredWidth

Number getMeasuredWidth ( )
Returns the measured, untransformed width of the text.
Returns: Number
The measured, untransformed width of the text.

initialize

protected void initialize ( )
Initialization method.
Returns: void

isVisible

Boolean isVisible ( )
Returns true or false indicating whether the display object would be visible if drawn to a canvas. This does not account for whether it would be visible within the boundaries of the stage. NOTE: This method is mainly for internal use, though it may be useful for advanced uses.
Returns: Boolean
Boolean indicating whether the display object would be visible if drawn to a canvas

toString

String toString ( )
Returns a string representation of this object.
Returns: String
a string representation of the instance.

Events inherited from DisplayObject: