Skip to content

Instantly share code, notes, and snippets.

@sklinov
Created March 28, 2022 08:40
Show Gist options
  • Save sklinov/7ae85a261035e91118ddd3f6f8195785 to your computer and use it in GitHub Desktop.
Save sklinov/7ae85a261035e91118ddd3f6f8195785 to your computer and use it in GitHub Desktop.
Bitwise RGB to HEX conversion
/*
Picked from https://blog.logrocket.com/interesting-use-cases-for-javascript-bitwise-operators/
**/
function rgbToHex ([red = 0, green = 0, blue = 0] = []) {
return `#${(red << 16 | green << 8 | blue).toString(16)}`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment