Skip to content

Instantly share code, notes, and snippets.

@leobetosouza
Last active July 5, 2018 22:39
Show Gist options
  • Save leobetosouza/23f24b89531c6701d84d8255c1ec9268 to your computer and use it in GitHub Desktop.
Save leobetosouza/23f24b89531c6701d84d8255c1ec9268 to your computer and use it in GitHub Desktop.
const transparentize = (r, g, b, alpha) => {
const a = (1 - alpha) * 255;
const calc = x => Math.round((x - a)/alpha);
return `rgba(${calc(r)}, ${calc(g)}, ${calc(b)}, ${alpha})`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment