RGB into color names | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

RGB into color names

How to turn RGB to color names. Takes a tuple as an argument returns "red", "green", "blue", "green", "black", "yellow", "black" or "pink" Each color should have a little bit of range. Dark gray would be same as black etc...

24th Sep 2020, 8:58 PM
Toni Isotalo
Toni Isotalo - avatar
1 Answer
+ 7
I really like this idea. I suppose you would have to define where the differences are. For example, (255, 0, 0) is of course red, and when the green and blue values raise, the color will be closer to pink. So you’d have to decide exactly how high the green and blue values can be before the color is no longer considered “red”, but “pink”. High red and green values create yellow (higher blue neutralizes the yellow), etc. Or maybe if all three values are the same, then values under 51 are black, 51-204 would be gray, and 205-255 would be white. It might be kinda complex to implement, but maybe this could steer you in the right direction.
24th Sep 2020, 9:08 PM
NULL - avatar