Updated color selection functionality with lookup approach, fixes #58 #182
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Previously implementation of color naming often had unknown appearing. When this was resolved, there were inaccuracies in the color / hue descriptions being calculated. This is a different approach using a curated list of colors, from which the closest matching HEX RGB color is selected and the associated name returned.
Details
In order to get around hue description mismatches, this PR adds a list of curated colors taken from
https://chir.ag/projects/ntc/ntc.js
, and uses an algorithm (similar to least squares regression, from what I can tell) to grab the nearest color name based on diff matching of the incoming color RGB /HSL values and the values in the list. This does add a significant amount of data into the utils file, but the payoff is increased accuracy of naming the colors. Inspired by creative commons 2.5 licensed code from Chirag Mehta.