/** Floats per glyph instance. */ export declare const TEXT_FLOATS_PER_INSTANCE = 12; /** Bytes per glyph instance. */ export declare const TEXT_BYTES_PER_INSTANCE: number; /** Metrics and atlas UV for a single glyph. */ export interface GlyphEntry { /** Atlas UV coordinates [u0, v0, u1, v1]. */ uv: [number, number, number, number]; /** Glyph bitmap width in atlas pixels (including SDF padding). */ glyphWidth: number; /** Glyph bitmap height in atlas pixels (including SDF padding). */ glyphHeight: number; /** Horizontal advance width at base font size. */ advance: number; /** Vertical bearing — distance from baseline to glyph top at base font size. */ bearingY: number; } export declare class ChartGlyphAtlas { private device; readonly texture: GPUTexture; readonly textureView: GPUTextureView; readonly sampler: GPUSampler; readonly baseFontSize = 24; private entries; private shelfX; private shelfY; private shelfHeight; private sdfOuterBuf; private sdfInnerBuf; private sdfFBuf; private sdfZBuf; private sdfVBuf; private constructor(); /** * Create the atlas and preload all chart-relevant glyphs. * Uses a scratch Canvas 2D context for initial glyph rasterization, * then computes the SDF and uploads to a GPU texture. */ static create(device: GPUDevice, fontFamily?: string): ChartGlyphAtlas; /** Look up a preloaded glyph entry. Returns undefined for unknown characters. */ getEntry(char: string): GlyphEntry | undefined; /** Release GPU resources. */ destroy(): void; /** * Rasterize a glyph, compute its SDF, pack into atlas, upload to GPU. * Follows the same pipeline as brainiac-engine's GlyphAtlas._generateGlyph. */ private _generateGlyph; private _ensureScratchBuffers; /** * 2D EDT via separable 1D passes (Felzenszwalb & Huttenlocher 2012, §3). * Rows first, then columns — exact Euclidean distances in O(n). */ private _edt2d; /** * 1D squared distance transform via lower envelope of parabolas. * Core algorithm from Felzenszwalb & Huttenlocher 2012, §2. */ private _edt1d; } export declare class TextPipeline { readonly pipeline: GPURenderPipeline; readonly bindGroupLayout: GPUBindGroupLayout; readonly atlas: ChartGlyphAtlas; private device; private instanceBuffer; private instanceCapacity; private instanceData; private instanceCount; private constructor(); /** Create the text pipeline with its SDF glyph atlas. */ static create(device: GPUDevice, format: GPUTextureFormat, uniformBuffer: GPUBuffer, fontFamily?: string): TextPipeline; /** Reset glyph instance count for a new frame. */ reset(): void; /** * Push a text string as a sequence of glyph instances. * * @param text The string to render. * @param x X position in pixels (anchor point depends on align). * @param y Y position in pixels (anchor point depends on baseline). * @param r,g,b,a Text color (0–1 range). * @param fontSize Target font size in pixels. * @param align Horizontal alignment: 'left', 'center', 'right'. * @param baseline Vertical alignment: 'top', 'middle', 'bottom'. */ pushText(text: string, x: number, y: number, r: number, g: number, b: number, a: number, fontSize: number, align: 'left' | 'center' | 'right', baseline: 'top' | 'middle' | 'bottom'): void; /** Upload glyph instance data and return draw parameters. */ flush(uniformBuffer: GPUBuffer): { bindGroup: GPUBindGroup; vertexCount: number; instanceCount: number; } | null; /** Release GPU resources. */ destroy(): void; private _pushGlyph; /** Power-of-two buffer growth. */ private _ensureCapacity; }