/** * Transform a HEX color to its RGB representation * @param {string} hex The color to transform * @returns The RGB representation of the passed color */
let sHex = hex.toLowerCase(); if (isHexColor(hex)) { if (sHex.length === 4) { let sColorNew = '#'; for (let i = 1; i < 4; i += 1) { sColorNew += sHex.slice(i, i + 1).concat(sHex.slice(i, i + 1)); } sHex = sColorNew; } const sColorChange = []; for (let i = 1; i < 7; i += 2) { sColorChange.push(parseInt('0x' + sHex.slice(i, i + 2))); } return 'RGB(' + sColorChange.join(',') + ')'; } return sHex;
/** * Darkens a HEX color given the passed percentage * @param {string} color The color to process * @param {number} amount The amount to change the color by * @returns {string} The HEX representation of the processed color */
/** * Lightens a 6 char HEX color according to the passed percentage * @param {string} color The color to change * @param {number} amount The amount to change the color by * @returns {string} The processed color represented as HEX */
/* Suma el porcentaje indicado a un color (RR, GG o BB) hexadecimal para aclararlo *//** * Sums the passed percentage to the R, G or B of a HEX color * @param {string} color The color to change * @param {number} amount The amount to change the color by * @returns {string} The processed part of the color */
/** * Determines what the best text color is (black or white) based con the contrast with the background * @param hexColor - Last selected color by the user */
/** * Subtracts the indicated percentage to the R, G or B of a HEX color * @param {string} color The color to change * @param {number} amount The amount to change the color by * @returns {string} The processed part of the color */