Created
March 28, 2022 08:40
-
-
Save sklinov/7ae85a261035e91118ddd3f6f8195785 to your computer and use it in GitHub Desktop.
Bitwise RGB to HEX conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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