Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I control the light/dark variations Excel 2007 color theme? | Excel Discussion (Misc queries) | |||
Colors too dark! | Excel Worksheet Functions | |||
Colors too dark.... | Excel Discussion (Misc queries) | |||
A shot in the dark | New Users to Excel | |||
VBE dark red highlight | Excel Programming |