@tsparticles/shape-emoji 3.5.0 → 3.6.0-beta.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/browser/EmojiDrawer.js +40 -21
- package/browser/Utils.js +5 -4
- package/cjs/EmojiDrawer.js +40 -21
- package/cjs/Utils.js +5 -4
- package/esm/EmojiDrawer.js +40 -21
- package/esm/Utils.js +5 -4
- package/package.json +2 -2
- package/report.html +1 -1
- package/tsparticles.shape.emoji.js +3 -3
- package/tsparticles.shape.emoji.min.js +1 -1
- package/tsparticles.shape.emoji.min.js.LICENSE.txt +1 -1
- package/types/EmojiDrawer.d.ts +1 -1
- package/types/EmojiParticle.d.ts +1 -1
- package/types/IEmojiShape.d.ts +7 -1
- package/types/Utils.d.ts +1 -1
- package/umd/EmojiDrawer.js +40 -21
- package/umd/Utils.js +5 -4
package/browser/EmojiDrawer.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import { executeOnSingleOrMultiple, getRangeMax, isInArray, itemFromSingleOrMultiple, loadFont, } from "@tsparticles/engine";
|
|
2
2
|
import { drawEmoji } from "./Utils.js";
|
|
3
|
-
const defaultFont = '"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"';
|
|
3
|
+
const defaultFont = '"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"', noPadding = 0;
|
|
4
4
|
export class EmojiDrawer {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.validTypes = ["emoji"];
|
|
7
7
|
this._emojiShapeDict = new Map();
|
|
8
8
|
}
|
|
9
9
|
destroy() {
|
|
10
|
-
for (const [key,
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
this._emojiShapeDict.delete(key);
|
|
10
|
+
for (const [key, data] of this._emojiShapeDict) {
|
|
11
|
+
if (data instanceof ImageBitmap) {
|
|
12
|
+
data?.close();
|
|
14
13
|
}
|
|
14
|
+
this._emojiShapeDict.delete(key);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
draw(data) {
|
|
18
|
-
|
|
18
|
+
const key = data.particle.emojiDataKey;
|
|
19
|
+
if (!key) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const image = this._emojiShapeDict.get(key);
|
|
23
|
+
if (!image) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
drawEmoji(data, image);
|
|
19
27
|
}
|
|
20
28
|
async init(container) {
|
|
21
29
|
const options = container.actualOptions, { validTypes } = this;
|
|
@@ -35,25 +43,36 @@ export class EmojiDrawer {
|
|
|
35
43
|
await Promise.all(promises);
|
|
36
44
|
}
|
|
37
45
|
particleDestroy(particle) {
|
|
38
|
-
|
|
46
|
+
particle.emojiDataKey = undefined;
|
|
39
47
|
}
|
|
40
|
-
particleInit(
|
|
48
|
+
particleInit(_container, particle) {
|
|
41
49
|
const double = 2, shapeData = particle.shapeData;
|
|
42
50
|
if (!shapeData?.value) {
|
|
43
51
|
return;
|
|
44
52
|
}
|
|
45
|
-
const emoji = itemFromSingleOrMultiple(shapeData.value, particle.randomIndexData)
|
|
53
|
+
const emoji = itemFromSingleOrMultiple(shapeData.value, particle.randomIndexData);
|
|
46
54
|
if (!emoji) {
|
|
47
55
|
return;
|
|
48
56
|
}
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
const emojiOptions = typeof emoji === "string"
|
|
58
|
+
? {
|
|
59
|
+
font: shapeData.font ?? defaultFont,
|
|
60
|
+
padding: shapeData.padding ?? noPadding,
|
|
61
|
+
value: emoji,
|
|
62
|
+
}
|
|
63
|
+
: {
|
|
64
|
+
font: defaultFont,
|
|
65
|
+
padding: noPadding,
|
|
66
|
+
...shapeData,
|
|
67
|
+
...emoji,
|
|
68
|
+
}, font = emojiOptions.font, value = emojiOptions.value;
|
|
69
|
+
const key = `${value}_${font}`;
|
|
70
|
+
if (this._emojiShapeDict.has(key)) {
|
|
71
|
+
particle.emojiDataKey = key;
|
|
52
72
|
return;
|
|
53
73
|
}
|
|
54
|
-
const
|
|
55
|
-
let
|
|
56
|
-
const maxSize = getRangeMax(particle.size.value);
|
|
74
|
+
const padding = emojiOptions.padding * double, maxSize = getRangeMax(particle.size.value), fullSize = maxSize + padding, canvasSize = fullSize * double;
|
|
75
|
+
let image;
|
|
57
76
|
if (typeof OffscreenCanvas !== "undefined") {
|
|
58
77
|
const canvas = new OffscreenCanvas(canvasSize, canvasSize), context = canvas.getContext("2d");
|
|
59
78
|
if (!context) {
|
|
@@ -62,8 +81,8 @@ export class EmojiDrawer {
|
|
|
62
81
|
context.font = `400 ${maxSize * double}px ${font}`;
|
|
63
82
|
context.textBaseline = "middle";
|
|
64
83
|
context.textAlign = "center";
|
|
65
|
-
context.fillText(
|
|
66
|
-
|
|
84
|
+
context.fillText(value, fullSize, fullSize);
|
|
85
|
+
image = canvas.transferToImageBitmap();
|
|
67
86
|
}
|
|
68
87
|
else {
|
|
69
88
|
const canvas = document.createElement("canvas");
|
|
@@ -76,10 +95,10 @@ export class EmojiDrawer {
|
|
|
76
95
|
context.font = `400 ${maxSize * double}px ${font}`;
|
|
77
96
|
context.textBaseline = "middle";
|
|
78
97
|
context.textAlign = "center";
|
|
79
|
-
context.fillText(
|
|
80
|
-
|
|
98
|
+
context.fillText(value, fullSize, fullSize);
|
|
99
|
+
image = canvas;
|
|
81
100
|
}
|
|
82
|
-
this._emojiShapeDict.set(key,
|
|
83
|
-
particle.
|
|
101
|
+
this._emojiShapeDict.set(key, image);
|
|
102
|
+
particle.emojiDataKey = key;
|
|
84
103
|
}
|
|
85
104
|
}
|
package/browser/Utils.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export function drawEmoji(data) {
|
|
2
|
-
const { context,
|
|
3
|
-
if (!
|
|
1
|
+
export function drawEmoji(data, image) {
|
|
2
|
+
const { context, opacity } = data, half = 0.5, previousAlpha = context.globalAlpha;
|
|
3
|
+
if (!image) {
|
|
4
4
|
return;
|
|
5
5
|
}
|
|
6
|
+
const diameter = image.width, radius = diameter * half;
|
|
6
7
|
context.globalAlpha = opacity;
|
|
7
|
-
context.drawImage(
|
|
8
|
+
context.drawImage(image, -radius, -radius, diameter, diameter);
|
|
8
9
|
context.globalAlpha = previousAlpha;
|
|
9
10
|
}
|
package/cjs/EmojiDrawer.js
CHANGED
|
@@ -3,22 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EmojiDrawer = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
5
|
const Utils_js_1 = require("./Utils.js");
|
|
6
|
-
const defaultFont = '"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"';
|
|
6
|
+
const defaultFont = '"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"', noPadding = 0;
|
|
7
7
|
class EmojiDrawer {
|
|
8
8
|
constructor() {
|
|
9
9
|
this.validTypes = ["emoji"];
|
|
10
10
|
this._emojiShapeDict = new Map();
|
|
11
11
|
}
|
|
12
12
|
destroy() {
|
|
13
|
-
for (const [key,
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
this._emojiShapeDict.delete(key);
|
|
13
|
+
for (const [key, data] of this._emojiShapeDict) {
|
|
14
|
+
if (data instanceof ImageBitmap) {
|
|
15
|
+
data?.close();
|
|
17
16
|
}
|
|
17
|
+
this._emojiShapeDict.delete(key);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
draw(data) {
|
|
21
|
-
|
|
21
|
+
const key = data.particle.emojiDataKey;
|
|
22
|
+
if (!key) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const image = this._emojiShapeDict.get(key);
|
|
26
|
+
if (!image) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
(0, Utils_js_1.drawEmoji)(data, image);
|
|
22
30
|
}
|
|
23
31
|
async init(container) {
|
|
24
32
|
const options = container.actualOptions, { validTypes } = this;
|
|
@@ -38,25 +46,36 @@ class EmojiDrawer {
|
|
|
38
46
|
await Promise.all(promises);
|
|
39
47
|
}
|
|
40
48
|
particleDestroy(particle) {
|
|
41
|
-
|
|
49
|
+
particle.emojiDataKey = undefined;
|
|
42
50
|
}
|
|
43
|
-
particleInit(
|
|
51
|
+
particleInit(_container, particle) {
|
|
44
52
|
const double = 2, shapeData = particle.shapeData;
|
|
45
53
|
if (!shapeData?.value) {
|
|
46
54
|
return;
|
|
47
55
|
}
|
|
48
|
-
const emoji = (0, engine_1.itemFromSingleOrMultiple)(shapeData.value, particle.randomIndexData)
|
|
56
|
+
const emoji = (0, engine_1.itemFromSingleOrMultiple)(shapeData.value, particle.randomIndexData);
|
|
49
57
|
if (!emoji) {
|
|
50
58
|
return;
|
|
51
59
|
}
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
const emojiOptions = typeof emoji === "string"
|
|
61
|
+
? {
|
|
62
|
+
font: shapeData.font ?? defaultFont,
|
|
63
|
+
padding: shapeData.padding ?? noPadding,
|
|
64
|
+
value: emoji,
|
|
65
|
+
}
|
|
66
|
+
: {
|
|
67
|
+
font: defaultFont,
|
|
68
|
+
padding: noPadding,
|
|
69
|
+
...shapeData,
|
|
70
|
+
...emoji,
|
|
71
|
+
}, font = emojiOptions.font, value = emojiOptions.value;
|
|
72
|
+
const key = `${value}_${font}`;
|
|
73
|
+
if (this._emojiShapeDict.has(key)) {
|
|
74
|
+
particle.emojiDataKey = key;
|
|
55
75
|
return;
|
|
56
76
|
}
|
|
57
|
-
const
|
|
58
|
-
let
|
|
59
|
-
const maxSize = (0, engine_1.getRangeMax)(particle.size.value);
|
|
77
|
+
const padding = emojiOptions.padding * double, maxSize = (0, engine_1.getRangeMax)(particle.size.value), fullSize = maxSize + padding, canvasSize = fullSize * double;
|
|
78
|
+
let image;
|
|
60
79
|
if (typeof OffscreenCanvas !== "undefined") {
|
|
61
80
|
const canvas = new OffscreenCanvas(canvasSize, canvasSize), context = canvas.getContext("2d");
|
|
62
81
|
if (!context) {
|
|
@@ -65,8 +84,8 @@ class EmojiDrawer {
|
|
|
65
84
|
context.font = `400 ${maxSize * double}px ${font}`;
|
|
66
85
|
context.textBaseline = "middle";
|
|
67
86
|
context.textAlign = "center";
|
|
68
|
-
context.fillText(
|
|
69
|
-
|
|
87
|
+
context.fillText(value, fullSize, fullSize);
|
|
88
|
+
image = canvas.transferToImageBitmap();
|
|
70
89
|
}
|
|
71
90
|
else {
|
|
72
91
|
const canvas = document.createElement("canvas");
|
|
@@ -79,11 +98,11 @@ class EmojiDrawer {
|
|
|
79
98
|
context.font = `400 ${maxSize * double}px ${font}`;
|
|
80
99
|
context.textBaseline = "middle";
|
|
81
100
|
context.textAlign = "center";
|
|
82
|
-
context.fillText(
|
|
83
|
-
|
|
101
|
+
context.fillText(value, fullSize, fullSize);
|
|
102
|
+
image = canvas;
|
|
84
103
|
}
|
|
85
|
-
this._emojiShapeDict.set(key,
|
|
86
|
-
particle.
|
|
104
|
+
this._emojiShapeDict.set(key, image);
|
|
105
|
+
particle.emojiDataKey = key;
|
|
87
106
|
}
|
|
88
107
|
}
|
|
89
108
|
exports.EmojiDrawer = EmojiDrawer;
|
package/cjs/Utils.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.drawEmoji = drawEmoji;
|
|
4
|
-
function drawEmoji(data) {
|
|
5
|
-
const { context,
|
|
6
|
-
if (!
|
|
4
|
+
function drawEmoji(data, image) {
|
|
5
|
+
const { context, opacity } = data, half = 0.5, previousAlpha = context.globalAlpha;
|
|
6
|
+
if (!image) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
|
+
const diameter = image.width, radius = diameter * half;
|
|
9
10
|
context.globalAlpha = opacity;
|
|
10
|
-
context.drawImage(
|
|
11
|
+
context.drawImage(image, -radius, -radius, diameter, diameter);
|
|
11
12
|
context.globalAlpha = previousAlpha;
|
|
12
13
|
}
|
package/esm/EmojiDrawer.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import { executeOnSingleOrMultiple, getRangeMax, isInArray, itemFromSingleOrMultiple, loadFont, } from "@tsparticles/engine";
|
|
2
2
|
import { drawEmoji } from "./Utils.js";
|
|
3
|
-
const defaultFont = '"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"';
|
|
3
|
+
const defaultFont = '"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"', noPadding = 0;
|
|
4
4
|
export class EmojiDrawer {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.validTypes = ["emoji"];
|
|
7
7
|
this._emojiShapeDict = new Map();
|
|
8
8
|
}
|
|
9
9
|
destroy() {
|
|
10
|
-
for (const [key,
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
this._emojiShapeDict.delete(key);
|
|
10
|
+
for (const [key, data] of this._emojiShapeDict) {
|
|
11
|
+
if (data instanceof ImageBitmap) {
|
|
12
|
+
data?.close();
|
|
14
13
|
}
|
|
14
|
+
this._emojiShapeDict.delete(key);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
draw(data) {
|
|
18
|
-
|
|
18
|
+
const key = data.particle.emojiDataKey;
|
|
19
|
+
if (!key) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const image = this._emojiShapeDict.get(key);
|
|
23
|
+
if (!image) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
drawEmoji(data, image);
|
|
19
27
|
}
|
|
20
28
|
async init(container) {
|
|
21
29
|
const options = container.actualOptions, { validTypes } = this;
|
|
@@ -35,25 +43,36 @@ export class EmojiDrawer {
|
|
|
35
43
|
await Promise.all(promises);
|
|
36
44
|
}
|
|
37
45
|
particleDestroy(particle) {
|
|
38
|
-
|
|
46
|
+
particle.emojiDataKey = undefined;
|
|
39
47
|
}
|
|
40
|
-
particleInit(
|
|
48
|
+
particleInit(_container, particle) {
|
|
41
49
|
const double = 2, shapeData = particle.shapeData;
|
|
42
50
|
if (!shapeData?.value) {
|
|
43
51
|
return;
|
|
44
52
|
}
|
|
45
|
-
const emoji = itemFromSingleOrMultiple(shapeData.value, particle.randomIndexData)
|
|
53
|
+
const emoji = itemFromSingleOrMultiple(shapeData.value, particle.randomIndexData);
|
|
46
54
|
if (!emoji) {
|
|
47
55
|
return;
|
|
48
56
|
}
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
const emojiOptions = typeof emoji === "string"
|
|
58
|
+
? {
|
|
59
|
+
font: shapeData.font ?? defaultFont,
|
|
60
|
+
padding: shapeData.padding ?? noPadding,
|
|
61
|
+
value: emoji,
|
|
62
|
+
}
|
|
63
|
+
: {
|
|
64
|
+
font: defaultFont,
|
|
65
|
+
padding: noPadding,
|
|
66
|
+
...shapeData,
|
|
67
|
+
...emoji,
|
|
68
|
+
}, font = emojiOptions.font, value = emojiOptions.value;
|
|
69
|
+
const key = `${value}_${font}`;
|
|
70
|
+
if (this._emojiShapeDict.has(key)) {
|
|
71
|
+
particle.emojiDataKey = key;
|
|
52
72
|
return;
|
|
53
73
|
}
|
|
54
|
-
const
|
|
55
|
-
let
|
|
56
|
-
const maxSize = getRangeMax(particle.size.value);
|
|
74
|
+
const padding = emojiOptions.padding * double, maxSize = getRangeMax(particle.size.value), fullSize = maxSize + padding, canvasSize = fullSize * double;
|
|
75
|
+
let image;
|
|
57
76
|
if (typeof OffscreenCanvas !== "undefined") {
|
|
58
77
|
const canvas = new OffscreenCanvas(canvasSize, canvasSize), context = canvas.getContext("2d");
|
|
59
78
|
if (!context) {
|
|
@@ -62,8 +81,8 @@ export class EmojiDrawer {
|
|
|
62
81
|
context.font = `400 ${maxSize * double}px ${font}`;
|
|
63
82
|
context.textBaseline = "middle";
|
|
64
83
|
context.textAlign = "center";
|
|
65
|
-
context.fillText(
|
|
66
|
-
|
|
84
|
+
context.fillText(value, fullSize, fullSize);
|
|
85
|
+
image = canvas.transferToImageBitmap();
|
|
67
86
|
}
|
|
68
87
|
else {
|
|
69
88
|
const canvas = document.createElement("canvas");
|
|
@@ -76,10 +95,10 @@ export class EmojiDrawer {
|
|
|
76
95
|
context.font = `400 ${maxSize * double}px ${font}`;
|
|
77
96
|
context.textBaseline = "middle";
|
|
78
97
|
context.textAlign = "center";
|
|
79
|
-
context.fillText(
|
|
80
|
-
|
|
98
|
+
context.fillText(value, fullSize, fullSize);
|
|
99
|
+
image = canvas;
|
|
81
100
|
}
|
|
82
|
-
this._emojiShapeDict.set(key,
|
|
83
|
-
particle.
|
|
101
|
+
this._emojiShapeDict.set(key, image);
|
|
102
|
+
particle.emojiDataKey = key;
|
|
84
103
|
}
|
|
85
104
|
}
|
package/esm/Utils.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export function drawEmoji(data) {
|
|
2
|
-
const { context,
|
|
3
|
-
if (!
|
|
1
|
+
export function drawEmoji(data, image) {
|
|
2
|
+
const { context, opacity } = data, half = 0.5, previousAlpha = context.globalAlpha;
|
|
3
|
+
if (!image) {
|
|
4
4
|
return;
|
|
5
5
|
}
|
|
6
|
+
const diameter = image.width, radius = diameter * half;
|
|
6
7
|
context.globalAlpha = opacity;
|
|
7
|
-
context.drawImage(
|
|
8
|
+
context.drawImage(image, -radius, -radius, diameter, diameter);
|
|
8
9
|
context.globalAlpha = previousAlpha;
|
|
9
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/shape-emoji",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0-beta.1",
|
|
4
4
|
"description": "tsParticles emoji shape",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"./package.json": "./package.json"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@tsparticles/engine": "^3.
|
|
62
|
+
"@tsparticles/engine": "^3.6.0-beta.1"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"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 [13 Oct 2024 at 17:29]</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
|
-
* v3.
|
|
7
|
+
* v3.6.0-beta.1
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -34,7 +34,7 @@ return /******/ (() => { // webpackBootstrap
|
|
|
34
34
|
\*************************************/
|
|
35
35
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
36
36
|
|
|
37
|
-
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 _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nconst defaultFont = '\"Twemoji Mozilla\", Apple Color Emoji, \"Segoe UI Emoji\", \"Noto Color Emoji\", \"EmojiOne Color\"';\nclass EmojiDrawer {\n constructor() {\n this.validTypes = [\"emoji\"];\n this._emojiShapeDict = new Map();\n }\n destroy() {\n for (const [key,
|
|
37
|
+
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 _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nconst defaultFont = '\"Twemoji Mozilla\", Apple Color Emoji, \"Segoe UI Emoji\", \"Noto Color Emoji\", \"EmojiOne Color\"',\n noPadding = 0;\nclass EmojiDrawer {\n constructor() {\n this.validTypes = [\"emoji\"];\n this._emojiShapeDict = new Map();\n }\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,\n {\n validTypes\n } = this;\n if (!validTypes.find(t => (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(t, options.particles.shape.type))) {\n return;\n }\n const promises = [(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.loadFont)(defaultFont)],\n shapeOptions = validTypes.map(t => options.particles.shape.options[t]).find(t => !!t);\n if (shapeOptions) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.executeOnSingleOrMultiple)(shapeOptions, shape => {\n if (shape.font) {\n promises.push((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.loadFont)(shape.font));\n }\n });\n }\n await Promise.all(promises);\n }\n particleDestroy(particle) {\n particle.emojiDataKey = undefined;\n }\n particleInit(_container, particle) {\n const double = 2,\n 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 },\n font = emojiOptions.font,\n value = emojiOptions.value;\n const key = `${value}_${font}`;\n if (this._emojiShapeDict.has(key)) {\n particle.emojiDataKey = key;\n return;\n }\n const padding = emojiOptions.padding * double,\n maxSize = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeMax)(particle.size.value),\n fullSize = maxSize + padding,\n canvasSize = fullSize * double;\n let image;\n if (typeof OffscreenCanvas !== \"undefined\") {\n const canvas = new OffscreenCanvas(canvasSize, canvasSize),\n context = canvas.getContext(\"2d\");\n if (!context) {\n return;\n }\n context.font = `400 ${maxSize * double}px ${font}`;\n context.textBaseline = \"middle\";\n context.textAlign = \"center\";\n context.fillText(value, fullSize, fullSize);\n image = canvas.transferToImageBitmap();\n } else {\n const canvas = document.createElement(\"canvas\");\n canvas.width = canvasSize;\n canvas.height = canvasSize;\n const context = canvas.getContext(\"2d\");\n if (!context) {\n return;\n }\n context.font = `400 ${maxSize * double}px ${font}`;\n context.textBaseline = \"middle\";\n context.textAlign = \"center\";\n context.fillText(value, fullSize, fullSize);\n image = canvas;\n }\n this._emojiShapeDict.set(key, image);\n particle.emojiDataKey = key;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-emoji/./dist/browser/EmojiDrawer.js?");
|
|
38
38
|
|
|
39
39
|
/***/ }),
|
|
40
40
|
|
|
@@ -44,7 +44,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
44
44
|
\*******************************/
|
|
45
45
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
46
46
|
|
|
47
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ drawEmoji: () => (/* binding */ drawEmoji)\n/* harmony export */ });\nfunction drawEmoji(data) {\n const {\n context,\n
|
|
47
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ drawEmoji: () => (/* binding */ drawEmoji)\n/* harmony export */ });\nfunction drawEmoji(data, image) {\n const {\n context,\n opacity\n } = data,\n half = 0.5,\n previousAlpha = context.globalAlpha;\n if (!image) {\n return;\n }\n const diameter = image.width,\n radius = diameter * 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?");
|
|
48
48
|
|
|
49
49
|
/***/ }),
|
|
50
50
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.shape.emoji.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(this,(e=>(()=>{var t={303:t=>{t.exports=e}},o={};function i(e){var n=o[e];if(void 0!==n)return n.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};i.r(n),i.d(n,{loadEmojiShape:()=>l});var a=i(303);const r='"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"';class s{constructor(){this.validTypes=["emoji"],this._emojiShapeDict=new Map}destroy(){for(const[e,t]of this._emojiShapeDict)t instanceof ImageBitmap&&
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(this,(e=>(()=>{var t={303:t=>{t.exports=e}},o={};function i(e){var n=o[e];if(void 0!==n)return n.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};i.r(n),i.d(n,{loadEmojiShape:()=>l});var a=i(303);const r='"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"';class s{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 o=this._emojiShapeDict.get(t);o&&function(e,t){const{context:o,opacity:i}=e,n=o.globalAlpha;if(!t)return;const a=t.width,r=.5*a;o.globalAlpha=i,o.drawImage(t,-r,-r,a,a),o.globalAlpha=n}(e,o)}async init(e){const t=e.actualOptions,{validTypes:o}=this;if(!o.find((e=>(0,a.isInArray)(e,t.particles.shape.type))))return;const i=[(0,a.loadFont)(r)],n=o.map((e=>t.particles.shape.options[e])).find((e=>!!e));n&&(0,a.executeOnSingleOrMultiple)(n,(e=>{e.font&&i.push((0,a.loadFont)(e.font))})),await Promise.all(i)}particleDestroy(e){e.emojiDataKey=void 0}particleInit(e,t){const o=t.shapeData;if(!o?.value)return;const i=(0,a.itemFromSingleOrMultiple)(o.value,t.randomIndexData);if(!i)return;const n="string"==typeof i?{font:o.font??r,padding:o.padding??0,value:i}:{font:r,padding:0,...o,...i},s=n.font,l=n.value,p=`${l}_${s}`;if(this._emojiShapeDict.has(p))return void(t.emojiDataKey=p);const c=2*n.padding,f=(0,a.getRangeMax)(t.size.value),d=f+c,u=2*d;let m;if("undefined"!=typeof OffscreenCanvas){const e=new OffscreenCanvas(u,u),t=e.getContext("2d");if(!t)return;t.font=`400 ${2*f}px ${s}`,t.textBaseline="middle",t.textAlign="center",t.fillText(l,d,d),m=e.transferToImageBitmap()}else{const e=document.createElement("canvas");e.width=u,e.height=u;const t=e.getContext("2d");if(!t)return;t.font=`400 ${2*f}px ${s}`,t.textBaseline="middle",t.textAlign="center",t.fillText(l,d,d),m=e}this._emojiShapeDict.set(p,m),t.emojiDataKey=p}}async function l(e,t=!0){await e.addShape(new s,t)}return n})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Emoji Shape v3.
|
|
1
|
+
/*! tsParticles Emoji Shape v3.6.0-beta.1 by Matteo Bruni */
|
package/types/EmojiDrawer.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare class EmojiDrawer implements IShapeDrawer<EmojiParticle> {
|
|
|
7
7
|
draw(data: IShapeDrawData<EmojiParticle>): void;
|
|
8
8
|
init(container: Container): Promise<void>;
|
|
9
9
|
particleDestroy(particle: EmojiParticle): void;
|
|
10
|
-
particleInit(
|
|
10
|
+
particleInit(_container: Container, particle: EmojiParticle): void;
|
|
11
11
|
}
|
package/types/EmojiParticle.d.ts
CHANGED
package/types/IEmojiShape.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { IShapeValues, SingleOrMultiple } from "@tsparticles/engine";
|
|
2
|
+
export interface ISingleEmojiShape {
|
|
3
|
+
font?: string;
|
|
4
|
+
padding?: number;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
2
7
|
export interface IEmojiShape extends IShapeValues {
|
|
3
8
|
font?: string;
|
|
4
|
-
|
|
9
|
+
padding?: number;
|
|
10
|
+
value: SingleOrMultiple<string | ISingleEmojiShape>;
|
|
5
11
|
}
|
package/types/Utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { EmojiParticle } from "./EmojiParticle.js";
|
|
2
2
|
import type { IShapeDrawData } from "@tsparticles/engine";
|
|
3
|
-
export declare function drawEmoji(data: IShapeDrawData<EmojiParticle
|
|
3
|
+
export declare function drawEmoji(data: IShapeDrawData<EmojiParticle>, image: ImageBitmap | HTMLCanvasElement): void;
|
package/umd/EmojiDrawer.js
CHANGED
|
@@ -12,22 +12,30 @@
|
|
|
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 defaultFont = '"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"';
|
|
15
|
+
const defaultFont = '"Twemoji Mozilla", Apple Color Emoji, "Segoe UI Emoji", "Noto Color Emoji", "EmojiOne Color"', noPadding = 0;
|
|
16
16
|
class EmojiDrawer {
|
|
17
17
|
constructor() {
|
|
18
18
|
this.validTypes = ["emoji"];
|
|
19
19
|
this._emojiShapeDict = new Map();
|
|
20
20
|
}
|
|
21
21
|
destroy() {
|
|
22
|
-
for (const [key,
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
this._emojiShapeDict.delete(key);
|
|
22
|
+
for (const [key, data] of this._emojiShapeDict) {
|
|
23
|
+
if (data instanceof ImageBitmap) {
|
|
24
|
+
data?.close();
|
|
26
25
|
}
|
|
26
|
+
this._emojiShapeDict.delete(key);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
draw(data) {
|
|
30
|
-
|
|
30
|
+
const key = data.particle.emojiDataKey;
|
|
31
|
+
if (!key) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const image = this._emojiShapeDict.get(key);
|
|
35
|
+
if (!image) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
(0, Utils_js_1.drawEmoji)(data, image);
|
|
31
39
|
}
|
|
32
40
|
async init(container) {
|
|
33
41
|
const options = container.actualOptions, { validTypes } = this;
|
|
@@ -47,25 +55,36 @@
|
|
|
47
55
|
await Promise.all(promises);
|
|
48
56
|
}
|
|
49
57
|
particleDestroy(particle) {
|
|
50
|
-
|
|
58
|
+
particle.emojiDataKey = undefined;
|
|
51
59
|
}
|
|
52
|
-
particleInit(
|
|
60
|
+
particleInit(_container, particle) {
|
|
53
61
|
const double = 2, shapeData = particle.shapeData;
|
|
54
62
|
if (!shapeData?.value) {
|
|
55
63
|
return;
|
|
56
64
|
}
|
|
57
|
-
const emoji = (0, engine_1.itemFromSingleOrMultiple)(shapeData.value, particle.randomIndexData)
|
|
65
|
+
const emoji = (0, engine_1.itemFromSingleOrMultiple)(shapeData.value, particle.randomIndexData);
|
|
58
66
|
if (!emoji) {
|
|
59
67
|
return;
|
|
60
68
|
}
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
const emojiOptions = typeof emoji === "string"
|
|
70
|
+
? {
|
|
71
|
+
font: shapeData.font ?? defaultFont,
|
|
72
|
+
padding: shapeData.padding ?? noPadding,
|
|
73
|
+
value: emoji,
|
|
74
|
+
}
|
|
75
|
+
: {
|
|
76
|
+
font: defaultFont,
|
|
77
|
+
padding: noPadding,
|
|
78
|
+
...shapeData,
|
|
79
|
+
...emoji,
|
|
80
|
+
}, font = emojiOptions.font, value = emojiOptions.value;
|
|
81
|
+
const key = `${value}_${font}`;
|
|
82
|
+
if (this._emojiShapeDict.has(key)) {
|
|
83
|
+
particle.emojiDataKey = key;
|
|
64
84
|
return;
|
|
65
85
|
}
|
|
66
|
-
const
|
|
67
|
-
let
|
|
68
|
-
const maxSize = (0, engine_1.getRangeMax)(particle.size.value);
|
|
86
|
+
const padding = emojiOptions.padding * double, maxSize = (0, engine_1.getRangeMax)(particle.size.value), fullSize = maxSize + padding, canvasSize = fullSize * double;
|
|
87
|
+
let image;
|
|
69
88
|
if (typeof OffscreenCanvas !== "undefined") {
|
|
70
89
|
const canvas = new OffscreenCanvas(canvasSize, canvasSize), context = canvas.getContext("2d");
|
|
71
90
|
if (!context) {
|
|
@@ -74,8 +93,8 @@
|
|
|
74
93
|
context.font = `400 ${maxSize * double}px ${font}`;
|
|
75
94
|
context.textBaseline = "middle";
|
|
76
95
|
context.textAlign = "center";
|
|
77
|
-
context.fillText(
|
|
78
|
-
|
|
96
|
+
context.fillText(value, fullSize, fullSize);
|
|
97
|
+
image = canvas.transferToImageBitmap();
|
|
79
98
|
}
|
|
80
99
|
else {
|
|
81
100
|
const canvas = document.createElement("canvas");
|
|
@@ -88,11 +107,11 @@
|
|
|
88
107
|
context.font = `400 ${maxSize * double}px ${font}`;
|
|
89
108
|
context.textBaseline = "middle";
|
|
90
109
|
context.textAlign = "center";
|
|
91
|
-
context.fillText(
|
|
92
|
-
|
|
110
|
+
context.fillText(value, fullSize, fullSize);
|
|
111
|
+
image = canvas;
|
|
93
112
|
}
|
|
94
|
-
this._emojiShapeDict.set(key,
|
|
95
|
-
particle.
|
|
113
|
+
this._emojiShapeDict.set(key, image);
|
|
114
|
+
particle.emojiDataKey = key;
|
|
96
115
|
}
|
|
97
116
|
}
|
|
98
117
|
exports.EmojiDrawer = EmojiDrawer;
|
package/umd/Utils.js
CHANGED
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.drawEmoji = drawEmoji;
|
|
13
|
-
function drawEmoji(data) {
|
|
14
|
-
const { context,
|
|
15
|
-
if (!
|
|
13
|
+
function drawEmoji(data, image) {
|
|
14
|
+
const { context, opacity } = data, half = 0.5, previousAlpha = context.globalAlpha;
|
|
15
|
+
if (!image) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
+
const diameter = image.width, radius = diameter * half;
|
|
18
19
|
context.globalAlpha = opacity;
|
|
19
|
-
context.drawImage(
|
|
20
|
+
context.drawImage(image, -radius, -radius, diameter, diameter);
|
|
20
21
|
context.globalAlpha = previousAlpha;
|
|
21
22
|
}
|
|
22
23
|
});
|