Skip to content

Instantly share code, notes, and snippets.

@Schneppi
Last active February 2, 2022 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Schneppi/3658ae9c6c3a8ccd06eded519a118133 to your computer and use it in GitHub Desktop.
Save Schneppi/3658ae9c6c3a8ccd06eded519a118133 to your computer and use it in GitHub Desktop.
Find the contrasting color to a given color
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