![]() |
How dark is a color
How do I ascertain how dark a selected color is ?
I want to amend the font color of a form to complement the backcolor selected by the user - i.e. white font on dark backgrounds, black font on light backgrounds |
How dark is a color
This function seems to work very well:
Function GetContrastingFont(lClr As Long) As Long 'returns a contrasting font colour, given a long colour '------------------------------------------------------ Dim R As Long Dim G As Long Dim B As Long B = Int(lClr / 65536) G = Int((lClr Mod 65536) / 256) R = Int(lClr Mod 256) 'calculation from Peter Thornton '------------------------------- If R * 0.206 + G * 0.679 + B * 0.115 135 Then GetContrastingFont = vbBlack Else GetContrastingFont = vbWhite End If End Function RBS "Paul" wrote in message ... How do I ascertain how dark a selected color is ? I want to amend the font color of a form to complement the backcolor selected by the user - i.e. white font on dark backgrounds, black font on light backgrounds |
All times are GMT +1. The time now is 10:37 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com