import { Point } from '../geom/point.js'; import { DisplayObject } from './display_object.js'; import { Image } from './image.js'; import type { BitmapFontCacheEntry } from '../core/cache.js'; import type { Game } from '../core/game.js'; import type { BitmapFontData } from '../core/loader_parser.js'; /** One measured line of bitmap text: its width, its content and where each glyph starts. */ export type BitmapTextLine = { width: number; text: string; end: boolean; chars: number[]; y: number; }; export declare class BitmapText extends DisplayObject { type: number; pendingDestroy: boolean; renderOrderID: number; textWidth: number; textHeight: number; _prevAnchor: Point; _glyphs: Image[]; _maxWidth: number; _text: string; _data: BitmapFontCacheEntry | null; _font: string; _fontSize: number; _align: string; _tint: number; dirty: boolean; /** * Creates a new BitmapText instance. * @param {Game} game - The game instance this bitmap text belongs to. * @param {number} x - The x position of the bitmap text. * @param {number} y - The y position of the bitmap text. * @param {string} font - The key of the bitmap font to use. * @param {string} text - The text to display. * @param {number} size - The font size. * @param {string} align - The text alignment (left, center, right). */ constructor(game: Game, x?: number, y?: number, font?: string, text?: string, size?: number, align?: string); /** * Destroys this bitmap text and cleans up resources. */ destroy(): void; /** * Called before the update cycle for this bitmap text. */ preUpdate(): void; /** * Sets the text to display. * @param {string} text - The new text to display. */ setText(text: string): void; /** * Scans a line of text to calculate its width and other properties. * @param {object} data - The font data for this bitmap text. * @param {number} scale - The scaling factor to apply to the font size. * @param {string} text - The text to scan. * @returns {{width: number, text: string, end: boolean, chars: number[]}} An object containing the width, processed text, end status, and character positions. */ scanLine(data: BitmapFontData, scale: number, text: string): Omit; /** * Cleans the provided text by removing invalid characters and replacing them with a specified character. * @param {string} text - The text to clean. * @param {string} replace - The character to use for replacement of invalid characters (default: ''). * @returns {string} The cleaned text. */ cleanText(text: string, replace?: string): string; /** * Updates the internal text rendering based on current properties and content. */ updateText(): void; /** * Removes unused glyphs from the pool and returns the number removed. * @returns {number} The number of glyphs that were removed from the pool. */ purgeGlyphs(): number; /** * Updates the transform of this bitmap text, updating its text if needed. */ updateTransform(): this; /** * Adds a color to a specific position in the text. * @param {string} value - The color to apply (in hex format or CSS color name). * @param {number} _position - The character position to apply the color to. * @returns {BitmapText} This bitmap text instance for chaining. */ addColor(value: string, _position: number): this; /** * Gets the text alignment property. * @returns {string} The current text alignment (left, center, right). */ get align(): string; /** * Sets the text alignment property. * @param {string} value - The new text alignment (left, center, right). */ set align(value: string); /** * Gets the tint color of this bitmap text. * @returns {number} The current tint color in RGB format. */ get tint(): number; /** * Sets the tint color of this bitmap text. * @param {number} value - The new tint color in RGB format. */ set tint(value: number); /** * Gets the fill color of this bitmap text as a hex string. * @returns {string} The current fill color in hex format. */ get fill(): string; /** * Sets the fill color of this bitmap text. * @param {string} value - The new fill color in hex format or CSS color name. */ set fill(value: string); /** * Gets the font key used by this bitmap text. * @returns {string} The current font key. */ get font(): string; /** * Sets the font key used by this bitmap text. * @param {string} value - The new font key to use. */ set font(value: string); /** * Gets the font size of this bitmap text. * @returns {number} The current font size. */ get fontSize(): number; /** * Sets the font size of this bitmap text. * @param {number} value - The new font size to use. */ set fontSize(value: number | string); /** * Gets the text content of this bitmap text. * @returns {string} The current text content. */ get text(): string; /** * Sets the text content of this bitmap text. * @param {string | number | boolean | Date} value - The new text content to set. */ set text(value: string | number | boolean | Date); /** * Gets the maximum width of this bitmap text. * @returns {number} The current maximum width. */ get maxWidth(): number; /** * Sets the maximum width of this bitmap text. * @param {number} value - The new maximum width to set. */ set maxWidth(value: number); /** * Gets whether smoothing is enabled for this bitmap text's font. * @returns {boolean} True if smoothing is enabled, false otherwise. */ get smoothed(): boolean; /** * Sets whether smoothing is enabled for this bitmap text's font. * @param {boolean} value - Whether to enable smoothing (true) or not (false). */ set smoothed(value: boolean); } //# sourceMappingURL=bitmap_text.d.ts.map