Requirement: if the background of some white text is close to White, the text cannot be clearly viewed. Therefore, you must set the text color to black for this background color. known invalid method: convert the color into a 10 hexadecimal value and cannot judge whether it is close to White {code ...} requirements:
If the background of some white text is close to White, the text cannot be clearly viewed. Therefore, you must set the text color to black for this background color.
Known invalid methods:
Converting the color to 10 decimal format cannot determine whether it is near White
Although the red value is 16711680, it can be distinguished from white, but the gray 12632256 is smaller than red, but it is difficult to distinguish from White.
Reply content:
Requirements:
If the background of some white text is close to White, the text cannot be clearly viewed. Therefore, you must set the text color to black for this background color.
Known invalid methods:
Converting the color to 10 decimal format cannot determine whether it is near White
Although the red value is 16711680, it can be distinguished from white, but the gray 12632256 is smaller than red, but it is difficult to distinguish from White.
Reversed. Smaller and brighter
You can use the RGB value to determine the color of an unclear font. if the color is greater than the RGB value, you can add an average value.
Convert each digit of rgb to decimal and 255 for comparison. for example, if the gap between each value and 255 is within 5, it is determined that it is very close to White, instead, the entire hexadecimal format cannot be directly converted to decimal.