import * as react_jsx_runtime from 'react/jsx-runtime'; import { CSSProperties } from 'react'; /** * Gradient engine for @outpacelabs/avatars. * * Framework-agnostic mesh-gradient avatar generator. Every seed (string or * number) deterministically produces a unique gradient, no stored images, * no network. Pure palette/RNG core plus optional Canvas2D render helpers. */ type Harmony = "analogous" | "triadic" | "splitComplementary" | "tetradic" | "complementary" /** Not a harmony rule, the palette came from caller-supplied `colors`. */ | "custom"; interface GradientPalette { /** The numeric seed the palette was derived from. */ seed: number; /** Hex color stops used to paint the mesh (`#RRGGBB`). */ colors: string[]; /** Which color-harmony rule produced the hues (or `"custom"`). */ harmony: Harmony; } interface PaletteOptions { /** * Bring your own colors instead of the seed-derived harmony. Accepts hex * (`#rgb` or `#rrggbb`, `#` optional); invalid entries are dropped, and an * empty/absent list falls back to seed generation. The seed still drives the * layout and rotates the palette, so each seed stays unique but on-brand. */ colors?: string[]; } /** Options shared by the Canvas2D renderers. */ interface DrawOptions extends PaletteOptions { /** * Render in the Display P3 wide-gamut color space. On P3-capable screens the * palette reads more vivid; elsewhere the browser maps it back to sRGB. * Requires the target canvas to be a P3 context, the `renderGradient`, * `gradientTo*`, and `` paths set this up for you. */ p3?: boolean; /** * The size the avatar is shown at on screen, in CSS pixels. This drives the * level of detail: a small avatar gets fewer colors and fewer, larger shapes * so it reads as one clean mark, a large one gets the full complexity. * * Defaults to the `size` the renderer draws at, which is correct when the * canvas draws at its display size. Set it when the render resolution is * higher than the display size, for example when you draw at 256 px for a * 32 px avatar. `` wires this from its `size` prop. */ displaySize?: number; } /** * Stable string → 32-bit unsigned hash (FNV-1a + bit-mixing avalanche). * Uses the full uint32 range as a seed so similar strings diverge fully. */ declare function seedFromString(input: string): number; /** Normalize a string or number seed to the numeric seed used internally. */ declare function toSeed(seed: number | string): number; /** * Derive the deterministic color palette for a seed. Pass `colors` to override * the harmony with your own palette (still placed deterministically per seed). */ declare function generatePalette(seed: number | string, options?: PaletteOptions): GradientPalette; /** * Minimal Canvas2D context surface the renderer needs. Both * `HTMLCanvasElement` and `OffscreenCanvas` 2D contexts satisfy it. */ type GradientContext = { fillStyle: string | CanvasGradient | CanvasPattern; globalCompositeOperation: GlobalCompositeOperation; fillRect(x: number, y: number, w: number, h: number): void; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; }; /** * Draw the mesh gradient for `seed` into `ctx` at `size` x `size`. * The caller is responsible for any blur, apply `filter: blur(…)` on the * displayed canvas (≈6% of the rendered dimension) for the signature look, * or use {@link renderGradient} / {@link gradientToDataURL} which bake it in. */ declare function drawMeshGradient(ctx: GradientContext, seed: number | string, size: number, options?: DrawOptions): void; /** Which engine paints the avatar. */ type Pattern = "mesh" | "dither"; /** * Draw an ordered (Bayer 8×8) dither of the seed's palette into `ctx` at * `size` x `size`. A crisp, retro alternative to {@link drawMeshGradient} that * shares the same deterministic colors, no blur wanted. */ declare function drawDither(ctx: GradientContext, seed: number | string, size: number, options?: DrawOptions): void; interface RenderOptions extends DrawOptions { /** * Blur radius in pixels. Defaults to ~6% of the canvas size for the * signature soft look. Pass `0` to disable. Ignored for the dither pattern, * which is always crisp. */ blur?: number; /** Which engine to paint. Default: `"mesh"`. */ pattern?: Pattern; } /** * Render a seed's gradient into an existing canvas, baking in the soft blur. * Draws at the canvas's current `width`/`height`. Browser/OffscreenCanvas only. */ declare function renderGradient(canvas: HTMLCanvasElement | OffscreenCanvas, seed: number | string, options?: RenderOptions): void; interface ExportOptions extends RenderOptions { /** Output pixel dimensions (square). Default: 512. */ size?: number; /** Image MIME type. Default: "image/png". */ type?: string; /** Quality 0–1 for lossy types. Default: 0.92. */ quality?: number; } /** Render a seed's gradient and return it as a data URL. Browser only. */ declare function gradientToDataURL(seed: number | string, options?: ExportOptions): string; /** Render a seed's gradient and resolve a Blob (or null). Browser only. */ declare function gradientToBlob(seed: number | string, options?: ExportOptions): Promise; interface GradientAvatarProps { /** Any string or number, each unique seed produces a unique gradient. */ seed: number | string; /** Rendered size in pixels. Default: 32. */ size?: number; /** * Render style. `"mesh"` is the signature soft gradient; `"dither"` is an * ordered (Bayer) dither of the same palette, crisp with no blur. * Default: `"mesh"`. */ pattern?: Pattern; /** * Corner radius. Number = pixels, string = any CSS length. * Defaults to a full circle; pass `0` for a square or e.g. `12` for a * rounded square. Default: "9999px". */ radius?: number | string; /** * Bring your own colors (hex) instead of the seed-derived harmony. The seed * still drives the layout, so each seed stays unique but on-brand. */ colors?: string[]; /** * Render in the Display P3 wide-gamut color space, more vivid on capable * screens, and the same on the rest. Default: `false`. */ p3?: boolean; /** Additional CSS classes on the wrapper. */ className?: string; /** Extra inline styles merged onto the wrapper. */ style?: CSSProperties; } /** * Renders a deterministic mesh-gradient avatar on a ``. * The same seed always produces the same gradient. */ declare function GradientAvatar({ seed, size, pattern, radius, colors, p3, className, style, }: GradientAvatarProps): react_jsx_runtime.JSX.Element; export { type DrawOptions, type ExportOptions, GradientAvatar, type GradientAvatarProps, type GradientPalette, type Harmony, type PaletteOptions, type Pattern, type RenderOptions, drawDither, drawMeshGradient, generatePalette, gradientToBlob, gradientToDataURL, renderGradient, seedFromString, toSeed };