css-color-parser-h 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/index.d.ts +308 -6
- package/dist/css-color-parser-h.common.js +258 -69
- package/dist/css-color-parser-h.common.min.js +1 -1
- package/dist/css-color-parser-h.umd.js +258 -69
- package/dist/css-color-parser-h.umd.min.js +1 -1
- package/example.html +3 -3
- package/package.json +6 -4
- package/readme.md +57 -28
- package/@types/css-color-parser-h.d.ts +0 -230
|
@@ -1201,19 +1201,39 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
1201
1201
|
var Check = /** @class */ (function () {
|
|
1202
1202
|
function Check() {
|
|
1203
1203
|
}
|
|
1204
|
-
Check.type = function (
|
|
1204
|
+
Check.type = function (paramName, value, type) {
|
|
1205
1205
|
var valueType = typeof value;
|
|
1206
1206
|
if (valueType !== type) {
|
|
1207
1207
|
throw new Error("Expected ".concat(paramName, " to be typeof ").concat(type, ", actual typeof was ").concat(valueType));
|
|
1208
1208
|
}
|
|
1209
1209
|
};
|
|
1210
|
-
Check.types = function (
|
|
1210
|
+
Check.types = function (paramName, value, types) {
|
|
1211
1211
|
var valueType = typeof value;
|
|
1212
1212
|
var isContained = types.includes(valueType);
|
|
1213
1213
|
if (!isContained) {
|
|
1214
1214
|
throw new Error("Expected ".concat(paramName, " to be typeof ").concat(types.join('|'), ", actual typeof was ").concat(valueType));
|
|
1215
1215
|
}
|
|
1216
1216
|
};
|
|
1217
|
+
Check.numValue = function (paramName, value, min, max) {
|
|
1218
|
+
Check.numMinValue(paramName, value, min);
|
|
1219
|
+
Check.numMaxValue(paramName, value, max);
|
|
1220
|
+
};
|
|
1221
|
+
Check.numMinValue = function (paramName, value, min) {
|
|
1222
|
+
if (value < min) {
|
|
1223
|
+
throw new Error("Expected ".concat(paramName, " to > ").concat(min, ", actual value was ").concat(value));
|
|
1224
|
+
}
|
|
1225
|
+
};
|
|
1226
|
+
Check.numMaxValue = function (paramName, value, max) {
|
|
1227
|
+
if (value > max) {
|
|
1228
|
+
throw new Error("Expected ".concat(paramName, " to < ").concat(max, ", actual value was ").concat(value));
|
|
1229
|
+
}
|
|
1230
|
+
};
|
|
1231
|
+
Check.numIsInt = function (paramName, value, expectIsInt) {
|
|
1232
|
+
var isInt = Math.floor(value) === value;
|
|
1233
|
+
if (isInt !== expectIsInt) {
|
|
1234
|
+
throw new Error("Expected ".concat(paramName, " to ").concat(expectIsInt ? 'Integer' : 'Float', ", actual value was ").concat(isInt ? 'Integer' : 'Float'));
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1217
1237
|
return Check;
|
|
1218
1238
|
}());
|
|
1219
1239
|
|
|
@@ -1242,7 +1262,9 @@ function limitNumber(min, max, v) {
|
|
|
1242
1262
|
return v;
|
|
1243
1263
|
}
|
|
1244
1264
|
function setNumberPrecision(number, precision) {
|
|
1245
|
-
|
|
1265
|
+
if (number === void 0) { number = 0; }
|
|
1266
|
+
var prec = Math.pow(10, precision);
|
|
1267
|
+
return Math.round(number * prec) / prec;
|
|
1246
1268
|
}
|
|
1247
1269
|
|
|
1248
1270
|
;// CONCATENATED MODULE: ./src/utils/color-tools.ts
|
|
@@ -1396,8 +1418,8 @@ var CssColorStringParser = /** @class */ (function () {
|
|
|
1396
1418
|
* @version: 1.0.0
|
|
1397
1419
|
* @Author: roman_123
|
|
1398
1420
|
* @Date: 2021-01-19 09:22:11
|
|
1399
|
-
* @LastEditors:
|
|
1400
|
-
* @LastEditTime: 2023-
|
|
1421
|
+
* @LastEditors: Roman
|
|
1422
|
+
* @LastEditTime: 2023-06-03 11:12:30
|
|
1401
1423
|
*/
|
|
1402
1424
|
|
|
1403
1425
|
|
|
@@ -1407,8 +1429,27 @@ var CssColorParser = /** @class */ (function () {
|
|
|
1407
1429
|
this.g = 255;
|
|
1408
1430
|
this.b = 255;
|
|
1409
1431
|
this.a = 1;
|
|
1432
|
+
this._outColorPrecision = 2;
|
|
1433
|
+
this._outAlphaPrecision = 2;
|
|
1410
1434
|
this.setColor(red, green, blue, alpha);
|
|
1411
1435
|
}
|
|
1436
|
+
/**
|
|
1437
|
+
* @description: 设置CssColorParser实例输出的精度
|
|
1438
|
+
* @param {number} colorPrecision 输出颜色的精度
|
|
1439
|
+
* @param {number} outAlphaPrecision 输出透明度的精度
|
|
1440
|
+
* @return {CssColorParser}
|
|
1441
|
+
*/
|
|
1442
|
+
CssColorParser.prototype.setOutPrecision = function (colorPrecision, outAlphaPrecision) {
|
|
1443
|
+
Check.type('colorPrecision', colorPrecision, 'number');
|
|
1444
|
+
Check.type('outAlphaPrecision', outAlphaPrecision, 'number');
|
|
1445
|
+
Check.numMinValue('colorPrecision', colorPrecision, 0);
|
|
1446
|
+
Check.numMinValue('outAlphaPrecision', outAlphaPrecision, 0);
|
|
1447
|
+
Check.numIsInt('colorPrecision', colorPrecision, true);
|
|
1448
|
+
Check.numIsInt('outAlphaPrecision', outAlphaPrecision, true);
|
|
1449
|
+
this._outColorPrecision = colorPrecision;
|
|
1450
|
+
this._outAlphaPrecision = outAlphaPrecision;
|
|
1451
|
+
return this;
|
|
1452
|
+
};
|
|
1412
1453
|
/**
|
|
1413
1454
|
* 设置颜色
|
|
1414
1455
|
* @param red
|
|
@@ -1422,11 +1463,47 @@ var CssColorParser = /** @class */ (function () {
|
|
|
1422
1463
|
this.g = limitNumber(0, 255, defaultValue(Number(green), 0));
|
|
1423
1464
|
this.b = limitNumber(0, 255, defaultValue(Number(blue), 0));
|
|
1424
1465
|
this.a = limitNumber(0, 1, defaultValue(Number(alpha), 1));
|
|
1466
|
+
return this;
|
|
1467
|
+
};
|
|
1468
|
+
/**
|
|
1469
|
+
* @description: 设置透明度
|
|
1470
|
+
* @param {number} alpha
|
|
1471
|
+
* @return {CssColorParser}
|
|
1472
|
+
*/
|
|
1473
|
+
CssColorParser.prototype.setAlpha = function (alpha) {
|
|
1474
|
+
this.a = limitNumber(0, 1, defaultValue(Number(alpha), 1));
|
|
1475
|
+
return this;
|
|
1476
|
+
};
|
|
1477
|
+
/**
|
|
1478
|
+
* @description: 设置红色值
|
|
1479
|
+
* @param {number} red
|
|
1480
|
+
* @return {CssColorParser}
|
|
1481
|
+
*/
|
|
1482
|
+
CssColorParser.prototype.setRed = function (red) {
|
|
1483
|
+
this.r = limitNumber(0, 255, defaultValue(Number(red), 0));
|
|
1484
|
+
return this;
|
|
1485
|
+
};
|
|
1486
|
+
/**
|
|
1487
|
+
* @description: 设置绿色值
|
|
1488
|
+
* @param {number} green
|
|
1489
|
+
* @return {CssColorParser}
|
|
1490
|
+
*/
|
|
1491
|
+
CssColorParser.prototype.setGreen = function (green) {
|
|
1492
|
+
this.g = limitNumber(0, 255, defaultValue(Number(green), 0));
|
|
1493
|
+
return this;
|
|
1494
|
+
};
|
|
1495
|
+
/**
|
|
1496
|
+
* @description: 设置蓝色值
|
|
1497
|
+
* @param {number} blue
|
|
1498
|
+
* @return {CssColorParser}
|
|
1499
|
+
*/
|
|
1500
|
+
CssColorParser.prototype.setBlue = function (blue) {
|
|
1501
|
+
this.b = limitNumber(0, 255, defaultValue(Number(blue), 0));
|
|
1502
|
+
return this;
|
|
1425
1503
|
};
|
|
1426
1504
|
/**
|
|
1427
1505
|
* @description: 返回rgba格式的css字符串
|
|
1428
|
-
* @return {
|
|
1429
|
-
* @author: roman_123
|
|
1506
|
+
* @return {string}
|
|
1430
1507
|
*/
|
|
1431
1508
|
CssColorParser.prototype.toRGBA = function () {
|
|
1432
1509
|
var color = this.toJson();
|
|
@@ -1437,29 +1514,25 @@ var CssColorParser = /** @class */ (function () {
|
|
|
1437
1514
|
};
|
|
1438
1515
|
/**
|
|
1439
1516
|
* @description: 返回字符串
|
|
1440
|
-
* @return {
|
|
1441
|
-
* @author: roman_123
|
|
1517
|
+
* @return {string}
|
|
1442
1518
|
*/
|
|
1443
1519
|
CssColorParser.prototype.toString = function () {
|
|
1444
1520
|
return this.toRGBA();
|
|
1445
1521
|
};
|
|
1446
1522
|
/**
|
|
1447
1523
|
* @description: 归一化
|
|
1448
|
-
* @return {
|
|
1449
|
-
* @author: roman_123
|
|
1524
|
+
* @return {array}
|
|
1450
1525
|
*/
|
|
1451
1526
|
CssColorParser.prototype.toNormalize = function () {
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
};
|
|
1527
|
+
var r = setNumberPrecision(this.r / 255, this._outColorPrecision);
|
|
1528
|
+
var g = setNumberPrecision(this.g / 255, this._outColorPrecision);
|
|
1529
|
+
var b = setNumberPrecision(this.b / 255, this._outColorPrecision);
|
|
1530
|
+
var a = setNumberPrecision(this.a, this._outAlphaPrecision);
|
|
1531
|
+
return [r, g, b, a];
|
|
1458
1532
|
};
|
|
1459
1533
|
/**
|
|
1460
1534
|
* @description: 返回16进制格式的css字符串
|
|
1461
|
-
* @return {
|
|
1462
|
-
* @author: roman_123
|
|
1535
|
+
* @return {string}
|
|
1463
1536
|
*/
|
|
1464
1537
|
CssColorParser.prototype.toHEX = function () {
|
|
1465
1538
|
var color = this.toJson();
|
|
@@ -1487,8 +1560,7 @@ var CssColorParser = /** @class */ (function () {
|
|
|
1487
1560
|
};
|
|
1488
1561
|
/**
|
|
1489
1562
|
* @description: 返回rgba数组
|
|
1490
|
-
* @return {
|
|
1491
|
-
* @author: roman_123
|
|
1563
|
+
* @return {array}
|
|
1492
1564
|
*/
|
|
1493
1565
|
CssColorParser.prototype.toArray = function () {
|
|
1494
1566
|
var color = this.toJson();
|
|
@@ -1496,47 +1568,172 @@ var CssColorParser = /** @class */ (function () {
|
|
|
1496
1568
|
};
|
|
1497
1569
|
/**
|
|
1498
1570
|
* @description: 返回ColorJson
|
|
1499
|
-
* @return {
|
|
1500
|
-
* @author: roman_123
|
|
1571
|
+
* @return {ColorJson}
|
|
1501
1572
|
*/
|
|
1502
1573
|
CssColorParser.prototype.toJson = function () {
|
|
1503
1574
|
return {
|
|
1504
|
-
r:
|
|
1505
|
-
g:
|
|
1506
|
-
b:
|
|
1507
|
-
a:
|
|
1575
|
+
r: setNumberPrecision(this.r, this._outColorPrecision),
|
|
1576
|
+
g: setNumberPrecision(this.g, this._outColorPrecision),
|
|
1577
|
+
b: setNumberPrecision(this.b, this._outColorPrecision),
|
|
1578
|
+
a: setNumberPrecision(this.a, this._outAlphaPrecision),
|
|
1508
1579
|
};
|
|
1509
1580
|
};
|
|
1581
|
+
/**
|
|
1582
|
+
* @description: 返回反色的CssColorParser实例
|
|
1583
|
+
* @return {CssColorParser}
|
|
1584
|
+
*/
|
|
1585
|
+
CssColorParser.prototype.toInvert = function () {
|
|
1586
|
+
var r = 255 - this.r;
|
|
1587
|
+
var g = 255 - this.g;
|
|
1588
|
+
var b = 255 - this.b;
|
|
1589
|
+
var a = 1 - this.a;
|
|
1590
|
+
return new CssColorParser(r, g, b, a);
|
|
1591
|
+
};
|
|
1510
1592
|
/**
|
|
1511
1593
|
* @description: 拷贝
|
|
1512
|
-
* @return {
|
|
1513
|
-
* @author: roman_123
|
|
1594
|
+
* @return {CssColorParser}
|
|
1514
1595
|
*/
|
|
1515
1596
|
CssColorParser.prototype.clone = function () {
|
|
1516
1597
|
return new CssColorParser(this.r, this.g, this.b, this.a);
|
|
1517
1598
|
};
|
|
1518
1599
|
/**
|
|
1519
1600
|
* @description: 比较两个解析对象的数据是否相等
|
|
1520
|
-
* @param {
|
|
1521
|
-
* @return {
|
|
1522
|
-
* @author: roman_123
|
|
1601
|
+
* @param {string} color
|
|
1602
|
+
* @return {boolean}
|
|
1523
1603
|
*/
|
|
1524
1604
|
CssColorParser.prototype.equals = function (color) {
|
|
1525
1605
|
if (this === color) {
|
|
1526
1606
|
return true;
|
|
1527
1607
|
}
|
|
1528
1608
|
else {
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1609
|
+
var json1 = this.toJson();
|
|
1610
|
+
var json2 = color.toJson();
|
|
1611
|
+
return (json1.r === json2.r &&
|
|
1612
|
+
json1.g === json2.g &&
|
|
1613
|
+
json1.b === json2.g &&
|
|
1614
|
+
json1.a === json2.a);
|
|
1533
1615
|
}
|
|
1534
1616
|
};
|
|
1617
|
+
/**
|
|
1618
|
+
* @description: 反色
|
|
1619
|
+
* @return {CssColorParser}
|
|
1620
|
+
*/
|
|
1621
|
+
CssColorParser.prototype.setInvert = function () {
|
|
1622
|
+
this.r = 255 - this.r;
|
|
1623
|
+
this.g = 255 - this.g;
|
|
1624
|
+
this.b = 255 - this.b;
|
|
1625
|
+
this.a = 1 - this.a;
|
|
1626
|
+
return this;
|
|
1627
|
+
};
|
|
1628
|
+
/**
|
|
1629
|
+
* @description: 乘以倍数
|
|
1630
|
+
* @param {number} scalar
|
|
1631
|
+
* @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是)
|
|
1632
|
+
* @return {CssColorParser}
|
|
1633
|
+
*/
|
|
1634
|
+
CssColorParser.prototype.multiplyByScalar = function (scalar, isSetAlpha) {
|
|
1635
|
+
if (isSetAlpha === void 0) { isSetAlpha = true; }
|
|
1636
|
+
var r = this.r * scalar;
|
|
1637
|
+
var g = this.g * scalar;
|
|
1638
|
+
var b = this.b * scalar;
|
|
1639
|
+
var a = isSetAlpha ? this.a * scalar : this.a;
|
|
1640
|
+
return this.setColor(r, g, b, a);
|
|
1641
|
+
};
|
|
1642
|
+
/**
|
|
1643
|
+
* @description: 除以倍数
|
|
1644
|
+
* @param {number} scalar
|
|
1645
|
+
* @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是)
|
|
1646
|
+
* @return {CssColorParser}
|
|
1647
|
+
*/
|
|
1648
|
+
CssColorParser.prototype.divideByScalar = function (scalar, isSetAlpha) {
|
|
1649
|
+
if (isSetAlpha === void 0) { isSetAlpha = true; }
|
|
1650
|
+
var r = this.r / scalar;
|
|
1651
|
+
var g = this.g / scalar;
|
|
1652
|
+
var b = this.b / scalar;
|
|
1653
|
+
var a = isSetAlpha ? this.a / scalar : this.a;
|
|
1654
|
+
return this.setColor(r, g, b, a);
|
|
1655
|
+
};
|
|
1656
|
+
/**
|
|
1657
|
+
* @description: 实例相加
|
|
1658
|
+
* @param {CssColorParser} colorParser
|
|
1659
|
+
* @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是)
|
|
1660
|
+
* @return {CssColorParser}
|
|
1661
|
+
*/
|
|
1662
|
+
CssColorParser.prototype.add = function (colorParser, isSetAlpha) {
|
|
1663
|
+
if (isSetAlpha === void 0) { isSetAlpha = true; }
|
|
1664
|
+
var r = this.r + colorParser.r;
|
|
1665
|
+
var g = this.g + colorParser.g;
|
|
1666
|
+
var b = this.b + colorParser.b;
|
|
1667
|
+
var a = isSetAlpha ? this.a + colorParser.a : this.a;
|
|
1668
|
+
return this.setColor(r, g, b, a);
|
|
1669
|
+
};
|
|
1670
|
+
/**
|
|
1671
|
+
* @description: 实例相减
|
|
1672
|
+
* @param {CssColorParser} colorParser
|
|
1673
|
+
* @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是)
|
|
1674
|
+
* @return {CssColorParser}
|
|
1675
|
+
*/
|
|
1676
|
+
CssColorParser.prototype.subtract = function (colorParser, isSetAlpha) {
|
|
1677
|
+
if (isSetAlpha === void 0) { isSetAlpha = true; }
|
|
1678
|
+
var r = this.r - colorParser.r;
|
|
1679
|
+
var g = this.g - colorParser.g;
|
|
1680
|
+
var b = this.b - colorParser.b;
|
|
1681
|
+
var a = isSetAlpha ? this.a - colorParser.a : this.a;
|
|
1682
|
+
return this.setColor(r, g, b, a);
|
|
1683
|
+
};
|
|
1684
|
+
/**
|
|
1685
|
+
* @description: 实例相乘
|
|
1686
|
+
* @param {CssColorParser} colorParser
|
|
1687
|
+
* @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是)
|
|
1688
|
+
* @return {CssColorParser}
|
|
1689
|
+
*/
|
|
1690
|
+
CssColorParser.prototype.multiply = function (colorParser, isSetAlpha) {
|
|
1691
|
+
if (isSetAlpha === void 0) { isSetAlpha = true; }
|
|
1692
|
+
var r = this.r * colorParser.r;
|
|
1693
|
+
var g = this.g * colorParser.g;
|
|
1694
|
+
var b = this.b * colorParser.b;
|
|
1695
|
+
var a = isSetAlpha ? this.a * colorParser.a : this.a;
|
|
1696
|
+
return this.setColor(r, g, b, a);
|
|
1697
|
+
};
|
|
1698
|
+
/**
|
|
1699
|
+
* @description: 实例相除
|
|
1700
|
+
* @param {CssColorParser} colorParser
|
|
1701
|
+
* @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是)
|
|
1702
|
+
* @return {CssColorParser}
|
|
1703
|
+
*/
|
|
1704
|
+
CssColorParser.prototype.divide = function (colorParser, isSetAlpha) {
|
|
1705
|
+
if (isSetAlpha === void 0) { isSetAlpha = true; }
|
|
1706
|
+
var r = this.r / colorParser.r;
|
|
1707
|
+
var g = this.g / colorParser.g;
|
|
1708
|
+
var b = this.b / colorParser.b;
|
|
1709
|
+
var a = isSetAlpha ? this.a / colorParser.a : this.a;
|
|
1710
|
+
return this.setColor(r, g, b, a);
|
|
1711
|
+
};
|
|
1712
|
+
/**
|
|
1713
|
+
* @description: 颜色RGB加上数字
|
|
1714
|
+
* @param {number} num
|
|
1715
|
+
* @return {CssColorParser}
|
|
1716
|
+
*/
|
|
1717
|
+
CssColorParser.prototype.addNumberForRGB = function (num) {
|
|
1718
|
+
this.r = this.r + num;
|
|
1719
|
+
this.g = this.g + num;
|
|
1720
|
+
this.b = this.b + num;
|
|
1721
|
+
return this;
|
|
1722
|
+
};
|
|
1723
|
+
/**
|
|
1724
|
+
* @description: 透明度加上数字
|
|
1725
|
+
* @param {number} num
|
|
1726
|
+
* @return {CssColorParser}
|
|
1727
|
+
*/
|
|
1728
|
+
CssColorParser.prototype.addNumberForAlpha = function (num) {
|
|
1729
|
+
this.a = this.a + num;
|
|
1730
|
+
return this;
|
|
1731
|
+
};
|
|
1535
1732
|
/**
|
|
1536
1733
|
* @description: 解析16进制颜色
|
|
1537
1734
|
* @param {string} v
|
|
1538
1735
|
* @return {CssColorParser}
|
|
1539
|
-
* @example: parseHEX('#FFF')
|
|
1736
|
+
* @example: CssColorParser.parseHEX('#FFF')
|
|
1540
1737
|
*/
|
|
1541
1738
|
CssColorParser.parseHEX = function (v) {
|
|
1542
1739
|
var cssStr = CssColorStringParser.clearStrSpace(v);
|
|
@@ -1550,7 +1747,7 @@ var CssColorParser = /** @class */ (function () {
|
|
|
1550
1747
|
* @description: 解析rgba、rgb颜色
|
|
1551
1748
|
* @param {string} v
|
|
1552
1749
|
* @return {CssColorParser}
|
|
1553
|
-
* @example: parseRGBA('rgba(255,255,255,1)')
|
|
1750
|
+
* @example: CssColorParser.parseRGBA('rgba(255,255,255,1)')
|
|
1554
1751
|
*/
|
|
1555
1752
|
CssColorParser.parseRGBA = function (v) {
|
|
1556
1753
|
var cssStr = CssColorStringParser.clearStrSpace(v);
|
|
@@ -1565,7 +1762,7 @@ var CssColorParser = /** @class */ (function () {
|
|
|
1565
1762
|
* @description: 将ColorJson格式的json数据转换为解析对象
|
|
1566
1763
|
* @param {ColorJson} json
|
|
1567
1764
|
* @return {CssColorParser}
|
|
1568
|
-
* @example: fromJson({r: 255, g: 255, b: 255, a: 1})
|
|
1765
|
+
* @example: CssColorParser.fromJson({r: 255, g: 255, b: 255, a: 1})
|
|
1569
1766
|
*/
|
|
1570
1767
|
CssColorParser.fromJson = function (json) {
|
|
1571
1768
|
return new CssColorParser(json.r, json.g, json.b, json.a);
|
|
@@ -1574,7 +1771,7 @@ var CssColorParser = /** @class */ (function () {
|
|
|
1574
1771
|
* @description: 将RGBA数组转换为解析对象
|
|
1575
1772
|
* @param {Array} color
|
|
1576
1773
|
* @return {CssColorParser}
|
|
1577
|
-
* @example:
|
|
1774
|
+
* @example: CssColorParser.fromArray([255,255,255,1])
|
|
1578
1775
|
*/
|
|
1579
1776
|
CssColorParser.fromArray = function (color) {
|
|
1580
1777
|
return new CssColorParser(color[0], color[1], color[2], color[3]);
|
|
@@ -1582,7 +1779,7 @@ var CssColorParser = /** @class */ (function () {
|
|
|
1582
1779
|
/**
|
|
1583
1780
|
* @description: 产生随机颜色
|
|
1584
1781
|
* @return {CssColorParser}
|
|
1585
|
-
* @example: fromRandom(new CssColorParser(0,0,0,0), new CssColorParser(255,255,255,1))
|
|
1782
|
+
* @example: CssColorParser.fromRandom(new CssColorParser(0,0,0,0), new CssColorParser(255,255,255,1))
|
|
1586
1783
|
*/
|
|
1587
1784
|
CssColorParser.fromRandom = function (color1, color2) {
|
|
1588
1785
|
var r = Math.random() * Math.abs(color2.r - color1.r) +
|
|
@@ -1595,6 +1792,18 @@ var CssColorParser = /** @class */ (function () {
|
|
|
1595
1792
|
Math.min(color1.a, color2.a);
|
|
1596
1793
|
return new CssColorParser(r, g, b, a);
|
|
1597
1794
|
};
|
|
1795
|
+
/**
|
|
1796
|
+
* @description: 颜色序列化数组转换为CssColorParser对象实例
|
|
1797
|
+
* @param {array} colorArr
|
|
1798
|
+
* @example: CssColorParser.fromNormaliz([1, 0, 0, 1])
|
|
1799
|
+
*/
|
|
1800
|
+
CssColorParser.fromNormalize = function (colorArr) {
|
|
1801
|
+
var r = colorArr[0] * 255;
|
|
1802
|
+
var g = colorArr[1] * 255;
|
|
1803
|
+
var b = colorArr[2] * 255;
|
|
1804
|
+
var a = colorArr[3];
|
|
1805
|
+
return CssColorParser.fromArray([r, g, b, a]);
|
|
1806
|
+
};
|
|
1598
1807
|
return CssColorParser;
|
|
1599
1808
|
}());
|
|
1600
1809
|
/* harmony default export */ var src_CssColorParser = (CssColorParser);
|
|
@@ -1625,12 +1834,7 @@ function parseKeyWord(v) {
|
|
|
1625
1834
|
* @example: parseHEX('#FFF')
|
|
1626
1835
|
*/
|
|
1627
1836
|
function parseHEX(v) {
|
|
1628
|
-
|
|
1629
|
-
var res = CssColorStringParser.parse3BitsHEX(cssStr);
|
|
1630
|
-
if (!res) {
|
|
1631
|
-
res = CssColorStringParser.parse6BitsHEX(cssStr);
|
|
1632
|
-
}
|
|
1633
|
-
return res && fromArray(res);
|
|
1837
|
+
return src_CssColorParser.parseHEX(v);
|
|
1634
1838
|
}
|
|
1635
1839
|
/**
|
|
1636
1840
|
* @description: 解析RGBA
|
|
@@ -1639,13 +1843,7 @@ function parseHEX(v) {
|
|
|
1639
1843
|
* @example: parseRGBA('rgba(255,255,255,1)')
|
|
1640
1844
|
*/
|
|
1641
1845
|
function parseRGBA(v) {
|
|
1642
|
-
|
|
1643
|
-
var res = CssColorStringParser.parseRGBA(cssStr);
|
|
1644
|
-
if (!res) {
|
|
1645
|
-
var cssStr2 = CssColorStringParser.trimStr(v);
|
|
1646
|
-
res = CssColorStringParser.parseRGBA2(cssStr2);
|
|
1647
|
-
}
|
|
1648
|
-
return res && fromArray(res);
|
|
1846
|
+
return src_CssColorParser.parseRGBA(v);
|
|
1649
1847
|
}
|
|
1650
1848
|
/**
|
|
1651
1849
|
* @description: 解析HSLA
|
|
@@ -1680,7 +1878,7 @@ function parseHWB(v) {
|
|
|
1680
1878
|
* @example: parseCssColorStr('rgba(255,255,255,1)')
|
|
1681
1879
|
*/
|
|
1682
1880
|
function parseCssColorStr(v) {
|
|
1683
|
-
Check.type('
|
|
1881
|
+
Check.type('color', v, 'string');
|
|
1684
1882
|
return parseHEX(v) || parseRGBA(v) || parseKeyWord(v) || parseHSLA(v) || parseHWB(v);
|
|
1685
1883
|
}
|
|
1686
1884
|
/**
|
|
@@ -1692,8 +1890,7 @@ function parseCssColorStr(v) {
|
|
|
1692
1890
|
* @example: fromColorStr('rgba(255,255,255,1)')
|
|
1693
1891
|
*/
|
|
1694
1892
|
function fromColorStr(v) {
|
|
1695
|
-
|
|
1696
|
-
return parseHEX(v) || parseRGBA(v) || parseKeyWord(v) || parseHSLA(v) || parseHWB(v);
|
|
1893
|
+
return parseCssColorStr(v);
|
|
1697
1894
|
}
|
|
1698
1895
|
/**
|
|
1699
1896
|
* @description: 将HSL色彩模式转换为解析对象
|
|
@@ -1736,24 +1933,16 @@ function fromRandom(color1, color2) {
|
|
|
1736
1933
|
if (!color1 || !color2) {
|
|
1737
1934
|
throw new Error('fail to create object from random');
|
|
1738
1935
|
}
|
|
1739
|
-
|
|
1740
|
-
Math.min(color1.r, color2.r);
|
|
1741
|
-
var g = Math.random() * Math.abs(color2.g - color1.g) +
|
|
1742
|
-
Math.min(color1.g, color2.g);
|
|
1743
|
-
var b = Math.random() * Math.abs(color2.b - color1.b) +
|
|
1744
|
-
Math.min(color1.b, color2.b);
|
|
1745
|
-
var a = Math.random() * Math.abs(color2.a - color1.a) +
|
|
1746
|
-
Math.min(color1.a, color2.a);
|
|
1747
|
-
return new src_CssColorParser(r, g, b, a);
|
|
1936
|
+
return src_CssColorParser.fromRandom(color1, color2);
|
|
1748
1937
|
}
|
|
1749
1938
|
/**
|
|
1750
1939
|
* @description: 将ColorJson格式的json数据转换为解析对象
|
|
1751
1940
|
* @param {ColorJson} json
|
|
1752
1941
|
* @return {CssColorParser}
|
|
1753
|
-
* @
|
|
1942
|
+
* @example: fromJson({r: 255, g:255, b:255, a:1})
|
|
1754
1943
|
*/
|
|
1755
1944
|
function fromJson(json) {
|
|
1756
|
-
return
|
|
1945
|
+
return src_CssColorParser.fromJson(json);
|
|
1757
1946
|
}
|
|
1758
1947
|
/**
|
|
1759
1948
|
* @description: 将rgba数组转换为解析对象
|
|
@@ -1762,7 +1951,7 @@ function fromJson(json) {
|
|
|
1762
1951
|
* @author: roman_123
|
|
1763
1952
|
*/
|
|
1764
1953
|
function fromArray(color) {
|
|
1765
|
-
return
|
|
1954
|
+
return src_CssColorParser.fromArray(color);
|
|
1766
1955
|
}
|
|
1767
1956
|
|
|
1768
1957
|
;// CONCATENATED MODULE: ./src/main.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Parser=e():r.Parser=e()}(this,(function(){return function(){var r={208:function(r,e,n){function t(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var n=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=n){var t,a,o,i,u=[],s=!0,c=!1;try{if(o=(n=n.call(r)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(t=o.call(n)).done)&&(u.push(t.value),u.length!==e);s=!0);}catch(r){c=!0,a=r}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw a}}return u}}(r,e)||function(r,e){if(r){if("string"==typeof r)return a(r,e);var n=Object.prototype.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(r,e):void 0}}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(r,e){(null==e||e>r.length)&&(e=r.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=r[n];return t}for(var o=n(101),i={},u=0,s=Object.keys(o);u<s.length;u++){var c=s[u];i[o[c]]=c}var l={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};r.exports=l;for(var h=0,f=Object.keys(l);h<f.length;h++){var p=f[h];if(!("channels"in l[p]))throw new Error("missing channels property: "+p);if(!("labels"in l[p]))throw new Error("missing channel labels property: "+p);if(l[p].labels.length!==l[p].channels)throw new Error("channel and label counts mismatch: "+p);var b=l[p],g=b.channels,v=b.labels;delete l[p].channels,delete l[p].labels,Object.defineProperty(l[p],"channels",{value:g}),Object.defineProperty(l[p],"labels",{value:v})}l.rgb.hsl=function(r){var e,n=r[0]/255,t=r[1]/255,a=r[2]/255,o=Math.min(n,t,a),i=Math.max(n,t,a),u=i-o;i===o?e=0:n===i?e=(t-a)/u:t===i?e=2+(a-n)/u:a===i&&(e=4+(n-t)/u),(e=Math.min(60*e,360))<0&&(e+=360);var s=(o+i)/2;return[e,100*(i===o?0:s<=.5?u/(i+o):u/(2-i-o)),100*s]},l.rgb.hsv=function(r){var e,n,t,a,o,i=r[0]/255,u=r[1]/255,s=r[2]/255,c=Math.max(i,u,s),l=c-Math.min(i,u,s),h=function(r){return(c-r)/6/l+.5};return 0===l?(a=0,o=0):(o=l/c,e=h(i),n=h(u),t=h(s),i===c?a=t-n:u===c?a=1/3+e-t:s===c&&(a=2/3+n-e),a<0?a+=1:a>1&&(a-=1)),[360*a,100*o,100*c]},l.rgb.hwb=function(r){var e=r[0],n=r[1],t=r[2];return[l.rgb.hsl(r)[0],1/255*Math.min(e,Math.min(n,t))*100,100*(t=1-1/255*Math.max(e,Math.max(n,t)))]},l.rgb.cmyk=function(r){var e=r[0]/255,n=r[1]/255,t=r[2]/255,a=Math.min(1-e,1-n,1-t);return[100*((1-e-a)/(1-a)||0),100*((1-n-a)/(1-a)||0),100*((1-t-a)/(1-a)||0),100*a]},l.rgb.keyword=function(r){var e=i[r];if(e)return e;for(var n,t,a,u=1/0,s=0,c=Object.keys(o);s<c.length;s++){var l=c[s],h=(t=r,a=o[l],Math.pow(t[0]-a[0],2)+Math.pow(t[1]-a[1],2)+Math.pow(t[2]-a[2],2));h<u&&(u=h,n=l)}return n},l.keyword.rgb=function(r){return o[r]},l.rgb.xyz=function(r){var e=r[0]/255,n=r[1]/255,t=r[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92)),100*(.2126*e+.7152*n+.0722*t),100*(.0193*e+.1192*n+.9505*t)]},l.rgb.lab=function(r){var e=l.rgb.xyz(r),n=e[0],t=e[1],a=e[2];return t/=100,a/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(t=t>.008856?Math.pow(t,1/3):7.787*t+16/116)-16,500*(n-t),200*(t-(a=a>.008856?Math.pow(a,1/3):7.787*a+16/116))]},l.hsl.rgb=function(r){var e,n,t,a=r[0]/360,o=r[1]/100,i=r[2]/100;if(0===o)return[t=255*i,t,t];for(var u=2*i-(e=i<.5?i*(1+o):i+o-i*o),s=[0,0,0],c=0;c<3;c++)(n=a+1/3*-(c-1))<0&&n++,n>1&&n--,t=6*n<1?u+6*(e-u)*n:2*n<1?e:3*n<2?u+(e-u)*(2/3-n)*6:u,s[c]=255*t;return s},l.hsl.hsv=function(r){var e=r[0],n=r[1]/100,t=r[2]/100,a=n,o=Math.max(t,.01);return n*=(t*=2)<=1?t:2-t,a*=o<=1?o:2-o,[e,100*(0===t?2*a/(o+a):2*n/(t+n)),(t+n)/2*100]},l.hsv.rgb=function(r){var e=r[0]/60,n=r[1]/100,t=r[2]/100,a=Math.floor(e)%6,o=e-Math.floor(e),i=255*t*(1-n),u=255*t*(1-n*o),s=255*t*(1-n*(1-o));switch(t*=255,a){case 0:return[t,s,i];case 1:return[u,t,i];case 2:return[i,t,s];case 3:return[i,u,t];case 4:return[s,i,t];case 5:return[t,i,u]}},l.hsv.hsl=function(r){var e,n,t=r[0],a=r[1]/100,o=r[2]/100,i=Math.max(o,.01);n=(2-a)*o;var u=(2-a)*i;return e=a*i,[t,100*(e=(e/=u<=1?u:2-u)||0),100*(n/=2)]},l.hwb.rgb=function(r){var e,n=r[0]/360,t=r[1]/100,a=r[2]/100,o=t+a;o>1&&(t/=o,a/=o);var i=Math.floor(6*n),u=1-a;e=6*n-i,0!=(1&i)&&(e=1-e);var s,c,l,h=t+e*(u-t);switch(i){default:case 6:case 0:s=u,c=h,l=t;break;case 1:s=h,c=u,l=t;break;case 2:s=t,c=u,l=h;break;case 3:s=t,c=h,l=u;break;case 4:s=h,c=t,l=u;break;case 5:s=u,c=t,l=h}return[255*s,255*c,255*l]},l.cmyk.rgb=function(r){var e=r[0]/100,n=r[1]/100,t=r[2]/100,a=r[3]/100;return[255*(1-Math.min(1,e*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a)),255*(1-Math.min(1,t*(1-a)+a))]},l.xyz.rgb=function(r){var e,n,t,a=r[0]/100,o=r[1]/100,i=r[2]/100;return n=-.9689*a+1.8758*o+.0415*i,t=.0557*a+-.204*o+1.057*i,e=(e=3.2406*a+-1.5372*o+-.4986*i)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,t=t>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(t=Math.min(Math.max(0,t),1))]},l.xyz.lab=function(r){var e=r[0],n=r[1],t=r[2];return n/=100,t/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(t=t>.008856?Math.pow(t,1/3):7.787*t+16/116))]},l.lab.xyz=function(r){var e,n,t,a=r[0];e=r[1]/500+(n=(a+16)/116),t=n-r[2]/200;var o=Math.pow(n,3),i=Math.pow(e,3),u=Math.pow(t,3);return n=o>.008856?o:(n-16/116)/7.787,e=i>.008856?i:(e-16/116)/7.787,t=u>.008856?u:(t-16/116)/7.787,[e*=95.047,n*=100,t*=108.883]},l.lab.lch=function(r){var e,n=r[0],t=r[1],a=r[2];return(e=360*Math.atan2(a,t)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(t*t+a*a),e]},l.lch.lab=function(r){var e=r[0],n=r[1],t=r[2]/360*2*Math.PI;return[e,n*Math.cos(t),n*Math.sin(t)]},l.rgb.ansi16=function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=t(r,3),a=n[0],o=n[1],i=n[2],u=null===e?l.rgb.hsv(r)[2]:e;if(0===(u=Math.round(u/50)))return 30;var s=30+(Math.round(i/255)<<2|Math.round(o/255)<<1|Math.round(a/255));return 2===u&&(s+=60),s},l.hsv.ansi16=function(r){return l.rgb.ansi16(l.hsv.rgb(r),r[2])},l.rgb.ansi256=function(r){var e=r[0],n=r[1],t=r[2];return e===n&&n===t?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(t/255*5)},l.ansi16.rgb=function(r){var e=r%10;if(0===e||7===e)return r>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(r>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},l.ansi256.rgb=function(r){if(r>=232){var e=10*(r-232)+8;return[e,e,e]}var n;return r-=16,[Math.floor(r/36)/5*255,Math.floor((n=r%36)/6)/5*255,n%6/5*255]},l.rgb.hex=function(r){var e=(((255&Math.round(r[0]))<<16)+((255&Math.round(r[1]))<<8)+(255&Math.round(r[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},l.hex.rgb=function(r){var e=r.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(r){return r+r})).join(""));var t=parseInt(n,16);return[t>>16&255,t>>8&255,255&t]},l.rgb.hcg=function(r){var e,n=r[0]/255,t=r[1]/255,a=r[2]/255,o=Math.max(Math.max(n,t),a),i=Math.min(Math.min(n,t),a),u=o-i;return e=u<=0?0:o===n?(t-a)/u%6:o===t?2+(a-n)/u:4+(n-t)/u,e/=6,[360*(e%=1),100*u,100*(u<1?i/(1-u):0)]},l.hsl.hcg=function(r){var e=r[1]/100,n=r[2]/100,t=n<.5?2*e*n:2*e*(1-n),a=0;return t<1&&(a=(n-.5*t)/(1-t)),[r[0],100*t,100*a]},l.hsv.hcg=function(r){var e=r[1]/100,n=r[2]/100,t=e*n,a=0;return t<1&&(a=(n-t)/(1-t)),[r[0],100*t,100*a]},l.hcg.rgb=function(r){var e=r[0]/360,n=r[1]/100,t=r[2]/100;if(0===n)return[255*t,255*t,255*t];var a,o=[0,0,0],i=e%1*6,u=i%1,s=1-u;switch(Math.floor(i)){case 0:o[0]=1,o[1]=u,o[2]=0;break;case 1:o[0]=s,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=u;break;case 3:o[0]=0,o[1]=s,o[2]=1;break;case 4:o[0]=u,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=s}return a=(1-n)*t,[255*(n*o[0]+a),255*(n*o[1]+a),255*(n*o[2]+a)]},l.hcg.hsv=function(r){var e=r[1]/100,n=e+r[2]/100*(1-e),t=0;return n>0&&(t=e/n),[r[0],100*t,100*n]},l.hcg.hsl=function(r){var e=r[1]/100,n=r[2]/100*(1-e)+.5*e,t=0;return n>0&&n<.5?t=e/(2*n):n>=.5&&n<1&&(t=e/(2*(1-n))),[r[0],100*t,100*n]},l.hcg.hwb=function(r){var e=r[1]/100,n=e+r[2]/100*(1-e);return[r[0],100*(n-e),100*(1-n)]},l.hwb.hcg=function(r){var e=r[1]/100,n=1-r[2]/100,t=n-e,a=0;return t<1&&(a=(n-t)/(1-t)),[r[0],100*t,100*a]},l.apple.rgb=function(r){return[r[0]/65535*255,r[1]/65535*255,r[2]/65535*255]},l.rgb.apple=function(r){return[r[0]/255*65535,r[1]/255*65535,r[2]/255*65535]},l.gray.rgb=function(r){return[r[0]/100*255,r[0]/100*255,r[0]/100*255]},l.gray.hsl=function(r){return[0,0,r[0]]},l.gray.hsv=l.gray.hsl,l.gray.hwb=function(r){return[0,100,r[0]]},l.gray.cmyk=function(r){return[0,0,0,r[0]]},l.gray.lab=function(r){return[r[0],0,0]},l.gray.hex=function(r){var e=255&Math.round(r[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},l.rgb.gray=function(r){return[(r[0]+r[1]+r[2])/3/255*100]}},907:function(r,e,n){function t(r){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},t(r)}var a=n(208),o=n(171),i={};Object.keys(a).forEach((function(r){i[r]={},Object.defineProperty(i[r],"channels",{value:a[r].channels}),Object.defineProperty(i[r],"labels",{value:a[r].labels});var e=o(r);Object.keys(e).forEach((function(n){var a=e[n];i[r][n]=function(r){var e=function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];var o=n[0];if(null==o)return o;o.length>1&&(n=o);var i=r(n);if("object"===t(i))for(var u=i.length,s=0;s<u;s++)i[s]=Math.round(i[s]);return i};return"conversion"in r&&(e.conversion=r.conversion),e}(a),i[r][n].raw=function(r){var e=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var a=n[0];return null==a?a:(a.length>1&&(n=a),r(n))};return"conversion"in r&&(e.conversion=r.conversion),e}(a)}))})),r.exports=i},171:function(r,e,n){var t=n(208);function a(r,e){return function(n){return e(r(n))}}function o(r,e){for(var n=[e[r].parent,r],o=t[e[r].parent][r],i=e[r].parent;e[i].parent;)n.unshift(e[i].parent),o=a(t[e[i].parent][i],o),i=e[i].parent;return o.conversion=n,o}r.exports=function(r){for(var e=function(r){var e=function(){for(var r={},e=Object.keys(t),n=e.length,a=0;a<n;a++)r[e[a]]={distance:-1,parent:null};return r}(),n=[r];for(e[r].distance=0;n.length;)for(var a=n.pop(),o=Object.keys(t[a]),i=o.length,u=0;u<i;u++){var s=o[u],c=e[s];-1===c.distance&&(c.distance=e[a].distance+1,c.parent=a,n.unshift(s))}return e}(r),n={},a=Object.keys(e),i=a.length,u=0;u<i;u++){var s=a[u];null!==e[s].parent&&(n[s]=o(s,e))}return n}},101:function(r){"use strict";r.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}}},e={};function n(t){var a=e[t];if(void 0!==a)return a.exports;var o=e[t]={exports:{}};return r[t](o,o.exports,n),o.exports}n.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(e,{a:e}),e},n.d=function(r,e){for(var t in e)n.o(e,t)&&!n.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:e[t]})},n.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},n.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var t={};return function(){"use strict";n.r(t),n.d(t,{CssColorParser:function(){return u},fromArray:function(){return w},fromColorStr:function(){return v},fromHSL:function(){return d},fromHWB:function(){return y},fromJson:function(){return M},fromRandom:function(){return m},parseCssColorStr:function(){return g},parseHEX:function(){return h},parseHSLA:function(){return p},parseHWB:function(){return b},parseKeyWord:function(){return l},parseRGBA:function(){return f}});var r=function(){function r(){}return r.type=function(r,e,n){var t=typeof n;if(t!==r)throw new Error("Expected ".concat(e," to be typeof ").concat(r,", actual typeof was ").concat(t))},r.types=function(r,e,n){var t=typeof n;if(!r.includes(t))throw new Error("Expected ".concat(e," to be typeof ").concat(r.join("|"),", actual typeof was ").concat(t))},r}();function e(r,e){return null==r||isNaN(r)&&"number"==typeof e?e:r}function a(r,e,n){return n>e?n=e:n<r&&(n=r),n}function o(r,e){return Number(r.toFixed(e))}var i=function(){function r(){}return r.clearStrSpace=function(r){return r.replace(/\s/g,"")},r.trimStr=function(r){return(r=r.replace(/\s+/g," ")).trim()},r.parse3BitsHEX=function(n){var t=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i.exec(n);if(t){var a=e(t[4],"f");return[r._parseResStrForRgb(parseInt(t[1]+t[1],16)),r._parseResStrForRgb(parseInt(t[2]+t[2],16)),r._parseResStrForRgb(parseInt(t[3]+t[3],16)),r._parsePercent(parseInt(a+a,16)/255)]}return null},r.parse6BitsHEX=function(n){var t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i.exec(n);if(t){var a=e(t[4],"ff");return[r._parseResStrForRgb(parseInt(t[1],16)),r._parseResStrForRgb(parseInt(t[2],16)),r._parseResStrForRgb(parseInt(t[3],16)),r._parsePercent(parseInt(a,16)/255)]}return null},r.parseRGBA=function(e){var n=/^rgba?\(([0-9.]+%?),([0-9.]+%?),([0-9.]+%?)(?:,([0-9.]+%?))?\)$/i.exec(e);return n?[r._parseResStrForRgb(n[1]),r._parseResStrForRgb(n[2]),r._parseResStrForRgb(n[3]),r._parsePercent(n[4])]:null},r.parseHSLA=function(e){var n=/^hsla?\(([0-9.]+)(?:deg)?,([0-9.]+%?),([0-9.]+%?)(?:,([0-9.]+%?))?\)$/i.exec(e);return n?[r._parseResStrForHue(n[1]),r._parsePercent(n[2]),r._parsePercent(n[3]),r._parsePercent(n[4])]:null},r.parseHWB=function(e){var n=/^hwb\s?\(\s?([0-9.]+)(?:deg)?\s([0-9.]+%?)\s([0-9.]+%?)\s?(?:\/\s?([0-9.]+%?))?\s?\)$/i.exec(e);return n?[r._parseResStrForHue(n[1]),r._parsePercent(n[2]),r._parsePercent(n[3]),r._parsePercent(n[4])]:null},r.parseRGBA2=function(e){var n=/^rgba?\s?\(\s?([0-9.]+%?)\s?([0-9.]+%?)\s?([0-9.]+%?)(?:\s?\/\s?([0-9.]+%?))?\s?\)$/i.exec(e);return n?[r._parseResStrForRgb(n[1]),r._parseResStrForRgb(n[2]),r._parseResStrForRgb(n[3]),r._parsePercent(n[4])]:null},r.parseHSLA2=function(e){var n=/^hsla?\s?\(\s?([0-9.]+)(?:deg)?\s([0-9.]+%?)\s([0-9.]+%?)\s?(?:\/\s?([0-9.]+%?))?\s?\)$/i.exec(e);return n?[r._parseResStrForHue(n[1]),r._parsePercent(n[2]),r._parsePercent(n[3]),r._parsePercent(n[4])]:null},r._parseResStrForRgb=function(r){return"string"==typeof r&&(r=parseFloat(r)/("%"===r.substr(-1)?100/255:1)),isNaN(r)&&(r=1),a(0,255,r)},r._parseResStrForHue=function(r){return"string"==typeof r&&(r=parseFloat(r)),isNaN(r)&&(r=0),a(0,360,r)},r._parsePercent=function(r){return"string"==typeof r&&(r=parseFloat(r)/("%"===r.substr(-1)?100:1)),isNaN(r)&&(r=1),a(0,1,r)},r}(),u=function(){function r(r,e,n,t){this.r=255,this.g=255,this.b=255,this.a=1,this.setColor(r,e,n,t)}return r.prototype.setColor=function(r,n,t,o){this.r=a(0,255,e(Number(r),0)),this.g=a(0,255,e(Number(n),0)),this.b=a(0,255,e(Number(t),0)),this.a=a(0,1,e(Number(o),1))},r.prototype.toRGBA=function(){var r=this.toJson();return 1===r.a?"rgb(".concat(r.r,",").concat(r.g,",").concat(r.b,")"):"rgba(".concat(r.r,",").concat(r.g,",").concat(r.b,",").concat(r.a,")")},r.prototype.toString=function(){return this.toRGBA()},r.prototype.toNormalize=function(){return{r:o(this.r/255,2),g:o(this.g/255,2),b:o(this.b/255,2),a:o(this.a,2)}},r.prototype.toHEX=function(){var r=this.toJson(),e=r.r.toString(16);e.length<2&&(e="0".concat(e));var n=r.g.toString(16);n.length<2&&(n="0".concat(n));var t=r.b.toString(16);if(t.length<2&&(t="0".concat(t)),this.a<1){var a=parseInt((255*this.a).toFixed()).toString(16);return a.length<2&&(a="0".concat(a)),"#".concat(e).concat(n).concat(t).concat(a)}return"#".concat(e).concat(n).concat(t)},r.prototype.toArray=function(){var r=this.toJson();return[r.r,r.g,r.b,r.a]},r.prototype.toJson=function(){return{r:parseInt(this.r.toFixed()),g:parseInt(this.g.toFixed()),b:parseInt(this.b.toFixed()),a:parseFloat(this.a.toFixed(2))}},r.prototype.clone=function(){return new r(this.r,this.g,this.b,this.a)},r.prototype.equals=function(r){return this===r||this.r===r.r&&this.g===r.g&&this.b===r.g&&this.a===r.a},r.parseHEX=function(e){var n=i.clearStrSpace(e),t=i.parse3BitsHEX(n);return t||(t=i.parse6BitsHEX(n)),t&&r.fromArray(t)},r.parseRGBA=function(e){var n=i.clearStrSpace(e),t=i.parseRGBA(n);if(!t){var a=i.trimStr(e);t=i.parseRGBA2(a)}return t&&r.fromArray(t)},r.fromJson=function(e){return new r(e.r,e.g,e.b,e.a)},r.fromArray=function(e){return new r(e[0],e[1],e[2],e[3])},r.fromRandom=function(e,n){return new r(Math.random()*Math.abs(n.r-e.r)+Math.min(e.r,n.r),Math.random()*Math.abs(n.g-e.g)+Math.min(e.g,n.g),Math.random()*Math.abs(n.b-e.b)+Math.min(e.b,n.b),Math.random()*Math.abs(n.a-e.a)+Math.min(e.a,n.a))},r}(),s=n(907),c=n.n(s);function l(r){var e=i.clearStrSpace(r),n=c().keyword.rgb(e);return n&&w(n)}function h(r){var e=i.clearStrSpace(r),n=i.parse3BitsHEX(e);return n||(n=i.parse6BitsHEX(e)),n&&w(n)}function f(r){var e=i.clearStrSpace(r),n=i.parseRGBA(e);if(!n){var t=i.trimStr(r);n=i.parseRGBA2(t)}return n&&w(n)}function p(r){var e=i.clearStrSpace(r),n=i.parseHSLA(e);if(!n){var t=i.trimStr(r);n=i.parseHSLA2(t)}return n&&d(n[0],n[1],n[2],n[3])}function b(r){var e=i.trimStr(r),n=i.parseHWB(e);return n&&y(n[0],n[1],n[2],n[3])}function g(e){return r.type("string","color",e),h(e)||f(e)||l(e)||p(e)||b(e)}function v(e){return r.type("string","color",e),h(e)||f(e)||l(e)||p(e)||b(e)}function d(r,n,t,o){var i=c().hsl.rgb(a(0,360,r),a(0,100,100*n),a(0,100,100*t));return new u(i[0],i[1],i[2],e(Number(o),1))}function y(r,n,t,o){var i=c().hwb.rgb(a(0,360,r),a(0,100,100*n),a(0,100,100*t));return new u(i[0],i[1],i[2],e(Number(o),1))}function m(r,e){if("string"==typeof r&&(r=g(r)),"string"==typeof e&&(e=g(e)),!r||!e)throw new Error("fail to create object from random");var n=Math.random()*Math.abs(e.r-r.r)+Math.min(r.r,e.r),t=Math.random()*Math.abs(e.g-r.g)+Math.min(r.g,e.g),a=Math.random()*Math.abs(e.b-r.b)+Math.min(r.b,e.b),o=Math.random()*Math.abs(e.a-r.a)+Math.min(r.a,e.a);return new u(n,t,a,o)}function M(r){return new u(r.r,r.g,r.b,r.a)}function w(r){return new u(r[0],r[1],r[2],r[3])}}(),t}()}));
|
|
1
|
+
!function(r,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Parser=t():r.Parser=t()}(this,(function(){return function(){var r={208:function(r,t,n){function e(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){var n=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=n){var e,a,o,i,s=[],u=!0,c=!1;try{if(o=(n=n.call(r)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(e=o.call(n)).done)&&(s.push(e.value),s.length!==t);u=!0);}catch(r){c=!0,a=r}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw a}}return s}}(r,t)||function(r,t){if(r){if("string"==typeof r)return a(r,t);var n=Object.prototype.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(r,t):void 0}}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(r,t){(null==t||t>r.length)&&(t=r.length);for(var n=0,e=new Array(t);n<t;n++)e[n]=r[n];return e}for(var o=n(101),i={},s=0,u=Object.keys(o);s<u.length;s++){var c=u[s];i[o[c]]=c}var l={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};r.exports=l;for(var h=0,f=Object.keys(l);h<f.length;h++){var p=f[h];if(!("channels"in l[p]))throw new Error("missing channels property: "+p);if(!("labels"in l[p]))throw new Error("missing channel labels property: "+p);if(l[p].labels.length!==l[p].channels)throw new Error("channel and label counts mismatch: "+p);var b=l[p],g=b.channels,v=b.labels;delete l[p].channels,delete l[p].labels,Object.defineProperty(l[p],"channels",{value:g}),Object.defineProperty(l[p],"labels",{value:v})}l.rgb.hsl=function(r){var t,n=r[0]/255,e=r[1]/255,a=r[2]/255,o=Math.min(n,e,a),i=Math.max(n,e,a),s=i-o;i===o?t=0:n===i?t=(e-a)/s:e===i?t=2+(a-n)/s:a===i&&(t=4+(n-e)/s),(t=Math.min(60*t,360))<0&&(t+=360);var u=(o+i)/2;return[t,100*(i===o?0:u<=.5?s/(i+o):s/(2-i-o)),100*u]},l.rgb.hsv=function(r){var t,n,e,a,o,i=r[0]/255,s=r[1]/255,u=r[2]/255,c=Math.max(i,s,u),l=c-Math.min(i,s,u),h=function(r){return(c-r)/6/l+.5};return 0===l?(a=0,o=0):(o=l/c,t=h(i),n=h(s),e=h(u),i===c?a=e-n:s===c?a=1/3+t-e:u===c&&(a=2/3+n-t),a<0?a+=1:a>1&&(a-=1)),[360*a,100*o,100*c]},l.rgb.hwb=function(r){var t=r[0],n=r[1],e=r[2];return[l.rgb.hsl(r)[0],1/255*Math.min(t,Math.min(n,e))*100,100*(e=1-1/255*Math.max(t,Math.max(n,e)))]},l.rgb.cmyk=function(r){var t=r[0]/255,n=r[1]/255,e=r[2]/255,a=Math.min(1-t,1-n,1-e);return[100*((1-t-a)/(1-a)||0),100*((1-n-a)/(1-a)||0),100*((1-e-a)/(1-a)||0),100*a]},l.rgb.keyword=function(r){var t=i[r];if(t)return t;for(var n,e,a,s=1/0,u=0,c=Object.keys(o);u<c.length;u++){var l=c[u],h=(e=r,a=o[l],Math.pow(e[0]-a[0],2)+Math.pow(e[1]-a[1],2)+Math.pow(e[2]-a[2],2));h<s&&(s=h,n=l)}return n},l.keyword.rgb=function(r){return o[r]},l.rgb.xyz=function(r){var t=r[0]/255,n=r[1]/255,e=r[2]/255;return[100*(.4124*(t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)),100*(.2126*t+.7152*n+.0722*e),100*(.0193*t+.1192*n+.9505*e)]},l.rgb.lab=function(r){var t=l.rgb.xyz(r),n=t[0],e=t[1],a=t[2];return e/=100,a/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(e=e>.008856?Math.pow(e,1/3):7.787*e+16/116)-16,500*(n-e),200*(e-(a=a>.008856?Math.pow(a,1/3):7.787*a+16/116))]},l.hsl.rgb=function(r){var t,n,e,a=r[0]/360,o=r[1]/100,i=r[2]/100;if(0===o)return[e=255*i,e,e];for(var s=2*i-(t=i<.5?i*(1+o):i+o-i*o),u=[0,0,0],c=0;c<3;c++)(n=a+1/3*-(c-1))<0&&n++,n>1&&n--,e=6*n<1?s+6*(t-s)*n:2*n<1?t:3*n<2?s+(t-s)*(2/3-n)*6:s,u[c]=255*e;return u},l.hsl.hsv=function(r){var t=r[0],n=r[1]/100,e=r[2]/100,a=n,o=Math.max(e,.01);return n*=(e*=2)<=1?e:2-e,a*=o<=1?o:2-o,[t,100*(0===e?2*a/(o+a):2*n/(e+n)),(e+n)/2*100]},l.hsv.rgb=function(r){var t=r[0]/60,n=r[1]/100,e=r[2]/100,a=Math.floor(t)%6,o=t-Math.floor(t),i=255*e*(1-n),s=255*e*(1-n*o),u=255*e*(1-n*(1-o));switch(e*=255,a){case 0:return[e,u,i];case 1:return[s,e,i];case 2:return[i,e,u];case 3:return[i,s,e];case 4:return[u,i,e];case 5:return[e,i,s]}},l.hsv.hsl=function(r){var t,n,e=r[0],a=r[1]/100,o=r[2]/100,i=Math.max(o,.01);n=(2-a)*o;var s=(2-a)*i;return t=a*i,[e,100*(t=(t/=s<=1?s:2-s)||0),100*(n/=2)]},l.hwb.rgb=function(r){var t,n=r[0]/360,e=r[1]/100,a=r[2]/100,o=e+a;o>1&&(e/=o,a/=o);var i=Math.floor(6*n),s=1-a;t=6*n-i,0!=(1&i)&&(t=1-t);var u,c,l,h=e+t*(s-e);switch(i){default:case 6:case 0:u=s,c=h,l=e;break;case 1:u=h,c=s,l=e;break;case 2:u=e,c=s,l=h;break;case 3:u=e,c=h,l=s;break;case 4:u=h,c=e,l=s;break;case 5:u=s,c=e,l=h}return[255*u,255*c,255*l]},l.cmyk.rgb=function(r){var t=r[0]/100,n=r[1]/100,e=r[2]/100,a=r[3]/100;return[255*(1-Math.min(1,t*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a)),255*(1-Math.min(1,e*(1-a)+a))]},l.xyz.rgb=function(r){var t,n,e,a=r[0]/100,o=r[1]/100,i=r[2]/100;return n=-.9689*a+1.8758*o+.0415*i,e=.0557*a+-.204*o+1.057*i,t=(t=3.2406*a+-1.5372*o+-.4986*i)>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,[255*(t=Math.min(Math.max(0,t),1)),255*(n=Math.min(Math.max(0,n),1)),255*(e=Math.min(Math.max(0,e),1))]},l.xyz.lab=function(r){var t=r[0],n=r[1],e=r[2];return n/=100,e/=108.883,t=(t/=95.047)>.008856?Math.pow(t,1/3):7.787*t+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(t-n),200*(n-(e=e>.008856?Math.pow(e,1/3):7.787*e+16/116))]},l.lab.xyz=function(r){var t,n,e,a=r[0];t=r[1]/500+(n=(a+16)/116),e=n-r[2]/200;var o=Math.pow(n,3),i=Math.pow(t,3),s=Math.pow(e,3);return n=o>.008856?o:(n-16/116)/7.787,t=i>.008856?i:(t-16/116)/7.787,e=s>.008856?s:(e-16/116)/7.787,[t*=95.047,n*=100,e*=108.883]},l.lab.lch=function(r){var t,n=r[0],e=r[1],a=r[2];return(t=360*Math.atan2(a,e)/2/Math.PI)<0&&(t+=360),[n,Math.sqrt(e*e+a*a),t]},l.lch.lab=function(r){var t=r[0],n=r[1],e=r[2]/360*2*Math.PI;return[t,n*Math.cos(e),n*Math.sin(e)]},l.rgb.ansi16=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=e(r,3),a=n[0],o=n[1],i=n[2],s=null===t?l.rgb.hsv(r)[2]:t;if(0===(s=Math.round(s/50)))return 30;var u=30+(Math.round(i/255)<<2|Math.round(o/255)<<1|Math.round(a/255));return 2===s&&(u+=60),u},l.hsv.ansi16=function(r){return l.rgb.ansi16(l.hsv.rgb(r),r[2])},l.rgb.ansi256=function(r){var t=r[0],n=r[1],e=r[2];return t===n&&n===e?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(e/255*5)},l.ansi16.rgb=function(r){var t=r%10;if(0===t||7===t)return r>50&&(t+=3.5),[t=t/10.5*255,t,t];var n=.5*(1+~~(r>50));return[(1&t)*n*255,(t>>1&1)*n*255,(t>>2&1)*n*255]},l.ansi256.rgb=function(r){if(r>=232){var t=10*(r-232)+8;return[t,t,t]}var n;return r-=16,[Math.floor(r/36)/5*255,Math.floor((n=r%36)/6)/5*255,n%6/5*255]},l.rgb.hex=function(r){var t=(((255&Math.round(r[0]))<<16)+((255&Math.round(r[1]))<<8)+(255&Math.round(r[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},l.hex.rgb=function(r){var t=r.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];var n=t[0];3===t[0].length&&(n=n.split("").map((function(r){return r+r})).join(""));var e=parseInt(n,16);return[e>>16&255,e>>8&255,255&e]},l.rgb.hcg=function(r){var t,n=r[0]/255,e=r[1]/255,a=r[2]/255,o=Math.max(Math.max(n,e),a),i=Math.min(Math.min(n,e),a),s=o-i;return t=s<=0?0:o===n?(e-a)/s%6:o===e?2+(a-n)/s:4+(n-e)/s,t/=6,[360*(t%=1),100*s,100*(s<1?i/(1-s):0)]},l.hsl.hcg=function(r){var t=r[1]/100,n=r[2]/100,e=n<.5?2*t*n:2*t*(1-n),a=0;return e<1&&(a=(n-.5*e)/(1-e)),[r[0],100*e,100*a]},l.hsv.hcg=function(r){var t=r[1]/100,n=r[2]/100,e=t*n,a=0;return e<1&&(a=(n-e)/(1-e)),[r[0],100*e,100*a]},l.hcg.rgb=function(r){var t=r[0]/360,n=r[1]/100,e=r[2]/100;if(0===n)return[255*e,255*e,255*e];var a,o=[0,0,0],i=t%1*6,s=i%1,u=1-s;switch(Math.floor(i)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=u,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=u,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=u}return a=(1-n)*e,[255*(n*o[0]+a),255*(n*o[1]+a),255*(n*o[2]+a)]},l.hcg.hsv=function(r){var t=r[1]/100,n=t+r[2]/100*(1-t),e=0;return n>0&&(e=t/n),[r[0],100*e,100*n]},l.hcg.hsl=function(r){var t=r[1]/100,n=r[2]/100*(1-t)+.5*t,e=0;return n>0&&n<.5?e=t/(2*n):n>=.5&&n<1&&(e=t/(2*(1-n))),[r[0],100*e,100*n]},l.hcg.hwb=function(r){var t=r[1]/100,n=t+r[2]/100*(1-t);return[r[0],100*(n-t),100*(1-n)]},l.hwb.hcg=function(r){var t=r[1]/100,n=1-r[2]/100,e=n-t,a=0;return e<1&&(a=(n-e)/(1-e)),[r[0],100*e,100*a]},l.apple.rgb=function(r){return[r[0]/65535*255,r[1]/65535*255,r[2]/65535*255]},l.rgb.apple=function(r){return[r[0]/255*65535,r[1]/255*65535,r[2]/255*65535]},l.gray.rgb=function(r){return[r[0]/100*255,r[0]/100*255,r[0]/100*255]},l.gray.hsl=function(r){return[0,0,r[0]]},l.gray.hsv=l.gray.hsl,l.gray.hwb=function(r){return[0,100,r[0]]},l.gray.cmyk=function(r){return[0,0,0,r[0]]},l.gray.lab=function(r){return[r[0],0,0]},l.gray.hex=function(r){var t=255&Math.round(r[0]/100*255),n=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(n.length)+n},l.rgb.gray=function(r){return[(r[0]+r[1]+r[2])/3/255*100]}},907:function(r,t,n){function e(r){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},e(r)}var a=n(208),o=n(171),i={};Object.keys(a).forEach((function(r){i[r]={},Object.defineProperty(i[r],"channels",{value:a[r].channels}),Object.defineProperty(i[r],"labels",{value:a[r].labels});var t=o(r);Object.keys(t).forEach((function(n){var a=t[n];i[r][n]=function(r){var t=function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];var o=n[0];if(null==o)return o;o.length>1&&(n=o);var i=r(n);if("object"===e(i))for(var s=i.length,u=0;u<s;u++)i[u]=Math.round(i[u]);return i};return"conversion"in r&&(t.conversion=r.conversion),t}(a),i[r][n].raw=function(r){var t=function(){for(var t=arguments.length,n=new Array(t),e=0;e<t;e++)n[e]=arguments[e];var a=n[0];return null==a?a:(a.length>1&&(n=a),r(n))};return"conversion"in r&&(t.conversion=r.conversion),t}(a)}))})),r.exports=i},171:function(r,t,n){var e=n(208);function a(r,t){return function(n){return t(r(n))}}function o(r,t){for(var n=[t[r].parent,r],o=e[t[r].parent][r],i=t[r].parent;t[i].parent;)n.unshift(t[i].parent),o=a(e[t[i].parent][i],o),i=t[i].parent;return o.conversion=n,o}r.exports=function(r){for(var t=function(r){var t=function(){for(var r={},t=Object.keys(e),n=t.length,a=0;a<n;a++)r[t[a]]={distance:-1,parent:null};return r}(),n=[r];for(t[r].distance=0;n.length;)for(var a=n.pop(),o=Object.keys(e[a]),i=o.length,s=0;s<i;s++){var u=o[s],c=t[u];-1===c.distance&&(c.distance=t[a].distance+1,c.parent=a,n.unshift(u))}return t}(r),n={},a=Object.keys(t),i=a.length,s=0;s<i;s++){var u=a[s];null!==t[u].parent&&(n[u]=o(u,t))}return n}},101:function(r){"use strict";r.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}}},t={};function n(e){var a=t[e];if(void 0!==a)return a.exports;var o=t[e]={exports:{}};return r[e](o,o.exports,n),o.exports}n.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(t,{a:t}),t},n.d=function(r,t){for(var e in t)n.o(t,e)&&!n.o(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:t[e]})},n.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},n.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var e={};return function(){"use strict";n.r(e),n.d(e,{CssColorParser:function(){return s},fromArray:function(){return M},fromColorStr:function(){return v},fromHSL:function(){return y},fromHWB:function(){return d},fromJson:function(){return w},fromRandom:function(){return m},parseCssColorStr:function(){return g},parseHEX:function(){return h},parseHSLA:function(){return p},parseHWB:function(){return b},parseKeyWord:function(){return l},parseRGBA:function(){return f}});var r=function(){function r(){}return r.type=function(r,t,n){var e=typeof t;if(e!==n)throw new Error("Expected ".concat(r," to be typeof ").concat(n,", actual typeof was ").concat(e))},r.types=function(r,t,n){var e=typeof t;if(!n.includes(e))throw new Error("Expected ".concat(r," to be typeof ").concat(n.join("|"),", actual typeof was ").concat(e))},r.numValue=function(t,n,e,a){r.numMinValue(t,n,e),r.numMaxValue(t,n,a)},r.numMinValue=function(r,t,n){if(t<n)throw new Error("Expected ".concat(r," to > ").concat(n,", actual value was ").concat(t))},r.numMaxValue=function(r,t,n){if(t>n)throw new Error("Expected ".concat(r," to < ").concat(n,", actual value was ").concat(t))},r.numIsInt=function(r,t,n){var e=Math.floor(t)===t;if(e!==n)throw new Error("Expected ".concat(r," to ").concat(n?"Integer":"Float",", actual value was ").concat(e?"Integer":"Float"))},r}();function t(r,t){return null==r||isNaN(r)&&"number"==typeof t?t:r}function a(r,t,n){return n>t?n=t:n<r&&(n=r),n}function o(r,t){void 0===r&&(r=0);var n=Math.pow(10,t);return Math.round(r*n)/n}var i=function(){function r(){}return r.clearStrSpace=function(r){return r.replace(/\s/g,"")},r.trimStr=function(r){return(r=r.replace(/\s+/g," ")).trim()},r.parse3BitsHEX=function(n){var e=/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?$/i.exec(n);if(e){var a=t(e[4],"f");return[r._parseResStrForRgb(parseInt(e[1]+e[1],16)),r._parseResStrForRgb(parseInt(e[2]+e[2],16)),r._parseResStrForRgb(parseInt(e[3]+e[3],16)),r._parsePercent(parseInt(a+a,16)/255)]}return null},r.parse6BitsHEX=function(n){var e=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i.exec(n);if(e){var a=t(e[4],"ff");return[r._parseResStrForRgb(parseInt(e[1],16)),r._parseResStrForRgb(parseInt(e[2],16)),r._parseResStrForRgb(parseInt(e[3],16)),r._parsePercent(parseInt(a,16)/255)]}return null},r.parseRGBA=function(t){var n=/^rgba?\(([0-9.]+%?),([0-9.]+%?),([0-9.]+%?)(?:,([0-9.]+%?))?\)$/i.exec(t);return n?[r._parseResStrForRgb(n[1]),r._parseResStrForRgb(n[2]),r._parseResStrForRgb(n[3]),r._parsePercent(n[4])]:null},r.parseHSLA=function(t){var n=/^hsla?\(([0-9.]+)(?:deg)?,([0-9.]+%?),([0-9.]+%?)(?:,([0-9.]+%?))?\)$/i.exec(t);return n?[r._parseResStrForHue(n[1]),r._parsePercent(n[2]),r._parsePercent(n[3]),r._parsePercent(n[4])]:null},r.parseHWB=function(t){var n=/^hwb\s?\(\s?([0-9.]+)(?:deg)?\s([0-9.]+%?)\s([0-9.]+%?)\s?(?:\/\s?([0-9.]+%?))?\s?\)$/i.exec(t);return n?[r._parseResStrForHue(n[1]),r._parsePercent(n[2]),r._parsePercent(n[3]),r._parsePercent(n[4])]:null},r.parseRGBA2=function(t){var n=/^rgba?\s?\(\s?([0-9.]+%?)\s?([0-9.]+%?)\s?([0-9.]+%?)(?:\s?\/\s?([0-9.]+%?))?\s?\)$/i.exec(t);return n?[r._parseResStrForRgb(n[1]),r._parseResStrForRgb(n[2]),r._parseResStrForRgb(n[3]),r._parsePercent(n[4])]:null},r.parseHSLA2=function(t){var n=/^hsla?\s?\(\s?([0-9.]+)(?:deg)?\s([0-9.]+%?)\s([0-9.]+%?)\s?(?:\/\s?([0-9.]+%?))?\s?\)$/i.exec(t);return n?[r._parseResStrForHue(n[1]),r._parsePercent(n[2]),r._parsePercent(n[3]),r._parsePercent(n[4])]:null},r._parseResStrForRgb=function(r){return"string"==typeof r&&(r=parseFloat(r)/("%"===r.substr(-1)?100/255:1)),isNaN(r)&&(r=1),a(0,255,r)},r._parseResStrForHue=function(r){return"string"==typeof r&&(r=parseFloat(r)),isNaN(r)&&(r=0),a(0,360,r)},r._parsePercent=function(r){return"string"==typeof r&&(r=parseFloat(r)/("%"===r.substr(-1)?100:1)),isNaN(r)&&(r=1),a(0,1,r)},r}(),s=function(){function n(r,t,n,e){this.r=255,this.g=255,this.b=255,this.a=1,this._outColorPrecision=2,this._outAlphaPrecision=2,this.setColor(r,t,n,e)}return n.prototype.setOutPrecision=function(t,n){return r.type("colorPrecision",t,"number"),r.type("outAlphaPrecision",n,"number"),r.numMinValue("colorPrecision",t,0),r.numMinValue("outAlphaPrecision",n,0),r.numIsInt("colorPrecision",t,!0),r.numIsInt("outAlphaPrecision",n,!0),this._outColorPrecision=t,this._outAlphaPrecision=n,this},n.prototype.setColor=function(r,n,e,o){return this.r=a(0,255,t(Number(r),0)),this.g=a(0,255,t(Number(n),0)),this.b=a(0,255,t(Number(e),0)),this.a=a(0,1,t(Number(o),1)),this},n.prototype.setAlpha=function(r){return this.a=a(0,1,t(Number(r),1)),this},n.prototype.setRed=function(r){return this.r=a(0,255,t(Number(r),0)),this},n.prototype.setGreen=function(r){return this.g=a(0,255,t(Number(r),0)),this},n.prototype.setBlue=function(r){return this.b=a(0,255,t(Number(r),0)),this},n.prototype.toRGBA=function(){var r=this.toJson();return 1===r.a?"rgb(".concat(r.r,",").concat(r.g,",").concat(r.b,")"):"rgba(".concat(r.r,",").concat(r.g,",").concat(r.b,",").concat(r.a,")")},n.prototype.toString=function(){return this.toRGBA()},n.prototype.toNormalize=function(){return[o(this.r/255,this._outColorPrecision),o(this.g/255,this._outColorPrecision),o(this.b/255,this._outColorPrecision),o(this.a,this._outAlphaPrecision)]},n.prototype.toHEX=function(){var r=this.toJson(),t=r.r.toString(16);t.length<2&&(t="0".concat(t));var n=r.g.toString(16);n.length<2&&(n="0".concat(n));var e=r.b.toString(16);if(e.length<2&&(e="0".concat(e)),this.a<1){var a=parseInt((255*this.a).toFixed()).toString(16);return a.length<2&&(a="0".concat(a)),"#".concat(t).concat(n).concat(e).concat(a)}return"#".concat(t).concat(n).concat(e)},n.prototype.toArray=function(){var r=this.toJson();return[r.r,r.g,r.b,r.a]},n.prototype.toJson=function(){return{r:o(this.r,this._outColorPrecision),g:o(this.g,this._outColorPrecision),b:o(this.b,this._outColorPrecision),a:o(this.a,this._outAlphaPrecision)}},n.prototype.toInvert=function(){return new n(255-this.r,255-this.g,255-this.b,1-this.a)},n.prototype.clone=function(){return new n(this.r,this.g,this.b,this.a)},n.prototype.equals=function(r){if(this===r)return!0;var t=this.toJson(),n=r.toJson();return t.r===n.r&&t.g===n.g&&t.b===n.g&&t.a===n.a},n.prototype.setInvert=function(){return this.r=255-this.r,this.g=255-this.g,this.b=255-this.b,this.a=1-this.a,this},n.prototype.multiplyByScalar=function(r,t){void 0===t&&(t=!0);var n=this.r*r,e=this.g*r,a=this.b*r,o=t?this.a*r:this.a;return this.setColor(n,e,a,o)},n.prototype.divideByScalar=function(r,t){void 0===t&&(t=!0);var n=this.r/r,e=this.g/r,a=this.b/r,o=t?this.a/r:this.a;return this.setColor(n,e,a,o)},n.prototype.add=function(r,t){void 0===t&&(t=!0);var n=this.r+r.r,e=this.g+r.g,a=this.b+r.b,o=t?this.a+r.a:this.a;return this.setColor(n,e,a,o)},n.prototype.subtract=function(r,t){void 0===t&&(t=!0);var n=this.r-r.r,e=this.g-r.g,a=this.b-r.b,o=t?this.a-r.a:this.a;return this.setColor(n,e,a,o)},n.prototype.multiply=function(r,t){void 0===t&&(t=!0);var n=this.r*r.r,e=this.g*r.g,a=this.b*r.b,o=t?this.a*r.a:this.a;return this.setColor(n,e,a,o)},n.prototype.divide=function(r,t){void 0===t&&(t=!0);var n=this.r/r.r,e=this.g/r.g,a=this.b/r.b,o=t?this.a/r.a:this.a;return this.setColor(n,e,a,o)},n.prototype.addNumberForRGB=function(r){return this.r=this.r+r,this.g=this.g+r,this.b=this.b+r,this},n.prototype.addNumberForAlpha=function(r){return this.a=this.a+r,this},n.parseHEX=function(r){var t=i.clearStrSpace(r),e=i.parse3BitsHEX(t);return e||(e=i.parse6BitsHEX(t)),e&&n.fromArray(e)},n.parseRGBA=function(r){var t=i.clearStrSpace(r),e=i.parseRGBA(t);if(!e){var a=i.trimStr(r);e=i.parseRGBA2(a)}return e&&n.fromArray(e)},n.fromJson=function(r){return new n(r.r,r.g,r.b,r.a)},n.fromArray=function(r){return new n(r[0],r[1],r[2],r[3])},n.fromRandom=function(r,t){return new n(Math.random()*Math.abs(t.r-r.r)+Math.min(r.r,t.r),Math.random()*Math.abs(t.g-r.g)+Math.min(r.g,t.g),Math.random()*Math.abs(t.b-r.b)+Math.min(r.b,t.b),Math.random()*Math.abs(t.a-r.a)+Math.min(r.a,t.a))},n.fromNormalize=function(r){var t=255*r[0],e=255*r[1],a=255*r[2],o=r[3];return n.fromArray([t,e,a,o])},n}(),u=n(907),c=n.n(u);function l(r){var t=i.clearStrSpace(r),n=c().keyword.rgb(t);return n&&M(n)}function h(r){return s.parseHEX(r)}function f(r){return s.parseRGBA(r)}function p(r){var t=i.clearStrSpace(r),n=i.parseHSLA(t);if(!n){var e=i.trimStr(r);n=i.parseHSLA2(e)}return n&&y(n[0],n[1],n[2],n[3])}function b(r){var t=i.trimStr(r),n=i.parseHWB(t);return n&&d(n[0],n[1],n[2],n[3])}function g(t){return r.type("color",t,"string"),h(t)||f(t)||l(t)||p(t)||b(t)}function v(r){return g(r)}function y(r,n,e,o){var i=c().hsl.rgb(a(0,360,r),a(0,100,100*n),a(0,100,100*e));return new s(i[0],i[1],i[2],t(Number(o),1))}function d(r,n,e,o){var i=c().hwb.rgb(a(0,360,r),a(0,100,100*n),a(0,100,100*e));return new s(i[0],i[1],i[2],t(Number(o),1))}function m(r,t){if("string"==typeof r&&(r=g(r)),"string"==typeof t&&(t=g(t)),!r||!t)throw new Error("fail to create object from random");return s.fromRandom(r,t)}function w(r){return s.fromJson(r)}function M(r){return s.fromArray(r)}}(),e}()}));
|
package/example.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: roman_123
|
|
3
3
|
* @Description:
|
|
4
4
|
* @Date: 2022-12-06 11:15:17
|
|
5
|
-
* @LastEditTime: 2023-
|
|
5
|
+
* @LastEditTime: 2023-06-02 16:27:46
|
|
6
6
|
-->
|
|
7
7
|
<!DOCTYPE html>
|
|
8
8
|
<html lang="en">
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
<body>
|
|
24
24
|
<h2>f12 to view console log</h2>
|
|
25
25
|
<script>
|
|
26
|
-
const
|
|
27
|
-
console.log(
|
|
26
|
+
const cssColorParser = new Parser.CssColorParser(255, 255, 255, 1)
|
|
27
|
+
console.log(cssColorParser.toHEX())
|
|
28
28
|
const parser0 = Parser.fromColorStr('blue').toRGBA()
|
|
29
29
|
console.log(parser0)
|
|
30
30
|
const parser1 = Parser.fromColorStr('blue')
|