Answer the question
In order to leave comments, you need to log in
How can I determine whether the background color in RGB is light or dark?
There is a background color - it can be anything, even #791
. And there are pre-known and defined light and dark text colors.
For example, light - #fff, #ff0, #0f0
Dark - #800, #000
Obviously, light text will not be visible on a light background, and dark text on a dark one.
How to determine if the background is light or dark (true/false) to match the appropriate text color?
Answer the question
In order to leave comments, you need to log in
Quick Google:
https://planetcalc.ru/7779/
https://habr.com/ru/post/304210/
Dark colors if all three values are less than 0.5, and in order to be considered light, it is enough that at least 1 of the 3 colors is greater than 0.5 i.e. RGB(255/2+1, 126, 126) is already light, and RGB(126, 126,126) is dark. Based on this, you can make a mini function that determines light or dark
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question