color-2-name
Version:
Finds the closest color name to a given hex, rgb and hsl color (with and without alpha). It uses the Euclidean distance formula to calculate the distance between colors in the RGB color space
22 lines (15 loc) • 1.03 kB
Markdown
# Changelog
All notable changes to this project will be documented in this file.
## [1.5.0] - 2025-11-27
### Fixed
- **HSL Conversion**: Fixed critical bug in `hslToRgb` where hue was incorrectly calculated using 0-360 range instead of 0-6, resulting in wrong colors.
- **Black Definition**: Corrected `BLACKANDWHITE` definition of black from `[1, 1, 1]` to `[0, 0, 0]`.
- **Comment Stripping**: Fixed regex to correctly strip single-line comments (`//`).
- **HSL Parsing**: Fixed fallback logic in `getHslValues` to correctly handle `0` values.
### Performance
- **getColors**: Optimized to O(n) complexity by removing nested linear searches.
- **closest**: Added caching for repeated color lookups and optimized distance calculation.
### Changed
- **Black Definition**: The definition of black in `BLACKANDWHITE` constant is now `[0, 0, 0]` (was `[1, 1, 1]`). This is a breaking change for consumers relying on the old value.
### Updated
- **Dependencies**: Updated dependencies to their latest versions.