DEV Community

Discussion on: Write a function that outputs a pleasant text color hex given a background color hex

Collapse
 
bladefidz profile image
Hafidz Jazuli Luthfi • Edited

To be honest, I am sorry to not post the code, but just underlying theory. Based what I already learn:

  1. Blue is not good for text color, so try to adding more proportion on Green or Red. Good one proportion is L = 31%R + 59%G + 10%B.
  2. 10% males are color blind and there are more man who code than women, so try to use font with sub-pixel rendering. Sans-serif family may the good one. Another good trick is try to adding more contrast.
  3. Eye can be exhausted, so try to use cooler color as background and sharp color for details such as text and button.

I am also attach an image below to help you interpret:
Color Perception

That's all, hope somebody find this post useful.