/** * A 2D Cartesian point used for Voronoi triangulation. */ export interface Point { readonly x: number; readonly y: number; } /** * An RGB color with each channel in the 0–255 range. */ export interface RGBColor { readonly r: number; readonly g: number; readonly b: number; } /** * A color value accepted by the Voronoi color utilities: either an {@link RGBColor} object or a hex color string (e.g. `'#ff0000'`). */ export type ColorValue = RGBColor | string; /** * A triangle in the Voronoi mesh: three vertices plus the fill color computed for its position. */ export interface Triangle { readonly points: [Point, Point, Point]; readonly color: string; } /** * Mulberry32 seeded pseudo-random number generator. * Returns a function that generates deterministic random values in [0, 1). * * @param initialSeed - Initial seed value for the generator * @returns A function that yields random numbers in the range [0, 1) * * @example * const random = mulberry32(42); * console.log(random()); // deterministic value based on seed 42 */ export declare const mulberry32: (initialSeed: number) => (() => number); /** * Parse a {@link ColorValue} (RGB object or hex string) to an {@link RGBColor}. * Supports 6-digit (#rrggbb) and 3-digit (#rgb) hex formats. * * @param color - An RGB object {r, g, b} (0–255 each) or hex string * @returns An RGBColor with components 0–255 * @throws {ReactSharedError} If the hex string is malformed or the color format is invalid * * @example * parseColorToRgb({r: 255, g: 0, b: 0}); // { r: 255, g: 0, b: 0 } * parseColorToRgb('#ff0000'); // { r: 255, g: 0, b: 0 } * parseColorToRgb('#f00'); // { r: 255, g: 0, b: 0 } */ export declare const parseColorToRgb: (color: ColorValue) => RGBColor; /** * Convert an {@link RGBColor} to HSV (hue–saturation–value) color space. * * @param rgb - RGB color with components 0–255 * @returns HSV object where h ∈ [0, 360], s ∈ [0, 100], v ∈ [0, 100] * * @example * rgbToHsv({r: 255, g: 0, b: 0}); // { h: 0, s: 100, v: 100 } * rgbToHsv({r: 128, g: 128, b: 128}); // { h: 0, s: 0, v: 50 } */ export declare const rgbToHsv: (rgb: RGBColor) => { h: number; s: number; v: number; }; /** * Convert HSV (hue–saturation–value) color space to an {@link RGBColor}. * * @param h - Hue in degrees, ∈ [0, 360] * @param s - Saturation percentage, ∈ [0, 100] * @param v - Value (brightness) percentage, ∈ [0, 100] * @returns RGBColor with components 0–255 * * @example * hsvToRgb(0, 100, 100); // { r: 255, g: 0, b: 0 } (red) * hsvToRgb(120, 100, 100); // { r: 0, g: 255, b: 0 } (green) */ export declare const hsvToRgb: (h: number, s: number, v: number) => RGBColor; /** * Linearly interpolate between two RGB colors. * * @param color1 - Start color (RGB) * @param color2 - End color (RGB) * @param t - Interpolation factor; clamped to [0, 1]. t=0 returns color1, t=1 returns color2 * @returns Interpolated RGBColor with components 0–255 * * @example * interpolateRGB({r: 0, g: 0, b: 0}, {r: 255, g: 255, b: 255}, 0.5); * // { r: 127, g: 127, b: 127 } */ export declare const interpolateRGB: (color1: RGBColor, color2: RGBColor, t: number) => RGBColor; /** * Calculate the area of a triangle using the cross-product formula. * * @param p1 - First vertex * @param p2 - Second vertex * @param p3 - Third vertex * @returns Triangle area (always non-negative) * * @example * calculateTriangleArea({x: 0, y: 0}, {x: 10, y: 0}, {x: 5, y: 10}); * // 50 */ export declare const calculateTriangleArea: (p1: Point, p2: Point, p3: Point) => number; /** * Convert triangle vertices to an SVG polygon points string. * Format: "x1,y1 x2,y2 x3,y3" * * @param pts - Triangle vertices as [p1, p2, p3] * @returns Points string suitable for SVG polygon element * * @example * triangleToPoints([{x: 0, y: 0}, {x: 10, y: 0}, {x: 5, y: 10}]); * // "0,0 10,0 5,10" */ export declare const triangleToPoints: (pts: [Point, Point, Point]) => string; /** * Calculate the Euclidean distance between two points. * * @param p1 - First point * @param p2 - Second point * @returns Distance between p1 and p2 * * @example * calculateSideLength({x: 0, y: 0}, {x: 3, y: 4}); // 5 */ export declare const calculateSideLength: (p1: Point, p2: Point) => number; /** * Find which point to remove from a small triangle during pruning. * Prefers removing the endpoint of the shortest side, but never removes * boundary points (those with index < boundaryCount). * * @param p1 - First vertex * @param p2 - Second vertex * @param p3 - Third vertex * @param a - Index of p1 in allPoints * @param b - Index of p2 in allPoints * @param c - Index of p3 in allPoints * @param boundaryCount - Number of boundary points; indices [0, boundaryCount) are immutable * @param allPoints - All points in the triangulation * @returns A removable point (internal, on shortest side), or null if no point can be safely removed * * @example * const p1 = { x: 0, y: 0 }; // index 0 — boundary point * const p2 = { x: 3, y: 0 }; // index 1 * const p3 = { x: 0, y: 4 }; // index 2 * findPointToRemove(p1, p2, p3, 0, 1, 2, 1, [p1, p2, p3]); * // { x: 3, y: 0 } — shortest side is p1-p2; p1 (index 0) is a boundary point * // (boundaryCount=1), so p2 (index 1) is returned instead */ export declare const findPointToRemove: (p1: Point, p2: Point, p3: Point, a: number, b: number, c: number, boundaryCount: number, allPoints: Point[]) => Point | null; /** * Generate a stable, unique key for a triangle for use as a React list key. * Uses centroid coordinates, color, and index to ensure collision resistance. * * @param triangle - Triangle to key * @param index - Triangle index in the list * @returns A stable string key suitable for React * * @example * generateTriangleKey({points: [{x: 0, y: 0}, {x: 10, y: 0}, {x: 5, y: 10}], color: 'red'}, 0); * // "tri-5-3-red-0" */ export declare const generateTriangleKey: (triangle: Triangle, index: number) => string; //# sourceMappingURL=voronoi.d.ts.map