color-interfaces
Advanced tools
Comparing version
@@ -0,0 +0,0 @@ import { Color } from "./ColorInterface"; |
@@ -5,4 +5,7 @@ import { Color as Color_ } from './ColorInterface'; | ||
import HSLInterface from './HSLInterface'; | ||
import HSLAInterface from './HSLAInterface'; | ||
import HSVInterface from './HSVInterface'; | ||
import HSVAInterface from './HSVAInterface'; | ||
import HexInterface from './HexInterface'; | ||
import HexAInterface from './HexAInterface'; | ||
import { ColorType } from './consts'; | ||
@@ -31,4 +34,7 @@ /** | ||
private _hsl; | ||
private _hsla; | ||
private _hsv; | ||
private _hsva; | ||
private _hex; | ||
private _hexa; | ||
constructor(value?: number[] | string, type?: ColorType); | ||
@@ -39,4 +45,7 @@ parseCSSColor(input: string): void; | ||
get hsl(): HSLInterface; | ||
get hsla(): HSLAInterface; | ||
get hsv(): HSVInterface; | ||
get hsva(): HSVAInterface; | ||
get hex(): HexInterface; | ||
get hexa(): HexAInterface; | ||
set alpha(alpha: number); | ||
@@ -43,0 +52,0 @@ get alpha(): number; |
@@ -5,4 +5,7 @@ export interface Color { | ||
hsl: HSLInterface; | ||
hsla: HSLAInterface; | ||
hsv: HSVInterface; | ||
hsva: HSVAInterface; | ||
hex: HexInterface; | ||
hexa: HexAInterface; | ||
alpha: number; | ||
@@ -58,2 +61,11 @@ getRed(): number; | ||
} | ||
export interface HSLAInterface { | ||
h: number; | ||
s: number; | ||
l: number; | ||
a: number; | ||
get: () => HSLA; | ||
set: (hsva: HSLA) => HSLAInterface; | ||
toCss: () => string; | ||
} | ||
export interface HSVInterface { | ||
@@ -67,2 +79,11 @@ h: number; | ||
} | ||
export interface HSVAInterface { | ||
h: number; | ||
s: number; | ||
v: number; | ||
a: number; | ||
get: () => HSVA; | ||
set: (hsv: HSVA) => HSVAInterface; | ||
toCss: () => string; | ||
} | ||
export interface HexInterface { | ||
@@ -73,2 +94,8 @@ get: () => HEX; | ||
} | ||
export interface HexAInterface { | ||
a: number; | ||
get: () => HEXA; | ||
set: (hexa: HEXA) => HexAInterface; | ||
toCss: () => string; | ||
} | ||
export declare type RGB = [number, number, number]; | ||
@@ -81,1 +108,2 @@ export declare type RGBA = [number, number, number, number]; | ||
export declare type HEX = string; | ||
export declare type HEXA = string; |
@@ -16,1 +16,3 @@ export declare enum ColorType { | ||
export declare const RE_HEX_3: RegExp; | ||
export declare const RE_HEX_4: RegExp; | ||
export declare const RE_HEX_8: RegExp; |
@@ -1,2 +0,2 @@ | ||
import { Color, HexInterface as HexInterface_, HEX } from "./ColorInterface"; | ||
import { Color, HexInterface as HexInterface_, HEX } from './ColorInterface'; | ||
declare class HexInterface implements HexInterface_ { | ||
@@ -3,0 +3,0 @@ private color; |
@@ -1,11 +0,4 @@ | ||
import { Color, HSLInterface as HSLInterface_, HSL } from "./ColorInterface"; | ||
declare class HSLInterface implements HSLInterface_ { | ||
private color; | ||
constructor(color: Color); | ||
set h(h: number); | ||
get h(): number; | ||
set s(s: number); | ||
get s(): number; | ||
set l(l: number); | ||
get l(): number; | ||
import { HSLInterface as HSLInterface_, HSL } from './ColorInterface'; | ||
import BaseHSLInterface from './BaseHSLInterface'; | ||
declare class HSLInterface extends BaseHSLInterface implements HSLInterface_ { | ||
get(): HSL; | ||
@@ -12,0 +5,0 @@ set(hsl: HSL): this; |
@@ -1,11 +0,4 @@ | ||
import { Color, HSVInterface as HSVInterface_, HSV } from "./ColorInterface"; | ||
declare class HSVInterface implements HSVInterface_ { | ||
private color; | ||
constructor(color: Color); | ||
set h(h: number); | ||
get h(): number; | ||
set s(s: number); | ||
get s(): number; | ||
set v(v: number); | ||
get v(): number; | ||
import { HSVInterface as HSVInterface_, HSV } from './ColorInterface'; | ||
import BaseHSVInterface from './BaseHSVInterface'; | ||
declare class HSVInterface extends BaseHSVInterface implements HSVInterface_ { | ||
get(): HSV; | ||
@@ -12,0 +5,0 @@ set(hsv: HSV): this; |
@@ -6,5 +6,8 @@ import Color from './Color'; | ||
export { default as HSLInterface } from './HSLInterface'; | ||
export { default as HSLAInterface } from './HSLAInterface'; | ||
export { default as HSVInterface } from './HSVInterface'; | ||
export { default as HSVAInterface } from './HSVAInterface'; | ||
export { default as HexInterface } from './HexInterface'; | ||
export { default as HexAInterface } from './HexAInterface'; | ||
export { RGB, RGBA, HSL, HSLA, HSV, HSVA, HEX } from './ColorInterface'; | ||
export { ColorType } from './consts'; |
568
dist/main.js
@@ -85,3 +85,3 @@ module.exports = | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 8); | ||
/******/ return __webpack_require__(__webpack_require__.s = 13); | ||
/******/ }) | ||
@@ -96,3 +96,66 @@ /************************************************************************/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RE_HEX_3 = exports.RE_HEX_6 = exports.GREY = exports.WHITE = exports.BLACK = exports.DEFAULT_COLOR = exports.ColorType = void 0; | ||
exports.toTwoHex = exports.getTestSpan = exports.parseInt10 = exports.hueToRgb = exports.toPercent = exports.mixRgbColors = exports.clamp = void 0; | ||
var consts_1 = __webpack_require__(1); | ||
exports.clamp = function (val, min, max) { | ||
return Math.min(Math.max(val, min), max); | ||
}; | ||
exports.mixRgbColors = function (rgb1, rgb2, m) { | ||
return [ | ||
rgb1[0] + m * (rgb2[0] - rgb1[0]), | ||
rgb1[1] + m * (rgb2[1] - rgb1[1]), | ||
rgb1[2] + m * (rgb2[2] - rgb1[2]), | ||
]; | ||
}; | ||
exports.toPercent = function (value) { | ||
return Math.round(value * 100) + "%"; | ||
}; | ||
exports.hueToRgb = function (hue) { | ||
hue %= 360; | ||
var delta = hue % 60; | ||
hue -= delta; | ||
delta = Math.round((255 / 60) * delta); | ||
switch (hue) { | ||
case 0: | ||
return [255, delta, 0]; | ||
case 60: | ||
return [255 - delta, 255, 0]; | ||
case 120: | ||
return [0, 255, delta]; | ||
case 180: | ||
return [0, 255 - delta, 255]; | ||
case 240: | ||
return [delta, 0, 255]; | ||
case 300: | ||
return [255, 0, 255 - delta]; | ||
} | ||
return [0, 0, 0]; | ||
}; | ||
exports.parseInt10 = function (i) { | ||
return Number.parseInt(i, 10); | ||
}; | ||
exports.getTestSpan = function () { | ||
var span = testSpan; | ||
if (!span || !span.parentNode) { | ||
span = testSpan = document.createElement('span'); | ||
span.style.display = 'none'; | ||
document.body.appendChild(span); | ||
} | ||
span.style.setProperty('color', consts_1.DEFAULT_COLOR, 'important'); | ||
return span; | ||
}; | ||
var testSpan = null; | ||
exports.toTwoHex = function (n) { | ||
var hex = n.toString(16); | ||
return hex.length === 1 ? "0" + hex : hex; | ||
}; | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RE_HEX_8 = exports.RE_HEX_4 = exports.RE_HEX_3 = exports.RE_HEX_6 = exports.GREY = exports.WHITE = exports.BLACK = exports.DEFAULT_COLOR = exports.ColorType = void 0; | ||
var ColorType; | ||
@@ -108,12 +171,14 @@ (function (ColorType) { | ||
})(ColorType = exports.ColorType || (exports.ColorType = {})); | ||
exports.DEFAULT_COLOR = "black"; | ||
exports.DEFAULT_COLOR = 'black'; | ||
exports.BLACK = [0, 0, 0]; | ||
exports.WHITE = [255, 255, 255]; | ||
exports.GREY = [127.5, 127.5, 127.5]; | ||
exports.RE_HEX_6 = new RegExp("^[0-9a-fA-F]{6}$"); | ||
exports.RE_HEX_3 = new RegExp("^[0-9a-fA-F]{3}$"); | ||
exports.RE_HEX_6 = new RegExp('^[0-9a-fA-F]{6}$'); | ||
exports.RE_HEX_3 = new RegExp('^[0-9a-fA-F]{3}$'); | ||
exports.RE_HEX_4 = new RegExp('^[0-9a-fA-F]{4}$'); | ||
exports.RE_HEX_8 = new RegExp('^[0-9a-fA-F]{8}$'); | ||
/***/ }), | ||
/* 1 */ | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -156,3 +221,3 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var BaseRGBInterface_1 = __importDefault(__webpack_require__(2)); | ||
var BaseRGBInterface_1 = __importDefault(__webpack_require__(3)); | ||
var RGBInterface = /** @class */ (function (_super) { | ||
@@ -180,3 +245,3 @@ __extends(RGBInterface, _super); | ||
/***/ }), | ||
/* 2 */ | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -227,3 +292,3 @@ | ||
/***/ }), | ||
/* 3 */ | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -266,3 +331,3 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var BaseRGBInterface_1 = __importDefault(__webpack_require__(2)); | ||
var BaseRGBInterface_1 = __importDefault(__webpack_require__(3)); | ||
var RGBAInterface = /** @class */ (function (_super) { | ||
@@ -300,3 +365,3 @@ __extends(RGBAInterface, _super); | ||
/***/ }), | ||
/* 4 */ | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -306,2 +371,15 @@ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __read = (this && this.__read) || function (o, n) { | ||
@@ -323,9 +401,43 @@ var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utils_1 = __webpack_require__(5); | ||
var HSLInterface = /** @class */ (function () { | ||
function HSLInterface(color) { | ||
var utils_1 = __webpack_require__(0); | ||
var BaseHSLInterface_1 = __importDefault(__webpack_require__(6)); | ||
var HSLInterface = /** @class */ (function (_super) { | ||
__extends(HSLInterface, _super); | ||
function HSLInterface() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
HSLInterface.prototype.get = function () { | ||
return [this.h, this.s, this.l]; | ||
}; | ||
HSLInterface.prototype.set = function (hsl) { | ||
var _a; | ||
_a = __read(hsl, 3), this.h = _a[0], this.s = _a[1], this.l = _a[2]; | ||
return this; | ||
}; | ||
HSLInterface.prototype.toCss = function () { | ||
var s = utils_1.toPercent(this.s); | ||
var l = utils_1.toPercent(this.l); | ||
return "hsl(" + this.h + ", " + s + ", " + l + ")"; | ||
}; | ||
return HSLInterface; | ||
}(BaseHSLInterface_1.default)); | ||
exports.default = HSLInterface; | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var BaseHSLInterface = /** @class */ (function () { | ||
function BaseHSLInterface(color) { | ||
this.color = color; | ||
} | ||
Object.defineProperty(HSLInterface.prototype, "h", { | ||
Object.defineProperty(BaseHSLInterface.prototype, "h", { | ||
get: function () { | ||
@@ -340,3 +452,3 @@ return this.color.getHue(); | ||
}); | ||
Object.defineProperty(HSLInterface.prototype, "s", { | ||
Object.defineProperty(BaseHSLInterface.prototype, "s", { | ||
get: function () { | ||
@@ -351,3 +463,3 @@ return this.color.getSaturation(); | ||
}); | ||
Object.defineProperty(HSLInterface.prototype, "l", { | ||
Object.defineProperty(BaseHSLInterface.prototype, "l", { | ||
get: function () { | ||
@@ -362,22 +474,9 @@ return this.color.getLightness(); | ||
}); | ||
HSLInterface.prototype.get = function () { | ||
return [this.h, this.s, this.l]; | ||
}; | ||
HSLInterface.prototype.set = function (hsl) { | ||
var _a; | ||
_a = __read(hsl, 3), this.h = _a[0], this.s = _a[1], this.l = _a[2]; | ||
return this; | ||
}; | ||
HSLInterface.prototype.toCss = function () { | ||
var s = utils_1.toPercent(this.s); | ||
var l = utils_1.toPercent(this.l); | ||
return "hsl(" + this.h + ", " + s + ", " + l + ")"; | ||
}; | ||
return HSLInterface; | ||
return BaseHSLInterface; | ||
}()); | ||
exports.default = HSLInterface; | ||
exports.default = BaseHSLInterface; | ||
/***/ }), | ||
/* 5 */ | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -387,57 +486,72 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTestSpan = exports.parseInt10 = exports.hueToRgb = exports.toPercent = exports.mixRgbColors = exports.clamp = void 0; | ||
var consts_1 = __webpack_require__(0); | ||
exports.clamp = function (val, min, max) { | ||
return Math.min(Math.max(val, min), max); | ||
}; | ||
exports.mixRgbColors = function (rgb1, rgb2, m) { | ||
return [ | ||
rgb1[0] + m * (rgb2[0] - rgb1[0]), | ||
rgb1[1] + m * (rgb2[1] - rgb1[1]), | ||
rgb1[2] + m * (rgb2[2] - rgb1[2]), | ||
]; | ||
}; | ||
exports.toPercent = function (value) { | ||
return Math.round(value * 100) + "%"; | ||
}; | ||
exports.hueToRgb = function (hue) { | ||
hue %= 360; | ||
var delta = hue % 60; | ||
hue -= delta; | ||
delta = Math.round((255 / 60) * delta); | ||
switch (hue) { | ||
case 0: | ||
return [255, delta, 0]; | ||
case 60: | ||
return [255 - delta, 255, 0]; | ||
case 120: | ||
return [0, 255, delta]; | ||
case 180: | ||
return [0, 255 - delta, 255]; | ||
case 240: | ||
return [delta, 0, 255]; | ||
case 300: | ||
return [255, 0, 255 - delta]; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
return [0, 0, 0]; | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
exports.parseInt10 = function (i) { | ||
return Number.parseInt(i, 10); | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
exports.getTestSpan = function () { | ||
var span = testSpan; | ||
if (!span || !span.parentNode) { | ||
span = testSpan = document.createElement('span'); | ||
span.style.display = 'none'; | ||
document.body.appendChild(span); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utils_1 = __webpack_require__(0); | ||
var BaseHSLInterface_1 = __importDefault(__webpack_require__(6)); | ||
var HSLAInterface = /** @class */ (function (_super) { | ||
__extends(HSLAInterface, _super); | ||
function HSLAInterface() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
span.style.setProperty('color', consts_1.DEFAULT_COLOR, 'important'); | ||
return span; | ||
}; | ||
var testSpan = null; | ||
Object.defineProperty(HSLAInterface.prototype, "a", { | ||
get: function () { | ||
return this.color.alpha; | ||
}, | ||
set: function (alpha) { | ||
this.color.alpha = alpha; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
HSLAInterface.prototype.get = function () { | ||
return [this.h, this.s, this.l, this.a]; | ||
}; | ||
HSLAInterface.prototype.set = function (hsla) { | ||
var _a; | ||
_a = __read(hsla, 4), this.h = _a[0], this.s = _a[1], this.l = _a[2], this.a = _a[3]; | ||
return this; | ||
}; | ||
HSLAInterface.prototype.toCss = function () { | ||
var s = utils_1.toPercent(this.s); | ||
var l = utils_1.toPercent(this.l); | ||
return "hsla(" + this.h + ", " + s + ", " + l + ", " + this.color.alpha.toFixed(2) + ")"; | ||
}; | ||
return HSLAInterface; | ||
}(BaseHSLInterface_1.default)); | ||
exports.default = HSLAInterface; | ||
/***/ }), | ||
/* 6 */ | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -447,2 +561,15 @@ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __read = (this && this.__read) || function (o, n) { | ||
@@ -464,8 +591,40 @@ var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var HSVInterface = /** @class */ (function () { | ||
function HSVInterface(color) { | ||
var BaseHSVInterface_1 = __importDefault(__webpack_require__(9)); | ||
var HSVInterface = /** @class */ (function (_super) { | ||
__extends(HSVInterface, _super); | ||
function HSVInterface() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
HSVInterface.prototype.get = function () { | ||
return [this.h, this.s, this.v]; | ||
}; | ||
HSVInterface.prototype.set = function (hsv) { | ||
var _a; | ||
_a = __read(hsv, 3), this.h = _a[0], this.s = _a[1], this.v = _a[2]; | ||
return this; | ||
}; | ||
HSVInterface.prototype.toCss = function () { | ||
return this.color.hsl.toCss(); | ||
}; | ||
return HSVInterface; | ||
}(BaseHSVInterface_1.default)); | ||
exports.default = HSVInterface; | ||
/***/ }), | ||
/* 9 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var HSVAInterface = /** @class */ (function () { | ||
function HSVAInterface(color) { | ||
this.color = color; | ||
} | ||
Object.defineProperty(HSVInterface.prototype, "h", { | ||
Object.defineProperty(HSVAInterface.prototype, "h", { | ||
get: function () { | ||
@@ -480,3 +639,3 @@ return this.color.getHue(); | ||
}); | ||
Object.defineProperty(HSVInterface.prototype, "s", { | ||
Object.defineProperty(HSVAInterface.prototype, "s", { | ||
get: function () { | ||
@@ -491,3 +650,3 @@ return this.color.getSaturationV(); | ||
}); | ||
Object.defineProperty(HSVInterface.prototype, "v", { | ||
Object.defineProperty(HSVAInterface.prototype, "v", { | ||
get: function () { | ||
@@ -502,20 +661,80 @@ return this.color.getValue(); | ||
}); | ||
HSVInterface.prototype.get = function () { | ||
return [this.h, this.s, this.v]; | ||
return HSVAInterface; | ||
}()); | ||
exports.default = HSVAInterface; | ||
/***/ }), | ||
/* 10 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
HSVInterface.prototype.set = function (hsv) { | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var BaseHSVInterface_1 = __importDefault(__webpack_require__(9)); | ||
var HSVAInterface = /** @class */ (function (_super) { | ||
__extends(HSVAInterface, _super); | ||
function HSVAInterface() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
Object.defineProperty(HSVAInterface.prototype, "a", { | ||
get: function () { | ||
return this.color.alpha; | ||
}, | ||
set: function (alpha) { | ||
this.color.alpha = alpha; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
HSVAInterface.prototype.get = function () { | ||
return [this.h, this.s, this.v, this.a]; | ||
}; | ||
HSVAInterface.prototype.set = function (hsva) { | ||
var _a; | ||
_a = __read(hsv, 3), this.h = _a[0], this.s = _a[1], this.v = _a[2]; | ||
_a = __read(hsva, 4), this.h = _a[0], this.s = _a[1], this.v = _a[2], this.a = _a[3]; | ||
return this; | ||
}; | ||
HSVInterface.prototype.toCss = function () { | ||
return this.color.hsl.toCss(); | ||
HSVAInterface.prototype.toCss = function () { | ||
return this.color.hsla.toCss(); | ||
}; | ||
return HSVInterface; | ||
}()); | ||
exports.default = HSVInterface; | ||
return HSVAInterface; | ||
}(BaseHSVInterface_1.default)); | ||
exports.default = HSVAInterface; | ||
/***/ }), | ||
/* 7 */ | ||
/* 11 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -526,3 +745,4 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var consts_1 = __webpack_require__(0); | ||
var consts_1 = __webpack_require__(1); | ||
var utils_1 = __webpack_require__(0); | ||
var HexInterface = /** @class */ (function () { | ||
@@ -534,3 +754,3 @@ function HexInterface(color) { | ||
if (!(consts_1.RE_HEX_3.test(hex) || consts_1.RE_HEX_6.test(hex))) { | ||
throw Error("Not valid hex color"); | ||
throw Error('Not valid hex color'); | ||
} | ||
@@ -545,5 +765,3 @@ if (consts_1.RE_HEX_3.test(hex)) { | ||
HexInterface.prototype.get = function () { | ||
var rgb = this.color.rgb; | ||
var hex = ((rgb.r << 16) | (rgb.g << 8) | rgb.b).toString(16); | ||
return "" + "0".repeat(6 - hex.length) + hex; | ||
return this.color.rgb.get().map(utils_1.toTwoHex).join(''); | ||
}; | ||
@@ -563,3 +781,3 @@ HexInterface.prototype.toCss = function () { | ||
/***/ }), | ||
/* 8 */ | ||
/* 12 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -569,2 +787,76 @@ | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var consts_1 = __webpack_require__(1); | ||
var utils_1 = __webpack_require__(0); | ||
var HexAInterface = /** @class */ (function () { | ||
function HexAInterface(color) { | ||
this.color = color; | ||
} | ||
Object.defineProperty(HexAInterface.prototype, "a", { | ||
get: function () { | ||
return this.color.alpha; | ||
}, | ||
set: function (alpha) { | ||
this.color.alpha = alpha; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
HexAInterface.prototype.set = function (hexa) { | ||
if (!(consts_1.RE_HEX_4.test(hexa) || consts_1.RE_HEX_8.test(hexa))) { | ||
throw Error('Not valid hexa color'); | ||
} | ||
if (consts_1.RE_HEX_4.test(hexa)) { | ||
hexa = Array.from(hexa) | ||
.flatMap(function (h) { return [h, h]; }) | ||
.join(''); | ||
} | ||
var _a = __read(hexa.match(/../g).map(function (h) { return Number.parseInt(h, 16); }), 4), r = _a[0], g = _a[1], b = _a[2], a = _a[3]; | ||
this.color.rgb.set([r, g, b]); | ||
this.a = a === 0 ? 0 : a / 255; | ||
return this; | ||
}; | ||
HexAInterface.prototype.get = function () { | ||
return this.color.rgba | ||
.get() | ||
.map(function (n, index) { return utils_1.toTwoHex(index === 3 ? Math.round(n * 255) : n); }) | ||
.join(''); | ||
}; | ||
HexAInterface.prototype.toCss = function () { | ||
var hexa = this.get(); | ||
if (hexa[0] === hexa[1] && | ||
hexa[2] === hexa[3] && | ||
hexa[4] === hexa[5] && | ||
hexa[6] === hexa[7]) { | ||
hexa = "" + hexa[0] + hexa[2] + hexa[4] + hexa[6]; | ||
} | ||
return "#" + hexa; | ||
}; | ||
return HexAInterface; | ||
}()); | ||
exports.default = HexAInterface; | ||
/***/ }), | ||
/* 13 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -574,15 +866,21 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Color_1 = __importDefault(__webpack_require__(9)); | ||
var Color_1 = __importDefault(__webpack_require__(14)); | ||
exports.default = Color_1.default; | ||
var RGBInterface_1 = __webpack_require__(1); | ||
var RGBInterface_1 = __webpack_require__(2); | ||
Object.defineProperty(exports, "RGBInterface", { enumerable: true, get: function () { return RGBInterface_1.default; } }); | ||
var RGBAInterface_1 = __webpack_require__(3); | ||
var RGBAInterface_1 = __webpack_require__(4); | ||
Object.defineProperty(exports, "RGBAInterface", { enumerable: true, get: function () { return RGBAInterface_1.default; } }); | ||
var HSLInterface_1 = __webpack_require__(4); | ||
var HSLInterface_1 = __webpack_require__(5); | ||
Object.defineProperty(exports, "HSLInterface", { enumerable: true, get: function () { return HSLInterface_1.default; } }); | ||
var HSVInterface_1 = __webpack_require__(6); | ||
var HSLAInterface_1 = __webpack_require__(7); | ||
Object.defineProperty(exports, "HSLAInterface", { enumerable: true, get: function () { return HSLAInterface_1.default; } }); | ||
var HSVInterface_1 = __webpack_require__(8); | ||
Object.defineProperty(exports, "HSVInterface", { enumerable: true, get: function () { return HSVInterface_1.default; } }); | ||
var HexInterface_1 = __webpack_require__(7); | ||
var HSVAInterface_1 = __webpack_require__(10); | ||
Object.defineProperty(exports, "HSVAInterface", { enumerable: true, get: function () { return HSVAInterface_1.default; } }); | ||
var HexInterface_1 = __webpack_require__(11); | ||
Object.defineProperty(exports, "HexInterface", { enumerable: true, get: function () { return HexInterface_1.default; } }); | ||
var consts_1 = __webpack_require__(0); | ||
var HexAInterface_1 = __webpack_require__(12); | ||
Object.defineProperty(exports, "HexAInterface", { enumerable: true, get: function () { return HexAInterface_1.default; } }); | ||
var consts_1 = __webpack_require__(1); | ||
Object.defineProperty(exports, "ColorType", { enumerable: true, get: function () { return consts_1.ColorType; } }); | ||
@@ -592,3 +890,3 @@ | ||
/***/ }), | ||
/* 9 */ | ||
/* 14 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -618,9 +916,12 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var RGBInterface_1 = __importDefault(__webpack_require__(1)); | ||
var RGBAInterface_1 = __importDefault(__webpack_require__(3)); | ||
var HSLInterface_1 = __importDefault(__webpack_require__(4)); | ||
var HSVInterface_1 = __importDefault(__webpack_require__(6)); | ||
var HexInterface_1 = __importDefault(__webpack_require__(7)); | ||
var consts_1 = __webpack_require__(0); | ||
var utils_1 = __webpack_require__(5); | ||
var RGBInterface_1 = __importDefault(__webpack_require__(2)); | ||
var RGBAInterface_1 = __importDefault(__webpack_require__(4)); | ||
var HSLInterface_1 = __importDefault(__webpack_require__(5)); | ||
var HSLAInterface_1 = __importDefault(__webpack_require__(7)); | ||
var HSVInterface_1 = __importDefault(__webpack_require__(8)); | ||
var HSVAInterface_1 = __importDefault(__webpack_require__(10)); | ||
var HexInterface_1 = __importDefault(__webpack_require__(11)); | ||
var HexAInterface_1 = __importDefault(__webpack_require__(12)); | ||
var consts_1 = __webpack_require__(1); | ||
var utils_1 = __webpack_require__(0); | ||
/** | ||
@@ -649,4 +950,7 @@ * @constructor | ||
this._hsl = null; | ||
this._hsla = null; | ||
this._hsv = null; | ||
this._hsva = null; | ||
this._hex = null; | ||
this._hexa = null; | ||
if (typeof value === 'string') { | ||
@@ -710,2 +1014,12 @@ this.parseCSSColor(value); | ||
}); | ||
Object.defineProperty(Color.prototype, "hsla", { | ||
get: function () { | ||
if (!this._hsla) { | ||
this._hsla = new HSLAInterface_1.default(this); | ||
} | ||
return this._hsla; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Color.prototype, "hsv", { | ||
@@ -721,2 +1035,12 @@ get: function () { | ||
}); | ||
Object.defineProperty(Color.prototype, "hsva", { | ||
get: function () { | ||
if (!this._hsva) { | ||
this._hsva = new HSVAInterface_1.default(this); | ||
} | ||
return this._hsva; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Color.prototype, "hex", { | ||
@@ -732,2 +1056,12 @@ get: function () { | ||
}); | ||
Object.defineProperty(Color.prototype, "hexa", { | ||
get: function () { | ||
if (!this._hexa) { | ||
this._hexa = new HexAInterface_1.default(this); | ||
} | ||
return this._hexa; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Color.prototype, "alpha", { | ||
@@ -734,0 +1068,0 @@ get: function () { |
@@ -1,1 +0,1 @@ | ||
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=8)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RE_HEX_3=e.RE_HEX_6=e.GREY=e.WHITE=e.BLACK=e.DEFAULT_COLOR=e.ColorType=void 0,function(t){t[t.KEYWORD=1]="KEYWORD",t[t.HEX=2]="HEX",t[t.RGB=3]="RGB",t[t.RGBA=4]="RGBA",t[t.HSL=5]="HSL",t[t.HSLA=6]="HSLA",t[t.HSV=7]="HSV"}(e.ColorType||(e.ColorType={})),e.DEFAULT_COLOR="black",e.BLACK=[0,0,0],e.WHITE=[255,255,255],e.GREY=[127.5,127.5,127.5],e.RE_HEX_6=new RegExp("^[0-9a-fA-F]{6}$"),e.RE_HEX_3=new RegExp("^[0-9a-fA-F]{3}$")},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u},u=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.get=function(){return[this.r,this.g,this.b]},e.prototype.set=function(t){var e;return e=i(t,3),this.r=e[0],this.g=e[1],this.b=e[2],this},e.prototype.toCss=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},e}(u(r(2)).default);e.default=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"r",{get:function(){return this.color.getRed()},set:function(t){this.color.setRed(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this.color.getGreen()},set:function(t){this.color.setGreen(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this.color.getBlue()},set:function(t){this.color.setBlue(t)},enumerable:!1,configurable:!0}),t}();e.default=n},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u},u=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),Object.defineProperty(e.prototype,"a",{get:function(){return this.color.alpha},set:function(t){this.color.alpha=t},enumerable:!1,configurable:!0}),e.prototype.get=function(){return[this.r,this.g,this.b,this.a]},e.prototype.set=function(t){var e;return e=i(t,4),this.r=e[0],this.g=e[1],this.b=e[2],this.a=e[3],this},e.prototype.toCss=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.a.toFixed(2)+")"},e}(u(r(2)).default);e.default=s},function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u};Object.defineProperty(e,"__esModule",{value:!0});var o=r(5),i=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"h",{get:function(){return this.color.getHue()},set:function(t){this.color.setHue(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"s",{get:function(){return this.color.getSaturation()},set:function(t){this.color.setSaturation(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"l",{get:function(){return this.color.getLightness()},set:function(t){this.color.setLightness(t)},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.h,this.s,this.l]},t.prototype.set=function(t){var e;return e=n(t,3),this.h=e[0],this.s=e[1],this.l=e[2],this},t.prototype.toCss=function(){var t=o.toPercent(this.s),e=o.toPercent(this.l);return"hsl("+this.h+", "+t+", "+e+")"},t}();e.default=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getTestSpan=e.parseInt10=e.hueToRgb=e.toPercent=e.mixRgbColors=e.clamp=void 0;var n=r(0);e.clamp=function(t,e,r){return Math.min(Math.max(t,e),r)},e.mixRgbColors=function(t,e,r){return[t[0]+r*(e[0]-t[0]),t[1]+r*(e[1]-t[1]),t[2]+r*(e[2]-t[2])]},e.toPercent=function(t){return Math.round(100*t)+"%"},e.hueToRgb=function(t){var e=(t%=360)%60;switch(t-=e,e=Math.round(4.25*e),t){case 0:return[255,e,0];case 60:return[255-e,255,0];case 120:return[0,255,e];case 180:return[0,255-e,255];case 240:return[e,0,255];case 300:return[255,0,255-e]}return[0,0,0]},e.parseInt10=function(t){return Number.parseInt(t,10)},e.getTestSpan=function(){var t=o;return t&&t.parentNode||((t=o=document.createElement("span")).style.display="none",document.body.appendChild(t)),t.style.setProperty("color",n.DEFAULT_COLOR,"important"),t};var o=null},function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u};Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"h",{get:function(){return this.color.getHue()},set:function(t){this.color.setHue(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"s",{get:function(){return this.color.getSaturationV()},set:function(t){this.color.setSaturationV(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"v",{get:function(){return this.color.getValue()},set:function(t){this.color.setValue(t)},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.h,this.s,this.v]},t.prototype.set=function(t){var e;return e=n(t,3),this.h=e[0],this.s=e[1],this.v=e[2],this},t.prototype.toCss=function(){return this.color.hsl.toCss()},t}();e.default=o},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(0),o=function(){function t(t){this.color=t}return t.prototype.set=function(t){if(!n.RE_HEX_3.test(t)&&!n.RE_HEX_6.test(t))throw Error("Not valid hex color");n.RE_HEX_3.test(t)&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);var e=Number.parseInt(t,16);return this.color.rgb.set([e>>16,e>>8&255,255&e]),this},t.prototype.get=function(){var t=this.color.rgb,e=(t.r<<16|t.g<<8|t.b).toString(16);return""+"0".repeat(6-e.length)+e},t.prototype.toCss=function(){var t=this.get();return t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5]&&(t=""+t[0]+t[2]+t[4]),"#"+t},t}();e.default=o},function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=n(r(9));e.default=o.default;var i=r(1);Object.defineProperty(e,"RGBInterface",{enumerable:!0,get:function(){return i.default}});var u=r(3);Object.defineProperty(e,"RGBAInterface",{enumerable:!0,get:function(){return u.default}});var s=r(4);Object.defineProperty(e,"HSLInterface",{enumerable:!0,get:function(){return s.default}});var a=r(6);Object.defineProperty(e,"HSVInterface",{enumerable:!0,get:function(){return a.default}});var l=r(7);Object.defineProperty(e,"HexInterface",{enumerable:!0,get:function(){return l.default}});var c=r(0);Object.defineProperty(e,"ColorType",{enumerable:!0,get:function(){return c.ColorType}})},function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var i=o(r(1)),u=o(r(3)),s=o(r(4)),a=o(r(6)),l=o(r(7)),c=r(0),h=r(5),p=function(){function t(t,e){if(this._alpha=1,this.red=0,this.green=0,this.blue=0,this.hue=0,this.saturation=0,this.lightness=0,this.saturationV=0,this.value=0,this._rgb=null,this._rgba=null,this._hsl=null,this._hsv=null,this._hex=null,"string"==typeof t&&this.parseCSSColor(t),Array.isArray(t))switch(e){case void 0:case c.ColorType.RGB:this.rgb.set(t);break;case c.ColorType.HSL:this.hsl.set(t);break;case c.ColorType.HSV:this.hsv.set(t)}}return t.prototype.parseCSSColor=function(t){var e=h.getTestSpan();e.style.setProperty("color",t,"important");var r=window.getComputedStyle(e).color.split(/rgba?\(|,s*|\)$/).filter(Boolean);4===r.length&&(this.alpha=parseFloat(r.pop())),this.rgb.set(r.map(h.parseInt10))},Object.defineProperty(t.prototype,"rgb",{get:function(){return null===this._rgb&&(this._rgb=new i.default(this)),this._rgb},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return null===this._rgba&&(this._rgba=new u.default(this)),this._rgba},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hsl",{get:function(){return this._hsl||(this._hsl=new s.default(this)),this._hsl},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hsv",{get:function(){return this._hsv||(this._hsv=new a.default(this)),this._hsv},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hex",{get:function(){return this._hex||(this._hex=new l.default(this)),this._hex},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return h.clamp(this._alpha,0,1)},set:function(t){this._alpha=t},enumerable:!1,configurable:!0}),t.prototype.setRed=function(t){this.red=h.clamp(t,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},t.prototype.getRed=function(){return Math.round(h.clamp(this.red,0,255))},t.prototype.setGreen=function(t){this.green=h.clamp(t,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},t.prototype.getGreen=function(){return Math.round(h.clamp(this.green,0,255))},t.prototype.setBlue=function(t){this.blue=h.clamp(t,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},t.prototype.getBlue=function(){return Math.round(h.clamp(this.blue,0,255))},t.prototype.setHue=function(t){this.hue=h.clamp(t,0,360),this.updateRgbFromHsl()},t.prototype.getHue=function(){return Math.round(h.clamp(this.hue,0,360))},t.prototype.setSaturation=function(t){this.saturation=h.clamp(t,0,1),this.updateRgbFromHsl(),this.updateHsvFromHsl()},t.prototype.getSaturation=function(){return h.clamp(this.saturation,0,1)},t.prototype.setSaturationV=function(t){this.saturationV=h.clamp(t,0,1),this.updateHslFromHsv(),this.updateRgbFromHsl()},t.prototype.getSaturationV=function(){return h.clamp(this.saturationV,0,1)},t.prototype.setLightness=function(t){this.lightness=h.clamp(t,0,1),this.updateRgbFromHsl(),this.updateHsvFromHsl()},t.prototype.getLightness=function(){return h.clamp(this.lightness,0,1)},t.prototype.setValue=function(t){this.value=h.clamp(t,0,1),this.updateHslFromHsv(),this.updateRgbFromHsl()},t.prototype.getValue=function(){return h.clamp(this.value,0,1)},t.prototype.getGreyValue=function(){return.2126*this.red+.7152*this.green+.0722*this.blue},t.prototype.invert=function(){return this.setHue((this.hue+180)%360),this},t.prototype.getLuminance=function(){var t=this.rgb.get().map((function(t){var e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}));return.2126*t[0]+.7152*t[1]+.0722*t[2]},t.prototype.getContrastRatio=function(t){var e=this.getLuminance(),r=t.getLuminance();return e>r?(e+.05)/(r+.05):(r+.05)/(e+.05)},t.prototype.copy=function(){var e=new t;return e.setRed(this.red),e.setGreen(this.green),e.setBlue(this.blue),e.alpha=this.alpha,e},t.prototype.mixWithColor=function(t,e){return this.rgb.set(h.mixRgbColors(this.rgb.get(),t.rgb.get(),e)),this},t.prototype.updateHslFromRgb=function(){var t=this.red/255,e=this.green/255,r=this.blue/255,n=Math.max(t,e,r),o=Math.min(t,e,r),i=n+o,u=n-o;if(this.hue=0,this.saturation=0,this.lightness=i/2,0!==u){this.saturation=u/(1-Math.abs(i-1));var s=60/u;switch(n){case t:this.hue=(360+(e-r)*s)%360;break;case e:this.hue=120+(r-t)*s;break;case r:this.hue=240+(t-e)*s}}},t.prototype.updateRgbFromHsl=function(){var t,e=h.hueToRgb(this.hue),r=h.mixRgbColors(e,c.GREY,1-this.saturation),o=this.lightness<=.5?c.BLACK:c.WHITE,i=1-Math.abs(2*this.lightness-1);t=n(h.mixRgbColors(o,r,i),3),this.red=t[0],this.green=t[1],this.blue=t[2]},t.prototype.updateHsvFromHsl=function(){var t=this.lightness,e=(2*t+this.saturation*(1-Math.abs(2*t-1)))/2;this.saturationV=2*(e-t)/e||0,this.value=e},t.prototype.updateHslFromHsv=function(){var t=this.value,e=this.saturationV,r=.5*t*(2-e);this.saturation=e*t/(1-Math.abs(2*r-1))||0,this.lightness=r},t}();e.default=p}]); | ||
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=13)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toTwoHex=e.getTestSpan=e.parseInt10=e.hueToRgb=e.toPercent=e.mixRgbColors=e.clamp=void 0;var n=r(1);e.clamp=function(t,e,r){return Math.min(Math.max(t,e),r)},e.mixRgbColors=function(t,e,r){return[t[0]+r*(e[0]-t[0]),t[1]+r*(e[1]-t[1]),t[2]+r*(e[2]-t[2])]},e.toPercent=function(t){return Math.round(100*t)+"%"},e.hueToRgb=function(t){var e=(t%=360)%60;switch(t-=e,e=Math.round(4.25*e),t){case 0:return[255,e,0];case 60:return[255-e,255,0];case 120:return[0,255,e];case 180:return[0,255-e,255];case 240:return[e,0,255];case 300:return[255,0,255-e]}return[0,0,0]},e.parseInt10=function(t){return Number.parseInt(t,10)},e.getTestSpan=function(){var t=o;return t&&t.parentNode||((t=o=document.createElement("span")).style.display="none",document.body.appendChild(t)),t.style.setProperty("color",n.DEFAULT_COLOR,"important"),t};var o=null;e.toTwoHex=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RE_HEX_8=e.RE_HEX_4=e.RE_HEX_3=e.RE_HEX_6=e.GREY=e.WHITE=e.BLACK=e.DEFAULT_COLOR=e.ColorType=void 0,function(t){t[t.KEYWORD=1]="KEYWORD",t[t.HEX=2]="HEX",t[t.RGB=3]="RGB",t[t.RGBA=4]="RGBA",t[t.HSL=5]="HSL",t[t.HSLA=6]="HSLA",t[t.HSV=7]="HSV"}(e.ColorType||(e.ColorType={})),e.DEFAULT_COLOR="black",e.BLACK=[0,0,0],e.WHITE=[255,255,255],e.GREY=[127.5,127.5,127.5],e.RE_HEX_6=new RegExp("^[0-9a-fA-F]{6}$"),e.RE_HEX_3=new RegExp("^[0-9a-fA-F]{3}$"),e.RE_HEX_4=new RegExp("^[0-9a-fA-F]{4}$"),e.RE_HEX_8=new RegExp("^[0-9a-fA-F]{8}$")},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u},u=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.get=function(){return[this.r,this.g,this.b]},e.prototype.set=function(t){var e;return e=i(t,3),this.r=e[0],this.g=e[1],this.b=e[2],this},e.prototype.toCss=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},e}(u(r(3)).default);e.default=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"r",{get:function(){return this.color.getRed()},set:function(t){this.color.setRed(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this.color.getGreen()},set:function(t){this.color.setGreen(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this.color.getBlue()},set:function(t){this.color.setBlue(t)},enumerable:!1,configurable:!0}),t}();e.default=n},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u},u=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),Object.defineProperty(e.prototype,"a",{get:function(){return this.color.alpha},set:function(t){this.color.alpha=t},enumerable:!1,configurable:!0}),e.prototype.get=function(){return[this.r,this.g,this.b,this.a]},e.prototype.set=function(t){var e;return e=i(t,4),this.r=e[0],this.g=e[1],this.b=e[2],this.a=e[3],this},e.prototype.toCss=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.a.toFixed(2)+")"},e}(u(r(3)).default);e.default=s},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u},u=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var s=r(0),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.get=function(){return[this.h,this.s,this.l]},e.prototype.set=function(t){var e;return e=i(t,3),this.h=e[0],this.s=e[1],this.l=e[2],this},e.prototype.toCss=function(){var t=s.toPercent(this.s),e=s.toPercent(this.l);return"hsl("+this.h+", "+t+", "+e+")"},e}(u(r(6)).default);e.default=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"h",{get:function(){return this.color.getHue()},set:function(t){this.color.setHue(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"s",{get:function(){return this.color.getSaturation()},set:function(t){this.color.setSaturation(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"l",{get:function(){return this.color.getLightness()},set:function(t){this.color.setLightness(t)},enumerable:!1,configurable:!0}),t}();e.default=n},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u},u=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var s=r(0),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),Object.defineProperty(e.prototype,"a",{get:function(){return this.color.alpha},set:function(t){this.color.alpha=t},enumerable:!1,configurable:!0}),e.prototype.get=function(){return[this.h,this.s,this.l,this.a]},e.prototype.set=function(t){var e;return e=i(t,4),this.h=e[0],this.s=e[1],this.l=e[2],this.a=e[3],this},e.prototype.toCss=function(){var t=s.toPercent(this.s),e=s.toPercent(this.l);return"hsla("+this.h+", "+t+", "+e+", "+this.color.alpha.toFixed(2)+")"},e}(u(r(6)).default);e.default=a},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u},u=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.get=function(){return[this.h,this.s,this.v]},e.prototype.set=function(t){var e;return e=i(t,3),this.h=e[0],this.s=e[1],this.v=e[2],this},e.prototype.toCss=function(){return this.color.hsl.toCss()},e}(u(r(9)).default);e.default=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"h",{get:function(){return this.color.getHue()},set:function(t){this.color.setHue(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"s",{get:function(){return this.color.getSaturationV()},set:function(t){this.color.setSaturationV(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"v",{get:function(){return this.color.getValue()},set:function(t){this.color.setValue(t)},enumerable:!1,configurable:!0}),t}();e.default=n},function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u},u=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),Object.defineProperty(e.prototype,"a",{get:function(){return this.color.alpha},set:function(t){this.color.alpha=t},enumerable:!1,configurable:!0}),e.prototype.get=function(){return[this.h,this.s,this.v,this.a]},e.prototype.set=function(t){var e;return e=i(t,4),this.h=e[0],this.s=e[1],this.v=e[2],this.a=e[3],this},e.prototype.toCss=function(){return this.color.hsla.toCss()},e}(u(r(9)).default);e.default=s},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(1),o=r(0),i=function(){function t(t){this.color=t}return t.prototype.set=function(t){if(!n.RE_HEX_3.test(t)&&!n.RE_HEX_6.test(t))throw Error("Not valid hex color");n.RE_HEX_3.test(t)&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);var e=Number.parseInt(t,16);return this.color.rgb.set([e>>16,e>>8&255,255&e]),this},t.prototype.get=function(){return this.color.rgb.get().map(o.toTwoHex).join("")},t.prototype.toCss=function(){var t=this.get();return t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5]&&(t=""+t[0]+t[2]+t[4]),"#"+t},t}();e.default=i},function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u};Object.defineProperty(e,"__esModule",{value:!0});var o=r(1),i=r(0),u=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"a",{get:function(){return this.color.alpha},set:function(t){this.color.alpha=t},enumerable:!1,configurable:!0}),t.prototype.set=function(t){if(!o.RE_HEX_4.test(t)&&!o.RE_HEX_8.test(t))throw Error("Not valid hexa color");o.RE_HEX_4.test(t)&&(t=Array.from(t).flatMap((function(t){return[t,t]})).join(""));var e=n(t.match(/../g).map((function(t){return Number.parseInt(t,16)})),4),r=e[0],i=e[1],u=e[2],s=e[3];return this.color.rgb.set([r,i,u]),this.a=0===s?0:s/255,this},t.prototype.get=function(){return this.color.rgba.get().map((function(t,e){return i.toTwoHex(3===e?Math.round(255*t):t)})).join("")},t.prototype.toCss=function(){var t=this.get();return t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5]&&t[6]===t[7]&&(t=""+t[0]+t[2]+t[4]+t[6]),"#"+t},t}();e.default=u},function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var o=n(r(14));e.default=o.default;var i=r(2);Object.defineProperty(e,"RGBInterface",{enumerable:!0,get:function(){return i.default}});var u=r(4);Object.defineProperty(e,"RGBAInterface",{enumerable:!0,get:function(){return u.default}});var s=r(5);Object.defineProperty(e,"HSLInterface",{enumerable:!0,get:function(){return s.default}});var a=r(7);Object.defineProperty(e,"HSLAInterface",{enumerable:!0,get:function(){return a.default}});var l=r(8);Object.defineProperty(e,"HSVInterface",{enumerable:!0,get:function(){return l.default}});var c=r(10);Object.defineProperty(e,"HSVAInterface",{enumerable:!0,get:function(){return c.default}});var h=r(11);Object.defineProperty(e,"HexInterface",{enumerable:!0,get:function(){return h.default}});var f=r(12);Object.defineProperty(e,"HexAInterface",{enumerable:!0,get:function(){return f.default}});var p=r(1);Object.defineProperty(e,"ColorType",{enumerable:!0,get:function(){return p.ColorType}})},function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var i=o(r(2)),u=o(r(4)),s=o(r(5)),a=o(r(7)),l=o(r(8)),c=o(r(10)),h=o(r(11)),f=o(r(12)),p=r(1),y=r(0),d=function(){function t(t,e){if(this._alpha=1,this.red=0,this.green=0,this.blue=0,this.hue=0,this.saturation=0,this.lightness=0,this.saturationV=0,this.value=0,this._rgb=null,this._rgba=null,this._hsl=null,this._hsla=null,this._hsv=null,this._hsva=null,this._hex=null,this._hexa=null,"string"==typeof t&&this.parseCSSColor(t),Array.isArray(t))switch(e){case void 0:case p.ColorType.RGB:this.rgb.set(t);break;case p.ColorType.HSL:this.hsl.set(t);break;case p.ColorType.HSV:this.hsv.set(t)}}return t.prototype.parseCSSColor=function(t){var e=y.getTestSpan();e.style.setProperty("color",t,"important");var r=window.getComputedStyle(e).color.split(/rgba?\(|,s*|\)$/).filter(Boolean);4===r.length&&(this.alpha=parseFloat(r.pop())),this.rgb.set(r.map(y.parseInt10))},Object.defineProperty(t.prototype,"rgb",{get:function(){return null===this._rgb&&(this._rgb=new i.default(this)),this._rgb},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return null===this._rgba&&(this._rgba=new u.default(this)),this._rgba},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hsl",{get:function(){return this._hsl||(this._hsl=new s.default(this)),this._hsl},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hsla",{get:function(){return this._hsla||(this._hsla=new a.default(this)),this._hsla},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hsv",{get:function(){return this._hsv||(this._hsv=new l.default(this)),this._hsv},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hsva",{get:function(){return this._hsva||(this._hsva=new c.default(this)),this._hsva},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hex",{get:function(){return this._hex||(this._hex=new h.default(this)),this._hex},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hexa",{get:function(){return this._hexa||(this._hexa=new f.default(this)),this._hexa},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return y.clamp(this._alpha,0,1)},set:function(t){this._alpha=t},enumerable:!1,configurable:!0}),t.prototype.setRed=function(t){this.red=y.clamp(t,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},t.prototype.getRed=function(){return Math.round(y.clamp(this.red,0,255))},t.prototype.setGreen=function(t){this.green=y.clamp(t,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},t.prototype.getGreen=function(){return Math.round(y.clamp(this.green,0,255))},t.prototype.setBlue=function(t){this.blue=y.clamp(t,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},t.prototype.getBlue=function(){return Math.round(y.clamp(this.blue,0,255))},t.prototype.setHue=function(t){this.hue=y.clamp(t,0,360),this.updateRgbFromHsl()},t.prototype.getHue=function(){return Math.round(y.clamp(this.hue,0,360))},t.prototype.setSaturation=function(t){this.saturation=y.clamp(t,0,1),this.updateRgbFromHsl(),this.updateHsvFromHsl()},t.prototype.getSaturation=function(){return y.clamp(this.saturation,0,1)},t.prototype.setSaturationV=function(t){this.saturationV=y.clamp(t,0,1),this.updateHslFromHsv(),this.updateRgbFromHsl()},t.prototype.getSaturationV=function(){return y.clamp(this.saturationV,0,1)},t.prototype.setLightness=function(t){this.lightness=y.clamp(t,0,1),this.updateRgbFromHsl(),this.updateHsvFromHsl()},t.prototype.getLightness=function(){return y.clamp(this.lightness,0,1)},t.prototype.setValue=function(t){this.value=y.clamp(t,0,1),this.updateHslFromHsv(),this.updateRgbFromHsl()},t.prototype.getValue=function(){return y.clamp(this.value,0,1)},t.prototype.getGreyValue=function(){return.2126*this.red+.7152*this.green+.0722*this.blue},t.prototype.invert=function(){return this.setHue((this.hue+180)%360),this},t.prototype.getLuminance=function(){var t=this.rgb.get().map((function(t){var e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}));return.2126*t[0]+.7152*t[1]+.0722*t[2]},t.prototype.getContrastRatio=function(t){var e=this.getLuminance(),r=t.getLuminance();return e>r?(e+.05)/(r+.05):(r+.05)/(e+.05)},t.prototype.copy=function(){var e=new t;return e.setRed(this.red),e.setGreen(this.green),e.setBlue(this.blue),e.alpha=this.alpha,e},t.prototype.mixWithColor=function(t,e){return this.rgb.set(y.mixRgbColors(this.rgb.get(),t.rgb.get(),e)),this},t.prototype.updateHslFromRgb=function(){var t=this.red/255,e=this.green/255,r=this.blue/255,n=Math.max(t,e,r),o=Math.min(t,e,r),i=n+o,u=n-o;if(this.hue=0,this.saturation=0,this.lightness=i/2,0!==u){this.saturation=u/(1-Math.abs(i-1));var s=60/u;switch(n){case t:this.hue=(360+(e-r)*s)%360;break;case e:this.hue=120+(r-t)*s;break;case r:this.hue=240+(t-e)*s}}},t.prototype.updateRgbFromHsl=function(){var t,e=y.hueToRgb(this.hue),r=y.mixRgbColors(e,p.GREY,1-this.saturation),o=this.lightness<=.5?p.BLACK:p.WHITE,i=1-Math.abs(2*this.lightness-1);t=n(y.mixRgbColors(o,r,i),3),this.red=t[0],this.green=t[1],this.blue=t[2]},t.prototype.updateHsvFromHsl=function(){var t=this.lightness,e=(2*t+this.saturation*(1-Math.abs(2*t-1)))/2;this.saturationV=2*(e-t)/e||0,this.value=e},t.prototype.updateHslFromHsv=function(){var t=this.value,e=this.saturationV,r=.5*t*(2-e);this.saturation=e*t/(1-Math.abs(2*r-1))||0,this.lightness=r},t}();e.default=d}]); |
@@ -0,0 +0,0 @@ import { RGBAInterface as RGBAInterface_, RGBA } from './ColorInterface'; |
@@ -0,0 +0,0 @@ import { RGBInterface as RGBInterface_, RGB } from './ColorInterface'; |
@@ -8,1 +8,2 @@ import { RGB } from './ColorInterface'; | ||
export declare const getTestSpan: () => HTMLSpanElement; | ||
export declare const toTwoHex: (n: number) => string; |
@@ -1,2 +0,2 @@ | ||
import Color from './dist/index'; | ||
import Color from './dist/Color'; | ||
export default Color; | ||
@@ -6,5 +6,8 @@ export { default as RGBInterface } from './dist/RGBInterface'; | ||
export { default as HSLInterface } from './dist/HSLInterface'; | ||
export { default as HSLAInterface } from './dist/HSLAInterface'; | ||
export { default as HSVInterface } from './dist/HSVInterface'; | ||
export { default as HSVAInterface } from './dist/HSVAInterface'; | ||
export { default as HexInterface } from './dist/HexInterface'; | ||
export { default as HexAInterface } from './dist/HexAInterface'; | ||
export { RGB, RGBA, HSL, HSLA, HSV, HSVA, HEX } from './dist/ColorInterface'; | ||
export { ColorType } from './dist/consts'; |
{ | ||
"name": "color-interfaces", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "interfaces for color spaces", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/chriskr/color-interfaces", |
@@ -5,4 +5,7 @@ import { Color as Color_, RGB, HSV, HSL } from './ColorInterface'; | ||
import HSLInterface from './HSLInterface'; | ||
import HSLAInterface from './HSLAInterface'; | ||
import HSVInterface from './HSVInterface'; | ||
import HSVAInterface from './HSVAInterface'; | ||
import HexInterface from './HexInterface'; | ||
import HexAInterface from './HexAInterface'; | ||
import { ColorType, BLACK, WHITE, GREY } from './consts'; | ||
@@ -40,4 +43,7 @@ import { | ||
private _hsl: HSLInterface | null = null; | ||
private _hsla: HSLAInterface | null = null; | ||
private _hsv: HSVInterface | null = null; | ||
private _hsva: HSVAInterface | null = null; | ||
private _hex: HexInterface | null = null; | ||
private _hexa: HexAInterface | null = null; | ||
@@ -96,2 +102,9 @@ constructor(value?: number[] | string, type?: ColorType) { | ||
get hsla(): HSLAInterface { | ||
if (!this._hsla) { | ||
this._hsla = new HSLAInterface(this); | ||
} | ||
return this._hsla; | ||
} | ||
get hsv(): HSVInterface { | ||
@@ -104,2 +117,9 @@ if (!this._hsv) { | ||
get hsva(): HSVAInterface { | ||
if (!this._hsva) { | ||
this._hsva = new HSVAInterface(this); | ||
} | ||
return this._hsva; | ||
} | ||
get hex(): HexInterface { | ||
@@ -112,2 +132,9 @@ if (!this._hex) { | ||
get hexa(): HexAInterface { | ||
if (!this._hexa) { | ||
this._hexa = new HexAInterface(this); | ||
} | ||
return this._hexa; | ||
} | ||
set alpha(alpha) { | ||
@@ -114,0 +141,0 @@ this._alpha = alpha; |
@@ -5,4 +5,7 @@ export interface Color { | ||
hsl: HSLInterface; | ||
hsla: HSLAInterface; | ||
hsv: HSVInterface; | ||
hsva: HSVAInterface; | ||
hex: HexInterface; | ||
hexa: HexAInterface; | ||
alpha: number; | ||
@@ -62,2 +65,12 @@ getRed(): number; | ||
export interface HSLAInterface { | ||
h: number; | ||
s: number; | ||
l: number; | ||
a: number; | ||
get: () => HSLA; | ||
set: (hsva: HSLA) => HSLAInterface; | ||
toCss: () => string; | ||
} | ||
export interface HSVInterface { | ||
@@ -72,2 +85,12 @@ h: number; | ||
export interface HSVAInterface { | ||
h: number; | ||
s: number; | ||
v: number; | ||
a: number; | ||
get: () => HSVA; | ||
set: (hsv: HSVA) => HSVAInterface; | ||
toCss: () => string; | ||
} | ||
export interface HexInterface { | ||
@@ -79,2 +102,9 @@ get: () => HEX; | ||
export interface HexAInterface { | ||
a: number; | ||
get: () => HEXA; | ||
set: (hexa: HEXA) => HexAInterface; | ||
toCss: () => string; | ||
} | ||
export type RGB = [number, number, number]; | ||
@@ -87,1 +117,2 @@ export type RGBA = [number, number, number, number]; | ||
export type HEX = string; | ||
export type HEXA = string; |
@@ -11,7 +11,9 @@ export enum ColorType { | ||
export const DEFAULT_COLOR = "black"; | ||
export const DEFAULT_COLOR = 'black'; | ||
export const BLACK = [0, 0, 0]; | ||
export const WHITE = [255, 255, 255]; | ||
export const GREY = [127.5, 127.5, 127.5]; | ||
export const RE_HEX_6 = new RegExp("^[0-9a-fA-F]{6}$"); | ||
export const RE_HEX_3 = new RegExp("^[0-9a-fA-F]{3}$"); | ||
export const RE_HEX_6 = new RegExp('^[0-9a-fA-F]{6}$'); | ||
export const RE_HEX_3 = new RegExp('^[0-9a-fA-F]{3}$'); | ||
export const RE_HEX_4 = new RegExp('^[0-9a-fA-F]{4}$'); | ||
export const RE_HEX_8 = new RegExp('^[0-9a-fA-F]{8}$'); |
@@ -1,3 +0,4 @@ | ||
import { Color, HexInterface as HexInterface_, HEX } from "./ColorInterface"; | ||
import { RE_HEX_3, RE_HEX_6 } from "./consts"; | ||
import { Color, HexInterface as HexInterface_, HEX } from './ColorInterface'; | ||
import { RE_HEX_3, RE_HEX_6 } from './consts'; | ||
import { toTwoHex } from './utils'; | ||
@@ -12,3 +13,3 @@ class HexInterface implements HexInterface_ { | ||
if (!(RE_HEX_3.test(hex) || RE_HEX_6.test(hex))) { | ||
throw Error("Not valid hex color"); | ||
throw Error('Not valid hex color'); | ||
} | ||
@@ -24,5 +25,3 @@ if (RE_HEX_3.test(hex)) { | ||
get() { | ||
const rgb = this.color.rgb; | ||
const hex = ((rgb.r << 16) | (rgb.g << 8) | rgb.b).toString(16); | ||
return `${"0".repeat(6 - hex.length)}${hex}`; | ||
return this.color.rgb.get().map(toTwoHex).join(''); | ||
} | ||
@@ -29,0 +28,0 @@ |
@@ -1,34 +0,6 @@ | ||
import { Color, HSLInterface as HSLInterface_, HSL } from "./ColorInterface"; | ||
import { toPercent } from "./utils"; | ||
import { Color, HSLInterface as HSLInterface_, HSL } from './ColorInterface'; | ||
import { toPercent } from './utils'; | ||
import BaseHSLInterface from './BaseHSLInterface'; | ||
class HSLInterface implements HSLInterface_ { | ||
private color: Color; | ||
constructor(color: Color) { | ||
this.color = color; | ||
} | ||
set h(h) { | ||
this.color.setHue(h); | ||
} | ||
get h() { | ||
return this.color.getHue(); | ||
} | ||
set s(s) { | ||
this.color.setSaturation(s); | ||
} | ||
get s() { | ||
return this.color.getSaturation(); | ||
} | ||
set l(l) { | ||
this.color.setLightness(l); | ||
} | ||
get l() { | ||
return this.color.getLightness(); | ||
} | ||
class HSLInterface extends BaseHSLInterface implements HSLInterface_ { | ||
get() { | ||
@@ -35,0 +7,0 @@ return [this.h, this.s, this.l] as HSL; |
@@ -1,33 +0,5 @@ | ||
import { Color, HSVInterface as HSVInterface_, HSV } from "./ColorInterface"; | ||
import { HSVInterface as HSVInterface_, HSV } from './ColorInterface'; | ||
import BaseHSVInterface from './BaseHSVInterface'; | ||
class HSVInterface implements HSVInterface_ { | ||
private color: Color; | ||
constructor(color: Color) { | ||
this.color = color; | ||
} | ||
set h(h) { | ||
this.color.setHue(h); | ||
} | ||
get h() { | ||
return this.color.getHue(); | ||
} | ||
set s(s) { | ||
this.color.setSaturationV(s); | ||
} | ||
get s() { | ||
return this.color.getSaturationV(); | ||
} | ||
set v(v) { | ||
this.color.setValue(v); | ||
} | ||
get v() { | ||
return this.color.getValue(); | ||
} | ||
class HSVInterface extends BaseHSVInterface implements HSVInterface_ { | ||
get() { | ||
@@ -34,0 +6,0 @@ return [this.h, this.s, this.v] as HSV; |
@@ -6,5 +6,8 @@ import Color from './Color'; | ||
export { default as HSLInterface } from './HSLInterface'; | ||
export { default as HSLAInterface } from './HSLAInterface'; | ||
export { default as HSVInterface } from './HSVInterface'; | ||
export { default as HSVAInterface } from './HSVAInterface'; | ||
export { default as HexInterface } from './HexInterface'; | ||
export { default as HexAInterface } from './HexAInterface'; | ||
export { RGB, RGBA, HSL, HSLA, HSV, HSVA, HEX } from './ColorInterface'; | ||
export { ColorType } from './consts'; |
@@ -57,1 +57,6 @@ import { RGB } from './ColorInterface'; | ||
let testSpan: HTMLSpanElement | null = null; | ||
export const toTwoHex = (n: number) => { | ||
const hex = n.toString(16); | ||
return hex.length === 1 ? `0${hex}` : hex; | ||
}; |
Sorry, the diff of this file is not supported yet
111657
31.01%42
31.25%2234
33.77%