Home Reference Source
private class | source

Text

Extends:

WorldElement → Text

A Text Box allows for text to be displayed on a Box element. The text can be multiline containing \n caracters. A Text object is created by calling the method Box.addText on the parent Box.

Constructor Summary

Public Constructor
public

constructor(box: Box, width: number, height: number, opts: object)

Member Summary

Public Members
public

box: Box

Sets the parent box where te Text will be placed.

public

Sets the height of the Text in pixels.

public

Contains the string to be displayed separated by every \n character.

public

Sets the width of the Text in pixels.

Method Summary

Public Methods
public

setText(rawText: string)

Sets the text that will be displayed.

Private Methods
private

debug()

Debug function used to draw a box around the dimensions of the text object.

private

draw()

Draw function for the Text called by the parent box.

Inherited Summary

From class WorldElement
public

Sets the color in HEX format of the element.

public

Sets the cursor style when the mouse is over the element.

public

Flag for enabling or diabling this element.

public

Flag set when the element is being dragged around.

public

Sets the font of the element.

public

Sets the current height of the element.

public

Flag for allowing the element to be dragged around.

public

Sets the move style of the element.

public

Flag set when the mouse is over the element.

public

Sets a callback function for when the element is dragged around.

public

Sets the position of the element.

public

Sets the renderer used for the element.

public

Sets the rotation of the element.

public

A copy of the z-index value is stored here.

public

Sets the drawing scale of the element.

public

Flag for determining if the element will be a top-most element when dragged around.

public

Flag used to determine if an object is a child of WorldElement.

public

Sets the current width of the element.

public

Sets the world where this element is found.

public

Sets the z-index of the element.

public

Adds the provided coordinates to the position.

public

Sets if the element is draggable.

public

Function called when the mouse moves to check if the pointer is over the element.

public

Sets the color in HEX format of the element.

public

Sets the position of the element.

public

Sets the scale of the element.

public

setZ(z: number)

Sets the z-index of the element.

private

resize()

Function called when the canvas gets resized.

private

setWorld(world: World)

Sets the world object where element will be drawn.

private

topmost(state: boolean)

Sets the element as a topmost element.

Public Constructors

public constructor(box: Box, width: number, height: number, opts: object) source

Override:

WorldElement#constructor

Params:

NameTypeAttributeDescription
box Box

Parent box.

width number

Width of the text in pixels.

height number

Height of the text in pixels.

opts object
  • optional

Object that contains valid Text properties with values. Their values will be assigned at the end of the constructor. If an invalid property is passed then the value will be ignored.

Public Members

public box: Box source

Sets the parent box where te Text will be placed.

public height: number source

Sets the height of the Text in pixels.

Override:

WorldElement#height

public text: string[] source

Contains the string to be displayed separated by every \n character. Default value is [].

public width: number source

Sets the width of the Text in pixels.

Override:

WorldElement#width

Public Methods

public setText(rawText: string) source

Sets the text that will be displayed. The text can have multiple lines.

Params:

NameTypeAttributeDescription
rawText string

Text to be displayed.

Private Methods

private debug() source

Debug function used to draw a box around the dimensions of the text object. It is only drawn if the parent box has the flag Box.debug enabled.

private draw() source

Draw function for the Text called by the parent box.