To set the color of the foreground based on background color to get best look.
Returns Black or white based on the color passed
Function FGColor_Calc(BGColor)
' To set the color of the foreground based on background color to get best look.
' Returns Black or white based on the color passed
' Needs HexToDec
C1 = BGColor
If Left(C1,1) = "#" Then C1 = Mid(C1,2)
If Len(BackgroundColor) = 3 Then C1 = Left(C1,1) & Left(C1,1) & Mid(C1,2,1) & Mid(C1,2,1) & Right(C1,1) & Right(C1,1)
NF1 = clng(HexToDec(left(C1,2)))
NF2 = clng(HexToDec(Mid(C1,3,2)))
NF3 = clng(HexToDec(Right(C1,2)))
Brightness = NF1*0.299 + NF2*0.587 + NF3*0.114
' From http://stackoverflow.com/questions/946544/good-text-foreground-color-for-a-given-background-color
' R*0.299 + G*0.587 + B*0.114
' 186
FF = "000000" ' Default is Black
If Brightness < 184 Then FF="FFFFFF"
FGColor_Calc= FF
End Function
' To set the color of the foreground based on background color to get best look.
' Returns Black or white based on the color passed
' Needs HexToDec
C1 = BGColor
If Left(C1,1) = "#" Then C1 = Mid(C1,2)
If Len(BackgroundColor) = 3 Then C1 = Left(C1,1) & Left(C1,1) & Mid(C1,2,1) & Mid(C1,2,1) & Right(C1,1) & Right(C1,1)
NF1 = clng(HexToDec(left(C1,2)))
NF2 = clng(HexToDec(Mid(C1,3,2)))
NF3 = clng(HexToDec(Right(C1,2)))
Brightness = NF1*0.299 + NF2*0.587 + NF3*0.114
' From http://stackoverflow.com/questions/946544/good-text-foreground-color-for-a-given-background-color
' R*0.299 + G*0.587 + B*0.114
' 186
FF = "000000" ' Default is Black
If Brightness < 184 Then FF="FFFFFF"
FGColor_Calc= FF
End Function
BGColor
Views 4,142
Downloads 1,328
CodeID
DB ID