Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated color selection functionality with lookup approach, fixes #58 #182

Merged
merged 2 commits into from
Mar 19, 2023

Conversation

prichter
Copy link
Contributor

@prichter prichter commented Mar 18, 2023

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.

@prichter
Copy link
Contributor Author

image

This is how it looks.

@prichter prichter marked this pull request as ready for review March 18, 2023 13:40
Not intended for this PR
@alexdanilowicz
Copy link
Contributor

alexdanilowicz commented Mar 19, 2023

Interesting! Thanks for this Paul. I have to say, it is a bit weird to see "dark purple" but the name is "Jacarta." I've also never heard of "Finn", "Fern Frond", or a few of the other color names on the list...

Let me think on this one a bit and do some user testing. I LOVE that "unknown" is no longer a possibly, but I think the best user experience might be what we had a version of what originally, and then if it's unknown we use this list.

I say this because I think most colors are simply some variation of: red, blue, green, purple, orange, pink, yellow, brown, white, black, grey... and they should be named as such. For example at Liveramp, the color name was simply "Liveramp Green" not "Celtic". Most companies simply name the color the name of their company + the simple color name. And I just hope this doesn't introduce confusion.

I like the approach tho. Let me get some input and thank you so much for opening the PR!

@prichter
Copy link
Contributor Author

@alexdanilowicz - I understand your thoughts re color naming, the reason I liked this list approach is that it helps obviate the "is this red or pink" question which can happen with a subjective analysis of hues. This approach also allows an option to (re)define a reduced list of colors more conventionally named or even rename the colors in this list if desired - the algorithm would then select the nearest from the reduced / renamed list... Just some food for thought.

@alexdanilowicz
Copy link
Contributor

"is this red or pink" question which can happen with a subjective analysis of hues.

Very true.

@alexdanilowicz
Copy link
Contributor

Alright, I'm cool with merging this, but if we hear some confusion for users might tweak it a bit. Thanks for your hard work @prichter!

@alexdanilowicz alexdanilowicz merged commit af71be4 into magicpatterns:main Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants