Label

Label

Creates a static single line text label.

Constructor

# new Label(parent, x, y, text)

Constructor
Parameters:
Name Type Description
parent HTMLElement The element to add this label to.
x number The x position of the label. Default 0.
y number The y position of the label. Default 0.
text string The initial text to display in the label. Default empty string.
Source:
Example
const panel = new Panel(document.body, 20, 20, 200, 200);
new Label(panel, 20, 20, "I am a label");

Extends

Classes

Label

Members

# (static) fontSize

Default fontSize of all labels.
Source:

# align

Gets and sets the horizontal alignment of the text in the label (left, right, center). This property will be ingored unless autosize is set to false and the label's width is set to a value higher than the actual width of the text.
Source:

# autosize

Gets and sets whether or not the size of the label will automatically adjust to fit the text assigned to it. If autosize is true, setting width or align will be ignored.
Source:

# bold

Gets and sets whether or not the text will be bold.
Source:

# color

Gets and sets the color of the text.
Source:

# enabled

Sets and gets whether or not this component is enabled. Non-enabled components will be faded out and not respond to events.
Overrides:

# fontSize

Gets and sets the size of the text.
Source:

# height

Sets and gets the height of this component.
Overrides:

# italic

Gets and sets whether or not the text will be italicized.
Source:

# text

Gets and sets the plain text to be displayed. Compare with the htmlText property.
Source:

# width

Sets and gets the width of this component.
Overrides:

# x

Sets and gets the x position of this component.
Overrides:

# y

Sets and gets the y position of this component.
Overrides:

Methods

# getAlign()

Source:
Returns:
the alignment of the text.

# getAutoSize()

Source:
Returns:
whether or not the label will adjust its size automatically.

# getBold()

Source:
Returns:
whether or not the text is bold.

# getColor()

Source:
Returns:
the color of the text.

# getEnabled()

Gets whether the component is enabled.
Returns:
Whether or not the component is enabled.

# getFontSize()

Source:
Returns:
the font size used in the label.

# getHeight()

Gets the height of the component.
Overrides:
Returns:
The height of the component.

# getItalic()

Source:
Returns:
whether or not the text will be italic.

# getText()

Source:
Returns:
the text in the label.

# getWidth()

Gets the width of the component.
Overrides:
Returns:
The width of the component.

# getX()

Gets the x position of the component.
Overrides:
Returns:
The x position of the component.

# getY()

Gets the y position of the component.
Overrides:
Returns:
The y position of the component.

# move(x, y)

Moves the component to a specified position.
Parameters:
Name Type Description
x number The new x position of the component.
y number The new y position of the component.
Overrides:
Returns:
This instance, suitable for chaining.

# rotate(rad)

Rotates the component.
Parameters:
Name Type Description
rad number The number of radians to rotate the component by.
Overrides:
Returns:
This instance, suitable for chaining.

# rotateDeg(deg)

Rotates the component.
Parameters:
Name Type Description
deg number The number of degrees to rotate the component by.
Overrides:
Returns:
This instance, suitable for chaining.

# setAlign(align)

Sets the alignment of the label's text - "left" (default), "right" or "center".
Parameters:
Name Type Description
align string The alignment of the text.
Source:
Returns:
This instance, suitable for chaining.

# setAutosize(autosize)

Sets whether the label will be automatically sized to fit its text.
Parameters:
Name Type Description
autosize boolean Whether the label will be auto-sized.
Source:
Returns:
This instance, suitable for chaining.

# setBold(bold)

Sets wheter or not the text will be bold.
Parameters:
Name Type Description
bold boolean Whether or not the text will be bold.
Source:
Returns:
This instance, suitable for chaining.

# setColor(color)

Sets the color of the text.
Parameters:
Name Type Description
color string The color of the text.
Source:
Returns:
This instance, suitable for chaining.

# setEnabled(enabled)

Sets the enabled state of this component.
Parameters:
Name Type Description
enabled boolean Whether or not the component will be enabled.
Returns:
This instance, suitable for chaining.

# setFontSize(fontSize)

Sets the font size of the text.
Parameters:
Name Type Description
fontSize number The font size of the text.
Source:
Returns:
This instance, suitable for chaining.

# setHeight(height)

Sets the height of this component.
Parameters:
Name Type Description
height number The height of this component.
Overrides:
Returns:
This instance, suitable for chaining.

# setItalic(italics)

Sets whether or not the text will be italicized.
Parameters:
Name Type Description
italics boolean Whether or not the text will be italicized.
Source:
Returns:
This instance, suitable for chaining.

# setSize(w, h)

Sizes the component.
Parameters:
Name Type Description
w number The new width of the component.
h number The new height of the component.
Overrides:
Returns:
This instance, suitable for chaining.

# setText(text)

Sets the label's text.
Parameters:
Name Type Description
text string The text of the label.
Source:
Returns:
This instance, suitable for chaining.

# setWidth(width)

Sets the width of this component.
Parameters:
Name Type Description
width number The width of this component.
Overrides:
Returns:
This instance, suitable for chaining.

# setX(x)

Sets the x position of this component.
Parameters:
Name Type Description
x number The x position of this component.
Overrides:
Returns:
This instance, suitable for chaining.

# setY(y)

Sets the y position of this component.
Parameters:
Name Type Description
y number The y position of this component.
Overrides:
Returns:
this instance, suitable for chaining.