Skip to content

Instantly share code, notes, and snippets.

View cole-acepph's full-sized avatar
👷‍♂️

cole-acepph

👷‍♂️
View GitHub Profile
@whitlockjc
whitlockjc / rgbaToHex.js
Last active July 18, 2022 10:25
Use JavaScript to Convert RGBA CSS Value to Hexadecimal
#!/usr/bin/env node
// Takes an rgba() CSS value and converts it to its 8 digit hexadecimal value.
//
// Usage: ./rgbaToHex.js "{YOUR_RGBA_STRING}"
//
// Example: ./rgbaToHex.js "rgba(197, 200, 198, .2)" => #C5C8C633
function trim (str) {
return str.replace(/^\s+|\s+$/gm,'');