Skip to content

Instantly share code, notes, and snippets.

View alexgrozav's full-sized avatar

Alex Grozav alexgrozav

View GitHub Profile
@alexgrozav
alexgrozav / contrastColor.styl
Last active September 24, 2017 19:54
A simple Stylus function for getting the contrasting text color (black or white) based on the background color. Extracted from Inkline framework https://github.com/inkline/inkline.
/**
* Get contrast text color for a background color by calculating the luminance
* of the given input color.
*
* @param color Text background color
* @return Contrasting text color
*/
contrastColor(color)
RGB = {
r: red(color)