You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
576 B
13 lines
576 B
4 years ago
|
function hexToRgb(hexCode) {
|
||
|
var patt = /^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/;
|
||
|
var matches = patt.exec(hexCode);
|
||
|
var rgb = "rgb(" + parseInt(matches[1], 16) + "," + parseInt(matches[2], 16) + "," + parseInt(matches[3], 16) + ")";
|
||
|
return rgb;
|
||
|
}
|
||
|
|
||
|
function hexToRgba(hexCode, opacity) {
|
||
|
var patt = /^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/;
|
||
|
var matches = patt.exec(hexCode);
|
||
|
var rgb = "rgba(" + parseInt(matches[1], 16) + "," + parseInt(matches[2], 16) + "," + parseInt(matches[3], 16) + "," + opacity + ")";
|
||
|
return rgb;
|
||
|
}
|