UNPKG

color-fns

Version:

Modern JavaScript color utility library.

22 lines 762 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var parseHex_1 = require("./parseHex"); var utils_1 = require("./utils"); function hexToRgb(hex) { var normalizedValue = typeof hex === 'string' ? parseHex_1.parseHex(hex) : hex; if (!normalizedValue) { return null; } var alpha = 1; if (typeof normalizedValue.alpha !== 'undefined') { alpha = Number((utils_1.hexNumToDec(normalizedValue.alpha) / 255).toFixed(2)); } return { alpha: alpha, blue: utils_1.hexNumToDec(normalizedValue.blue), green: utils_1.hexNumToDec(normalizedValue.green), red: utils_1.hexNumToDec(normalizedValue.red) }; } exports.hexToRgb = hexToRgb; //# sourceMappingURL=hexToRgb.js.map