Skip to content

Instantly share code, notes, and snippets.

@vdclouis
Last active May 11, 2016 07:55
Show Gist options
  • Save vdclouis/0154a0a073e6d934f465 to your computer and use it in GitHub Desktop.
Save vdclouis/0154a0a073e6d934f465 to your computer and use it in GitHub Desktop.
rgb to hex 1 liner
const rgbToHex = (r, g, b) =>
'#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
rgbToHex(24, 42, 99); // #182a63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment