css-color-parser-h 2.0.4 → 3.0.1
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 +219 -143
- package/dist/css-color-parser-h.cjs +2550 -0
- package/dist/css-color-parser-h.min.cjs +1 -0
- package/dist/css-color-parser-h.min.mjs +1 -0
- package/dist/css-color-parser-h.mjs +2532 -0
- package/dist/css-color-parser-h.umd.js +741 -154
- package/dist/css-color-parser-h.umd.min.js +1 -1
- package/example.html +9 -47
- package/package.json +3 -2
- package/readme.md +52 -41
- package/dist/css-color-parser-h.common.js +0 -841
- package/dist/css-color-parser-h.common.min.js +0 -1
|
@@ -1183,18 +1183,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1183
1183
|
// EXPORTS
|
|
1184
1184
|
__webpack_require__.d(__webpack_exports__, {
|
|
1185
1185
|
"CssColorParser": function() { return /* reexport */ src_CssColorParser; },
|
|
1186
|
-
"
|
|
1187
|
-
"fromColorStr": function() { return /* reexport */ fromColorStr; },
|
|
1188
|
-
"fromHSL": function() { return /* reexport */ fromHSL; },
|
|
1189
|
-
"fromHWB": function() { return /* reexport */ fromHWB; },
|
|
1190
|
-
"fromJson": function() { return /* reexport */ fromJson; },
|
|
1191
|
-
"fromRandom": function() { return /* reexport */ fromRandom; },
|
|
1192
|
-
"parseCssColorStr": function() { return /* reexport */ parseCssColorStr; },
|
|
1193
|
-
"parseHEX": function() { return /* reexport */ parseHEX; },
|
|
1194
|
-
"parseHSLA": function() { return /* reexport */ parseHSLA; },
|
|
1195
|
-
"parseHWB": function() { return /* reexport */ parseHWB; },
|
|
1196
|
-
"parseKeyWord": function() { return /* reexport */ parseKeyWord; },
|
|
1197
|
-
"parseRGBA": function() { return /* reexport */ parseRGBA; }
|
|
1186
|
+
"CssColorParserPlus": function() { return /* reexport */ src_CssColorParserPlus; }
|
|
1198
1187
|
});
|
|
1199
1188
|
|
|
1200
1189
|
;// CONCATENATED MODULE: ./src/utils/common.ts
|
|
@@ -1414,12 +1403,12 @@ var CssColorStringParser = /** @class */ (function () {
|
|
|
1414
1403
|
|
|
1415
1404
|
;// CONCATENATED MODULE: ./src/CssColorParser.ts
|
|
1416
1405
|
/*
|
|
1417
|
-
* @Descripttion:
|
|
1406
|
+
* @Descripttion: 颜色解析器(轻量)
|
|
1418
1407
|
* @version: 1.0.0
|
|
1419
1408
|
* @Author: roman_123
|
|
1420
1409
|
* @Date: 2021-01-19 09:22:11
|
|
1421
|
-
* @LastEditors:
|
|
1422
|
-
* @LastEditTime: 2023-06-
|
|
1410
|
+
* @LastEditors: Please set LastEditors
|
|
1411
|
+
* @LastEditTime: 2023-06-27 19:01:50
|
|
1423
1412
|
*/
|
|
1424
1413
|
|
|
1425
1414
|
|
|
@@ -1579,7 +1568,7 @@ var CssColorParser = /** @class */ (function () {
|
|
|
1579
1568
|
};
|
|
1580
1569
|
};
|
|
1581
1570
|
/**
|
|
1582
|
-
* @description:
|
|
1571
|
+
* @description: 返回取反色后的新的实例
|
|
1583
1572
|
* @return {CssColorParser}
|
|
1584
1573
|
*/
|
|
1585
1574
|
CssColorParser.prototype.toInvert = function () {
|
|
@@ -1808,158 +1797,756 @@ var CssColorParser = /** @class */ (function () {
|
|
|
1808
1797
|
}());
|
|
1809
1798
|
/* harmony default export */ var src_CssColorParser = (CssColorParser);
|
|
1810
1799
|
|
|
1800
|
+
;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.js
|
|
1801
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
1802
|
+
/******************************************************************************
|
|
1803
|
+
Copyright (c) Microsoft Corporation.
|
|
1804
|
+
|
|
1805
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1806
|
+
purpose with or without fee is hereby granted.
|
|
1807
|
+
|
|
1808
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1809
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1810
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1811
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1812
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1813
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1814
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1815
|
+
***************************************************************************** */
|
|
1816
|
+
/* global Reflect, Promise */
|
|
1817
|
+
|
|
1818
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
1819
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
1820
|
+
__proto__: []
|
|
1821
|
+
} instanceof Array && function (d, b) {
|
|
1822
|
+
d.__proto__ = b;
|
|
1823
|
+
} || function (d, b) {
|
|
1824
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
1825
|
+
};
|
|
1826
|
+
return _extendStatics(d, b);
|
|
1827
|
+
};
|
|
1828
|
+
function __extends(d, b) {
|
|
1829
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1830
|
+
_extendStatics(d, b);
|
|
1831
|
+
function __() {
|
|
1832
|
+
this.constructor = d;
|
|
1833
|
+
}
|
|
1834
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1835
|
+
}
|
|
1836
|
+
var _assign = function __assign() {
|
|
1837
|
+
_assign = Object.assign || function __assign(t) {
|
|
1838
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1839
|
+
s = arguments[i];
|
|
1840
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
1841
|
+
}
|
|
1842
|
+
return t;
|
|
1843
|
+
};
|
|
1844
|
+
return _assign.apply(this, arguments);
|
|
1845
|
+
};
|
|
1846
|
+
|
|
1847
|
+
function __rest(s, e) {
|
|
1848
|
+
var t = {};
|
|
1849
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
1850
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1851
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
1852
|
+
}
|
|
1853
|
+
return t;
|
|
1854
|
+
}
|
|
1855
|
+
function __decorate(decorators, target, key, desc) {
|
|
1856
|
+
var c = arguments.length,
|
|
1857
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
1858
|
+
d;
|
|
1859
|
+
if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1860
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1861
|
+
}
|
|
1862
|
+
function __param(paramIndex, decorator) {
|
|
1863
|
+
return function (target, key) {
|
|
1864
|
+
decorator(target, key, paramIndex);
|
|
1865
|
+
};
|
|
1866
|
+
}
|
|
1867
|
+
function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
1868
|
+
function accept(f) {
|
|
1869
|
+
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
1870
|
+
return f;
|
|
1871
|
+
}
|
|
1872
|
+
var kind = contextIn.kind,
|
|
1873
|
+
key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
1874
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
1875
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
1876
|
+
var _,
|
|
1877
|
+
done = false;
|
|
1878
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1879
|
+
var context = {};
|
|
1880
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
1881
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
1882
|
+
context.addInitializer = function (f) {
|
|
1883
|
+
if (done) throw new TypeError("Cannot add initializers after decoration has completed");
|
|
1884
|
+
extraInitializers.push(accept(f || null));
|
|
1885
|
+
};
|
|
1886
|
+
var result = (0, decorators[i])(kind === "accessor" ? {
|
|
1887
|
+
get: descriptor.get,
|
|
1888
|
+
set: descriptor.set
|
|
1889
|
+
} : descriptor[key], context);
|
|
1890
|
+
if (kind === "accessor") {
|
|
1891
|
+
if (result === void 0) continue;
|
|
1892
|
+
if (result === null || _typeof(result) !== "object") throw new TypeError("Object expected");
|
|
1893
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
1894
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
1895
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
1896
|
+
} else if (_ = accept(result)) {
|
|
1897
|
+
if (kind === "field") initializers.unshift(_);else descriptor[key] = _;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
1901
|
+
done = true;
|
|
1902
|
+
}
|
|
1903
|
+
;
|
|
1904
|
+
function __runInitializers(thisArg, initializers, value) {
|
|
1905
|
+
var useValue = arguments.length > 2;
|
|
1906
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
1907
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
1908
|
+
}
|
|
1909
|
+
return useValue ? value : void 0;
|
|
1910
|
+
}
|
|
1911
|
+
;
|
|
1912
|
+
function __propKey(x) {
|
|
1913
|
+
return _typeof(x) === "symbol" ? x : "".concat(x);
|
|
1914
|
+
}
|
|
1915
|
+
;
|
|
1916
|
+
function __setFunctionName(f, name, prefix) {
|
|
1917
|
+
if (_typeof(name) === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
1918
|
+
return Object.defineProperty(f, "name", {
|
|
1919
|
+
configurable: true,
|
|
1920
|
+
value: prefix ? "".concat(prefix, " ", name) : name
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
;
|
|
1924
|
+
function __metadata(metadataKey, metadataValue) {
|
|
1925
|
+
if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
1926
|
+
}
|
|
1927
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1928
|
+
function adopt(value) {
|
|
1929
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
1930
|
+
resolve(value);
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1934
|
+
function fulfilled(value) {
|
|
1935
|
+
try {
|
|
1936
|
+
step(generator.next(value));
|
|
1937
|
+
} catch (e) {
|
|
1938
|
+
reject(e);
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
function rejected(value) {
|
|
1942
|
+
try {
|
|
1943
|
+
step(generator["throw"](value));
|
|
1944
|
+
} catch (e) {
|
|
1945
|
+
reject(e);
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
function step(result) {
|
|
1949
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1950
|
+
}
|
|
1951
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
function __generator(thisArg, body) {
|
|
1955
|
+
var _ = {
|
|
1956
|
+
label: 0,
|
|
1957
|
+
sent: function sent() {
|
|
1958
|
+
if (t[0] & 1) throw t[1];
|
|
1959
|
+
return t[1];
|
|
1960
|
+
},
|
|
1961
|
+
trys: [],
|
|
1962
|
+
ops: []
|
|
1963
|
+
},
|
|
1964
|
+
f,
|
|
1965
|
+
y,
|
|
1966
|
+
t,
|
|
1967
|
+
g;
|
|
1968
|
+
return g = {
|
|
1969
|
+
next: verb(0),
|
|
1970
|
+
"throw": verb(1),
|
|
1971
|
+
"return": verb(2)
|
|
1972
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
1973
|
+
return this;
|
|
1974
|
+
}), g;
|
|
1975
|
+
function verb(n) {
|
|
1976
|
+
return function (v) {
|
|
1977
|
+
return step([n, v]);
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
function step(op) {
|
|
1981
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1982
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
1983
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1984
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1985
|
+
switch (op[0]) {
|
|
1986
|
+
case 0:
|
|
1987
|
+
case 1:
|
|
1988
|
+
t = op;
|
|
1989
|
+
break;
|
|
1990
|
+
case 4:
|
|
1991
|
+
_.label++;
|
|
1992
|
+
return {
|
|
1993
|
+
value: op[1],
|
|
1994
|
+
done: false
|
|
1995
|
+
};
|
|
1996
|
+
case 5:
|
|
1997
|
+
_.label++;
|
|
1998
|
+
y = op[1];
|
|
1999
|
+
op = [0];
|
|
2000
|
+
continue;
|
|
2001
|
+
case 7:
|
|
2002
|
+
op = _.ops.pop();
|
|
2003
|
+
_.trys.pop();
|
|
2004
|
+
continue;
|
|
2005
|
+
default:
|
|
2006
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
2007
|
+
_ = 0;
|
|
2008
|
+
continue;
|
|
2009
|
+
}
|
|
2010
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
2011
|
+
_.label = op[1];
|
|
2012
|
+
break;
|
|
2013
|
+
}
|
|
2014
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
2015
|
+
_.label = t[1];
|
|
2016
|
+
t = op;
|
|
2017
|
+
break;
|
|
2018
|
+
}
|
|
2019
|
+
if (t && _.label < t[2]) {
|
|
2020
|
+
_.label = t[2];
|
|
2021
|
+
_.ops.push(op);
|
|
2022
|
+
break;
|
|
2023
|
+
}
|
|
2024
|
+
if (t[2]) _.ops.pop();
|
|
2025
|
+
_.trys.pop();
|
|
2026
|
+
continue;
|
|
2027
|
+
}
|
|
2028
|
+
op = body.call(thisArg, _);
|
|
2029
|
+
} catch (e) {
|
|
2030
|
+
op = [6, e];
|
|
2031
|
+
y = 0;
|
|
2032
|
+
} finally {
|
|
2033
|
+
f = t = 0;
|
|
2034
|
+
}
|
|
2035
|
+
if (op[0] & 5) throw op[1];
|
|
2036
|
+
return {
|
|
2037
|
+
value: op[0] ? op[1] : void 0,
|
|
2038
|
+
done: true
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
var __createBinding = Object.create ? function (o, m, k, k2) {
|
|
2043
|
+
if (k2 === undefined) k2 = k;
|
|
2044
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2045
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2046
|
+
desc = {
|
|
2047
|
+
enumerable: true,
|
|
2048
|
+
get: function get() {
|
|
2049
|
+
return m[k];
|
|
2050
|
+
}
|
|
2051
|
+
};
|
|
2052
|
+
}
|
|
2053
|
+
Object.defineProperty(o, k2, desc);
|
|
2054
|
+
} : function (o, m, k, k2) {
|
|
2055
|
+
if (k2 === undefined) k2 = k;
|
|
2056
|
+
o[k2] = m[k];
|
|
2057
|
+
};
|
|
2058
|
+
function __exportStar(m, o) {
|
|
2059
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
|
|
2060
|
+
}
|
|
2061
|
+
function __values(o) {
|
|
2062
|
+
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
2063
|
+
m = s && o[s],
|
|
2064
|
+
i = 0;
|
|
2065
|
+
if (m) return m.call(o);
|
|
2066
|
+
if (o && typeof o.length === "number") return {
|
|
2067
|
+
next: function next() {
|
|
2068
|
+
if (o && i >= o.length) o = void 0;
|
|
2069
|
+
return {
|
|
2070
|
+
value: o && o[i++],
|
|
2071
|
+
done: !o
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
};
|
|
2075
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
2076
|
+
}
|
|
2077
|
+
function __read(o, n) {
|
|
2078
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
2079
|
+
if (!m) return o;
|
|
2080
|
+
var i = m.call(o),
|
|
2081
|
+
r,
|
|
2082
|
+
ar = [],
|
|
2083
|
+
e;
|
|
2084
|
+
try {
|
|
2085
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
2086
|
+
} catch (error) {
|
|
2087
|
+
e = {
|
|
2088
|
+
error: error
|
|
2089
|
+
};
|
|
2090
|
+
} finally {
|
|
2091
|
+
try {
|
|
2092
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
2093
|
+
} finally {
|
|
2094
|
+
if (e) throw e.error;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
return ar;
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
/** @deprecated */
|
|
2101
|
+
function __spread() {
|
|
2102
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
2103
|
+
return ar;
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
/** @deprecated */
|
|
2107
|
+
function __spreadArrays() {
|
|
2108
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
2109
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
|
|
2110
|
+
return r;
|
|
2111
|
+
}
|
|
2112
|
+
function __spreadArray(to, from, pack) {
|
|
2113
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2114
|
+
if (ar || !(i in from)) {
|
|
2115
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2116
|
+
ar[i] = from[i];
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2120
|
+
}
|
|
2121
|
+
function __await(v) {
|
|
2122
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
2123
|
+
}
|
|
2124
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
2125
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
2126
|
+
var g = generator.apply(thisArg, _arguments || []),
|
|
2127
|
+
i,
|
|
2128
|
+
q = [];
|
|
2129
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
|
|
2130
|
+
return this;
|
|
2131
|
+
}, i;
|
|
2132
|
+
function verb(n) {
|
|
2133
|
+
if (g[n]) i[n] = function (v) {
|
|
2134
|
+
return new Promise(function (a, b) {
|
|
2135
|
+
q.push([n, v, a, b]) > 1 || resume(n, v);
|
|
2136
|
+
});
|
|
2137
|
+
};
|
|
2138
|
+
}
|
|
2139
|
+
function resume(n, v) {
|
|
2140
|
+
try {
|
|
2141
|
+
step(g[n](v));
|
|
2142
|
+
} catch (e) {
|
|
2143
|
+
settle(q[0][3], e);
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
function step(r) {
|
|
2147
|
+
r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
|
|
2148
|
+
}
|
|
2149
|
+
function fulfill(value) {
|
|
2150
|
+
resume("next", value);
|
|
2151
|
+
}
|
|
2152
|
+
function reject(value) {
|
|
2153
|
+
resume("throw", value);
|
|
2154
|
+
}
|
|
2155
|
+
function settle(f, v) {
|
|
2156
|
+
if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]);
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
function __asyncDelegator(o) {
|
|
2160
|
+
var i, p;
|
|
2161
|
+
return i = {}, verb("next"), verb("throw", function (e) {
|
|
2162
|
+
throw e;
|
|
2163
|
+
}), verb("return"), i[Symbol.iterator] = function () {
|
|
2164
|
+
return this;
|
|
2165
|
+
}, i;
|
|
2166
|
+
function verb(n, f) {
|
|
2167
|
+
i[n] = o[n] ? function (v) {
|
|
2168
|
+
return (p = !p) ? {
|
|
2169
|
+
value: __await(o[n](v)),
|
|
2170
|
+
done: false
|
|
2171
|
+
} : f ? f(v) : v;
|
|
2172
|
+
} : f;
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
function __asyncValues(o) {
|
|
2176
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
2177
|
+
var m = o[Symbol.asyncIterator],
|
|
2178
|
+
i;
|
|
2179
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () {
|
|
2180
|
+
return this;
|
|
2181
|
+
}, i);
|
|
2182
|
+
function verb(n) {
|
|
2183
|
+
i[n] = o[n] && function (v) {
|
|
2184
|
+
return new Promise(function (resolve, reject) {
|
|
2185
|
+
v = o[n](v), settle(resolve, reject, v.done, v.value);
|
|
2186
|
+
});
|
|
2187
|
+
};
|
|
2188
|
+
}
|
|
2189
|
+
function settle(resolve, reject, d, v) {
|
|
2190
|
+
Promise.resolve(v).then(function (v) {
|
|
2191
|
+
resolve({
|
|
2192
|
+
value: v,
|
|
2193
|
+
done: d
|
|
2194
|
+
});
|
|
2195
|
+
}, reject);
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
function __makeTemplateObject(cooked, raw) {
|
|
2199
|
+
if (Object.defineProperty) {
|
|
2200
|
+
Object.defineProperty(cooked, "raw", {
|
|
2201
|
+
value: raw
|
|
2202
|
+
});
|
|
2203
|
+
} else {
|
|
2204
|
+
cooked.raw = raw;
|
|
2205
|
+
}
|
|
2206
|
+
return cooked;
|
|
2207
|
+
}
|
|
2208
|
+
;
|
|
2209
|
+
var __setModuleDefault = Object.create ? function (o, v) {
|
|
2210
|
+
Object.defineProperty(o, "default", {
|
|
2211
|
+
enumerable: true,
|
|
2212
|
+
value: v
|
|
2213
|
+
});
|
|
2214
|
+
} : function (o, v) {
|
|
2215
|
+
o["default"] = v;
|
|
2216
|
+
};
|
|
2217
|
+
function __importStar(mod) {
|
|
2218
|
+
if (mod && mod.__esModule) return mod;
|
|
2219
|
+
var result = {};
|
|
2220
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
2221
|
+
__setModuleDefault(result, mod);
|
|
2222
|
+
return result;
|
|
2223
|
+
}
|
|
2224
|
+
function __importDefault(mod) {
|
|
2225
|
+
return mod && mod.__esModule ? mod : {
|
|
2226
|
+
"default": mod
|
|
2227
|
+
};
|
|
2228
|
+
}
|
|
2229
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
2230
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
2231
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
2232
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
2233
|
+
}
|
|
2234
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
2235
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
2236
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
2237
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
2238
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
2239
|
+
}
|
|
2240
|
+
function __classPrivateFieldIn(state, receiver) {
|
|
2241
|
+
if (receiver === null || _typeof(receiver) !== "object" && typeof receiver !== "function") throw new TypeError("Cannot use 'in' operator on non-object");
|
|
2242
|
+
return typeof state === "function" ? receiver === state : state.has(receiver);
|
|
2243
|
+
}
|
|
2244
|
+
/* harmony default export */ var tslib_es6 = ({
|
|
2245
|
+
__extends: __extends,
|
|
2246
|
+
__assign: _assign,
|
|
2247
|
+
__rest: __rest,
|
|
2248
|
+
__decorate: __decorate,
|
|
2249
|
+
__param: __param,
|
|
2250
|
+
__metadata: __metadata,
|
|
2251
|
+
__awaiter: __awaiter,
|
|
2252
|
+
__generator: __generator,
|
|
2253
|
+
__createBinding: __createBinding,
|
|
2254
|
+
__exportStar: __exportStar,
|
|
2255
|
+
__values: __values,
|
|
2256
|
+
__read: __read,
|
|
2257
|
+
__spread: __spread,
|
|
2258
|
+
__spreadArrays: __spreadArrays,
|
|
2259
|
+
__spreadArray: __spreadArray,
|
|
2260
|
+
__await: __await,
|
|
2261
|
+
__asyncGenerator: __asyncGenerator,
|
|
2262
|
+
__asyncDelegator: __asyncDelegator,
|
|
2263
|
+
__asyncValues: __asyncValues,
|
|
2264
|
+
__makeTemplateObject: __makeTemplateObject,
|
|
2265
|
+
__importStar: __importStar,
|
|
2266
|
+
__importDefault: __importDefault,
|
|
2267
|
+
__classPrivateFieldGet: __classPrivateFieldGet,
|
|
2268
|
+
__classPrivateFieldSet: __classPrivateFieldSet,
|
|
2269
|
+
__classPrivateFieldIn: __classPrivateFieldIn
|
|
2270
|
+
});
|
|
1811
2271
|
// EXTERNAL MODULE: ./node_modules/color-convert/index.js
|
|
1812
2272
|
var color_convert = __webpack_require__(907);
|
|
1813
2273
|
var color_convert_default = /*#__PURE__*/__webpack_require__.n(color_convert);
|
|
1814
|
-
;// CONCATENATED MODULE: ./src/
|
|
2274
|
+
;// CONCATENATED MODULE: ./src/CssColorParserPlus.ts
|
|
2275
|
+
/*
|
|
2276
|
+
* @Descripttion: 颜色解析器(增强)
|
|
2277
|
+
* @version: 1.0.0
|
|
2278
|
+
* @Author: roman_123
|
|
2279
|
+
* @Date: 2021-01-19 09:22:11
|
|
2280
|
+
* @LastEditors: Please set LastEditors
|
|
2281
|
+
* @LastEditTime: 2023-06-27 18:53:31
|
|
2282
|
+
*/
|
|
1815
2283
|
|
|
1816
2284
|
|
|
1817
2285
|
|
|
1818
2286
|
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
*/
|
|
1825
|
-
function parseKeyWord(v) {
|
|
1826
|
-
var cssStr = CssColorStringParser.clearStrSpace(v);
|
|
1827
|
-
var res = color_convert_default().keyword.rgb(cssStr);
|
|
1828
|
-
return res && fromArray(res);
|
|
1829
|
-
}
|
|
1830
|
-
/**
|
|
1831
|
-
* @description: 解析16进制字符串
|
|
1832
|
-
* @param {string} v
|
|
1833
|
-
* @return {CssColorParser}
|
|
1834
|
-
* @example: parseHEX('#FFF')
|
|
1835
|
-
*/
|
|
1836
|
-
function parseHEX(v) {
|
|
1837
|
-
return src_CssColorParser.parseHEX(v);
|
|
1838
|
-
}
|
|
1839
|
-
/**
|
|
1840
|
-
* @description: 解析RGBA
|
|
1841
|
-
* @param {string} v
|
|
1842
|
-
* @return {CssColorParser}
|
|
1843
|
-
* @example: parseRGBA('rgba(255,255,255,1)')
|
|
1844
|
-
*/
|
|
1845
|
-
function parseRGBA(v) {
|
|
1846
|
-
return src_CssColorParser.parseRGBA(v);
|
|
1847
|
-
}
|
|
1848
|
-
/**
|
|
1849
|
-
* @description: 解析HSLA
|
|
1850
|
-
* @param {string} v
|
|
1851
|
-
* @return {CssColorParser}
|
|
1852
|
-
* @example: parseHSLA('hsla(215,85%,62%,0.8)')
|
|
1853
|
-
*/
|
|
1854
|
-
function parseHSLA(v) {
|
|
1855
|
-
var cssStr = CssColorStringParser.clearStrSpace(v);
|
|
1856
|
-
var res = CssColorStringParser.parseHSLA(cssStr);
|
|
1857
|
-
if (!res) {
|
|
1858
|
-
var cssStr2 = CssColorStringParser.trimStr(v);
|
|
1859
|
-
res = CssColorStringParser.parseHSLA2(cssStr2);
|
|
1860
|
-
}
|
|
1861
|
-
return res && fromHSL(res[0], res[1], res[2], res[3]);
|
|
1862
|
-
}
|
|
1863
|
-
/**
|
|
1864
|
-
* @description: 解析HWB
|
|
1865
|
-
* @param {string} v
|
|
1866
|
-
* @return {CssColorParser}
|
|
1867
|
-
* @example: parseHWB('hwb(215deg 30% 6% / 80%)')
|
|
1868
|
-
*/
|
|
1869
|
-
function parseHWB(v) {
|
|
1870
|
-
var cssStr2 = CssColorStringParser.trimStr(v);
|
|
1871
|
-
var res = CssColorStringParser.parseHWB(cssStr2);
|
|
1872
|
-
return res && fromHWB(res[0], res[1], res[2], res[3]);
|
|
1873
|
-
}
|
|
1874
|
-
/**
|
|
1875
|
-
* @description: 将css字符串转换为解析对象
|
|
1876
|
-
* @param {string} v
|
|
1877
|
-
* @return {CssColorParser}
|
|
1878
|
-
* @example: parseCssColorStr('rgba(255,255,255,1)')
|
|
1879
|
-
*/
|
|
1880
|
-
function parseCssColorStr(v) {
|
|
1881
|
-
Check.type('color', v, 'string');
|
|
1882
|
-
return parseHEX(v) || parseRGBA(v) || parseKeyWord(v) || parseHSLA(v) || parseHWB(v);
|
|
1883
|
-
}
|
|
1884
|
-
/**
|
|
1885
|
-
* **Deprecated method.** Use `parseCssColorStr()` instead.
|
|
1886
|
-
* @description: since 2.0.1
|
|
1887
|
-
* @deprecated
|
|
1888
|
-
* @param {string} v
|
|
1889
|
-
* @return {CssColorParser}
|
|
1890
|
-
* @example: fromColorStr('rgba(255,255,255,1)')
|
|
1891
|
-
*/
|
|
1892
|
-
function fromColorStr(v) {
|
|
1893
|
-
return parseCssColorStr(v);
|
|
1894
|
-
}
|
|
1895
|
-
/**
|
|
1896
|
-
* @description: 将HSL色彩模式转换为解析对象
|
|
1897
|
-
* @param {number} hue 色相
|
|
1898
|
-
* @param {number} saturation 饱和度
|
|
1899
|
-
* @param {number} lightness 亮度
|
|
1900
|
-
* @param {number} alpha 不透明度
|
|
1901
|
-
* @return {CssColorParser}
|
|
1902
|
-
* @example: fromHSL(0,1,1,1)
|
|
1903
|
-
*/
|
|
1904
|
-
function fromHSL(h, s, l, a) {
|
|
1905
|
-
var res = color_convert_default().hsl.rgb(limitNumber(0, 360, h), limitNumber(0, 100, s * 100), limitNumber(0, 100, l * 100));
|
|
1906
|
-
return new src_CssColorParser(res[0], res[1], res[2], defaultValue(Number(a), 1));
|
|
1907
|
-
}
|
|
1908
|
-
/**
|
|
1909
|
-
* @description: 将HWB色彩模式转换为解析对象
|
|
1910
|
-
* @param {number} h 色调
|
|
1911
|
-
* @param {number} w 白度
|
|
1912
|
-
* @param {number} b 黑度
|
|
1913
|
-
* @param {number} a 不透明度
|
|
1914
|
-
* @return {CssColorParser}
|
|
1915
|
-
* @example: fromHSL(0,1,1,1)
|
|
1916
|
-
*/
|
|
1917
|
-
function fromHWB(h, w, b, a) {
|
|
1918
|
-
var res = color_convert_default().hwb.rgb(limitNumber(0, 360, h), limitNumber(0, 100, w * 100), limitNumber(0, 100, b * 100));
|
|
1919
|
-
return new src_CssColorParser(res[0], res[1], res[2], defaultValue(Number(a), 1));
|
|
1920
|
-
}
|
|
1921
|
-
/**
|
|
1922
|
-
* @description: 产生随机颜色
|
|
1923
|
-
* @return {CssColorParser}
|
|
1924
|
-
* @example: fromRandom('#000', ''#fff)
|
|
1925
|
-
*/
|
|
1926
|
-
function fromRandom(color1, color2) {
|
|
1927
|
-
if (typeof color1 === 'string') {
|
|
1928
|
-
color1 = parseCssColorStr(color1);
|
|
1929
|
-
}
|
|
1930
|
-
if (typeof color2 === 'string') {
|
|
1931
|
-
color2 = parseCssColorStr(color2);
|
|
1932
|
-
}
|
|
1933
|
-
if (!color1 || !color2) {
|
|
1934
|
-
throw new Error('fail to create object from random');
|
|
2287
|
+
|
|
2288
|
+
var CssColorParserPlus = /** @class */ (function (_super) {
|
|
2289
|
+
__extends(CssColorParserPlus, _super);
|
|
2290
|
+
function CssColorParserPlus() {
|
|
2291
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1935
2292
|
}
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
}
|
|
1947
|
-
/**
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
2293
|
+
/**
|
|
2294
|
+
* @description: 返回取反色后的新的实例
|
|
2295
|
+
* @return {CssColorParserPlus}
|
|
2296
|
+
*/
|
|
2297
|
+
CssColorParserPlus.prototype.toInvert = function () {
|
|
2298
|
+
var r = 255 - this.r;
|
|
2299
|
+
var g = 255 - this.g;
|
|
2300
|
+
var b = 255 - this.b;
|
|
2301
|
+
var a = 1 - this.a;
|
|
2302
|
+
return new CssColorParserPlus(r, g, b, a);
|
|
2303
|
+
};
|
|
2304
|
+
/**
|
|
2305
|
+
* @description: 拷贝
|
|
2306
|
+
* @return {CssColorParserPlus}
|
|
2307
|
+
*/
|
|
2308
|
+
CssColorParserPlus.prototype.clone = function () {
|
|
2309
|
+
return new CssColorParserPlus(this.r, this.g, this.b, this.a);
|
|
2310
|
+
};
|
|
2311
|
+
/**
|
|
2312
|
+
* @description: 比较两个解析对象的数据是否相等
|
|
2313
|
+
* @param {string} color
|
|
2314
|
+
* @return {boolean}
|
|
2315
|
+
*/
|
|
2316
|
+
CssColorParserPlus.prototype.equals = function (color) {
|
|
2317
|
+
color = CssColorParserPlus.parseColor(color);
|
|
2318
|
+
if (this === color) {
|
|
2319
|
+
return true;
|
|
2320
|
+
}
|
|
2321
|
+
else {
|
|
2322
|
+
var json1 = this.toJson();
|
|
2323
|
+
var json2 = color.toJson();
|
|
2324
|
+
return (json1.r === json2.r &&
|
|
2325
|
+
json1.g === json2.g &&
|
|
2326
|
+
json1.b === json2.g &&
|
|
2327
|
+
json1.a === json2.a);
|
|
2328
|
+
}
|
|
2329
|
+
};
|
|
2330
|
+
/**
|
|
2331
|
+
* @description: 实例相加
|
|
2332
|
+
* @param {CssColorParser} colorParser
|
|
2333
|
+
* @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是)
|
|
2334
|
+
* @return {CssColorParser}
|
|
2335
|
+
*/
|
|
2336
|
+
CssColorParserPlus.prototype.add = function (color, isSetAlpha) {
|
|
2337
|
+
if (isSetAlpha === void 0) { isSetAlpha = true; }
|
|
2338
|
+
var colorParser = CssColorParserPlus.parseColor(color);
|
|
2339
|
+
return _super.prototype.add.call(this, colorParser, isSetAlpha);
|
|
2340
|
+
};
|
|
2341
|
+
/**
|
|
2342
|
+
* @description: 实例相减
|
|
2343
|
+
* @param {CssColorParser} colorParser
|
|
2344
|
+
* @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是)
|
|
2345
|
+
* @return {CssColorParser}
|
|
2346
|
+
*/
|
|
2347
|
+
CssColorParserPlus.prototype.subtract = function (color, isSetAlpha) {
|
|
2348
|
+
if (isSetAlpha === void 0) { isSetAlpha = true; }
|
|
2349
|
+
var colorParser = CssColorParserPlus.parseColor(color);
|
|
2350
|
+
return _super.prototype.subtract.call(this, colorParser, isSetAlpha);
|
|
2351
|
+
};
|
|
2352
|
+
/**
|
|
2353
|
+
* @description: 实例相乘
|
|
2354
|
+
* @param {CssColorParser} colorParser
|
|
2355
|
+
* @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是)
|
|
2356
|
+
* @return {CssColorParser}
|
|
2357
|
+
*/
|
|
2358
|
+
CssColorParserPlus.prototype.multiply = function (color, isSetAlpha) {
|
|
2359
|
+
if (isSetAlpha === void 0) { isSetAlpha = true; }
|
|
2360
|
+
var colorParser = CssColorParserPlus.parseColor(color);
|
|
2361
|
+
return _super.prototype.multiply.call(this, colorParser, isSetAlpha);
|
|
2362
|
+
};
|
|
2363
|
+
/**
|
|
2364
|
+
* @description: 实例相除
|
|
2365
|
+
* @param {CssColorParser} colorParser
|
|
2366
|
+
* @param {boolean} isSetAlpha 透明度值是否参与计算(默认:是)
|
|
2367
|
+
* @return {CssColorParser}
|
|
2368
|
+
*/
|
|
2369
|
+
CssColorParserPlus.prototype.divide = function (color, isSetAlpha) {
|
|
2370
|
+
if (isSetAlpha === void 0) { isSetAlpha = true; }
|
|
2371
|
+
var colorParser = CssColorParserPlus.parseColor(color);
|
|
2372
|
+
return _super.prototype.divide.call(this, colorParser, isSetAlpha);
|
|
2373
|
+
};
|
|
2374
|
+
/**
|
|
2375
|
+
* @description: 解析css颜色
|
|
2376
|
+
* @param {string} v
|
|
2377
|
+
* @return {CssColorParserPlus}
|
|
2378
|
+
* @example: parseCssColorStr('rgba(255,255,255,1)')
|
|
2379
|
+
*/
|
|
2380
|
+
CssColorParserPlus.parseColor = function (v) {
|
|
2381
|
+
if (v instanceof src_CssColorParser) {
|
|
2382
|
+
return v;
|
|
2383
|
+
}
|
|
2384
|
+
return CssColorParserPlus.parseCssColorStr(v);
|
|
2385
|
+
};
|
|
2386
|
+
/**
|
|
2387
|
+
* @description: 将css字符串转换为解析对象
|
|
2388
|
+
* @param {string} v
|
|
2389
|
+
* @return {CssColorParserPlus}
|
|
2390
|
+
* @example: parseCssColorStr('rgba(255,255,255,1)')
|
|
2391
|
+
*/
|
|
2392
|
+
CssColorParserPlus.parseCssColorStr = function (v) {
|
|
2393
|
+
Check.type('color', v, 'string');
|
|
2394
|
+
return (CssColorParserPlus.parseHEX(v) ||
|
|
2395
|
+
CssColorParserPlus.parseRGBA(v) ||
|
|
2396
|
+
CssColorParserPlus.parseKeyWord(v) ||
|
|
2397
|
+
CssColorParserPlus.parseHSLA(v) ||
|
|
2398
|
+
CssColorParserPlus.parseHWB(v));
|
|
2399
|
+
};
|
|
2400
|
+
/**
|
|
2401
|
+
* @description: 解析颜色关键字
|
|
2402
|
+
* @param {string} v
|
|
2403
|
+
* @return {CssColorParserPlus}
|
|
2404
|
+
* @example: parseKeyWord('red')
|
|
2405
|
+
*/
|
|
2406
|
+
CssColorParserPlus.parseKeyWord = function (v) {
|
|
2407
|
+
var cssStr = CssColorStringParser.clearStrSpace(v);
|
|
2408
|
+
var res = color_convert_default().keyword.rgb(cssStr);
|
|
2409
|
+
return res && CssColorParserPlus.fromArray(res);
|
|
2410
|
+
};
|
|
2411
|
+
/**
|
|
2412
|
+
* @description: 解析HSLA
|
|
2413
|
+
* @param {string} v
|
|
2414
|
+
* @return {CssColorParserPlus}
|
|
2415
|
+
* @example: parseHSLA('hsla(215,85%,62%,0.8)')
|
|
2416
|
+
*/
|
|
2417
|
+
CssColorParserPlus.parseHSLA = function (v) {
|
|
2418
|
+
var cssStr = CssColorStringParser.clearStrSpace(v);
|
|
2419
|
+
var res = CssColorStringParser.parseHSLA(cssStr);
|
|
2420
|
+
if (!res) {
|
|
2421
|
+
var cssStr2 = CssColorStringParser.trimStr(v);
|
|
2422
|
+
res = CssColorStringParser.parseHSLA2(cssStr2);
|
|
2423
|
+
}
|
|
2424
|
+
return res && CssColorParserPlus.fromHSL(res[0], res[1], res[2], res[3]);
|
|
2425
|
+
};
|
|
2426
|
+
/**
|
|
2427
|
+
* @description: 解析HWB
|
|
2428
|
+
* @param {string} v
|
|
2429
|
+
* @return {CssColorParserPlus}
|
|
2430
|
+
* @example: parseHWB('hwb(215deg 30% 6% / 80%)')
|
|
2431
|
+
*/
|
|
2432
|
+
CssColorParserPlus.parseHWB = function (v) {
|
|
2433
|
+
var cssStr2 = CssColorStringParser.trimStr(v);
|
|
2434
|
+
var res = CssColorStringParser.parseHWB(cssStr2);
|
|
2435
|
+
return res && CssColorParserPlus.fromHWB(res[0], res[1], res[2], res[3]);
|
|
2436
|
+
};
|
|
2437
|
+
/**
|
|
2438
|
+
* @description: 将HSL色彩模式转换为解析对象
|
|
2439
|
+
* @param {number} hue 色相
|
|
2440
|
+
* @param {number} saturation 饱和度
|
|
2441
|
+
* @param {number} lightness 亮度
|
|
2442
|
+
* @param {number} alpha 不透明度
|
|
2443
|
+
* @return {CssColorParserPlus}
|
|
2444
|
+
* @example: fromHSL(0,1,1,1)
|
|
2445
|
+
*/
|
|
2446
|
+
CssColorParserPlus.fromHSL = function (h, s, l, a) {
|
|
2447
|
+
var res = color_convert_default().hsl.rgb(limitNumber(0, 360, h), limitNumber(0, 100, s * 100), limitNumber(0, 100, l * 100));
|
|
2448
|
+
return new CssColorParserPlus(res[0], res[1], res[2], defaultValue(Number(a), 1));
|
|
2449
|
+
};
|
|
2450
|
+
/**
|
|
2451
|
+
* @description: 将HWB色彩模式转换为解析对象
|
|
2452
|
+
* @param {number} h 色调
|
|
2453
|
+
* @param {number} w 白度
|
|
2454
|
+
* @param {number} b 黑度
|
|
2455
|
+
* @param {number} a 不透明度
|
|
2456
|
+
* @return {CssColorParserPlus}
|
|
2457
|
+
* @example: fromHSL(0,1,1,1)
|
|
2458
|
+
*/
|
|
2459
|
+
CssColorParserPlus.fromHWB = function (h, w, b, a) {
|
|
2460
|
+
var res = color_convert_default().hwb.rgb(limitNumber(0, 360, h), limitNumber(0, 100, w * 100), limitNumber(0, 100, b * 100));
|
|
2461
|
+
return new CssColorParserPlus(res[0], res[1], res[2], defaultValue(Number(a), 1));
|
|
2462
|
+
};
|
|
2463
|
+
/**
|
|
2464
|
+
* @description: 解析16进制颜色
|
|
2465
|
+
* @param {string} v
|
|
2466
|
+
* @return {CssColorParserPlus}
|
|
2467
|
+
* @example: CssColorParserPlus.parseHEX('#FFF')
|
|
2468
|
+
*/
|
|
2469
|
+
CssColorParserPlus.parseHEX = function (v) {
|
|
2470
|
+
var cssStr = CssColorStringParser.clearStrSpace(v);
|
|
2471
|
+
var res = CssColorStringParser.parse3BitsHEX(cssStr);
|
|
2472
|
+
if (!res) {
|
|
2473
|
+
res = CssColorStringParser.parse6BitsHEX(cssStr);
|
|
2474
|
+
}
|
|
2475
|
+
return res && CssColorParserPlus.fromArray(res);
|
|
2476
|
+
};
|
|
2477
|
+
/**
|
|
2478
|
+
* @description: 解析rgba、rgb颜色
|
|
2479
|
+
* @param {string} v
|
|
2480
|
+
* @return {CssColorParserPlus}
|
|
2481
|
+
* @example: CssColorParserPlus.parseRGBA('rgba(255,255,255,1)')
|
|
2482
|
+
*/
|
|
2483
|
+
CssColorParserPlus.parseRGBA = function (v) {
|
|
2484
|
+
var cssStr = CssColorStringParser.clearStrSpace(v);
|
|
2485
|
+
var res = CssColorStringParser.parseRGBA(cssStr);
|
|
2486
|
+
if (!res) {
|
|
2487
|
+
var cssStr2 = CssColorStringParser.trimStr(v);
|
|
2488
|
+
res = CssColorStringParser.parseRGBA2(cssStr2);
|
|
2489
|
+
}
|
|
2490
|
+
return res && CssColorParserPlus.fromArray(res);
|
|
2491
|
+
};
|
|
2492
|
+
/**
|
|
2493
|
+
* @description: 将ColorJson格式的json数据转换为解析对象
|
|
2494
|
+
* @param {ColorJson} json
|
|
2495
|
+
* @return {CssColorParserPlus}
|
|
2496
|
+
* @example: CssColorParserPlus.fromJson({r: 255, g: 255, b: 255, a: 1})
|
|
2497
|
+
*/
|
|
2498
|
+
CssColorParserPlus.fromJson = function (json) {
|
|
2499
|
+
return new CssColorParserPlus(json.r, json.g, json.b, json.a);
|
|
2500
|
+
};
|
|
2501
|
+
/**
|
|
2502
|
+
* @description: 将RGBA数组转换为解析对象
|
|
2503
|
+
* @param {Array} color
|
|
2504
|
+
* @return {CssColorParserPlus}
|
|
2505
|
+
* @example: CssColorParserPlus.fromArray([255,255,255,1])
|
|
2506
|
+
*/
|
|
2507
|
+
CssColorParserPlus.fromArray = function (color) {
|
|
2508
|
+
return new CssColorParserPlus(color[0], color[1], color[2], color[3]);
|
|
2509
|
+
};
|
|
2510
|
+
/**
|
|
2511
|
+
* @description: 产生随机颜色
|
|
2512
|
+
* @return {CssColorParserPlus}
|
|
2513
|
+
* @example: CssColorParserPlus.fromRandom('black', new CssColorParserPlus(255,255,255,1))
|
|
2514
|
+
*/
|
|
2515
|
+
CssColorParserPlus.fromRandom = function (color1, color2) {
|
|
2516
|
+
color1 = CssColorParserPlus.parseColor(color1);
|
|
2517
|
+
color2 = CssColorParserPlus.parseColor(color2);
|
|
2518
|
+
var r = Math.random() * Math.abs(color2.r - color1.r) +
|
|
2519
|
+
Math.min(color1.r, color2.r);
|
|
2520
|
+
var g = Math.random() * Math.abs(color2.g - color1.g) +
|
|
2521
|
+
Math.min(color1.g, color2.g);
|
|
2522
|
+
var b = Math.random() * Math.abs(color2.b - color1.b) +
|
|
2523
|
+
Math.min(color1.b, color2.b);
|
|
2524
|
+
var a = Math.random() * Math.abs(color2.a - color1.a) +
|
|
2525
|
+
Math.min(color1.a, color2.a);
|
|
2526
|
+
return new CssColorParserPlus(r, g, b, a);
|
|
2527
|
+
};
|
|
2528
|
+
/**
|
|
2529
|
+
* @description: 颜色序列化数组转换为CssColorParserPlus对象实例
|
|
2530
|
+
* @param {array} colorArr
|
|
2531
|
+
* @example: CssColorParserPlus.fromNormaliz([1, 0, 0, 1])
|
|
2532
|
+
*/
|
|
2533
|
+
CssColorParserPlus.fromNormalize = function (colorArr) {
|
|
2534
|
+
var r = colorArr[0] * 255;
|
|
2535
|
+
var g = colorArr[1] * 255;
|
|
2536
|
+
var b = colorArr[2] * 255;
|
|
2537
|
+
var a = colorArr[3];
|
|
2538
|
+
return CssColorParserPlus.fromArray([r, g, b, a]);
|
|
2539
|
+
};
|
|
2540
|
+
return CssColorParserPlus;
|
|
2541
|
+
}(src_CssColorParser));
|
|
2542
|
+
/* harmony default export */ var src_CssColorParserPlus = (CssColorParserPlus);
|
|
1956
2543
|
|
|
1957
2544
|
;// CONCATENATED MODULE: ./src/main.ts
|
|
1958
2545
|
/*
|
|
1959
2546
|
* @Author: roman_123
|
|
1960
2547
|
* @Description:
|
|
1961
2548
|
* @Date: 2023-05-25 17:45:22
|
|
1962
|
-
* @LastEditTime: 2023-
|
|
2549
|
+
* @LastEditTime: 2023-06-27 18:45:32
|
|
1963
2550
|
*/
|
|
1964
2551
|
|
|
1965
2552
|
|