1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports["default"] = toColorString;
|
5 | var _hsl = _interopRequireDefault(require("./hsl"));
|
6 | var _hsla = _interopRequireDefault(require("./hsla"));
|
7 | var _rgb = _interopRequireDefault(require("./rgb"));
|
8 | var _rgba = _interopRequireDefault(require("./rgba"));
|
9 | var _errors = _interopRequireDefault(require("../internalHelpers/_errors"));
|
10 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
11 | var isRgb = function isRgb(color) {
|
12 | return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
13 | };
|
14 | var isRgba = function isRgba(color) {
|
15 | return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && typeof color.alpha === 'number';
|
16 | };
|
17 | var isHsl = function isHsl(color) {
|
18 | return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
19 | };
|
20 | var isHsla = function isHsla(color) {
|
21 | return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && typeof color.alpha === 'number';
|
22 | };
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | function toColorString(color) {
|
56 | if (typeof color !== 'object') throw new _errors["default"](8);
|
57 | if (isRgba(color)) return (0, _rgba["default"])(color);
|
58 | if (isRgb(color)) return (0, _rgb["default"])(color);
|
59 | if (isHsla(color)) return (0, _hsla["default"])(color);
|
60 | if (isHsl(color)) return (0, _hsl["default"])(color);
|
61 | throw new _errors["default"](8);
|
62 | }
|
63 | module.exports = exports.default; |
\ | No newline at end of file |