@tsparticles/plugin-emitters-shape-circle 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 +21 -0
- package/README.md +79 -0
- package/browser/EmittersCircleShape.js +32 -0
- package/browser/EmittersCircleShapeGenerator.js +6 -0
- package/browser/index.js +7 -0
- package/browser/package.json +1 -0
- package/cjs/EmittersCircleShape.js +36 -0
- package/cjs/EmittersCircleShapeGenerator.js +10 -0
- package/cjs/index.js +11 -0
- package/cjs/package.json +1 -0
- package/esm/EmittersCircleShape.js +32 -0
- package/esm/EmittersCircleShapeGenerator.js +6 -0
- package/esm/index.js +7 -0
- package/esm/package.json +1 -0
- package/package.json +109 -0
- package/report.html +39 -0
- package/tsparticles.plugin.emitters.shape.circle.js +166 -0
- package/tsparticles.plugin.emitters.shape.circle.min.js +2 -0
- package/tsparticles.plugin.emitters.shape.circle.min.js.LICENSE.txt +1 -0
- package/types/EmittersCircleShape.d.ts +7 -0
- package/types/EmittersCircleShapeGenerator.d.ts +5 -0
- package/types/index.d.ts +2 -0
- package/umd/EmittersCircleShape.js +46 -0
- package/umd/EmittersCircleShapeGenerator.js +20 -0
- package/umd/index.js +21 -0
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
|
+
[](https://particles.js.org)
|
|
2
|
+
|
|
3
|
+
# tsParticles Emitters Shape Circle Plugin
|
|
4
|
+
|
|
5
|
+
[](https://www.jsdelivr.com/package/npm/@tsparticles/plugin-emitters-shape-circle)
|
|
6
|
+
[](https://www.npmjs.com/package/@tsparticles/plugin-emitters-shape-circle)
|
|
7
|
+
[](https://www.npmjs.com/package/@tsparticles/plugin-emitters-shape-circle) [](https://github.com/sponsors/matteobruni)
|
|
8
|
+
|
|
9
|
+
[tsParticles](https://github.com/tsparticles/tsparticles) plugin for adding the emitters shape circle 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.circle.min.js` file will export the function to load the plugin:
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
loadEmittersShapeCirclePlugin
|
|
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 loadEmittersShapeCirclePlugin(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-circle
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
or
|
|
50
|
+
|
|
51
|
+
```shell
|
|
52
|
+
$ yarn add @tsparticles/plugin-emitters-shape-circle
|
|
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 { loadEmittersShapeCirclePlugin } = require("@tsparticles/plugin-emitters-shape-circle");
|
|
61
|
+
|
|
62
|
+
(async () => {
|
|
63
|
+
await loadEmittersPlugin(tsParticles);
|
|
64
|
+
await loadEmittersShapeCirclePlugin(tsParticles);
|
|
65
|
+
})();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
or
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
import { tsParticles } from "@tsparticles/engine";
|
|
72
|
+
import { loadEmittersPlugin } from "@tsparticles/plugin-emitters";
|
|
73
|
+
import { loadEmittersShapeCirclePlugin } from "@tsparticles/plugin-emitters-shape-circle";
|
|
74
|
+
|
|
75
|
+
(async () => {
|
|
76
|
+
await loadEmittersPlugin(tsParticles);
|
|
77
|
+
await loadEmittersShapeCirclePlugin(tsParticles);
|
|
78
|
+
})();
|
|
79
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EmitterShapeBase } from "@tsparticles/plugin-emitters";
|
|
2
|
+
import { getRandom } from "@tsparticles/engine";
|
|
3
|
+
export class EmittersCircleShape extends EmitterShapeBase {
|
|
4
|
+
constructor(position, size, fill, options) {
|
|
5
|
+
super(position, size, fill, options);
|
|
6
|
+
}
|
|
7
|
+
async init() {
|
|
8
|
+
}
|
|
9
|
+
async randomPosition() {
|
|
10
|
+
const size = this.size, fill = this.fill, position = this.position, generateTheta = (x, y) => {
|
|
11
|
+
const u = getRandom() / 4.0, theta = Math.atan((y / x) * Math.tan(2 * Math.PI * u)), v = getRandom();
|
|
12
|
+
if (v < 0.25) {
|
|
13
|
+
return theta;
|
|
14
|
+
}
|
|
15
|
+
else if (v < 0.5) {
|
|
16
|
+
return Math.PI - theta;
|
|
17
|
+
}
|
|
18
|
+
else if (v < 0.75) {
|
|
19
|
+
return Math.PI + theta;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return -theta;
|
|
23
|
+
}
|
|
24
|
+
}, radius = (x, y, theta) => (x * y) / Math.sqrt((y * Math.cos(theta)) ** 2 + (x * Math.sin(theta)) ** 2), [a, b] = [size.width / 2, size.height / 2], randomTheta = generateTheta(a, b), maxRadius = radius(a, b, randomTheta), randomRadius = fill ? maxRadius * Math.sqrt(getRandom()) : maxRadius;
|
|
25
|
+
return {
|
|
26
|
+
position: {
|
|
27
|
+
x: position.x + randomRadius * Math.cos(randomTheta),
|
|
28
|
+
y: position.y + randomRadius * Math.sin(randomTheta),
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
package/browser/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EmittersCircleShapeGenerator } from "./EmittersCircleShapeGenerator.js";
|
|
2
|
+
export async function loadEmittersShapeCircle(engine, refresh = true) {
|
|
3
|
+
const emittersEngine = engine;
|
|
4
|
+
emittersEngine.addEmitterShapeGenerator &&
|
|
5
|
+
emittersEngine.addEmitterShapeGenerator("circle", new EmittersCircleShapeGenerator());
|
|
6
|
+
await emittersEngine.refresh(refresh);
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "module" }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmittersCircleShape = void 0;
|
|
4
|
+
const plugin_emitters_1 = require("@tsparticles/plugin-emitters");
|
|
5
|
+
const engine_1 = require("@tsparticles/engine");
|
|
6
|
+
class EmittersCircleShape extends plugin_emitters_1.EmitterShapeBase {
|
|
7
|
+
constructor(position, size, fill, options) {
|
|
8
|
+
super(position, size, fill, options);
|
|
9
|
+
}
|
|
10
|
+
async init() {
|
|
11
|
+
}
|
|
12
|
+
async randomPosition() {
|
|
13
|
+
const size = this.size, fill = this.fill, position = this.position, generateTheta = (x, y) => {
|
|
14
|
+
const u = (0, engine_1.getRandom)() / 4.0, theta = Math.atan((y / x) * Math.tan(2 * Math.PI * u)), v = (0, engine_1.getRandom)();
|
|
15
|
+
if (v < 0.25) {
|
|
16
|
+
return theta;
|
|
17
|
+
}
|
|
18
|
+
else if (v < 0.5) {
|
|
19
|
+
return Math.PI - theta;
|
|
20
|
+
}
|
|
21
|
+
else if (v < 0.75) {
|
|
22
|
+
return Math.PI + theta;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return -theta;
|
|
26
|
+
}
|
|
27
|
+
}, radius = (x, y, theta) => (x * y) / Math.sqrt((y * Math.cos(theta)) ** 2 + (x * Math.sin(theta)) ** 2), [a, b] = [size.width / 2, size.height / 2], randomTheta = generateTheta(a, b), maxRadius = radius(a, b, randomTheta), randomRadius = fill ? maxRadius * Math.sqrt((0, engine_1.getRandom)()) : maxRadius;
|
|
28
|
+
return {
|
|
29
|
+
position: {
|
|
30
|
+
x: position.x + randomRadius * Math.cos(randomTheta),
|
|
31
|
+
y: position.y + randomRadius * Math.sin(randomTheta),
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.EmittersCircleShape = EmittersCircleShape;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmittersCircleShapeGenerator = void 0;
|
|
4
|
+
const EmittersCircleShape_js_1 = require("./EmittersCircleShape.js");
|
|
5
|
+
class EmittersCircleShapeGenerator {
|
|
6
|
+
generate(position, size, fill, options) {
|
|
7
|
+
return new EmittersCircleShape_js_1.EmittersCircleShape(position, size, fill, options);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.EmittersCircleShapeGenerator = EmittersCircleShapeGenerator;
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadEmittersShapeCircle = void 0;
|
|
4
|
+
const EmittersCircleShapeGenerator_js_1 = require("./EmittersCircleShapeGenerator.js");
|
|
5
|
+
async function loadEmittersShapeCircle(engine, refresh = true) {
|
|
6
|
+
const emittersEngine = engine;
|
|
7
|
+
emittersEngine.addEmitterShapeGenerator &&
|
|
8
|
+
emittersEngine.addEmitterShapeGenerator("circle", new EmittersCircleShapeGenerator_js_1.EmittersCircleShapeGenerator());
|
|
9
|
+
await emittersEngine.refresh(refresh);
|
|
10
|
+
}
|
|
11
|
+
exports.loadEmittersShapeCircle = loadEmittersShapeCircle;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs" }
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EmitterShapeBase } from "@tsparticles/plugin-emitters";
|
|
2
|
+
import { getRandom } from "@tsparticles/engine";
|
|
3
|
+
export class EmittersCircleShape extends EmitterShapeBase {
|
|
4
|
+
constructor(position, size, fill, options) {
|
|
5
|
+
super(position, size, fill, options);
|
|
6
|
+
}
|
|
7
|
+
async init() {
|
|
8
|
+
}
|
|
9
|
+
async randomPosition() {
|
|
10
|
+
const size = this.size, fill = this.fill, position = this.position, generateTheta = (x, y) => {
|
|
11
|
+
const u = getRandom() / 4.0, theta = Math.atan((y / x) * Math.tan(2 * Math.PI * u)), v = getRandom();
|
|
12
|
+
if (v < 0.25) {
|
|
13
|
+
return theta;
|
|
14
|
+
}
|
|
15
|
+
else if (v < 0.5) {
|
|
16
|
+
return Math.PI - theta;
|
|
17
|
+
}
|
|
18
|
+
else if (v < 0.75) {
|
|
19
|
+
return Math.PI + theta;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return -theta;
|
|
23
|
+
}
|
|
24
|
+
}, radius = (x, y, theta) => (x * y) / Math.sqrt((y * Math.cos(theta)) ** 2 + (x * Math.sin(theta)) ** 2), [a, b] = [size.width / 2, size.height / 2], randomTheta = generateTheta(a, b), maxRadius = radius(a, b, randomTheta), randomRadius = fill ? maxRadius * Math.sqrt(getRandom()) : maxRadius;
|
|
25
|
+
return {
|
|
26
|
+
position: {
|
|
27
|
+
x: position.x + randomRadius * Math.cos(randomTheta),
|
|
28
|
+
y: position.y + randomRadius * Math.sin(randomTheta),
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EmittersCircleShapeGenerator } from "./EmittersCircleShapeGenerator.js";
|
|
2
|
+
export async function loadEmittersShapeCircle(engine, refresh = true) {
|
|
3
|
+
const emittersEngine = engine;
|
|
4
|
+
emittersEngine.addEmitterShapeGenerator &&
|
|
5
|
+
emittersEngine.addEmitterShapeGenerator("circle", new EmittersCircleShapeGenerator());
|
|
6
|
+
await emittersEngine.refresh(refresh);
|
|
7
|
+
}
|
package/esm/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "module" }
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tsparticles/plugin-emitters-shape-circle",
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
|
+
"description": "tsParticles emitters shape circle 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/circle"
|
|
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.circle.min.js",
|
|
86
|
+
"unpkg": "tsparticles.plugin.emitters.shape.circle.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
|
+
}
|