Socket
Socket
Sign inDemoInstall

tsparticles-shape-text

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsparticles-shape-text - npm Package Compare versions

Comparing version 2.0.0-beta.2 to 2.0.0-beta.3

2

index.d.ts
import type { Main } from "tsparticles-engine";
export declare function loadTextShape(tsParticles: Main): void;
export declare function loadTextShape(tsParticles: Main): Promise<void>;

@@ -0,7 +1,18 @@

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { validTypes, TextDrawer } from "./TextDrawer";
export function loadTextShape(tsParticles) {
const drawer = new TextDrawer();
for (const type of validTypes) {
tsParticles.addShape(type, drawer);
}
return __awaiter(this, void 0, void 0, function* () {
const drawer = new TextDrawer();
for (const type of validTypes) {
yield tsParticles.addShape(type, drawer);
}
});
}
{
"name": "tsparticles-shape-text",
"version": "2.0.0-beta.2",
"version": "2.0.0-beta.3",
"description": "tsParticles text shape",

@@ -48,4 +48,4 @@ "homepage": "https://particles.js.org/",

"dependencies": {
"tsparticles-engine": "^2.0.0-beta.1"
"tsparticles-engine": "^2.0.0-beta.2"
}
}
[![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org)
# tsparticles-shape-text
# tsParticles Text Shape
tsParticles text shape
[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-shape-text/badge)](https://www.jsdelivr.com/package/npm/tsparticles-shape-text)
[![npmjs](https://badge.fury.io/js/tsparticles-shape-text.svg)](https://www.npmjs.com/package/tsparticles-shape-text)
[![npmjs](https://img.shields.io/npm/dt/tsparticles-shape-text)](https://www.npmjs.com/package/tsparticles-shape-text)
[tsParticles](https://github.com/matteobruni/tsparticles) additional text shape.
## How to use it
### CDN / Vanilla JS / jQuery
The CDN/Vanilla version JS has one required file in vanilla configuration:
Including the `tsparticles.shape.text.min.js` file will export the function to load the shape:
```javascript
loadTextShape;
```
### Usage
Once the scripts are loaded you can set up `tsParticles` and the shape like this:
```javascript
loadTextShape(tsParticles);
tsParticles.load("tsparticles", {
/* options */
/* here you can use particles.shape.type: "text" */
});
```
### ESM / CommonJS
This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
```shell
$ npm install tsparticles-shape-text
```
or
```shell
$ yarn add tsparticles-shape-text
```
Then you need to import it in the app, like this:
```javascript
const { tsParticles } = require("tsparticles-engine");
const { loadTextShape } = require("tsparticles-shape-text");
loadTextShape(tsParticles);
```
or
```javascript
import { tsParticles } from "tsparticles-engine";
import { loadTextShape } from "tsparticles-shape-text";
loadTextShape(tsParticles);
```

@@ -7,3 +7,3 @@ /*!

* How to use? : Check the GitHub README
* v2.0.0-beta.2
* v2.0.0-beta.3
*/

@@ -210,9 +210,43 @@ (function webpackUniversalModuleDefinition(root, factory) {

;// CONCATENATED MODULE: ./dist/index.js
var dist_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function (resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
function loadTextShape(tsParticles) {
const drawer = new TextDrawer();
return dist_awaiter(this, void 0, void 0, function* () {
const drawer = new TextDrawer();
for (const type of validTypes) {
tsParticles.addShape(type, drawer);
}
for (const type of validTypes) {
yield tsParticles.addShape(type, drawer);
}
});
}

@@ -219,0 +253,0 @@ })();

@@ -1,2 +0,2 @@

/*! tsParticles Text Shape v2.0.0-beta.2 by Matteo Bruni */
!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 n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(this,(function(e){return(()=>{"use strict";var t={818:t=>{t.exports=e}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{loadTextShape:()=>a});var e=n(818),t=function(e,t,o,n){return new(o||(o=Promise))((function(r,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))};const o=["text","character","char"];class i{getSidesCount(){return 12}init(n){return t(this,void 0,void 0,(function*(){const t=n.actualOptions;if(o.find((o=>(0,e.isInArray)(o,t.particles.shape.type)))){const n=o.map((e=>t.particles.shape.options[e])).find((e=>!!e));if(n instanceof Array){const t=[];for(const o of n)t.push((0,e.loadFont)(o));yield Promise.allSettled(t)}else void 0!==n&&(yield(0,e.loadFont)(n))}}))}draw(t,o,n,r){var i,a,s;const l=o.shapeData;if(void 0===l)return;const c=l.value;if(void 0===c)return;const f=o;void 0===f.text&&(f.text=c instanceof Array?(0,e.itemFromArray)(c,o.randomIndexData):c);const d=f.text,p=null!==(i=l.style)&&void 0!==i?i:"",u=null!==(a=l.weight)&&void 0!==a?a:"400",y=2*Math.round(n),v=null!==(s=l.font)&&void 0!==s?s:"Verdana",x=o.fill,h=d.length*n/2;t.font=`${p} ${u} ${y}px "${v}"`;const b={x:-h,y:n/2};t.globalAlpha=r,x?t.fillText(d,b.x,b.y):t.strokeText(d,b.x,b.y),t.globalAlpha=1}}function a(e){const t=new i;for(const n of o)e.addShape(n,t)}})(),r})()}));
/*! tsParticles Text Shape v2.0.0-beta.3 by Matteo Bruni */
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("tsparticles-engine"));else if("function"==typeof define&&define.amd)define(["tsparticles-engine"],e);else{var n="object"==typeof exports?e(require("tsparticles-engine")):e(t.window);for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(this,(function(t){return(()=>{"use strict";var e={818:e=>{e.exports=t}},n={};function o(t){var r=n[t];if(void 0!==r)return r.exports;var i=n[t]={exports:{}};return e[t](i,i.exports,o),i.exports}o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{loadTextShape:()=>c});var t=o(818),e=function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{s(o.next(t))}catch(t){i(t)}}function c(t){try{s(o.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}s((o=o.apply(t,e||[])).next())}))};const n=["text","character","char"];class i{getSidesCount(){return 12}init(o){return e(this,void 0,void 0,(function*(){const e=o.actualOptions;if(n.find((n=>(0,t.isInArray)(n,e.particles.shape.type)))){const o=n.map((t=>e.particles.shape.options[t])).find((t=>!!t));if(o instanceof Array){const e=[];for(const n of o)e.push((0,t.loadFont)(n));yield Promise.allSettled(e)}else void 0!==o&&(yield(0,t.loadFont)(o))}}))}draw(e,n,o,r){var i,a,c;const s=n.shapeData;if(void 0===s)return;const l=s.value;if(void 0===l)return;const f=n;void 0===f.text&&(f.text=l instanceof Array?(0,t.itemFromArray)(l,n.randomIndexData):l);const u=f.text,d=null!==(i=s.style)&&void 0!==i?i:"",p=null!==(a=s.weight)&&void 0!==a?a:"400",y=2*Math.round(o),v=null!==(c=s.font)&&void 0!==c?c:"Verdana",x=n.fill,h=u.length*o/2;e.font=`${d} ${p} ${y}px "${v}"`;const b={x:-h,y:o/2};e.globalAlpha=r,x?e.fillText(u,b.x,b.y):e.strokeText(u,b.x,b.y),e.globalAlpha=1}}var a=function(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{s(o.next(t))}catch(t){i(t)}}function c(t){try{s(o.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}s((o=o.apply(t,e||[])).next())}))};function c(t){return a(this,void 0,void 0,(function*(){const e=new i;for(const o of n)yield t.addShape(o,e)}))}})(),r})()}));

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc