import RenderComponent from './RenderComponent.js'; import type { HorizontalAlign, VerticalAlign } from '../objects/Text.js'; /** * Component that holds data for rendering text. */ export default class TextComponent extends RenderComponent { /** Text fill colour. */ colour: string; /** Background box colour. */ backgroundColour: string; /** Compiled font string (e.g., '25px Helvetica'). */ font: string; /** The text content. */ text: string; /** Horizontal alignment. */ horizontalAlign: HorizontalAlign; /** Vertical alignment. */ verticalAlign: VerticalAlign; /** Width of the background box or interaction area. */ get width(): number; set width(val: number); /** Height of the background box or interaction area. */ get height(): number; set height(val: number); private _initialWidth; private _initialHeight; constructor(text: string, font: string, colour: string, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, width: number, height: number, backgroundColour?: string); /** * Ensures the parent GameObject has a BoundsComponent synced with this component. * Note: Bounds represent the BASE local size (unscaled). */ private _updateGameObjectBounds; /** * Lifecycle hook called when the component is added to a GameObject. */ onAttach(): void; /** * Draws the text to the canvas. * @param ctx The canvas 2D rendering context. */ draw(ctx: CanvasRenderingContext2D): void; }