Last active
February 2, 2022 14:09
-
-
Save Schneppi/3658ae9c6c3a8ccd06eded519a118133 to your computer and use it in GitHub Desktop.
Find the contrasting color to a given color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Var c As Integer | |
Var luminance As Double | |
luminance = (0.299 * BackgroundColor.Red + 0.587 * BackgroundColor.Green + 0.114 * BackgroundColor.Blue)/255 | |
If luminance > 0.5 Then | |
c = 0 // bright colors - black font | |
Else | |
c = 255 // dark colors - white font | |
End If | |
Return Color.RGB(c,c,c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment