Skip to content

v0.4.0 - Nearest Color Fallback

Choose a tag to compare

@AnttiRask AnttiRask released this 24 Jan 09:18
· 25 commits to main since this release

What's New

Nearest Color Fallback

hex_to_color() now automatically finds the nearest named color when no exact match exists in the database. This uses LAB color distance for perceptually accurate matching.

# Hex code without exact match - finds nearest named color
hex_to_color("#ABCDEF")
#> [1] "alphabet blue"

# Disable fallback to get NA for unmatched colors  
hex_to_color("#ABCDEF", fallback_nearest_color = FALSE)
#> [1] NA

Performance Improvements

  • Pre-computed LAB color values with caching in get_color_data()
  • Exact match fast path before computing distances
  • Efficient color distance calculations

Other Changes

  • White/black normalization (gray100 → white, gray0 → black)
  • Added farver and cli to Suggests for enhanced functionality

Contributors

Thank you to @iamYannC for contributing the nearest color fallback functionality!

Full Changelog: v0.3.1...v0.4.0