@tsparticles/plugin-hwb-color 4.0.0-alpha.2 → 4.0.0-alpha.21
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/893.min.js +1 -0
- package/browser/HwbColorManager.js +2 -5
- package/browser/index.js +4 -4
- package/cjs/HwbColorManager.js +2 -5
- package/cjs/index.js +4 -4
- package/dist_browser_HwbColorManager_js.js +2 -2
- package/esm/HwbColorManager.js +2 -5
- package/esm/index.js +4 -4
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.plugin.hwbColor.js +11 -11
- package/tsparticles.plugin.hwbColor.min.js +2 -2
- package/types/HwbColorManager.d.ts +0 -2
- package/types/index.d.ts +1 -1
- package/umd/HwbColorManager.js +2 -5
- package/umd/index.js +4 -4
- package/833.min.js +0 -2
- package/833.min.js.LICENSE.txt +0 -1
- package/tsparticles.plugin.hwbColor.min.js.LICENSE.txt +0 -1
package/893.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_hwb_color=this.webpackChunk_tsparticles_plugin_hwb_color||[]).push([[893],{893(e,a,t){t.d(a,{HwbColorManager:()=>u});var r,s,h=t(303);(r=s||(s={}))[r.h=1]="h",r[r.w=2]="w",r[r.b=3]="b",r[r.a=5]="a";let l=/hwba?\(\s*(\d{1,3}(?:\.\d+)?(?:deg|rad|grad|turn)?)\s*[\s,]\s*(\d{1,3}(?:\.\d+)?)%\s*[\s,]\s*(\d{1,3}(?:\.\d+)?)%\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i;function n(e){let a,t,r,s=e.h/360,h=e.w/100,l=e.b/100,n=h+l;if(n>=1){let e=h/n;a=e,t=e,r=e}else{let e=e=>{let a=(e+6*s)%6;return 1-l-(1-h-l)*Math.max(0,Math.min(a,4-a,1))};a=e(5),t=e(3),r=e(1)}return{r:Math.round(255*a),g:Math.round(255*t),b:Math.round(255*r)}}class u{accepts(e){return e.startsWith("hwb")}handleColor(e){let a=e.value.hwb??e.value;if(Object.hasOwn(a,"h")&&Object.hasOwn(a,"w")&&Object.hasOwn(a,"b"))return n(a)}handleRangeColor(e){let a=e.value.hwb??e.value;if(Object.hasOwn(a,"h")&&Object.hasOwn(a,"w")&&Object.hasOwn(a,"b"))return n({h:(0,h.getRangeValue)(a.h),w:(0,h.getRangeValue)(a.w),b:(0,h.getRangeValue)(a.b)})}parseString(e){var a;if(!this.accepts(e))return;let t=l.exec(e);if(!t)return;let r=t[s.h],u=t[s.w],b=t[s.b];return{a:(a={a:t.length>4?(0,h.parseAlpha)(t[s.a]):1,h:void 0!==r?parseFloat(r):0,w:void 0!==u?parseFloat(u):0,b:void 0!==b?parseFloat(b):0}).a,...n(a)}}}}}]);
|
|
@@ -38,22 +38,19 @@ function hwbaToRgba(hwba) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
export class HwbColorManager {
|
|
41
|
-
constructor() {
|
|
42
|
-
this.key = "hwb";
|
|
43
|
-
}
|
|
44
41
|
accepts(input) {
|
|
45
42
|
return input.startsWith("hwb");
|
|
46
43
|
}
|
|
47
44
|
handleColor(color) {
|
|
48
45
|
const colorValue = color.value, hwbColor = colorValue.hwb ?? color.value;
|
|
49
|
-
if (!Object.hasOwn(hwbColor, "h")) {
|
|
46
|
+
if (!Object.hasOwn(hwbColor, "h") || !Object.hasOwn(hwbColor, "w") || !Object.hasOwn(hwbColor, "b")) {
|
|
50
47
|
return;
|
|
51
48
|
}
|
|
52
49
|
return hwbToRgb(hwbColor);
|
|
53
50
|
}
|
|
54
51
|
handleRangeColor(color) {
|
|
55
52
|
const colorValue = color.value, hwbColor = colorValue.hwb ?? color.value;
|
|
56
|
-
if (!Object.hasOwn(hwbColor, "h")) {
|
|
53
|
+
if (!Object.hasOwn(hwbColor, "h") || !Object.hasOwn(hwbColor, "w") || !Object.hasOwn(hwbColor, "b")) {
|
|
57
54
|
return;
|
|
58
55
|
}
|
|
59
56
|
return hwbToRgb({
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function loadHwbColorPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
3
|
-
engine.register(async (e) => {
|
|
1
|
+
export async function loadHwbColorPlugin(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.21");
|
|
3
|
+
await engine.register(async (e) => {
|
|
4
4
|
const { HwbColorManager } = await import("./HwbColorManager.js");
|
|
5
|
-
e.addColorManager(new HwbColorManager());
|
|
5
|
+
e.addColorManager("hwb", new HwbColorManager());
|
|
6
6
|
});
|
|
7
7
|
}
|
package/cjs/HwbColorManager.js
CHANGED
|
@@ -38,22 +38,19 @@ function hwbaToRgba(hwba) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
export class HwbColorManager {
|
|
41
|
-
constructor() {
|
|
42
|
-
this.key = "hwb";
|
|
43
|
-
}
|
|
44
41
|
accepts(input) {
|
|
45
42
|
return input.startsWith("hwb");
|
|
46
43
|
}
|
|
47
44
|
handleColor(color) {
|
|
48
45
|
const colorValue = color.value, hwbColor = colorValue.hwb ?? color.value;
|
|
49
|
-
if (!Object.hasOwn(hwbColor, "h")) {
|
|
46
|
+
if (!Object.hasOwn(hwbColor, "h") || !Object.hasOwn(hwbColor, "w") || !Object.hasOwn(hwbColor, "b")) {
|
|
50
47
|
return;
|
|
51
48
|
}
|
|
52
49
|
return hwbToRgb(hwbColor);
|
|
53
50
|
}
|
|
54
51
|
handleRangeColor(color) {
|
|
55
52
|
const colorValue = color.value, hwbColor = colorValue.hwb ?? color.value;
|
|
56
|
-
if (!Object.hasOwn(hwbColor, "h")) {
|
|
53
|
+
if (!Object.hasOwn(hwbColor, "h") || !Object.hasOwn(hwbColor, "w") || !Object.hasOwn(hwbColor, "b")) {
|
|
57
54
|
return;
|
|
58
55
|
}
|
|
59
56
|
return hwbToRgb({
|
package/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function loadHwbColorPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
3
|
-
engine.register(async (e) => {
|
|
1
|
+
export async function loadHwbColorPlugin(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.21");
|
|
3
|
+
await engine.register(async (e) => {
|
|
4
4
|
const { HwbColorManager } = await import("./HwbColorManager.js");
|
|
5
|
-
e.addColorManager(new HwbColorManager());
|
|
5
|
+
e.addColorManager("hwb", new HwbColorManager());
|
|
6
6
|
});
|
|
7
7
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v4.0.0-alpha.
|
|
7
|
+
* v4.0.0-alpha.21
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\*****************************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
25
|
|
|
26
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HwbColorManager: () => (/* binding */ HwbColorManager)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nvar HwbIndexes;\n(function
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HwbColorManager: () => (/* binding */ HwbColorManager)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nvar HwbIndexes;\n(function(HwbIndexes) {\n HwbIndexes[HwbIndexes[\"h\"] = 1] = \"h\";\n HwbIndexes[HwbIndexes[\"w\"] = 2] = \"w\";\n HwbIndexes[HwbIndexes[\"b\"] = 3] = \"b\";\n HwbIndexes[HwbIndexes[\"a\"] = 5] = \"a\";\n})(HwbIndexes || (HwbIndexes = {}));\nconst hwbRegex = /hwba?\\(\\s*(\\d{1,3}(?:\\.\\d+)?(?:deg|rad|grad|turn)?)\\s*[\\s,]\\s*(\\d{1,3}(?:\\.\\d+)?)%\\s*[\\s,]\\s*(\\d{1,3}(?:\\.\\d+)?)%\\s*([\\s,]\\s*(0|1|0?\\.\\d+|(\\d{1,3})%)\\s*)?\\)/i, maxDegree = 360, maxPercentage = 100, maxHwbValue = 255, hueSectors = 6, redOffset = 5, greenOffset = 3, blueOffset = 1, clampingMin = 0, clampingMax = 1, clampingReference = 4, unitValue = 1, defaultFallbackValue = 0;\nfunction hwbToRgb(hwb) {\n const normalizedHue = hwb.h / maxDegree, whiteness = hwb.w / maxPercentage, blackness = hwb.b / maxPercentage, totalWhitenessBlackness = whiteness + blackness;\n let red, green, blue;\n if (totalWhitenessBlackness >= unitValue) {\n const greyShade = whiteness / totalWhitenessBlackness;\n red = greyShade;\n green = greyShade;\n blue = greyShade;\n } else {\n const calculateChannel = (channelOffset)=>{\n const sectorPosition = (channelOffset + normalizedHue * hueSectors) % hueSectors, availableChroma = unitValue - whiteness - blackness, intensityFactor = Math.max(clampingMin, Math.min(sectorPosition, clampingReference - sectorPosition, clampingMax));\n return unitValue - blackness - availableChroma * intensityFactor;\n };\n red = calculateChannel(redOffset);\n green = calculateChannel(greenOffset);\n blue = calculateChannel(blueOffset);\n }\n return {\n r: Math.round(red * maxHwbValue),\n g: Math.round(green * maxHwbValue),\n b: Math.round(blue * maxHwbValue)\n };\n}\nfunction hwbaToRgba(hwba) {\n return {\n a: hwba.a,\n ...hwbToRgb(hwba)\n };\n}\nclass HwbColorManager {\n accepts(input) {\n return input.startsWith(\"hwb\");\n }\n handleColor(color) {\n const colorValue = color.value, hwbColor = colorValue.hwb ?? color.value;\n if (!Object.hasOwn(hwbColor, \"h\") || !Object.hasOwn(hwbColor, \"w\") || !Object.hasOwn(hwbColor, \"b\")) {\n return;\n }\n return hwbToRgb(hwbColor);\n }\n handleRangeColor(color) {\n const colorValue = color.value, hwbColor = colorValue.hwb ?? color.value;\n if (!Object.hasOwn(hwbColor, \"h\") || !Object.hasOwn(hwbColor, \"w\") || !Object.hasOwn(hwbColor, \"b\")) {\n return;\n }\n return hwbToRgb({\n h: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(hwbColor.h),\n w: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(hwbColor.w),\n b: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(hwbColor.b)\n });\n }\n parseString(input) {\n if (!this.accepts(input)) {\n return;\n }\n const result = hwbRegex.exec(input), minLength = 4, defaultAlpha = 1;\n if (!result) {\n return;\n }\n const h = result[HwbIndexes.h], w = result[HwbIndexes.w], b = result[HwbIndexes.b];\n return hwbaToRgba({\n a: result.length > minLength ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.parseAlpha)(result[HwbIndexes.a]) : defaultAlpha,\n h: h !== undefined ? parseFloat(h) : defaultFallbackValue,\n w: w !== undefined ? parseFloat(w) : defaultFallbackValue,\n b: b !== undefined ? parseFloat(b) : defaultFallbackValue\n });\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-hwb-color/./dist/browser/HwbColorManager.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ }
|
|
29
29
|
|
package/esm/HwbColorManager.js
CHANGED
|
@@ -38,22 +38,19 @@ function hwbaToRgba(hwba) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
export class HwbColorManager {
|
|
41
|
-
constructor() {
|
|
42
|
-
this.key = "hwb";
|
|
43
|
-
}
|
|
44
41
|
accepts(input) {
|
|
45
42
|
return input.startsWith("hwb");
|
|
46
43
|
}
|
|
47
44
|
handleColor(color) {
|
|
48
45
|
const colorValue = color.value, hwbColor = colorValue.hwb ?? color.value;
|
|
49
|
-
if (!Object.hasOwn(hwbColor, "h")) {
|
|
46
|
+
if (!Object.hasOwn(hwbColor, "h") || !Object.hasOwn(hwbColor, "w") || !Object.hasOwn(hwbColor, "b")) {
|
|
50
47
|
return;
|
|
51
48
|
}
|
|
52
49
|
return hwbToRgb(hwbColor);
|
|
53
50
|
}
|
|
54
51
|
handleRangeColor(color) {
|
|
55
52
|
const colorValue = color.value, hwbColor = colorValue.hwb ?? color.value;
|
|
56
|
-
if (!Object.hasOwn(hwbColor, "h")) {
|
|
53
|
+
if (!Object.hasOwn(hwbColor, "h") || !Object.hasOwn(hwbColor, "w") || !Object.hasOwn(hwbColor, "b")) {
|
|
57
54
|
return;
|
|
58
55
|
}
|
|
59
56
|
return hwbToRgb({
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function loadHwbColorPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
3
|
-
engine.register(async (e) => {
|
|
1
|
+
export async function loadHwbColorPlugin(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.21");
|
|
3
|
+
await engine.register(async (e) => {
|
|
4
4
|
const { HwbColorManager } = await import("./HwbColorManager.js");
|
|
5
|
-
e.addColorManager(new HwbColorManager());
|
|
5
|
+
e.addColorManager("hwb", new HwbColorManager());
|
|
6
6
|
});
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-hwb-color",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.21",
|
|
4
4
|
"description": "tsParticles HWB color plugin",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"./package.json": "./package.json"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@tsparticles/engine": "4.0.0-alpha.
|
|
103
|
+
"@tsparticles/engine": "4.0.0-alpha.21"
|
|
104
104
|
},
|
|
105
105
|
"publishConfig": {
|
|
106
106
|
"access": "public"
|