Class: Label

Label()

new Label()

A simple UI element for displaying text.
Source:

Extends

  • BaseUIElement

Methods

(protected) _drawSelf(context, engine)

Specific drawing logic for the Label. Called by BaseUIElement.render after visibility and context checks.
Parameters:
Name Type Description
context CanvasRenderingContext2D The rendering context.
engine
Source:

setText(newText)

Sets the text content of the label.
Parameters:
Name Type Description
newText string The new text to display.
Source:

update(deltaTime, engine, mousePosopt)

Update logic for the Label (typically none for a static label).
Parameters:
Name Type Attributes Description
deltaTime number The time elapsed since the last frame.
engine
mousePos Object <optional>
Current canvas-relative mouse position.
Source:

Label(options)

new Label(options)

Creates an instance of Label.
Parameters:
Name Type Description
options object Configuration options for the label.
Properties
Name Type Attributes Default Description
x number <optional>
0 The x-coordinate of the label.
y number <optional>
0 The y-coordinate of the label.
text string The text content of the label.
font string <optional>
'16px sans-serif' The font style (e.g., '20px Arial', 'bold 16px Verdana').
color string <optional>
'white' The color of the text.
textAlign string <optional>
'left' Horizontal alignment of the text ('left', 'center', 'right', 'start', 'end').
textBaseline string <optional>
'top' Vertical alignment of the text ('top', 'middle', 'bottom', 'alphabetic', 'hanging', 'ideographic').
visible boolean <optional>
true Whether the label is visible.
enabled boolean <optional>
true Whether the label is enabled (usually doesn't affect Labels directly unless for color change).
id string <optional>
Optional ID for the label.
disabledColor string <optional>
'gray' Optional color for text when element is disabled.
width number <optional>
Optional: Explicit width.
height number <optional>
Optional: Explicit height.
Source:

Methods

(protected) _drawSelf(context, engine)

Specific drawing logic for the Label. Called by BaseUIElement.render after visibility and context checks.
Parameters:
Name Type Description
context CanvasRenderingContext2D The rendering context.
engine
Source:

setText(newText)

Sets the text content of the label.
Parameters:
Name Type Description
newText string The new text to display.
Source:

update(deltaTime, engine, mousePosopt)

Update logic for the Label (typically none for a static label).
Parameters:
Name Type Attributes Description
deltaTime number The time elapsed since the last frame.
engine
mousePos Object <optional>
Current canvas-relative mouse position.
Source: