Is Light Color

Check if a hex color is light (good for determining text color).

Code

General
h = hex.lstrip('#')
r, g, b = int(h[0:2], 16), int(h[2:4], 16), int(h[4:6], 16)
return (r * 0.299 + g * 0.587 + b * 0.114) > 186

Parameters

Hex color to check

Server

More Python Snippets