/** * Signed Distance Field (SDF) rasterizer * * For each pixel, compute the shortest distance to the outline. * Positive values are inside the outline, negative are outside. * This allows GPU text rendering at any scale. * * Algorithm: * 1. For each pixel center, find the minimum distance to all outline edges * 2. Determine sign based on whether point is inside or outside the outline * 3. Normalize and encode to 0-255 (128 = on the edge) */ import type { GlyphPath } from "../render/path.ts"; import { type Bitmap } from "./types.ts"; /** * Options for SDF rendering */ export interface SdfOptions { /** Width in pixels */ width: number; /** Height in pixels */ height: number; /** Scale factor (font units to pixels) */ scale: number; /** X offset in pixels */ offsetX?: number; /** Y offset in pixels */ offsetY?: number; /** Flip Y axis (font coords are Y-up, bitmap is Y-down) */ flipY?: boolean; /** Spread/radius - how far the distance field extends in pixels (default: 8) */ spread?: number; } /** * Render a glyph path as a signed distance field * @param path Glyph path to render * @param options SDF rendering options (dimensions, scale, spread) * @returns Grayscale bitmap with signed distance field (128 = on edge, 255 = inside, 0 = outside) */ export declare function renderSdf(path: GlyphPath, options: SdfOptions): Bitmap;