Requirements:
Because if the background of some white text is close to white, the text will be unclear, so the text color needs to be set to black for this type of background color.
Known invalid methods:
Converting the color to decimal cannot determine whether it is close to white
<code>红色的值虽然是16711680 但和白色可以很好的区分. 但是灰色 12632256 比红色要小,但是和白色是很难区分的.</code>
Requirements:
Because if the background of some white text is close to white, the text will be unclear, so the text color needs to be set to black for this type of background color.
Known invalid methods:
Converting the color to decimal cannot determine whether it is close to white
<code>红色的值虽然是16711680 但和白色可以很好的区分. 但是灰色 12632256 比红色要小,但是和白色是很难区分的.</code>
Inverted. The smaller, the brighter
Just use the RGB value to judge. Find an unclear font and choose a color. If it meets the requirements and is greater than the RGB value, it must be unclear. You can also add an average value to judge.
Convert each digit of rgb to decimal and compare it with 255. For example, if the difference between each value and 255 is within 5, then it is considered to be very close to white, and you cannot directly convert the entire hexadecimal to decimal.