/** * Pipe-style functional utilities for composing transforms and rendering * * Provides an alternative to the builder pattern for users who prefer * functional composition. */ import type { Font } from "../font/font.ts"; import { type AsymmetricStrokeOptions } from "../raster/asymmetric-stroke.ts"; import type { Gradient } from "../raster/gradient.ts"; import { type MsdfOptions } from "../raster/msdf.ts"; import { type SdfOptions } from "../raster/sdf.ts"; import type { LineCap, LineJoin, StrokerOptions } from "../raster/stroker.ts"; import type { Bitmap, PixelMode, RasterizeOptions, RasterizedGlyph } from "../raster/types.ts"; import type { Matrix2D, Matrix3x3 } from "../render/outline-transform.ts"; import type { GlyphPath } from "../render/path.ts"; import type { GlyphId } from "../types.ts"; /** * Compose functions left-to-right * * @example * ```typescript * const result = pipe( * getGlyphPath(font, glyphId), * scale(2, 2), * rotate(Math.PI / 4), * rasterize({ width: 100, height: 100 }), * blur(5), * toRGBA * ); * ``` */ export declare function pipe(a: A): A; export declare function pipe(a: A, ab: (a: A) => B): B; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C): C; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D): D; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E): E; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F): F; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G): G; export declare function pipe(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H): H; /** * Get glyph path from font (for use with pipe) */ export declare function fromGlyph(font: Font, glyphId: GlyphId): GlyphPath | null; /** * Scale path uniformly or non-uniformly */ export declare function scale(sx: number, sy?: number): (path: GlyphPath) => GlyphPath; /** * Translate path by offset */ export declare function translate(dx: number, dy: number): (path: GlyphPath) => GlyphPath; /** * Rotate path by angle in radians */ export declare function rotate(angle: number): (path: GlyphPath) => GlyphPath; /** * Rotate path by angle in degrees */ export declare function rotateDeg(angleDeg: number): (path: GlyphPath) => GlyphPath; /** * Shear/skew path */ export declare function shear(shearX: number, shearY: number): (path: GlyphPath) => GlyphPath; /** * Apply italic slant (angle in degrees) */ export declare function italic(angleDeg: number): (path: GlyphPath) => GlyphPath; /** * Apply custom 2D affine matrix */ export declare function matrix(m: Matrix2D): (path: GlyphPath) => GlyphPath; /** * Apply 3D perspective matrix */ export declare function perspective(m: Matrix3x3): (path: GlyphPath) => GlyphPath; /** * Embolden path */ export declare function emboldenPath(strength: number): (path: GlyphPath) => GlyphPath; /** * Condense/expand path horizontally */ export declare function condensePath(factor: number): (path: GlyphPath) => GlyphPath; /** * Apply oblique/slant to path */ export declare function obliquePath(slant: number): (path: GlyphPath) => GlyphPath; /** * Stroke path to create outline */ export declare function strokePath(options: StrokerOptions): (path: GlyphPath) => GlyphPath; export declare function strokePath(width: number, cap?: LineCap, join?: LineJoin): (path: GlyphPath) => GlyphPath; /** * Clone path */ export declare function clone(): (path: GlyphPath) => GlyphPath; /** * Combine multiple paths */ export declare function combinePaths(paths: GlyphPath[]): GlyphPath; /** * Asymmetric stroke with independent X/Y border widths */ export declare function strokeAsymmetric(options: AsymmetricStrokeOptions): (path: GlyphPath) => { outer: GlyphPath; inner: GlyphPath; }; /** * Asymmetric stroke combined (both inner and outer as single fillable path) */ export declare function strokeAsymmetricCombined(options: AsymmetricStrokeOptions): (path: GlyphPath) => GlyphPath; /** * Rasterize path to bitmap */ export declare function rasterize(options: RasterizeOptions): (path: GlyphPath) => Bitmap; /** * Rasterize with auto-computed size from bounds */ export declare function rasterizeAuto(options?: { padding?: number; scale?: number; pixelMode?: PixelMode; }): (path: GlyphPath) => Bitmap; /** * Rasterize with gradient fill */ export declare function rasterizeWithGradient(gradient: Gradient, options: RasterizeOptions): (path: GlyphPath) => Bitmap; /** * Render path as Signed Distance Field */ export declare function renderSdf(options: SdfOptions): (path: GlyphPath) => Bitmap; /** * Render path as Multi-channel Signed Distance Field */ export declare function renderMsdf(options: MsdfOptions): (path: GlyphPath) => Bitmap; /** * Gaussian blur bitmap */ export declare function blur(radius: number): (bitmap: Bitmap) => Bitmap; /** * Box blur bitmap */ export declare function boxBlur(radius: number): (bitmap: Bitmap) => Bitmap; /** * Cascade blur (fast for large radii) */ export declare function cascadeBlur(radiusX: number, radiusY?: number): (bitmap: Bitmap) => Bitmap; /** * Adaptive blur (auto-selects best algorithm) */ export declare function adaptiveBlur(radiusX: number, radiusY?: number): (bitmap: Bitmap) => Bitmap; /** * Fast Gaussian blur using cascade algorithm * Recommended for large radii (> 3 pixels) */ export declare function fastBlur(radius: number): (bitmap: Bitmap) => Bitmap; /** * Embolden bitmap operator */ export declare function embolden(xStrength: number, yStrength?: number): (bitmap: Bitmap) => Bitmap; /** * Embolden bitmap and expand bearings (for rasterized glyphs) */ export declare function emboldenGlyph(xStrength: number, yStrength?: number): (glyph: RasterizedGlyph) => RasterizedGlyph; /** * Transform bitmap with 2D matrix (origin at top-left) */ export declare function transformBitmap2D(matrix: Matrix2D, options?: { offsetX26?: number; offsetY26?: number; }): (bitmap: Bitmap) => Bitmap; /** * Transform bitmap with 3D matrix (origin at top-left) */ export declare function transformBitmap3D(matrix: Matrix3x3, options?: { offsetX26?: number; offsetY26?: number; }): (bitmap: Bitmap) => Bitmap; /** * Transform rasterized glyph with 2D matrix (bearing-aware) */ export declare function transformGlyph2D(matrix: Matrix2D, options?: { offsetX26?: number; offsetY26?: number; }): (glyph: RasterizedGlyph) => RasterizedGlyph; /** * Transform rasterized glyph with 3D matrix (bearing-aware) */ export declare function transformGlyph3D(matrix: Matrix3x3, options?: { offsetX26?: number; offsetY26?: number; }): (glyph: RasterizedGlyph) => RasterizedGlyph; /** * Shear bitmap horizontally (origin at top-left) */ export declare function shearBitmapX(amount: number, options?: { offsetX26?: number; offsetY26?: number; }): (bitmap: Bitmap) => Bitmap; /** * Shear bitmap vertically (origin at top-left) */ export declare function shearBitmapY(amount: number, options?: { offsetX26?: number; offsetY26?: number; }): (bitmap: Bitmap) => Bitmap; /** * Shear rasterized glyph horizontally (bearing-aware) */ export declare function shearGlyphX(amount: number, options?: { offsetX26?: number; offsetY26?: number; }): (glyph: RasterizedGlyph) => RasterizedGlyph; /** * Shear rasterized glyph vertically (bearing-aware) */ export declare function shearGlyphY(amount: number, options?: { offsetX26?: number; offsetY26?: number; }): (glyph: RasterizedGlyph) => RasterizedGlyph; /** * Shift bitmap position */ export declare function shift(dx: number, dy: number): (bitmap: Bitmap) => Bitmap; /** * Resize bitmap with nearest-neighbor */ export declare function resize(width: number, height: number): (bitmap: Bitmap) => Bitmap; /** * Resize bitmap with bilinear interpolation */ export declare function resizeBilinear(width: number, height: number): (bitmap: Bitmap) => Bitmap; /** * Pad bitmap */ export declare function pad(left: number, top: number, right: number, bottom: number): (bitmap: Bitmap) => Bitmap; export declare function pad(all: number): (bitmap: Bitmap) => Bitmap; /** * Convert bitmap to different pixel mode */ export declare function convert(targetMode: PixelMode): (bitmap: Bitmap) => Bitmap; /** * Convert bitmap to RGBA array */ export declare function toRGBA(bitmap: Bitmap): Uint8Array; /** * Convert bitmap to grayscale array */ export declare function toGray(bitmap: Bitmap): Uint8Array; /** * Convert path to SVG string */ export declare function toSVG(options?: { flipY?: boolean; scale?: number; }): (path: GlyphPath) => string; /** * Copy bitmap */ export declare function copy(bitmap: Bitmap): Bitmap;