To determine whether a color is dark or light, you can calculate the perceived brightness of the color using the following formula:
Brightness=0.2126R+0.7152G+0.0722B
where R, G, and B are the red, green, and blue values of the color, respectively. If the brightness value is greater than or equal to 128, the color is considered light. If the brightness value is less than 128, the color is considered dark.
How to find if a given color is Dark or Light.

Asgar Ali
86
Reputation points
Given a RGB or Hex Value of a color How to find out if the Color is Dark or Light.I am working on a theme where I want to find out if the color is Dark or Light and depending on it I want to set the Text Color to white or Black.
Developer technologies .NET Xamarin
5,380 questions
Developer technologies C#
11,567 questions
Accepted answer
-
Ken Kam Hung, Lin 91 Reputation points
2024-01-16T11:48:32.16+00:00
1 additional answer
Sort by: Most helpful
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more