examinedliving
9/24/2014 - 2:42 PM

rgbToHex

rgbToHex

// created from this StackOverflow post: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb

function rgbToHex(r,g,b){
    function componentToHex(c) {
        var hex = c.toString(16);
        return hex.length == 1 ? "0" + hex : hex;
    }
        return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}