Skip to content

Instantly share code, notes, and snippets.

View jamespjarvis's full-sized avatar

James Jarvis jamespjarvis

View GitHub Profile
@jamespjarvis
jamespjarvis / lightenDarkenColor.js
Last active December 13, 2017 16:11
LightenDarkenColor
const LightenDarkernColor = (color, amount) => {
const usePound = color[0] === '#';
const col = usePound ? color.slice(1) : color;
const num = parseInt(col, 16);
let r = (num >> 16) + amount;
if (r > 255) r = 255;
else if (r < 0) r = 0;
let b = ((num >> 8) & 0x00FF) + amount;
if (b > 255) b = 255;
else if (b < 0) b = 0;