const hexToRGB = (hex) => {
if (hex.charAt(0) === '#') {
hex = hex.substring(1);
}
if (hex.length !== 3 && hex.length !== 6) {
return false;
}
if (hex.length === 3) {
hex = hex.split('').map(c => c.repeat(2)).join('');
}
const red = parseInt(hex.substring(0, 2), 16);
const blue = parseInt(hex.substring(4, 6), 16);
const green = parseInt(hex.substring(2, 4), 16);
return { red, green, blue };
};