@tsparticles/shape-emoji 4.0.0-alpha.8 → 4.0.0-beta.0
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/477.min.js +1 -0
- package/browser/EmojiDrawer.js +30 -39
- package/browser/Utils.js +1 -0
- package/browser/index.js +7 -4
- package/cjs/EmojiDrawer.js +30 -39
- package/cjs/Utils.js +1 -0
- package/cjs/index.js +7 -4
- package/dist_browser_EmojiDrawer_js.js +2 -12
- package/esm/EmojiDrawer.js +30 -39
- package/esm/Utils.js +1 -0
- package/esm/index.js +7 -4
- package/package.json +3 -2
- package/report.html +1 -1
- package/tsparticles.shape.emoji.js +51 -19
- package/tsparticles.shape.emoji.min.js +2 -2
- package/types/EmojiDrawer.d.ts +1 -2
- package/types/Utils.d.ts +1 -0
- package/umd/EmojiDrawer.js +30 -39
- package/umd/Utils.js +2 -0
- package/umd/index.js +8 -5
- package/860.min.js +0 -2
- package/860.min.js.LICENSE.txt +0 -1
- package/tsparticles.shape.emoji.min.js.LICENSE.txt +0 -1
package/477.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_shape_emoji=this.webpackChunk_tsparticles_shape_emoji||[]).push([[477],{477(e,t,a){a.d(t,{EmojiDrawer:()=>l});var i=a(303),n=a(183),o=a(425);let s='"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif';class l{_emojiShapeDict=new Map;destroy(){for(let[e,t]of this._emojiShapeDict)t instanceof ImageBitmap&&t.close(),this._emojiShapeDict.delete(e)}draw(e){let t=e.particle.emojiDataKey;if(!t)return;let a=this._emojiShapeDict.get(t);a&&(0,n.j)(e,a)}async init(e){let t=e.actualOptions.particles.shape;if(!n.u.some(e=>(0,i.isInArray)(e,t.type)))return;let a=[(0,o.loadFont)(s)],l=n.u.map(e=>t.options[e])[0];(0,i.executeOnSingleOrMultiple)(l,e=>{e.font&&a.push((0,o.loadFont)(e.font))}),await Promise.all(a)}particleDestroy(e){e.emojiDataKey=void 0}particleInit(e,t){let a,n,o=t.shapeData;if(!o.value)return;let l=(0,i.itemFromSingleOrMultiple)(o.value,t.randomIndexData);if(!l)return;let r="string"==typeof l?{font:o.font??s,padding:o.padding??0,value:l}:{font:s,padding:0,...o,...l},p=r.font,c=r.value,m=`${c}_${p}`;if(this._emojiShapeDict.has(m)){t.emojiDataKey=m;return}let f=r.padding*i.double,u=(0,i.getRangeMax)(t.size.value),d=u+f,h=d*i.double;if("u"<typeof OffscreenCanvas){let t=(0,i.safeDocument)().createElement("canvas");t.width=h,t.height=h,n=t.getContext("2d",e.canvas.settings),a=t}else n=(a=new OffscreenCanvas(h,h)).getContext("2d",e.canvas.settings);if(!n)return;n.font=`400 ${(u*i.double).toString()}px ${p}`,n.textBaseline="middle",n.textAlign="center",n.fillText(c,d,d);let g=a instanceof HTMLCanvasElement?a:a.transferToImageBitmap();this._emojiShapeDict.set(m,g),t.emojiDataKey=m}}}}]);
|
package/browser/EmojiDrawer.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { double, executeOnSingleOrMultiple, getRangeMax, isInArray, itemFromSingleOrMultiple,
|
|
2
|
-
import { drawEmoji } from "./Utils.js";
|
|
3
|
-
|
|
1
|
+
import { double, executeOnSingleOrMultiple, getRangeMax, isInArray, itemFromSingleOrMultiple, safeDocument, } from "@tsparticles/engine";
|
|
2
|
+
import { drawEmoji, validTypes } from "./Utils.js";
|
|
3
|
+
import { loadFont } from "@tsparticles/canvas-utils";
|
|
4
|
+
const defaultFont = '"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif', noPadding = 0, firstItem = 0;
|
|
4
5
|
export class EmojiDrawer {
|
|
5
|
-
|
|
6
|
-
this.validTypes = ["emoji"];
|
|
7
|
-
this._emojiShapeDict = new Map();
|
|
8
|
-
}
|
|
6
|
+
_emojiShapeDict = new Map();
|
|
9
7
|
destroy() {
|
|
10
8
|
for (const [key, data] of this._emojiShapeDict) {
|
|
11
9
|
if (data instanceof ImageBitmap) {
|
|
@@ -26,11 +24,11 @@ export class EmojiDrawer {
|
|
|
26
24
|
drawEmoji(data, image);
|
|
27
25
|
}
|
|
28
26
|
async init(container) {
|
|
29
|
-
const options = container.actualOptions,
|
|
30
|
-
if (!validTypes.
|
|
27
|
+
const options = container.actualOptions, shapeData = options.particles.shape;
|
|
28
|
+
if (!validTypes.some(t => isInArray(t, shapeData.type))) {
|
|
31
29
|
return;
|
|
32
30
|
}
|
|
33
|
-
const promises = [loadFont(defaultFont)], shapeOptions = validTypes.map(t =>
|
|
31
|
+
const promises = [loadFont(defaultFont)], shapeOptions = validTypes.map(t => shapeData.options[t])[firstItem];
|
|
34
32
|
executeOnSingleOrMultiple(shapeOptions, shape => {
|
|
35
33
|
if (shape.font) {
|
|
36
34
|
promises.push(loadFont(shape.font));
|
|
@@ -41,7 +39,7 @@ export class EmojiDrawer {
|
|
|
41
39
|
particleDestroy(particle) {
|
|
42
40
|
particle.emojiDataKey = undefined;
|
|
43
41
|
}
|
|
44
|
-
particleInit(
|
|
42
|
+
particleInit(container, particle) {
|
|
45
43
|
const shapeData = particle.shapeData;
|
|
46
44
|
if (!shapeData.value) {
|
|
47
45
|
return;
|
|
@@ -61,40 +59,33 @@ export class EmojiDrawer {
|
|
|
61
59
|
padding: noPadding,
|
|
62
60
|
...shapeData,
|
|
63
61
|
...emoji,
|
|
64
|
-
}, font = emojiOptions.font, value = emojiOptions.value
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
particle.emojiDataKey = key;
|
|
62
|
+
}, font = emojiOptions.font, value = emojiOptions.value, cacheKey = `${value}_${font}`;
|
|
63
|
+
if (this._emojiShapeDict.has(cacheKey)) {
|
|
64
|
+
particle.emojiDataKey = cacheKey;
|
|
68
65
|
return;
|
|
69
66
|
}
|
|
70
67
|
const padding = emojiOptions.padding * double, maxSize = getRangeMax(particle.size.value), fullSize = maxSize + padding, canvasSize = fullSize * double;
|
|
71
|
-
let
|
|
72
|
-
if (typeof OffscreenCanvas
|
|
73
|
-
const canvas = new OffscreenCanvas(canvasSize, canvasSize), context = canvas.getContext("2d");
|
|
74
|
-
if (!context) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
context.font = `400 ${(maxSize * double).toString()}px ${font}`;
|
|
78
|
-
context.textBaseline = "middle";
|
|
79
|
-
context.textAlign = "center";
|
|
80
|
-
context.fillText(value, fullSize, fullSize);
|
|
81
|
-
image = canvas.transferToImageBitmap();
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
68
|
+
let cacheCanvas, context;
|
|
69
|
+
if (typeof OffscreenCanvas === "undefined") {
|
|
84
70
|
const canvas = safeDocument().createElement("canvas");
|
|
85
71
|
canvas.width = canvasSize;
|
|
86
72
|
canvas.height = canvasSize;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
context
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
73
|
+
context = canvas.getContext("2d", container.canvas.settings);
|
|
74
|
+
cacheCanvas = canvas;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
cacheCanvas = new OffscreenCanvas(canvasSize, canvasSize);
|
|
78
|
+
context = cacheCanvas.getContext("2d", container.canvas.settings);
|
|
79
|
+
}
|
|
80
|
+
if (!context) {
|
|
81
|
+
return;
|
|
96
82
|
}
|
|
97
|
-
|
|
98
|
-
|
|
83
|
+
context.font = `400 ${(maxSize * double).toString()}px ${font}`;
|
|
84
|
+
context.textBaseline = "middle";
|
|
85
|
+
context.textAlign = "center";
|
|
86
|
+
context.fillText(value, fullSize, fullSize);
|
|
87
|
+
const image = cacheCanvas instanceof HTMLCanvasElement ? cacheCanvas : cacheCanvas.transferToImageBitmap();
|
|
88
|
+
this._emojiShapeDict.set(cacheKey, image);
|
|
89
|
+
particle.emojiDataKey = cacheKey;
|
|
99
90
|
}
|
|
100
91
|
}
|
package/browser/Utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { half } from "@tsparticles/engine";
|
|
2
|
+
export const validTypes = ["emoji"];
|
|
2
3
|
export function drawEmoji(data, image) {
|
|
3
4
|
const { context, opacity } = data, previousAlpha = context.globalAlpha, diameter = image.width, radius = diameter * half;
|
|
4
5
|
context.globalAlpha = opacity;
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { validTypes } from "./Utils.js";
|
|
1
2
|
export async function loadEmojiShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
4
|
+
await engine.register(e => {
|
|
5
|
+
e.addShape(validTypes, async () => {
|
|
6
|
+
const { EmojiDrawer } = await import("./EmojiDrawer.js");
|
|
7
|
+
return new EmojiDrawer();
|
|
8
|
+
});
|
|
6
9
|
});
|
|
7
10
|
}
|
package/cjs/EmojiDrawer.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { double, executeOnSingleOrMultiple, getRangeMax, isInArray, itemFromSingleOrMultiple,
|
|
2
|
-
import { drawEmoji } from "./Utils.js";
|
|
3
|
-
|
|
1
|
+
import { double, executeOnSingleOrMultiple, getRangeMax, isInArray, itemFromSingleOrMultiple, safeDocument, } from "@tsparticles/engine";
|
|
2
|
+
import { drawEmoji, validTypes } from "./Utils.js";
|
|
3
|
+
import { loadFont } from "@tsparticles/canvas-utils";
|
|
4
|
+
const defaultFont = '"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif', noPadding = 0, firstItem = 0;
|
|
4
5
|
export class EmojiDrawer {
|
|
5
|
-
|
|
6
|
-
this.validTypes = ["emoji"];
|
|
7
|
-
this._emojiShapeDict = new Map();
|
|
8
|
-
}
|
|
6
|
+
_emojiShapeDict = new Map();
|
|
9
7
|
destroy() {
|
|
10
8
|
for (const [key, data] of this._emojiShapeDict) {
|
|
11
9
|
if (data instanceof ImageBitmap) {
|
|
@@ -26,11 +24,11 @@ export class EmojiDrawer {
|
|
|
26
24
|
drawEmoji(data, image);
|
|
27
25
|
}
|
|
28
26
|
async init(container) {
|
|
29
|
-
const options = container.actualOptions,
|
|
30
|
-
if (!validTypes.
|
|
27
|
+
const options = container.actualOptions, shapeData = options.particles.shape;
|
|
28
|
+
if (!validTypes.some(t => isInArray(t, shapeData.type))) {
|
|
31
29
|
return;
|
|
32
30
|
}
|
|
33
|
-
const promises = [loadFont(defaultFont)], shapeOptions = validTypes.map(t =>
|
|
31
|
+
const promises = [loadFont(defaultFont)], shapeOptions = validTypes.map(t => shapeData.options[t])[firstItem];
|
|
34
32
|
executeOnSingleOrMultiple(shapeOptions, shape => {
|
|
35
33
|
if (shape.font) {
|
|
36
34
|
promises.push(loadFont(shape.font));
|
|
@@ -41,7 +39,7 @@ export class EmojiDrawer {
|
|
|
41
39
|
particleDestroy(particle) {
|
|
42
40
|
particle.emojiDataKey = undefined;
|
|
43
41
|
}
|
|
44
|
-
particleInit(
|
|
42
|
+
particleInit(container, particle) {
|
|
45
43
|
const shapeData = particle.shapeData;
|
|
46
44
|
if (!shapeData.value) {
|
|
47
45
|
return;
|
|
@@ -61,40 +59,33 @@ export class EmojiDrawer {
|
|
|
61
59
|
padding: noPadding,
|
|
62
60
|
...shapeData,
|
|
63
61
|
...emoji,
|
|
64
|
-
}, font = emojiOptions.font, value = emojiOptions.value
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
particle.emojiDataKey = key;
|
|
62
|
+
}, font = emojiOptions.font, value = emojiOptions.value, cacheKey = `${value}_${font}`;
|
|
63
|
+
if (this._emojiShapeDict.has(cacheKey)) {
|
|
64
|
+
particle.emojiDataKey = cacheKey;
|
|
68
65
|
return;
|
|
69
66
|
}
|
|
70
67
|
const padding = emojiOptions.padding * double, maxSize = getRangeMax(particle.size.value), fullSize = maxSize + padding, canvasSize = fullSize * double;
|
|
71
|
-
let
|
|
72
|
-
if (typeof OffscreenCanvas
|
|
73
|
-
const canvas = new OffscreenCanvas(canvasSize, canvasSize), context = canvas.getContext("2d");
|
|
74
|
-
if (!context) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
context.font = `400 ${(maxSize * double).toString()}px ${font}`;
|
|
78
|
-
context.textBaseline = "middle";
|
|
79
|
-
context.textAlign = "center";
|
|
80
|
-
context.fillText(value, fullSize, fullSize);
|
|
81
|
-
image = canvas.transferToImageBitmap();
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
68
|
+
let cacheCanvas, context;
|
|
69
|
+
if (typeof OffscreenCanvas === "undefined") {
|
|
84
70
|
const canvas = safeDocument().createElement("canvas");
|
|
85
71
|
canvas.width = canvasSize;
|
|
86
72
|
canvas.height = canvasSize;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
context
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
73
|
+
context = canvas.getContext("2d", container.canvas.settings);
|
|
74
|
+
cacheCanvas = canvas;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
cacheCanvas = new OffscreenCanvas(canvasSize, canvasSize);
|
|
78
|
+
context = cacheCanvas.getContext("2d", container.canvas.settings);
|
|
79
|
+
}
|
|
80
|
+
if (!context) {
|
|
81
|
+
return;
|
|
96
82
|
}
|
|
97
|
-
|
|
98
|
-
|
|
83
|
+
context.font = `400 ${(maxSize * double).toString()}px ${font}`;
|
|
84
|
+
context.textBaseline = "middle";
|
|
85
|
+
context.textAlign = "center";
|
|
86
|
+
context.fillText(value, fullSize, fullSize);
|
|
87
|
+
const image = cacheCanvas instanceof HTMLCanvasElement ? cacheCanvas : cacheCanvas.transferToImageBitmap();
|
|
88
|
+
this._emojiShapeDict.set(cacheKey, image);
|
|
89
|
+
particle.emojiDataKey = cacheKey;
|
|
99
90
|
}
|
|
100
91
|
}
|
package/cjs/Utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { half } from "@tsparticles/engine";
|
|
2
|
+
export const validTypes = ["emoji"];
|
|
2
3
|
export function drawEmoji(data, image) {
|
|
3
4
|
const { context, opacity } = data, previousAlpha = context.globalAlpha, diameter = image.width, radius = diameter * half;
|
|
4
5
|
context.globalAlpha = opacity;
|
package/cjs/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { validTypes } from "./Utils.js";
|
|
1
2
|
export async function loadEmojiShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
4
|
+
await engine.register(e => {
|
|
5
|
+
e.addShape(validTypes, async () => {
|
|
6
|
+
const { EmojiDrawer } = await import("./EmojiDrawer.js");
|
|
7
|
+
return new EmojiDrawer();
|
|
8
|
+
});
|
|
6
9
|
});
|
|
7
10
|
}
|
|
@@ -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-
|
|
7
|
+
* v4.0.0-beta.0
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,17 +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 */ EmojiDrawer: () => (/* binding */ EmojiDrawer)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nconst defaultFont = '\"
|
|
27
|
-
|
|
28
|
-
/***/ },
|
|
29
|
-
|
|
30
|
-
/***/ "./dist/browser/Utils.js"
|
|
31
|
-
/*!*******************************!*\
|
|
32
|
-
!*** ./dist/browser/Utils.js ***!
|
|
33
|
-
\*******************************/
|
|
34
|
-
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
-
|
|
36
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ drawEmoji: () => (/* binding */ drawEmoji)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nfunction drawEmoji(data, image) {\n const {\n context,\n opacity\n } = data,\n previousAlpha = context.globalAlpha,\n diameter = image.width,\n radius = diameter * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half;\n context.globalAlpha = opacity;\n context.drawImage(image, -radius, -radius, diameter, diameter);\n context.globalAlpha = previousAlpha;\n}\n\n//# sourceURL=webpack://@tsparticles/shape-emoji/./dist/browser/Utils.js?\n}");
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EmojiDrawer: () => (/* binding */ EmojiDrawer)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _tsparticles_canvas_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tsparticles/canvas-utils */ \"@tsparticles/canvas-utils\");\n\n\n\nconst defaultFont = '\"Apple Color Emoji\", \"Segoe UI Emoji\", \"Noto Color Emoji\", sans-serif', noPadding = 0, firstItem = 0;\nclass EmojiDrawer {\n _emojiShapeDict = new Map();\n destroy() {\n for (const [key, data] of this._emojiShapeDict){\n if (data instanceof ImageBitmap) {\n data.close();\n }\n this._emojiShapeDict.delete(key);\n }\n }\n draw(data) {\n const key = data.particle.emojiDataKey;\n if (!key) {\n return;\n }\n const image = this._emojiShapeDict.get(key);\n if (!image) {\n return;\n }\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawEmoji)(data, image);\n }\n async init(container) {\n const options = container.actualOptions, shapeData = options.particles.shape;\n if (!_Utils_js__WEBPACK_IMPORTED_MODULE_1__.validTypes.some((t)=>(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(t, shapeData.type))) {\n return;\n }\n const promises = [\n (0,_tsparticles_canvas_utils__WEBPACK_IMPORTED_MODULE_2__.loadFont)(defaultFont)\n ], shapeOptions = _Utils_js__WEBPACK_IMPORTED_MODULE_1__.validTypes.map((t)=>shapeData.options[t])[firstItem];\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.executeOnSingleOrMultiple)(shapeOptions, (shape)=>{\n if (shape.font) {\n promises.push((0,_tsparticles_canvas_utils__WEBPACK_IMPORTED_MODULE_2__.loadFont)(shape.font));\n }\n });\n await Promise.all(promises);\n }\n particleDestroy(particle) {\n particle.emojiDataKey = undefined;\n }\n particleInit(container, particle) {\n const shapeData = particle.shapeData;\n if (!shapeData.value) {\n return;\n }\n const emoji = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromSingleOrMultiple)(shapeData.value, particle.randomIndexData);\n if (!emoji) {\n return;\n }\n const emojiOptions = typeof emoji === \"string\" ? {\n font: shapeData.font ?? defaultFont,\n padding: shapeData.padding ?? noPadding,\n value: emoji\n } : {\n font: defaultFont,\n padding: noPadding,\n ...shapeData,\n ...emoji\n }, font = emojiOptions.font, value = emojiOptions.value, cacheKey = `${value}_${font}`;\n if (this._emojiShapeDict.has(cacheKey)) {\n particle.emojiDataKey = cacheKey;\n return;\n }\n const padding = emojiOptions.padding * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double, maxSize = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeMax)(particle.size.value), fullSize = maxSize + padding, canvasSize = fullSize * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double;\n let cacheCanvas, context;\n if (typeof OffscreenCanvas === \"undefined\") {\n const canvas = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.safeDocument)().createElement(\"canvas\");\n canvas.width = canvasSize;\n canvas.height = canvasSize;\n context = canvas.getContext(\"2d\", container.canvas.settings);\n cacheCanvas = canvas;\n } else {\n cacheCanvas = new OffscreenCanvas(canvasSize, canvasSize);\n context = cacheCanvas.getContext(\"2d\", container.canvas.settings);\n }\n if (!context) {\n return;\n }\n context.font = `400 ${(maxSize * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double).toString()}px ${font}`;\n context.textBaseline = \"middle\";\n context.textAlign = \"center\";\n context.fillText(value, fullSize, fullSize);\n const image = cacheCanvas instanceof HTMLCanvasElement ? cacheCanvas : cacheCanvas.transferToImageBitmap();\n this._emojiShapeDict.set(cacheKey, image);\n particle.emojiDataKey = cacheKey;\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-emoji/./dist/browser/EmojiDrawer.js?\n}");
|
|
37
27
|
|
|
38
28
|
/***/ }
|
|
39
29
|
|
package/esm/EmojiDrawer.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { double, executeOnSingleOrMultiple, getRangeMax, isInArray, itemFromSingleOrMultiple,
|
|
2
|
-
import { drawEmoji } from "./Utils.js";
|
|
3
|
-
|
|
1
|
+
import { double, executeOnSingleOrMultiple, getRangeMax, isInArray, itemFromSingleOrMultiple, safeDocument, } from "@tsparticles/engine";
|
|
2
|
+
import { drawEmoji, validTypes } from "./Utils.js";
|
|
3
|
+
import { loadFont } from "@tsparticles/canvas-utils";
|
|
4
|
+
const defaultFont = '"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif', noPadding = 0, firstItem = 0;
|
|
4
5
|
export class EmojiDrawer {
|
|
5
|
-
|
|
6
|
-
this.validTypes = ["emoji"];
|
|
7
|
-
this._emojiShapeDict = new Map();
|
|
8
|
-
}
|
|
6
|
+
_emojiShapeDict = new Map();
|
|
9
7
|
destroy() {
|
|
10
8
|
for (const [key, data] of this._emojiShapeDict) {
|
|
11
9
|
if (data instanceof ImageBitmap) {
|
|
@@ -26,11 +24,11 @@ export class EmojiDrawer {
|
|
|
26
24
|
drawEmoji(data, image);
|
|
27
25
|
}
|
|
28
26
|
async init(container) {
|
|
29
|
-
const options = container.actualOptions,
|
|
30
|
-
if (!validTypes.
|
|
27
|
+
const options = container.actualOptions, shapeData = options.particles.shape;
|
|
28
|
+
if (!validTypes.some(t => isInArray(t, shapeData.type))) {
|
|
31
29
|
return;
|
|
32
30
|
}
|
|
33
|
-
const promises = [loadFont(defaultFont)], shapeOptions = validTypes.map(t =>
|
|
31
|
+
const promises = [loadFont(defaultFont)], shapeOptions = validTypes.map(t => shapeData.options[t])[firstItem];
|
|
34
32
|
executeOnSingleOrMultiple(shapeOptions, shape => {
|
|
35
33
|
if (shape.font) {
|
|
36
34
|
promises.push(loadFont(shape.font));
|
|
@@ -41,7 +39,7 @@ export class EmojiDrawer {
|
|
|
41
39
|
particleDestroy(particle) {
|
|
42
40
|
particle.emojiDataKey = undefined;
|
|
43
41
|
}
|
|
44
|
-
particleInit(
|
|
42
|
+
particleInit(container, particle) {
|
|
45
43
|
const shapeData = particle.shapeData;
|
|
46
44
|
if (!shapeData.value) {
|
|
47
45
|
return;
|
|
@@ -61,40 +59,33 @@ export class EmojiDrawer {
|
|
|
61
59
|
padding: noPadding,
|
|
62
60
|
...shapeData,
|
|
63
61
|
...emoji,
|
|
64
|
-
}, font = emojiOptions.font, value = emojiOptions.value
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
particle.emojiDataKey = key;
|
|
62
|
+
}, font = emojiOptions.font, value = emojiOptions.value, cacheKey = `${value}_${font}`;
|
|
63
|
+
if (this._emojiShapeDict.has(cacheKey)) {
|
|
64
|
+
particle.emojiDataKey = cacheKey;
|
|
68
65
|
return;
|
|
69
66
|
}
|
|
70
67
|
const padding = emojiOptions.padding * double, maxSize = getRangeMax(particle.size.value), fullSize = maxSize + padding, canvasSize = fullSize * double;
|
|
71
|
-
let
|
|
72
|
-
if (typeof OffscreenCanvas
|
|
73
|
-
const canvas = new OffscreenCanvas(canvasSize, canvasSize), context = canvas.getContext("2d");
|
|
74
|
-
if (!context) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
context.font = `400 ${(maxSize * double).toString()}px ${font}`;
|
|
78
|
-
context.textBaseline = "middle";
|
|
79
|
-
context.textAlign = "center";
|
|
80
|
-
context.fillText(value, fullSize, fullSize);
|
|
81
|
-
image = canvas.transferToImageBitmap();
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
68
|
+
let cacheCanvas, context;
|
|
69
|
+
if (typeof OffscreenCanvas === "undefined") {
|
|
84
70
|
const canvas = safeDocument().createElement("canvas");
|
|
85
71
|
canvas.width = canvasSize;
|
|
86
72
|
canvas.height = canvasSize;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
context
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
73
|
+
context = canvas.getContext("2d", container.canvas.settings);
|
|
74
|
+
cacheCanvas = canvas;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
cacheCanvas = new OffscreenCanvas(canvasSize, canvasSize);
|
|
78
|
+
context = cacheCanvas.getContext("2d", container.canvas.settings);
|
|
79
|
+
}
|
|
80
|
+
if (!context) {
|
|
81
|
+
return;
|
|
96
82
|
}
|
|
97
|
-
|
|
98
|
-
|
|
83
|
+
context.font = `400 ${(maxSize * double).toString()}px ${font}`;
|
|
84
|
+
context.textBaseline = "middle";
|
|
85
|
+
context.textAlign = "center";
|
|
86
|
+
context.fillText(value, fullSize, fullSize);
|
|
87
|
+
const image = cacheCanvas instanceof HTMLCanvasElement ? cacheCanvas : cacheCanvas.transferToImageBitmap();
|
|
88
|
+
this._emojiShapeDict.set(cacheKey, image);
|
|
89
|
+
particle.emojiDataKey = cacheKey;
|
|
99
90
|
}
|
|
100
91
|
}
|
package/esm/Utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { half } from "@tsparticles/engine";
|
|
2
|
+
export const validTypes = ["emoji"];
|
|
2
3
|
export function drawEmoji(data, image) {
|
|
3
4
|
const { context, opacity } = data, previousAlpha = context.globalAlpha, diameter = image.width, radius = diameter * half;
|
|
4
5
|
context.globalAlpha = opacity;
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { validTypes } from "./Utils.js";
|
|
1
2
|
export async function loadEmojiShape(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
4
|
+
await engine.register(e => {
|
|
5
|
+
e.addShape(validTypes, async () => {
|
|
6
|
+
const { EmojiDrawer } = await import("./EmojiDrawer.js");
|
|
7
|
+
return new EmojiDrawer();
|
|
8
|
+
});
|
|
6
9
|
});
|
|
7
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/shape-emoji",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"description": "tsParticles emoji shape",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
"./package.json": "./package.json"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@tsparticles/
|
|
62
|
+
"@tsparticles/canvas-utils": "4.0.0-beta.0",
|
|
63
|
+
"@tsparticles/engine": "4.0.0-beta.0"
|
|
63
64
|
},
|
|
64
65
|
"publishConfig": {
|
|
65
66
|
"access": "public"
|
package/report.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8"/>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>@tsparticles/shape-emoji [
|
|
6
|
+
<title>@tsparticles/shape-emoji [19 Mar 2026 at 13:58]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
8
8
|
|
|
9
9
|
<script>
|
|
@@ -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-
|
|
7
|
+
* v4.0.0-beta.0
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -16,25 +16,25 @@
|
|
|
16
16
|
*/
|
|
17
17
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
18
18
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
19
|
-
module.exports = factory(require("@tsparticles/engine"));
|
|
19
|
+
module.exports = factory(require("@tsparticles/engine"), require("@tsparticles/canvas-utils"));
|
|
20
20
|
else if(typeof define === 'function' && define.amd)
|
|
21
|
-
define(["@tsparticles/engine"], factory);
|
|
21
|
+
define(["@tsparticles/engine", "@tsparticles/canvas-utils"], factory);
|
|
22
22
|
else {
|
|
23
|
-
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
23
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine"), require("@tsparticles/canvas-utils")) : factory(root["window"], root["window"]);
|
|
24
24
|
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
25
25
|
}
|
|
26
|
-
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
|
|
26
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__, __WEBPACK_EXTERNAL_MODULE__tsparticles_canvas_utils__) => {
|
|
27
27
|
return /******/ (() => { // webpackBootstrap
|
|
28
28
|
/******/ "use strict";
|
|
29
29
|
/******/ var __webpack_modules__ = ({
|
|
30
30
|
|
|
31
|
-
/***/ "
|
|
32
|
-
|
|
33
|
-
!***
|
|
34
|
-
|
|
35
|
-
(
|
|
31
|
+
/***/ "@tsparticles/canvas-utils"
|
|
32
|
+
/*!***************************************************************************************************************************************************!*\
|
|
33
|
+
!*** external {"commonjs":"@tsparticles/canvas-utils","commonjs2":"@tsparticles/canvas-utils","amd":"@tsparticles/canvas-utils","root":"window"} ***!
|
|
34
|
+
\***************************************************************************************************************************************************/
|
|
35
|
+
(module) {
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_canvas_utils__;
|
|
38
38
|
|
|
39
39
|
/***/ },
|
|
40
40
|
|
|
@@ -46,6 +46,26 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
46
46
|
|
|
47
47
|
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
48
48
|
|
|
49
|
+
/***/ },
|
|
50
|
+
|
|
51
|
+
/***/ "./dist/browser/Utils.js"
|
|
52
|
+
/*!*******************************!*\
|
|
53
|
+
!*** ./dist/browser/Utils.js ***!
|
|
54
|
+
\*******************************/
|
|
55
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
56
|
+
|
|
57
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ drawEmoji: () => (/* binding */ drawEmoji),\n/* harmony export */ validTypes: () => (/* binding */ validTypes)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst validTypes = [\n \"emoji\"\n];\nfunction drawEmoji(data, image) {\n const { context, opacity } = data, previousAlpha = context.globalAlpha, diameter = image.width, radius = diameter * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half;\n context.globalAlpha = opacity;\n context.drawImage(image, -radius, -radius, diameter, diameter);\n context.globalAlpha = previousAlpha;\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-emoji/./dist/browser/Utils.js?\n}");
|
|
58
|
+
|
|
59
|
+
/***/ },
|
|
60
|
+
|
|
61
|
+
/***/ "./dist/browser/index.js"
|
|
62
|
+
/*!*******************************!*\
|
|
63
|
+
!*** ./dist/browser/index.js ***!
|
|
64
|
+
\*******************************/
|
|
65
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
66
|
+
|
|
67
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadEmojiShape: () => (/* binding */ loadEmojiShape)\n/* harmony export */ });\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\nasync function loadEmojiShape(engine) {\n engine.checkVersion(\"4.0.0-beta.0\");\n await engine.register((e)=>{\n e.addShape(_Utils_js__WEBPACK_IMPORTED_MODULE_0__.validTypes, async ()=>{\n const { EmojiDrawer } = await __webpack_require__.e(/*! import() */ \"dist_browser_EmojiDrawer_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./EmojiDrawer.js */ \"./dist/browser/EmojiDrawer.js\"));\n return new EmojiDrawer();\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/shape-emoji/./dist/browser/index.js?\n}");
|
|
68
|
+
|
|
49
69
|
/***/ }
|
|
50
70
|
|
|
51
71
|
/******/ });
|
|
@@ -60,12 +80,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
60
80
|
/******/ if (cachedModule !== undefined) {
|
|
61
81
|
/******/ return cachedModule.exports;
|
|
62
82
|
/******/ }
|
|
63
|
-
/******/ // Check if module exists (development only)
|
|
64
|
-
/******/ if (__webpack_modules__[moduleId] === undefined) {
|
|
65
|
-
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
|
|
66
|
-
/******/ e.code = 'MODULE_NOT_FOUND';
|
|
67
|
-
/******/ throw e;
|
|
68
|
-
/******/ }
|
|
69
83
|
/******/ // Create a new module (and put it into the cache)
|
|
70
84
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
71
85
|
/******/ // no module.id needed
|
|
@@ -74,6 +88,12 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
74
88
|
/******/ };
|
|
75
89
|
/******/
|
|
76
90
|
/******/ // Execute the module function
|
|
91
|
+
/******/ if (!(moduleId in __webpack_modules__)) {
|
|
92
|
+
/******/ delete __webpack_module_cache__[moduleId];
|
|
93
|
+
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
|
|
94
|
+
/******/ e.code = 'MODULE_NOT_FOUND';
|
|
95
|
+
/******/ throw e;
|
|
96
|
+
/******/ }
|
|
77
97
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
78
98
|
/******/
|
|
79
99
|
/******/ // Return the exports of the module
|
|
@@ -118,6 +138,18 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
118
138
|
/******/ };
|
|
119
139
|
/******/ })();
|
|
120
140
|
/******/
|
|
141
|
+
/******/ /* webpack/runtime/global */
|
|
142
|
+
/******/ (() => {
|
|
143
|
+
/******/ __webpack_require__.g = (function() {
|
|
144
|
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
145
|
+
/******/ try {
|
|
146
|
+
/******/ return this || new Function('return this')();
|
|
147
|
+
/******/ } catch (e) {
|
|
148
|
+
/******/ if (typeof window === 'object') return window;
|
|
149
|
+
/******/ }
|
|
150
|
+
/******/ })();
|
|
151
|
+
/******/ })();
|
|
152
|
+
/******/
|
|
121
153
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
122
154
|
/******/ (() => {
|
|
123
155
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
@@ -182,8 +214,8 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
182
214
|
/******/ /* webpack/runtime/publicPath */
|
|
183
215
|
/******/ (() => {
|
|
184
216
|
/******/ var scriptUrl;
|
|
185
|
-
/******/ if (
|
|
186
|
-
/******/ var document =
|
|
217
|
+
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
|
|
218
|
+
/******/ var document = __webpack_require__.g.document;
|
|
187
219
|
/******/ if (!scriptUrl && document) {
|
|
188
220
|
/******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
|
|
189
221
|
/******/ scriptUrl = document.currentScript.src;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"),require("@tsparticles/canvas-utils"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/canvas-utils"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine"),require("@tsparticles/canvas-utils")):t(e.window,e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e,t)=>(()=>{"use strict";var r,o,i,a={425(e){e.exports=t},303(t){t.exports=e},183(e,t,r){r.d(t,{j:()=>a,u:()=>i});var o=r(303);let i=["emoji"];function a(e,t){let{context:r,opacity:i}=e,a=r.globalAlpha,n=t.width,s=n*o.half;r.globalAlpha=i,r.drawImage(t,-s,-s,n,n),r.globalAlpha=a}}},n={};function s(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return a[e](r,r.exports,s),r.exports}s.m=a,s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce((t,r)=>(s.f[r](e,t),t),[])),s.u=e=>""+e+".min.js",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l={},s.l=(e,t,r,o)=>{if(l[e])return void l[e].push(t);if(void 0!==r)for(var i,a,n=document.getElementsByTagName("script"),p=0;p<n.length;p++){var c=n[p];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")=="@tsparticles/shape-emoji:"+r){i=c;break}}i||(a=!0,(i=document.createElement("script")).charset="utf-8",s.nc&&i.setAttribute("nonce",s.nc),i.setAttribute("data-webpack","@tsparticles/shape-emoji:"+r),i.src=e),l[e]=[t];var u=(t,r)=>{i.onerror=i.onload=null,clearTimeout(d);var o=l[e];if(delete l[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach(e=>e(r)),t)return t(r)},d=setTimeout(u.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=u.bind(null,i.onerror),i.onload=u.bind(null,i.onload),a&&document.head.appendChild(i)},s.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(p=s.g.location+"");var l,p,c=s.g.document;if(!p&&c&&(c.currentScript&&"SCRIPT"===c.currentScript.tagName.toUpperCase()&&(p=c.currentScript.src),!p)){var u=c.getElementsByTagName("script");if(u.length)for(var d=u.length-1;d>-1&&(!p||!/^http(s?):/.test(p));)p=u[d--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");s.p=p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={390:0},s.f.j=(e,t)=>{var o=s.o(r,e)?r[e]:void 0;if(0!==o)if(o)t.push(o[2]);else{var i=new Promise((t,i)=>o=r[e]=[t,i]);t.push(o[2]=i);var a=s.p+s.u(e),n=Error();s.l(a,t=>{if(s.o(r,e)&&(0!==(o=r[e])&&(r[e]=void 0),o)){var i=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;n.message="Loading chunk "+e+` failed.
|
|
2
|
+
(`+i+": "+a+")",n.name="ChunkLoadError",n.type=i,n.request=a,o[1](n)}},"chunk-"+e,e)}},o=(e,t)=>{var o,i,[a,n,l]=t,p=0;if(a.some(e=>0!==r[e])){for(o in n)s.o(n,o)&&(s.m[o]=n[o]);l&&l(s)}for(e&&e(t);p<a.length;p++)i=a[p],s.o(r,i)&&r[i]&&r[i][0](),r[i]=0},(i=this.webpackChunk_tsparticles_shape_emoji=this.webpackChunk_tsparticles_shape_emoji||[]).forEach(o.bind(null,0)),i.push=o.bind(null,i.push.bind(i));var f={};s.r(f),s.d(f,{loadEmojiShape:()=>b});var h=s(183);async function b(e){e.checkVersion("4.0.0-beta.0"),await e.register(e=>{e.addShape(h.u,async()=>{let{EmojiDrawer:e}=await s.e(477).then(s.bind(s,477));return new e})})}return f})());
|
package/types/EmojiDrawer.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { type Container, type IShapeDrawData, type IShapeDrawer } from "@tsparticles/engine";
|
|
2
2
|
import type { EmojiParticle } from "./EmojiParticle.js";
|
|
3
3
|
export declare class EmojiDrawer implements IShapeDrawer<EmojiParticle> {
|
|
4
|
-
readonly validTypes: readonly ["emoji"];
|
|
5
4
|
private readonly _emojiShapeDict;
|
|
6
5
|
destroy(): void;
|
|
7
6
|
draw(data: IShapeDrawData<EmojiParticle>): void;
|
|
8
7
|
init(container: Container): Promise<void>;
|
|
9
8
|
particleDestroy(particle: EmojiParticle): void;
|
|
10
|
-
particleInit(
|
|
9
|
+
particleInit(container: Container, particle: EmojiParticle): void;
|
|
11
10
|
}
|
package/types/Utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type IShapeDrawData } from "@tsparticles/engine";
|
|
2
2
|
import type { EmojiParticle } from "./EmojiParticle.js";
|
|
3
|
+
export declare const validTypes: string[];
|
|
3
4
|
export declare function drawEmoji(data: IShapeDrawData<EmojiParticle>, image: ImageBitmap | HTMLCanvasElement): void;
|
package/umd/EmojiDrawer.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@tsparticles/engine", "./Utils.js"], factory);
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Utils.js", "@tsparticles/canvas-utils"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
@@ -12,12 +12,10 @@
|
|
|
12
12
|
exports.EmojiDrawer = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const Utils_js_1 = require("./Utils.js");
|
|
15
|
-
const
|
|
15
|
+
const canvas_utils_1 = require("@tsparticles/canvas-utils");
|
|
16
|
+
const defaultFont = '"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif', noPadding = 0, firstItem = 0;
|
|
16
17
|
class EmojiDrawer {
|
|
17
|
-
|
|
18
|
-
this.validTypes = ["emoji"];
|
|
19
|
-
this._emojiShapeDict = new Map();
|
|
20
|
-
}
|
|
18
|
+
_emojiShapeDict = new Map();
|
|
21
19
|
destroy() {
|
|
22
20
|
for (const [key, data] of this._emojiShapeDict) {
|
|
23
21
|
if (data instanceof ImageBitmap) {
|
|
@@ -38,14 +36,14 @@
|
|
|
38
36
|
(0, Utils_js_1.drawEmoji)(data, image);
|
|
39
37
|
}
|
|
40
38
|
async init(container) {
|
|
41
|
-
const options = container.actualOptions,
|
|
42
|
-
if (!validTypes.
|
|
39
|
+
const options = container.actualOptions, shapeData = options.particles.shape;
|
|
40
|
+
if (!Utils_js_1.validTypes.some(t => (0, engine_1.isInArray)(t, shapeData.type))) {
|
|
43
41
|
return;
|
|
44
42
|
}
|
|
45
|
-
const promises = [(0,
|
|
43
|
+
const promises = [(0, canvas_utils_1.loadFont)(defaultFont)], shapeOptions = Utils_js_1.validTypes.map(t => shapeData.options[t])[firstItem];
|
|
46
44
|
(0, engine_1.executeOnSingleOrMultiple)(shapeOptions, shape => {
|
|
47
45
|
if (shape.font) {
|
|
48
|
-
promises.push((0,
|
|
46
|
+
promises.push((0, canvas_utils_1.loadFont)(shape.font));
|
|
49
47
|
}
|
|
50
48
|
});
|
|
51
49
|
await Promise.all(promises);
|
|
@@ -53,7 +51,7 @@
|
|
|
53
51
|
particleDestroy(particle) {
|
|
54
52
|
particle.emojiDataKey = undefined;
|
|
55
53
|
}
|
|
56
|
-
particleInit(
|
|
54
|
+
particleInit(container, particle) {
|
|
57
55
|
const shapeData = particle.shapeData;
|
|
58
56
|
if (!shapeData.value) {
|
|
59
57
|
return;
|
|
@@ -73,41 +71,34 @@
|
|
|
73
71
|
padding: noPadding,
|
|
74
72
|
...shapeData,
|
|
75
73
|
...emoji,
|
|
76
|
-
}, font = emojiOptions.font, value = emojiOptions.value
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
particle.emojiDataKey = key;
|
|
74
|
+
}, font = emojiOptions.font, value = emojiOptions.value, cacheKey = `${value}_${font}`;
|
|
75
|
+
if (this._emojiShapeDict.has(cacheKey)) {
|
|
76
|
+
particle.emojiDataKey = cacheKey;
|
|
80
77
|
return;
|
|
81
78
|
}
|
|
82
79
|
const padding = emojiOptions.padding * engine_1.double, maxSize = (0, engine_1.getRangeMax)(particle.size.value), fullSize = maxSize + padding, canvasSize = fullSize * engine_1.double;
|
|
83
|
-
let
|
|
84
|
-
if (typeof OffscreenCanvas
|
|
85
|
-
const canvas = new OffscreenCanvas(canvasSize, canvasSize), context = canvas.getContext("2d");
|
|
86
|
-
if (!context) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
context.font = `400 ${(maxSize * engine_1.double).toString()}px ${font}`;
|
|
90
|
-
context.textBaseline = "middle";
|
|
91
|
-
context.textAlign = "center";
|
|
92
|
-
context.fillText(value, fullSize, fullSize);
|
|
93
|
-
image = canvas.transferToImageBitmap();
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
80
|
+
let cacheCanvas, context;
|
|
81
|
+
if (typeof OffscreenCanvas === "undefined") {
|
|
96
82
|
const canvas = (0, engine_1.safeDocument)().createElement("canvas");
|
|
97
83
|
canvas.width = canvasSize;
|
|
98
84
|
canvas.height = canvasSize;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
context
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
85
|
+
context = canvas.getContext("2d", container.canvas.settings);
|
|
86
|
+
cacheCanvas = canvas;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
cacheCanvas = new OffscreenCanvas(canvasSize, canvasSize);
|
|
90
|
+
context = cacheCanvas.getContext("2d", container.canvas.settings);
|
|
91
|
+
}
|
|
92
|
+
if (!context) {
|
|
93
|
+
return;
|
|
108
94
|
}
|
|
109
|
-
|
|
110
|
-
|
|
95
|
+
context.font = `400 ${(maxSize * engine_1.double).toString()}px ${font}`;
|
|
96
|
+
context.textBaseline = "middle";
|
|
97
|
+
context.textAlign = "center";
|
|
98
|
+
context.fillText(value, fullSize, fullSize);
|
|
99
|
+
const image = cacheCanvas instanceof HTMLCanvasElement ? cacheCanvas : cacheCanvas.transferToImageBitmap();
|
|
100
|
+
this._emojiShapeDict.set(cacheKey, image);
|
|
101
|
+
particle.emojiDataKey = cacheKey;
|
|
111
102
|
}
|
|
112
103
|
}
|
|
113
104
|
exports.EmojiDrawer = EmojiDrawer;
|
package/umd/Utils.js
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.validTypes = void 0;
|
|
12
13
|
exports.drawEmoji = drawEmoji;
|
|
13
14
|
const engine_1 = require("@tsparticles/engine");
|
|
15
|
+
exports.validTypes = ["emoji"];
|
|
14
16
|
function drawEmoji(data, image) {
|
|
15
17
|
const { context, opacity } = data, previousAlpha = context.globalAlpha, diameter = image.width, radius = diameter * engine_1.half;
|
|
16
18
|
context.globalAlpha = opacity;
|
package/umd/index.js
CHANGED
|
@@ -37,18 +37,21 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
37
37
|
if (v !== undefined) module.exports = v;
|
|
38
38
|
}
|
|
39
39
|
else if (typeof define === "function" && define.amd) {
|
|
40
|
-
define(["require", "exports"], factory);
|
|
40
|
+
define(["require", "exports", "./Utils.js"], factory);
|
|
41
41
|
}
|
|
42
42
|
})(function (require, exports) {
|
|
43
43
|
"use strict";
|
|
44
44
|
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
46
|
exports.loadEmojiShape = loadEmojiShape;
|
|
47
|
+
const Utils_js_1 = require("./Utils.js");
|
|
47
48
|
async function loadEmojiShape(engine) {
|
|
48
|
-
engine.checkVersion("4.0.0-
|
|
49
|
-
await engine.register(
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
50
|
+
await engine.register(e => {
|
|
51
|
+
e.addShape(Utils_js_1.validTypes, async () => {
|
|
52
|
+
const { EmojiDrawer } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./EmojiDrawer.js"))) : new Promise((resolve_1, reject_1) => { require(["./EmojiDrawer.js"], resolve_1, reject_1); }).then(__importStar));
|
|
53
|
+
return new EmojiDrawer();
|
|
54
|
+
});
|
|
52
55
|
});
|
|
53
56
|
}
|
|
54
57
|
});
|
package/860.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 860.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_shape_emoji=this.webpackChunk_tsparticles_shape_emoji||[]).push([[860],{860(e,t,i){i.d(t,{EmojiDrawer:()=>n});var a=i(303);const o='"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"';class n{constructor(){this.validTypes=["emoji"],this._emojiShapeDict=new Map}destroy(){for(const[e,t]of this._emojiShapeDict)t instanceof ImageBitmap&&t.close(),this._emojiShapeDict.delete(e)}draw(e){const t=e.particle.emojiDataKey;if(!t)return;const i=this._emojiShapeDict.get(t);i&&function(e,t){const{context:i,opacity:o}=e,n=i.globalAlpha,s=t.width,l=s*a.half;i.globalAlpha=o,i.drawImage(t,-l,-l,s,s),i.globalAlpha=n}(e,i)}async init(e){const t=e.actualOptions,{validTypes:i}=this;if(!i.find((e=>(0,a.isInArray)(e,t.particles.shape.type))))return;const n=[(0,a.loadFont)(o)],s=i.map((e=>t.particles.shape.options[e]))[0];(0,a.executeOnSingleOrMultiple)(s,(e=>{e.font&&n.push((0,a.loadFont)(e.font))})),await Promise.all(n)}particleDestroy(e){e.emojiDataKey=void 0}particleInit(e,t){const i=t.shapeData;if(!i.value)return;const n=(0,a.itemFromSingleOrMultiple)(i.value,t.randomIndexData);if(!n)return;const s="string"==typeof n?{font:i.font??o,padding:i.padding??0,value:n}:{font:o,padding:0,...i,...n},l=s.font,r=s.value,c=`${r}_${l}`;if(this._emojiShapeDict.has(c))return void(t.emojiDataKey=c);const p=s.padding*a.double,d=(0,a.getRangeMax)(t.size.value),h=d+p,f=h*a.double;let m;if("undefined"!=typeof OffscreenCanvas){const e=new OffscreenCanvas(f,f),t=e.getContext("2d");if(!t)return;t.font=`400 ${(d*a.double).toString()}px ${l}`,t.textBaseline="middle",t.textAlign="center",t.fillText(r,h,h),m=e.transferToImageBitmap()}else{const e=(0,a.safeDocument)().createElement("canvas");e.width=f,e.height=f;const t=e.getContext("2d");if(!t)return;t.font=`400 ${(d*a.double).toString()}px ${l}`,t.textBaseline="middle",t.textAlign="center",t.fillText(r,h,h),m=e}this._emojiShapeDict.set(c,m),t.emojiDataKey=c}}}}]);
|
package/860.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Emoji Shape v4.0.0-alpha.8 by Matteo Bruni */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Emoji Shape v4.0.0-alpha.8 by Matteo Bruni */
|