UNPKG

@mlightcad/common

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://img.shields.io/npm/v/@mlightcad/common.svg)](https://www.npmjs.com/package/@mlightcad/common)

74 lines 2.83 kB
/** * Utility functions for AutoCAD color index mapping and manipulation. * * This module provides functions to convert between AutoCAD color indices and RGB values, * supporting the standard AutoCAD color palette used in DWG files. */ /** * Utility class for AutoCAD color operations. */ export declare class AcCmColorUtil { /** * Returns the RGB color value for a given AutoCAD color index. * * @param {number} index - The AutoCAD color index value (0-255). * @returns {number} The RGB color value as a 24-bit integer. * * @example * ```typescript * // Get the RGB value for color index 1 (red) * const redColor = AcCmColorUtil.getAcadColor(1); // returns 16711680 (0xFF0000) * ``` * * @example * ```typescript * // Get special inheritance colors * const byBlock = AcCmColorUtil.getAcadColor(0); // "ByBlock" color * const byLayer = AcCmColorUtil.getAcadColor(256); // "ByLayer" color * ``` */ static getColorByIndex(index: number): number; /** * Finds the AutoCAD color index associated with a given RGB value. * * @private * @param {number} color - The RGB value to find an index for. * @returns {number | undefined} The color index if found, undefined otherwise. */ static getIndexByColor(color: number): number | undefined; /** * Returns the RGB color value for a given CSS color name. * * @param {string} name - The CSS color name (e.g., "red", "blue", "aliceblue"). * @returns {number | undefined} The RGB color value as a 24-bit integer, or undefined if the name is not found. * * @example * ```typescript * // Get the RGB value for a standard color name * const redColor = AcCmColorUtil.getColorByName("red"); // returns 16711680 (0xFF0000) * const blueColor = AcCmColorUtil.getColorByName("blue"); // returns 255 (0x0000FF) * ``` * * @example * ```typescript * // Handle undefined for unknown color names * const unknownColor = AcCmColorUtil.getColorByName("unknown"); // returns undefined * ``` */ static getColorByName(name: string): number; /** * Finds the color name associated with a given RGB value. * * @param {number} rgb - The RGB value to find a name for. * @returns {string | undefined} The color name if found, undefined otherwise. */ static getNameByColor(rgb: number): string | undefined; /** * Finds the color name associated with a given color index. * * @param {number} index - The color index to find a name for. * @returns {string | undefined} The color name if found, undefined otherwise. */ static getNameByIndex(index: number): string | undefined; } //# sourceMappingURL=AcCmColorUtil.d.ts.map