How to convert Hex to RGB?

后端 未结 8 1552
暖寄归人
暖寄归人 2021-02-12 11:13

I am trying to use this to figure out if a color is light or dark

Evaluate whether a HEX value is dark or light

Now. It takes in a int



        
相关标签:
8条回答
  • 2021-02-12 12:09

    calcLuminance only returns a percentage.

    0 讨论(0)
  • 2021-02-12 12:10

    I am trying to use this to figure out if a color is light or dark

    Just use Color.GetBrightness()


    [Edit]

    I want to determine if I should use white or black for my text. So anything ≤ .5 I should use white and > .5 black?

    There are a number of ways to determine what color to use on a given background, none of which are perfect.

    That last link actually recommends using black/white only, but choosing a cutoff point of 0.73 instead of 0.5. I think you should just go with that, and change it if you find it doesn't work for you.

    0 讨论(0)
提交回复
热议问题