Skip to content

Instantly share code, notes, and snippets.

Jan Mauler maulerjan

View GitHub Profile
@maulerjan
maulerjan / getBrightness.js
Created Oct 25, 2018
Get color brightness (from hexa)
View getBrightness.js
export default function getBrightness(c) {
var c = c.substring(1) // strip #
var rgb = parseInt(c, 16) // convert rrggbb to decimal
var r = (rgb >> 16) & 0xff // extract red
var g = (rgb >> 8) & 0xff // extract green
var b = (rgb >> 0) & 0xff // extract blue
var luma = (r * 299 + g * 587 + b * 114) / 1000
return luma
@maulerjan
maulerjan / Time regex (HH:mm:ss)
Last active Aug 29, 2018
Time validating regular expressions
View Time regex (HH:mm:ss)
^(?:[0-1][0-9]|2[0-3])(?::[0-5]\d){2}$
You can’t perform that action at this time.