From: "Filsinger, Andreas (Softwareentwicklung)" To: Subject: Suggestion for additional "Color Project" Date: Monday, October 08, 2001 5:43 Earl, i had to place text on a coloured backgound. I knew the color of the background, now i had to calculate automatically the Font-Color viewed best on the specific background-color. My first try was "textcolor := BackgroundColor xor $FFFFFF". That results in well visible (but funny) Font-Colors, but fails if the background is grey. Next i set Font-Color to "white" on dark backgounds, and "black" on bright ones. But what is Brigthness? (R + G + B) / 3 seems to be a good value. It fails because the human eye does not see all the colours in the same density. Next i read something about "Luminanz" and created my final code: function VisibleContrast(BackGroundColor : TColor):TColor; const cHalfBrightness = ((0.3 * 255.0) + (0.59 * 255.0) + (0.11 * 255.0)) / 2.0; var Brightness : double; begin with TRGBQuad(BackGroundColor) do BrightNess := (0.3 * rgbRed) + (0.59 * rgbGreen) + (0.11 * rgbBlue); if (Brightness>cHalfBrightNess) then result := clblack else result := clwhite; end; in the picture you can see more than my (perfect) english ever will imagine. Andreas