@tsparticles/shape-text 3.3.0 → 3.4.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/browser/TextDrawer.js +9 -7
- package/browser/index.js +2 -3
- package/cjs/TextDrawer.js +11 -9
- package/cjs/index.js +1 -2
- package/esm/TextDrawer.js +9 -7
- package/esm/index.js +2 -3
- package/package.json +2 -2
- package/report.html +1 -1
- package/tsparticles.shape.text.js +3 -3
- package/tsparticles.shape.text.min.js +1 -1
- package/tsparticles.shape.text.min.js.LICENSE.txt +1 -1
- package/types/TextDrawer.d.ts +1 -1
- package/umd/TextDrawer.js +11 -9
- package/umd/index.js +1 -26
package/browser/TextDrawer.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { executeOnSingleOrMultiple, isInArray, itemFromSingleOrMultiple, loadFont, } from "@tsparticles/engine";
|
|
2
2
|
import { drawText } from "./Utils.js";
|
|
3
|
-
export const validTypes = ["text", "character", "char", "multiline-text"];
|
|
4
3
|
export class TextDrawer {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.validTypes = ["text", "character", "char", "multiline-text"];
|
|
6
|
+
}
|
|
5
7
|
draw(data) {
|
|
6
8
|
drawText(data);
|
|
7
9
|
}
|
|
8
10
|
async init(container) {
|
|
9
|
-
const options = container.actualOptions;
|
|
10
|
-
if (validTypes.find(
|
|
11
|
+
const options = container.actualOptions, { validTypes } = this;
|
|
12
|
+
if (validTypes.find(t => isInArray(t, options.particles.shape.type))) {
|
|
11
13
|
const shapeOptions = validTypes
|
|
12
|
-
.map(
|
|
13
|
-
.find(
|
|
14
|
-
executeOnSingleOrMultiple(shapeOptions,
|
|
14
|
+
.map(t => options.particles.shape.options[t])
|
|
15
|
+
.find(t => !!t), promises = [];
|
|
16
|
+
executeOnSingleOrMultiple(shapeOptions, shape => {
|
|
15
17
|
promises.push(loadFont(shape.font, shape.weight));
|
|
16
18
|
});
|
|
17
19
|
await Promise.all(promises);
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
particleInit(container, particle) {
|
|
21
|
-
if (!particle.shape || !validTypes.includes(particle.shape)) {
|
|
23
|
+
if (!particle.shape || !this.validTypes.includes(particle.shape)) {
|
|
22
24
|
return;
|
|
23
25
|
}
|
|
24
26
|
const character = particle.shapeData;
|
package/browser/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TextDrawer } from "./TextDrawer.js";
|
|
2
2
|
export async function loadTextShape(engine, refresh = true) {
|
|
3
|
-
|
|
4
|
-
await engine.addShape(validTypes, new TextDrawer(), refresh);
|
|
3
|
+
await engine.addShape(new TextDrawer(), refresh);
|
|
5
4
|
}
|
package/cjs/TextDrawer.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextDrawer =
|
|
3
|
+
exports.TextDrawer = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
5
|
const Utils_js_1 = require("./Utils.js");
|
|
6
|
-
exports.validTypes = ["text", "character", "char", "multiline-text"];
|
|
7
6
|
class TextDrawer {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.validTypes = ["text", "character", "char", "multiline-text"];
|
|
9
|
+
}
|
|
8
10
|
draw(data) {
|
|
9
11
|
(0, Utils_js_1.drawText)(data);
|
|
10
12
|
}
|
|
11
13
|
async init(container) {
|
|
12
|
-
const options = container.actualOptions;
|
|
13
|
-
if (
|
|
14
|
-
const shapeOptions =
|
|
15
|
-
.map(
|
|
16
|
-
.find(
|
|
17
|
-
(0, engine_1.executeOnSingleOrMultiple)(shapeOptions,
|
|
14
|
+
const options = container.actualOptions, { validTypes } = this;
|
|
15
|
+
if (validTypes.find(t => (0, engine_1.isInArray)(t, options.particles.shape.type))) {
|
|
16
|
+
const shapeOptions = validTypes
|
|
17
|
+
.map(t => options.particles.shape.options[t])
|
|
18
|
+
.find(t => !!t), promises = [];
|
|
19
|
+
(0, engine_1.executeOnSingleOrMultiple)(shapeOptions, shape => {
|
|
18
20
|
promises.push((0, engine_1.loadFont)(shape.font, shape.weight));
|
|
19
21
|
});
|
|
20
22
|
await Promise.all(promises);
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
particleInit(container, particle) {
|
|
24
|
-
if (!particle.shape || !
|
|
26
|
+
if (!particle.shape || !this.validTypes.includes(particle.shape)) {
|
|
25
27
|
return;
|
|
26
28
|
}
|
|
27
29
|
const character = particle.shapeData;
|
package/cjs/index.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.loadTextShape = void 0;
|
|
4
4
|
const TextDrawer_js_1 = require("./TextDrawer.js");
|
|
5
5
|
async function loadTextShape(engine, refresh = true) {
|
|
6
|
-
|
|
7
|
-
await engine.addShape(TextDrawer_js_1.validTypes, new TextDrawer(), refresh);
|
|
6
|
+
await engine.addShape(new TextDrawer_js_1.TextDrawer(), refresh);
|
|
8
7
|
}
|
|
9
8
|
exports.loadTextShape = loadTextShape;
|
package/esm/TextDrawer.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { executeOnSingleOrMultiple, isInArray, itemFromSingleOrMultiple, loadFont, } from "@tsparticles/engine";
|
|
2
2
|
import { drawText } from "./Utils.js";
|
|
3
|
-
export const validTypes = ["text", "character", "char", "multiline-text"];
|
|
4
3
|
export class TextDrawer {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.validTypes = ["text", "character", "char", "multiline-text"];
|
|
6
|
+
}
|
|
5
7
|
draw(data) {
|
|
6
8
|
drawText(data);
|
|
7
9
|
}
|
|
8
10
|
async init(container) {
|
|
9
|
-
const options = container.actualOptions;
|
|
10
|
-
if (validTypes.find(
|
|
11
|
+
const options = container.actualOptions, { validTypes } = this;
|
|
12
|
+
if (validTypes.find(t => isInArray(t, options.particles.shape.type))) {
|
|
11
13
|
const shapeOptions = validTypes
|
|
12
|
-
.map(
|
|
13
|
-
.find(
|
|
14
|
-
executeOnSingleOrMultiple(shapeOptions,
|
|
14
|
+
.map(t => options.particles.shape.options[t])
|
|
15
|
+
.find(t => !!t), promises = [];
|
|
16
|
+
executeOnSingleOrMultiple(shapeOptions, shape => {
|
|
15
17
|
promises.push(loadFont(shape.font, shape.weight));
|
|
16
18
|
});
|
|
17
19
|
await Promise.all(promises);
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
particleInit(container, particle) {
|
|
21
|
-
if (!particle.shape || !validTypes.includes(particle.shape)) {
|
|
23
|
+
if (!particle.shape || !this.validTypes.includes(particle.shape)) {
|
|
22
24
|
return;
|
|
23
25
|
}
|
|
24
26
|
const character = particle.shapeData;
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TextDrawer } from "./TextDrawer.js";
|
|
2
2
|
export async function loadTextShape(engine, refresh = true) {
|
|
3
|
-
|
|
4
|
-
await engine.addShape(validTypes, new TextDrawer(), refresh);
|
|
3
|
+
await engine.addShape(new TextDrawer(), refresh);
|
|
5
4
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/shape-text",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "tsParticles text 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.4.0"
|
|
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-text [
|
|
6
|
+
<title>@tsparticles/shape-text [13 May 2024 at 00:14]</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.4.0
|
|
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 */ TextDrawer: () => (/* binding */ TextDrawer)
|
|
37
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TextDrawer: () => (/* binding */ TextDrawer)\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\nclass TextDrawer {\n constructor() {\n this.validTypes = [\"text\", \"character\", \"char\", \"multiline-text\"];\n }\n draw(data) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawText)(data);\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 const shapeOptions = validTypes.map(t => options.particles.shape.options[t]).find(t => !!t),\n promises = [];\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.executeOnSingleOrMultiple)(shapeOptions, shape => {\n promises.push((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.loadFont)(shape.font, shape.weight));\n });\n await Promise.all(promises);\n }\n }\n particleInit(container, particle) {\n if (!particle.shape || !this.validTypes.includes(particle.shape)) {\n return;\n }\n const character = particle.shapeData;\n if (character === undefined) {\n return;\n }\n const textData = character.value;\n if (textData === undefined) {\n return;\n }\n particle.text = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromSingleOrMultiple)(textData, particle.randomIndexData);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-text/./dist/browser/TextDrawer.js?");
|
|
38
38
|
|
|
39
39
|
/***/ }),
|
|
40
40
|
|
|
@@ -54,7 +54,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
54
54
|
\*******************************/
|
|
55
55
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
56
56
|
|
|
57
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadTextShape: () => (/* binding */ loadTextShape)\n/* harmony export */ });\n/* harmony import */ var _TextDrawer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./TextDrawer.js */ \"./dist/browser/TextDrawer.js\");\n\nasync function loadTextShape(engine, refresh = true) {\n
|
|
57
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadTextShape: () => (/* binding */ loadTextShape)\n/* harmony export */ });\n/* harmony import */ var _TextDrawer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./TextDrawer.js */ \"./dist/browser/TextDrawer.js\");\n\nasync function loadTextShape(engine, refresh = true) {\n await engine.addShape(new _TextDrawer_js__WEBPACK_IMPORTED_MODULE_0__.TextDrawer(), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/shape-text/./dist/browser/index.js?");
|
|
58
58
|
|
|
59
59
|
/***/ }),
|
|
60
60
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.shape.text.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
|
|
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 r=o[e]={exports:{}};return t[e](r,r.exports,i),r.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={};return(()=>{i.r(n),i.d(n,{loadTextShape:()=>s});var e=i(303);const t=2,o=.5;function r(e,i,n,r,a,s){const l={x:-(i.length*n*o),y:n*o},p=n*t;s?e.fillText(i,l.x,l.y+p*a):e.strokeText(i,l.x,l.y+p*a)}class a{constructor(){this.validTypes=["text","character","char","multiline-text"]}draw(o){!function(o){const{context:i,particle:n,radius:a,opacity:s}=o,l=n.shapeData;if(!l)return;const p=l.value;if(void 0===p)return;void 0===n.text&&(n.text=(0,e.itemFromSingleOrMultiple)(p,n.randomIndexData));const c=n.text,d=l.style??"",f=l.weight??"400",u=Math.round(a)*t,x=l.font??"Verdana",y=n.shapeFill,h=c?.split("\n");if(h){i.font=`${d} ${f} ${u}px "${x}"`,i.globalAlpha=s;for(let e=0;e<h.length;e++)r(i,h[e],a,0,e,y);i.globalAlpha=1}}(o)}async init(t){const o=t.actualOptions,{validTypes:i}=this;if(i.find((t=>(0,e.isInArray)(t,o.particles.shape.type)))){const t=i.map((e=>o.particles.shape.options[e])).find((e=>!!e)),n=[];(0,e.executeOnSingleOrMultiple)(t,(t=>{n.push((0,e.loadFont)(t.font,t.weight))})),await Promise.all(n)}}particleInit(t,o){if(!o.shape||!this.validTypes.includes(o.shape))return;const i=o.shapeData;if(void 0===i)return;const n=i.value;void 0!==n&&(o.text=(0,e.itemFromSingleOrMultiple)(n,o.randomIndexData))}}async function s(e,t=!0){await e.addShape(new a,t)}})(),n})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Text Shape v3.
|
|
1
|
+
/*! tsParticles Text Shape v3.4.0 by Matteo Bruni */
|
package/types/TextDrawer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Container, type IShapeDrawData, type IShapeDrawer } from "@tsparticles/engine";
|
|
2
2
|
import type { TextParticle } from "./TextParticle.js";
|
|
3
|
-
export declare const validTypes: string[];
|
|
4
3
|
export declare class TextDrawer implements IShapeDrawer<TextParticle> {
|
|
4
|
+
readonly validTypes: readonly ["text", "character", "char", "multiline-text"];
|
|
5
5
|
draw(data: IShapeDrawData<TextParticle>): void;
|
|
6
6
|
init(container: Container): Promise<void>;
|
|
7
7
|
particleInit(container: Container, particle: TextParticle): void;
|
package/umd/TextDrawer.js
CHANGED
|
@@ -9,28 +9,30 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TextDrawer =
|
|
12
|
+
exports.TextDrawer = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const Utils_js_1 = require("./Utils.js");
|
|
15
|
-
exports.validTypes = ["text", "character", "char", "multiline-text"];
|
|
16
15
|
class TextDrawer {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.validTypes = ["text", "character", "char", "multiline-text"];
|
|
18
|
+
}
|
|
17
19
|
draw(data) {
|
|
18
20
|
(0, Utils_js_1.drawText)(data);
|
|
19
21
|
}
|
|
20
22
|
async init(container) {
|
|
21
|
-
const options = container.actualOptions;
|
|
22
|
-
if (
|
|
23
|
-
const shapeOptions =
|
|
24
|
-
.map(
|
|
25
|
-
.find(
|
|
26
|
-
(0, engine_1.executeOnSingleOrMultiple)(shapeOptions,
|
|
23
|
+
const options = container.actualOptions, { validTypes } = this;
|
|
24
|
+
if (validTypes.find(t => (0, engine_1.isInArray)(t, options.particles.shape.type))) {
|
|
25
|
+
const shapeOptions = validTypes
|
|
26
|
+
.map(t => options.particles.shape.options[t])
|
|
27
|
+
.find(t => !!t), promises = [];
|
|
28
|
+
(0, engine_1.executeOnSingleOrMultiple)(shapeOptions, shape => {
|
|
27
29
|
promises.push((0, engine_1.loadFont)(shape.font, shape.weight));
|
|
28
30
|
});
|
|
29
31
|
await Promise.all(promises);
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
particleInit(container, particle) {
|
|
33
|
-
if (!particle.shape || !
|
|
35
|
+
if (!particle.shape || !this.validTypes.includes(particle.shape)) {
|
|
34
36
|
return;
|
|
35
37
|
}
|
|
36
38
|
const character = particle.shapeData;
|
package/umd/index.js
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
-
if (k2 === undefined) k2 = k;
|
|
3
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
-
}
|
|
7
|
-
Object.defineProperty(o, k2, desc);
|
|
8
|
-
}) : (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
o[k2] = m[k];
|
|
11
|
-
}));
|
|
12
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
-
}) : function(o, v) {
|
|
15
|
-
o["default"] = v;
|
|
16
|
-
});
|
|
17
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
-
if (mod && mod.__esModule) return mod;
|
|
19
|
-
var result = {};
|
|
20
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
-
__setModuleDefault(result, mod);
|
|
22
|
-
return result;
|
|
23
|
-
};
|
|
24
1
|
(function (factory) {
|
|
25
2
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
26
3
|
var v = factory(require, exports);
|
|
@@ -31,13 +8,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
8
|
}
|
|
32
9
|
})(function (require, exports) {
|
|
33
10
|
"use strict";
|
|
34
|
-
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
35
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
12
|
exports.loadTextShape = void 0;
|
|
37
13
|
const TextDrawer_js_1 = require("./TextDrawer.js");
|
|
38
14
|
async function loadTextShape(engine, refresh = true) {
|
|
39
|
-
|
|
40
|
-
await engine.addShape(TextDrawer_js_1.validTypes, new TextDrawer(), refresh);
|
|
15
|
+
await engine.addShape(new TextDrawer_js_1.TextDrawer(), refresh);
|
|
41
16
|
}
|
|
42
17
|
exports.loadTextShape = loadTextShape;
|
|
43
18
|
});
|