1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports["default"] = _default;
|
7 |
|
8 | function _default(hexColor, lightness) {
|
9 | var hex = String(hexColor).replace(/[^0-9a-f]/gi, '');
|
10 |
|
11 | if (hex.length < 6) {
|
12 | hex = hex.replace(/(.)/g, '$1$1');
|
13 | }
|
14 |
|
15 | var lum = lightness || 0;
|
16 | var rgb = '#';
|
17 | var c;
|
18 |
|
19 | for (var i = 0; i < 3; ++i) {
|
20 | c = parseInt(hex.substr(i * 2, 2), 16);
|
21 | c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
|
22 | rgb += ('00' + c).substr(c.length);
|
23 | }
|
24 |
|
25 | return rgb;
|
26 | } |
\ | No newline at end of file |