import GameObject from '../core/GameObject.js'; import Vector2 from '../math/Vector2.js'; /** Horizontal alignment options for text. */ export type HorizontalAlign = 'left' | 'right' | 'centre' | 'start' | 'end'; /** Vertical alignment options for text. */ export type VerticalAlign = 'top' | 'hanging' | 'middle' | 'alphabetic' | 'ideographic' | 'bottom'; /** * Configuration for creating a Text object. */ export interface TextProperties { /** Unique tag for identification. */ tag?: string; /** Hidden identifier linking runtime object to its source code location. */ __sourceId?: string; /** Fill colour of the text. */ colour?: string; /** Optional background box colour. */ backgroundColour?: string; /** Font size in pixels. */ fontSize?: string; /** Font family (e.g., 'Arial', 'Helvetica'). */ font?: string; /** The text content to display. */ text: string; /** Horizontal alignment relative to the position. */ horizontalAlign?: HorizontalAlign; /** Vertical alignment relative to the position. */ verticalAlign?: VerticalAlign; /** Anchor position for the text. */ position: Vector2; /** Optional width for background box. */ width?: number; /** Optional height for background box. */ height?: number; /** Render order. */ zIndex?: number; /** Whether to register with the engine immediately. */ register?: boolean; /** Callback for click events. */ onClick?: () => void; /** Whether the text is initially visible. */ visible?: boolean; /** Initial physics configuration. */ physics?: { velocity?: Vector2; acceleration?: Vector2; mass?: number; isStatic?: boolean; restitution?: number; friction?: number; isSensor?: boolean; }; } /** * Represents text that can be drawn to the screen and interact with input. */ export default class Text extends GameObject { #private; /** Internal text component. */ private _textComponent; /** Text fill colour. */ get colour(): string; set colour(val: string); /** Background box colour. */ get backgroundColour(): string; set backgroundColour(val: string); /** Font size in pixels. */ fontSize: number; /** Compiled font string (e.g., '25px Helvetica'). */ get font(): string; set font(val: string); /** The text content. */ get text(): string; set text(val: string); /** Number of characters in the text string. */ length: number; /** Horizontal alignment ('left', 'centre', 'right'). */ get horizontalAlign(): HorizontalAlign; set horizontalAlign(val: HorizontalAlign); /** Vertical alignment ('top', 'middle', 'bottom'). */ get verticalAlign(): VerticalAlign; set verticalAlign(val: VerticalAlign); /** Whether the object should be automatically registered with the engine. */ register: boolean; /** Whether the object is currently registered with the engine. */ registered: boolean; /** * Callback function for click events. * Only triggered if the object is registered. */ onClick: () => void; /** * initialises a new instance of a Text object. * @param props Configuration properties for the text. */ constructor(props: TextProperties); /** Registers the text object with the engine for rendering and interaction. */ registerSelf(): void; /** Removes the text object from the engine. */ destroySelf(): void; }