/** * SVG Renderer for DataMatrix barcodes * * This module handles the conversion of DataMatrix matrices to SVG elements. * It supports customizable colors, dimensions, padding, and output optimization. * * @module svg-renderer */ import type { DataMatrixResult } from './encoder.js'; /** * Named CSS colors supported by SVG (partial list) */ export type NamedColor = 'black' | 'white' | 'red' | 'green' | 'blue' | 'yellow' | 'cyan' | 'magenta' | 'gray' | 'grey' | 'silver' | 'maroon' | 'olive' | 'navy' | 'purple' | 'teal' | 'aqua' | 'fuchsia' | 'lime' | 'orange' | 'pink' | 'brown' | 'transparent'; /** * SVG-compatible color values * Supports all standard SVG/CSS color formats: * - Hex: #RGB, #RRGGBB * - RGB: rgb(r, g, b), rgba(r, g, b, a) * - HSL: hsl(h, s%, l%), hsla(h, s%, l%, a) * - Named colors: black, white, red, etc. * - Special: currentColor, inherit, none, transparent * - URL references: url(#gradient-id) */ export type SvgColor = `#${string}` | `rgb(${string})` | `rgba(${string})` | `hsl(${string})` | `hsla(${string})` | `url(${string})` | 'currentColor' | 'inherit' | 'none' | NamedColor; /** * Color palette for the barcode */ export interface Palette { /** Color for data modules (dark cells). Default: '#000' */ foreground?: SvgColor; /** Color for background (light cells). Default: transparent (no background) */ background?: SvgColor; } /** * SVG rendering options */ export interface SvgOptions { /** Output height in pixels. Default: 256 */ dimension?: number; /** Quiet zone padding in modules. Default: 2 */ padding?: number; /** Color palette for foreground and background */ palette?: Palette; /** Use verbose SVG output (one rect per module vs optimized paths). Default: false */ verbose?: boolean; } /** * Converts a DataMatrix pixel matrix to an SVG element * * This function takes the matrix result from encodeMessage() and renders it * as an SVG element with customizable styling options. * * @example * // Basic usage * import { encodeMessage } from './encoder'; * const matrixResult = encodeMessage('Hello World!'); * const svg = matrixToSvg(matrixResult); * * @example * // With custom options * const svg = matrixToSvg(matrixResult, { * dimension: 512, * padding: 4, * palette: { foreground: '#000000', background: '#ffffff' } * }); * * @param matrixResult - The result from encodeMessage() * @param options - SVG rendering options * @returns SVG element containing the DataMatrix barcode */ export declare function matrixToSvg(matrixResult: DataMatrixResult, options?: SvgOptions): SVGSVGElement; //# sourceMappingURL=svg-renderer.d.ts.map