@tsparticles/plugin-emitters-shape-square 3.0.0-beta.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Matteo Bruni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ [![banner](https://particles.js.org/images/banner3.png)](https://particles.js.org)
2
+
3
+ # tsParticles Emitters Shape Square Plugin
4
+
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/plugin-emitters-shape-square/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/plugin-emitters-shape-square)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/plugin-emitters-shape-square.svg)](https://www.npmjs.com/package/@tsparticles/plugin-emitters-shape-square)
7
+ [![npmjs](https://img.shields.io/npm/dt/@tsparticles/plugin-emitters-shape-square)](https://www.npmjs.com/package/@tsparticles/plugin-emitters-shape-square) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
+
9
+ [tsParticles](https://github.com/tsparticles/tsparticles) plugin for adding the emitters shape square support.
10
+
11
+ ## How to use it
12
+
13
+ ### CDN / Vanilla JS / jQuery
14
+
15
+ The CDN/Vanilla version JS has one required file in vanilla configuration:
16
+
17
+ Including the `tsparticles.plugin.emitters.shape.square.min.js` file will export the function to load the plugin:
18
+
19
+ ```text
20
+ loadEmittersShapeSquarePlugin
21
+ ```
22
+
23
+ ### Usage
24
+
25
+ Once the scripts are loaded you can set up `tsParticles` and the plugin like this:
26
+
27
+ ```javascript
28
+ (async () => {
29
+ await loadEmittersPlugin(tsParticles);
30
+ await loadEmittersShapeSquarePlugin(tsParticles);
31
+
32
+ await tsParticles.load({
33
+ id: "tsparticles",
34
+ options: {
35
+ /* options */
36
+ },
37
+ });
38
+ })();
39
+ ```
40
+
41
+ ### ESM / CommonJS
42
+
43
+ This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
44
+
45
+ ```shell
46
+ $ npm install @tsparticles/plugin-emitters-shape-square
47
+ ```
48
+
49
+ or
50
+
51
+ ```shell
52
+ $ yarn add @tsparticles/plugin-emitters-shape-square
53
+ ```
54
+
55
+ Then you need to import it in the app, like this:
56
+
57
+ ```javascript
58
+ const { tsParticles } = require("@tsparticles/engine");
59
+ const { loadEmittersPlugin } = require("@tsparticles/plugin-emitters");
60
+ const { loadEmittersShapeSquarePlugin } = require("@tsparticles/plugin-emitters-shape-square");
61
+
62
+ (async () => {
63
+ await loadEmittersPlugin(tsParticles);
64
+ await loadEmittersShapeSquarePlugin(tsParticles);
65
+ })();
66
+ ```
67
+
68
+ or
69
+
70
+ ```javascript
71
+ import { tsParticles } from "@tsparticles/engine";
72
+ import { loadEmittersPlugin } from "@tsparticles/plugin-emitters";
73
+ import { loadEmittersShapeSquarePlugin } from "@tsparticles/plugin-emitters-shape-square";
74
+
75
+ (async () => {
76
+ await loadEmittersPlugin(tsParticles);
77
+ await loadEmittersShapeSquarePlugin(tsParticles);
78
+ })();
79
+ ```
@@ -0,0 +1,57 @@
1
+ import { EmitterShapeBase } from "@tsparticles/plugin-emitters";
2
+ import { getRandom } from "@tsparticles/engine";
3
+ function randomSquareCoordinate(position, offset) {
4
+ return position + offset * (getRandom() - 0.5);
5
+ }
6
+ export class EmittersSquareShape extends EmitterShapeBase {
7
+ constructor(position, size, fill, options) {
8
+ super(position, size, fill, options);
9
+ }
10
+ async init() {
11
+ }
12
+ async randomPosition() {
13
+ const fill = this.fill, position = this.position, size = this.size;
14
+ if (fill) {
15
+ return {
16
+ position: {
17
+ x: randomSquareCoordinate(position.x, size.width),
18
+ y: randomSquareCoordinate(position.y, size.height),
19
+ },
20
+ };
21
+ }
22
+ else {
23
+ const halfW = size.width / 2, halfH = size.height / 2, side = Math.floor(getRandom() * 4), v = (getRandom() - 0.5) * 2;
24
+ switch (side) {
25
+ case 0:
26
+ return {
27
+ position: {
28
+ x: position.x + v * halfW,
29
+ y: position.y - halfH,
30
+ },
31
+ };
32
+ case 1:
33
+ return {
34
+ position: {
35
+ x: position.x - halfW,
36
+ y: position.y + v * halfH,
37
+ },
38
+ };
39
+ case 2:
40
+ return {
41
+ position: {
42
+ x: position.x + v * halfW,
43
+ y: position.y + halfH,
44
+ },
45
+ };
46
+ case 3:
47
+ default:
48
+ return {
49
+ position: {
50
+ x: position.x + halfW,
51
+ y: position.y + v * halfH,
52
+ },
53
+ };
54
+ }
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,6 @@
1
+ import { EmittersSquareShape } from "./EmittersSquareShape.js";
2
+ export class EmittersSquareShapeGenerator {
3
+ generate(position, size, fill, options) {
4
+ return new EmittersSquareShape(position, size, fill, options);
5
+ }
6
+ }
@@ -0,0 +1,7 @@
1
+ import { EmittersSquareShapeGenerator } from "./EmittersSquareShapeGenerator.js";
2
+ export async function loadEmittersShapeSquare(engine, refresh = true) {
3
+ const emittersEngine = engine;
4
+ emittersEngine.addEmitterShapeGenerator &&
5
+ emittersEngine.addEmitterShapeGenerator("square", new EmittersSquareShapeGenerator());
6
+ await emittersEngine.refresh(refresh);
7
+ }
@@ -0,0 +1 @@
1
+ { "type": "module" }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmittersSquareShape = void 0;
4
+ const plugin_emitters_1 = require("@tsparticles/plugin-emitters");
5
+ const engine_1 = require("@tsparticles/engine");
6
+ function randomSquareCoordinate(position, offset) {
7
+ return position + offset * ((0, engine_1.getRandom)() - 0.5);
8
+ }
9
+ class EmittersSquareShape extends plugin_emitters_1.EmitterShapeBase {
10
+ constructor(position, size, fill, options) {
11
+ super(position, size, fill, options);
12
+ }
13
+ async init() {
14
+ }
15
+ async randomPosition() {
16
+ const fill = this.fill, position = this.position, size = this.size;
17
+ if (fill) {
18
+ return {
19
+ position: {
20
+ x: randomSquareCoordinate(position.x, size.width),
21
+ y: randomSquareCoordinate(position.y, size.height),
22
+ },
23
+ };
24
+ }
25
+ else {
26
+ const halfW = size.width / 2, halfH = size.height / 2, side = Math.floor((0, engine_1.getRandom)() * 4), v = ((0, engine_1.getRandom)() - 0.5) * 2;
27
+ switch (side) {
28
+ case 0:
29
+ return {
30
+ position: {
31
+ x: position.x + v * halfW,
32
+ y: position.y - halfH,
33
+ },
34
+ };
35
+ case 1:
36
+ return {
37
+ position: {
38
+ x: position.x - halfW,
39
+ y: position.y + v * halfH,
40
+ },
41
+ };
42
+ case 2:
43
+ return {
44
+ position: {
45
+ x: position.x + v * halfW,
46
+ y: position.y + halfH,
47
+ },
48
+ };
49
+ case 3:
50
+ default:
51
+ return {
52
+ position: {
53
+ x: position.x + halfW,
54
+ y: position.y + v * halfH,
55
+ },
56
+ };
57
+ }
58
+ }
59
+ }
60
+ }
61
+ exports.EmittersSquareShape = EmittersSquareShape;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmittersSquareShapeGenerator = void 0;
4
+ const EmittersSquareShape_js_1 = require("./EmittersSquareShape.js");
5
+ class EmittersSquareShapeGenerator {
6
+ generate(position, size, fill, options) {
7
+ return new EmittersSquareShape_js_1.EmittersSquareShape(position, size, fill, options);
8
+ }
9
+ }
10
+ exports.EmittersSquareShapeGenerator = EmittersSquareShapeGenerator;
package/cjs/index.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadEmittersShapeSquare = void 0;
4
+ const EmittersSquareShapeGenerator_js_1 = require("./EmittersSquareShapeGenerator.js");
5
+ async function loadEmittersShapeSquare(engine, refresh = true) {
6
+ const emittersEngine = engine;
7
+ emittersEngine.addEmitterShapeGenerator &&
8
+ emittersEngine.addEmitterShapeGenerator("square", new EmittersSquareShapeGenerator_js_1.EmittersSquareShapeGenerator());
9
+ await emittersEngine.refresh(refresh);
10
+ }
11
+ exports.loadEmittersShapeSquare = loadEmittersShapeSquare;
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
@@ -0,0 +1,57 @@
1
+ import { EmitterShapeBase } from "@tsparticles/plugin-emitters";
2
+ import { getRandom } from "@tsparticles/engine";
3
+ function randomSquareCoordinate(position, offset) {
4
+ return position + offset * (getRandom() - 0.5);
5
+ }
6
+ export class EmittersSquareShape extends EmitterShapeBase {
7
+ constructor(position, size, fill, options) {
8
+ super(position, size, fill, options);
9
+ }
10
+ async init() {
11
+ }
12
+ async randomPosition() {
13
+ const fill = this.fill, position = this.position, size = this.size;
14
+ if (fill) {
15
+ return {
16
+ position: {
17
+ x: randomSquareCoordinate(position.x, size.width),
18
+ y: randomSquareCoordinate(position.y, size.height),
19
+ },
20
+ };
21
+ }
22
+ else {
23
+ const halfW = size.width / 2, halfH = size.height / 2, side = Math.floor(getRandom() * 4), v = (getRandom() - 0.5) * 2;
24
+ switch (side) {
25
+ case 0:
26
+ return {
27
+ position: {
28
+ x: position.x + v * halfW,
29
+ y: position.y - halfH,
30
+ },
31
+ };
32
+ case 1:
33
+ return {
34
+ position: {
35
+ x: position.x - halfW,
36
+ y: position.y + v * halfH,
37
+ },
38
+ };
39
+ case 2:
40
+ return {
41
+ position: {
42
+ x: position.x + v * halfW,
43
+ y: position.y + halfH,
44
+ },
45
+ };
46
+ case 3:
47
+ default:
48
+ return {
49
+ position: {
50
+ x: position.x + halfW,
51
+ y: position.y + v * halfH,
52
+ },
53
+ };
54
+ }
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,6 @@
1
+ import { EmittersSquareShape } from "./EmittersSquareShape.js";
2
+ export class EmittersSquareShapeGenerator {
3
+ generate(position, size, fill, options) {
4
+ return new EmittersSquareShape(position, size, fill, options);
5
+ }
6
+ }
package/esm/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import { EmittersSquareShapeGenerator } from "./EmittersSquareShapeGenerator.js";
2
+ export async function loadEmittersShapeSquare(engine, refresh = true) {
3
+ const emittersEngine = engine;
4
+ emittersEngine.addEmitterShapeGenerator &&
5
+ emittersEngine.addEmitterShapeGenerator("square", new EmittersSquareShapeGenerator());
6
+ await emittersEngine.refresh(refresh);
7
+ }
@@ -0,0 +1 @@
1
+ { "type": "module" }
package/package.json ADDED
@@ -0,0 +1,109 @@
1
+ {
2
+ "name": "@tsparticles/plugin-emitters-shape-square",
3
+ "version": "3.0.0-beta.4",
4
+ "description": "tsParticles emitters shape square plugin",
5
+ "homepage": "https://particles.js.org",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/tsparticles/tsparticles.git",
9
+ "directory": "plugins/emitterShapes/square"
10
+ },
11
+ "keywords": [
12
+ "front-end",
13
+ "frontend",
14
+ "tsparticles",
15
+ "particles.js",
16
+ "particlesjs",
17
+ "particles",
18
+ "particle",
19
+ "canvas",
20
+ "jsparticles",
21
+ "xparticles",
22
+ "particles-js",
23
+ "particles-bg",
24
+ "particles-bg-vue",
25
+ "particles-ts",
26
+ "particles.ts",
27
+ "react-particles-js",
28
+ "react-particles.js",
29
+ "react-particles",
30
+ "react",
31
+ "reactjs",
32
+ "vue-particles",
33
+ "ngx-particles",
34
+ "angular-particles",
35
+ "particleground",
36
+ "vue",
37
+ "vuejs",
38
+ "preact",
39
+ "preactjs",
40
+ "jquery",
41
+ "angularjs",
42
+ "angular",
43
+ "typescript",
44
+ "javascript",
45
+ "animation",
46
+ "web",
47
+ "html5",
48
+ "web-design",
49
+ "webdesign",
50
+ "css",
51
+ "html",
52
+ "css3",
53
+ "animated",
54
+ "background",
55
+ "confetti",
56
+ "canvas",
57
+ "fireworks",
58
+ "fireworks-js",
59
+ "confetti-js",
60
+ "confettijs",
61
+ "fireworksjs",
62
+ "canvas-confetti",
63
+ "tsparticles-plugin"
64
+ ],
65
+ "author": "Matteo Bruni <matteo.bruni@me.com>",
66
+ "license": "MIT",
67
+ "bugs": {
68
+ "url": "https://github.com/tsparticles/tsparticles/issues"
69
+ },
70
+ "funding": [
71
+ {
72
+ "type": "github",
73
+ "url": "https://github.com/sponsors/matteobruni"
74
+ },
75
+ {
76
+ "type": "github",
77
+ "url": "https://github.com/sponsors/tsparticles"
78
+ },
79
+ {
80
+ "type": "buymeacoffee",
81
+ "url": "https://www.buymeacoffee.com/matteobruni"
82
+ }
83
+ ],
84
+ "sideEffects": false,
85
+ "jsdelivr": "tsparticles.plugin.emitters.shape.square.min.js",
86
+ "unpkg": "tsparticles.plugin.emitters.shape.square.min.js",
87
+ "browser": "browser/index.js",
88
+ "main": "cjs/index.js",
89
+ "module": "esm/index.js",
90
+ "types": "types/index.d.ts",
91
+ "exports": {
92
+ ".": {
93
+ "types": "./types/index.d.ts",
94
+ "browser": "./browser/index.js",
95
+ "import": "./esm/index.js",
96
+ "require": "./cjs/index.js",
97
+ "umd": "./umd/index.js",
98
+ "default": "./cjs/index.js"
99
+ },
100
+ "./package.json": "./package.json"
101
+ },
102
+ "dependencies": {
103
+ "@tsparticles/engine": "^3.0.0-beta.4",
104
+ "@tsparticles/plugin-emitters": "^3.0.0-beta.4"
105
+ },
106
+ "publishConfig": {
107
+ "access": "public"
108
+ }
109
+ }