반응형
//ColorCode : #ffffff
function ChangeRGB(ColorCode) {
    const Color = ColorCode.replace('#', '');
    const rgb = Color.length === 3 ? Color.match(/a-f\d/gi) : Color.match(/[a-f\d]{2}/gi);

    return rgb.map((el) => {
        if (el.length === 1) el = el + el;
        return parseInt(el, 16);
    });
}

컬러코드를 넣으면 RGB를 변환하여 컬러코드로 Return 시켜주는 함수 입니다.

+ Recent posts