@mescius/dsimageviewer
Version:
Document Solutions Image Viewer
48 lines (47 loc) • 2.34 kB
TypeScript
import { Color } from "@dt/core-ui";
import { Bounds } from "../Models/SelectionBoxTypes";
/**
* Function to get the color of a pixel at specified coordinates
* @param x
* @param y
* @param context
* @returns
*/
export declare function getPixelColor(x: number, y: number, context: CanvasRenderingContext2D): string;
/**
* Function to detect and fill regions using the flood fill algorithm
* @param x
* @param y
* @param sourceContext
* @param xyOffset
* @returns
*/
export declare function detectAndFillRegions(x: number, y: number, sourceContext: CanvasRenderingContext2D, xyOffset: {
x: number;
y: number;
}): {
paths: Path2D[];
bounds?: Bounds;
};
/**
* Ensures the input color value is converted to a proper Color object.
* Handles string formats (hex, rgba, etc.), existing Color objects, and fallback defaults.
*
* @param {Color | string | null | undefined} colorValue - The input color to normalize.
* Can be a Color object, CSS color string, or null/undefined.
* @param {string} [defaultHexColor="#000000"] - Fallback color in hex format if conversion fails.
* @returns {Color} A valid Color object (either converted or fallback).
* @example
* ensureColorType("#FF5733"); // Returns Color from hex string
* ensureColorType(null, "#00FF00"); // Returns green fallback
* ensureColorType(existingColorObject); // Returns the same object
*/
export declare function ensureColorType(colorValue: Color | string | null | undefined, defaultHexColor?: string): Color;
export declare function colorToDispayLabel(color?: string | any): string;
export declare function rgbToHex(val: number[] | string): string;
export declare function hexToRgb(hex: string | any): number[] | null;
export declare function darkerColor(color: string | Uint8ClampedArray | number[], coef?: number): string | null;
export declare function enlightColor(color: string | Uint8ClampedArray | number[], englight?: number): string | null;
export declare function applyColorOpacity(color: string | Uint8ClampedArray | number[], opacity?: number): string | null;
export declare function toCssColor(colorVal?: string | number[] | Uint8ClampedArray | Color | null, defaultCssVal?: string): string;
export declare function getLocalizedWebColorNames(in17n: any): Record<string, string>;