Returns white (RGB 255,255,255) or Black (RGB 0,0,0) based on background color passed.
Background color is expected to be in format of R:G:B:T (T for transparency).
This is very similar to FGColor_Calc except it defaults to black and it has transparency as part of background color.
Image again created by AI (Microsoft Designer)
Function ForegroundColor(BackgroundColor_String)
' Calculates foregroundColor White or Black, based on Background color
' Pass BackgroundColor_String As R:G:B:T = Red:Green:Blue:Transparency (0 to 100) "100:255:100:50" "0:157:87:0" ' R:G:B:T
' Will default to white, until calculation proves color is too bright, then make it black
' Needs CutString3
'
Rett = RGB(255, 255, 255)
BCo1 = Val(CutString3(BackgroundColor_String, 1, ":"))
BCo2 = Val(CutString3(BackgroundColor_String, 2, ":"))
BCo3 = Val(CutString3(BackgroundColor_String, 3, ":"))
BCo4 = Val(CutString3(BackgroundColor_String, 4, ":"))
If BCo1 + BCo2 + BCo3 + BCo4 > 128 * 3 + 20 Then Rett = RGB(0, 0, 0)
ForegroundColor = Rett
End Function
' Calculates foregroundColor White or Black, based on Background color
' Pass BackgroundColor_String As R:G:B:T = Red:Green:Blue:Transparency (0 to 100) "100:255:100:50" "0:157:87:0" ' R:G:B:T
' Will default to white, until calculation proves color is too bright, then make it black
' Needs CutString3
'
Rett = RGB(255, 255, 255)
BCo1 = Val(CutString3(BackgroundColor_String, 1, ":"))
BCo2 = Val(CutString3(BackgroundColor_String, 2, ":"))
BCo3 = Val(CutString3(BackgroundColor_String, 3, ":"))
BCo4 = Val(CutString3(BackgroundColor_String, 4, ":"))
If BCo1 + BCo2 + BCo3 + BCo4 > 128 * 3 + 20 Then Rett = RGB(0, 0, 0)
ForegroundColor = Rett
End Function
BackgroundColor_String
Views 158
Downloads 73
CodeID
DB ID