trying to convert rgb from a .net Color to a string such as “red” or “blue”

前端 未结 5 743
你的背包
你的背包 2020-12-02 00:41

All of my methods are failing me in various ways. different lighting can mess it all up too.

has anyone every trying to return a name given a rgb value? \"red\" \"gr

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 01:09

    I personally find it more natural to think of colors in terms of hue/saturation/brightness than RGB values, and I think that would work well for you in this case. Try this:

    Assign color names to certain ranges of the spectrum, as you see fit. For example, maybe red is 0-39, orange is 40-79, etc. (those are arbitrary numbers - I have no idea if they fit on any kind of scale or not). Then calculate the hue from your RGB value (you can find a formula here, although there may be others). Once you know the hue, you know what range of the spectrum it's in, and you can give it a name.

提交回复
热议问题