Evaluate whether a HEX value is dark or light

前端 未结 4 853
难免孤独
难免孤独 2020-12-28 20:03

The user of the ASP.NET web app I\'m building can select colors for use on some of the elements (e.g. buttons/titles) to facilitate some degree of personalisation.

4条回答
  •  自闭症患者
    2020-12-28 20:54

    A hex color code is composed of three intensity values, one for red, one for green and one for blue, with 2 hex digits for each. To determine dark vs. light, simply add the three values together. Smaller numbers would be darker than larger values.

    For #010203, adding the RGB values together gives 01+02+03 = 06. That will be darker than #102030 = 60.

提交回复
热议问题