@tsparticles/ribbons 4.0.5
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 +83 -0
- package/browser/IRibbonsOptions.js +1 -0
- package/browser/RibbonsOptions.js +138 -0
- package/browser/RibbonsParams.js +1 -0
- package/browser/browser.js +4 -0
- package/browser/bundle.js +5 -0
- package/browser/index.js +1 -0
- package/browser/index.lazy.js +1 -0
- package/browser/package.json +1 -0
- package/browser/ribbons.js +79 -0
- package/browser/ribbons.lazy.js +80 -0
- package/browser/types.js +1 -0
- package/browser/utils.js +195 -0
- package/cjs/IRibbonsOptions.js +1 -0
- package/cjs/RibbonsOptions.js +138 -0
- package/cjs/RibbonsParams.js +1 -0
- package/cjs/browser.js +4 -0
- package/cjs/bundle.js +5 -0
- package/cjs/index.js +1 -0
- package/cjs/index.lazy.js +1 -0
- package/cjs/package.json +1 -0
- package/cjs/ribbons.js +79 -0
- package/cjs/ribbons.lazy.js +80 -0
- package/cjs/types.js +1 -0
- package/cjs/utils.js +195 -0
- package/esm/IRibbonsOptions.js +1 -0
- package/esm/RibbonsOptions.js +138 -0
- package/esm/RibbonsParams.js +1 -0
- package/esm/browser.js +4 -0
- package/esm/bundle.js +5 -0
- package/esm/index.js +1 -0
- package/esm/index.lazy.js +1 -0
- package/esm/package.json +1 -0
- package/esm/ribbons.js +79 -0
- package/esm/ribbons.lazy.js +80 -0
- package/esm/types.js +1 -0
- package/esm/utils.js +195 -0
- package/package.json +88 -0
- package/report.html +4950 -0
- package/tsparticles.ribbons.bundle.js +8433 -0
- package/tsparticles.ribbons.bundle.min.js +1 -0
- package/tsparticles.ribbons.js +424 -0
- package/tsparticles.ribbons.min.js +1 -0
- package/types/IRibbonsOptions.d.ts +17 -0
- package/types/RibbonsOptions.d.ts +22 -0
- package/types/RibbonsParams.d.ts +7 -0
- package/types/browser.d.ts +1 -0
- package/types/bundle.d.ts +2 -0
- package/types/index.d.ts +5 -0
- package/types/index.lazy.d.ts +5 -0
- package/types/ribbons.d.ts +16 -0
- package/types/ribbons.lazy.d.ts +16 -0
- package/types/types.d.ts +4 -0
- package/types/utils.d.ts +7 -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,83 @@
|
|
|
1
|
+
[](https://particles.js.org)
|
|
2
|
+
|
|
3
|
+
# tsParticles Ribbons Bundle
|
|
4
|
+
|
|
5
|
+
[](https://www.jsdelivr.com/package/npm/@tsparticles/ribbons) [](https://www.npmjs.com/package/@tsparticles/ribbons) [](https://www.npmjs.com/package/@tsparticles/ribbons) [](https://github.com/sponsors/matteobruni)
|
|
6
|
+
|
|
7
|
+
[tsParticles](https://github.com/tsparticles/tsparticles) ribbons bundle to create animated ribbons effects with a single API.
|
|
8
|
+
|
|
9
|
+
## Exposed API
|
|
10
|
+
|
|
11
|
+
The package API is centered on `ribbons`.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { ribbons } from "@tsparticles/ribbons";
|
|
15
|
+
|
|
16
|
+
await ribbons(options);
|
|
17
|
+
await ribbons("canvas-id", options);
|
|
18
|
+
|
|
19
|
+
await ribbons.init();
|
|
20
|
+
const fireOnCanvas = await ribbons.create(canvas, defaultOptions);
|
|
21
|
+
await fireOnCanvas(options);
|
|
22
|
+
|
|
23
|
+
console.log(ribbons.version);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pnpm add @tsparticles/ribbons
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## How to use it
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { ribbons } from "@tsparticles/ribbons";
|
|
36
|
+
|
|
37
|
+
await ribbons({
|
|
38
|
+
count: 5,
|
|
39
|
+
spread: 0,
|
|
40
|
+
position: { x: 50, y: 0 },
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
With advanced ribbon shape customization:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { ribbons } from "@tsparticles/ribbons";
|
|
48
|
+
|
|
49
|
+
await ribbons({
|
|
50
|
+
ribbonOptions: {
|
|
51
|
+
count: 70,
|
|
52
|
+
oscillationDistance: {
|
|
53
|
+
min: 120,
|
|
54
|
+
max: 170,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Options
|
|
61
|
+
|
|
62
|
+
Main options:
|
|
63
|
+
|
|
64
|
+
- `count` _Integer (default: 5)_
|
|
65
|
+
- `angle` _Number (default: 90)_
|
|
66
|
+
- `spread` _Number (default: 0)_
|
|
67
|
+
- `drift` _Number (default: 0)_
|
|
68
|
+
- `ticks` _Number (default: 200)_
|
|
69
|
+
- `position` _Object_ (`x`/`y`, default 50/0)
|
|
70
|
+
- `colors` _Array<String>_
|
|
71
|
+
- `ribbonOptions` _Object_ (`particles.shape.options.ribbon`)
|
|
72
|
+
- Includes `darken: { enable: true, value: 30 }` by default
|
|
73
|
+
- `scalar` _Number (default: 1)_
|
|
74
|
+
- `zIndex` _Integer (default: 100)_
|
|
75
|
+
- `disableForReducedMotion` _Boolean (default: true)_
|
|
76
|
+
|
|
77
|
+
The `ribbons` bundle disables `roll`, `rotate`, `tilt`, and `wobble` on ribbon particles by default for better shape stability.
|
|
78
|
+
The emitter uses a full-width top strip (`width: 100`, `height: 0`) and downward movement speed range (`4..6`) for a falling-from-top behavior.
|
|
79
|
+
|
|
80
|
+
Deprecated aliases still accepted:
|
|
81
|
+
|
|
82
|
+
- `particleCount` (use `count`)
|
|
83
|
+
- `origin` (use `position`)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { deepExtend, isArray, isNull, percentDenominator, } from "@tsparticles/engine";
|
|
2
|
+
export class RibbonsOptions {
|
|
3
|
+
angle;
|
|
4
|
+
colors;
|
|
5
|
+
count;
|
|
6
|
+
disableForReducedMotion;
|
|
7
|
+
drift;
|
|
8
|
+
emitterSize;
|
|
9
|
+
position;
|
|
10
|
+
ribbonOptions;
|
|
11
|
+
scalar;
|
|
12
|
+
spread;
|
|
13
|
+
ticks;
|
|
14
|
+
zIndex;
|
|
15
|
+
constructor() {
|
|
16
|
+
this.angle = 90;
|
|
17
|
+
this.count = 5;
|
|
18
|
+
this.spread = 0;
|
|
19
|
+
this.drift = 0;
|
|
20
|
+
this.emitterSize = {
|
|
21
|
+
width: 100,
|
|
22
|
+
height: 0,
|
|
23
|
+
};
|
|
24
|
+
this.ticks = 200;
|
|
25
|
+
this.position = {
|
|
26
|
+
x: 50,
|
|
27
|
+
y: 0,
|
|
28
|
+
};
|
|
29
|
+
this.colors = ["#FF0055", "#00D1FF", "#FFD23F", "#61FF7E", "#B284FF"];
|
|
30
|
+
this.ribbonOptions = {
|
|
31
|
+
angle: 45,
|
|
32
|
+
darken: {
|
|
33
|
+
enable: true,
|
|
34
|
+
value: 30,
|
|
35
|
+
},
|
|
36
|
+
count: 60,
|
|
37
|
+
drag: 0.02,
|
|
38
|
+
mass: 1,
|
|
39
|
+
oscillationDistance: {
|
|
40
|
+
min: 100,
|
|
41
|
+
max: 140,
|
|
42
|
+
},
|
|
43
|
+
oscillationSpeed: {
|
|
44
|
+
min: 3,
|
|
45
|
+
max: 5,
|
|
46
|
+
},
|
|
47
|
+
particleDist: 8,
|
|
48
|
+
velocityInherit: {
|
|
49
|
+
min: 4,
|
|
50
|
+
max: 6,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
this.scalar = 1;
|
|
54
|
+
this.zIndex = 100;
|
|
55
|
+
this.disableForReducedMotion = true;
|
|
56
|
+
}
|
|
57
|
+
get origin() {
|
|
58
|
+
return {
|
|
59
|
+
x: this.position.x / percentDenominator,
|
|
60
|
+
y: this.position.y / percentDenominator,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
set origin(value) {
|
|
64
|
+
this.position.x = value.x * percentDenominator;
|
|
65
|
+
this.position.y = value.y * percentDenominator;
|
|
66
|
+
}
|
|
67
|
+
get particleCount() {
|
|
68
|
+
return this.count;
|
|
69
|
+
}
|
|
70
|
+
set particleCount(value) {
|
|
71
|
+
this.count = value;
|
|
72
|
+
}
|
|
73
|
+
load(data) {
|
|
74
|
+
if (isNull(data)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (data.angle !== undefined) {
|
|
78
|
+
this.angle = data.angle;
|
|
79
|
+
}
|
|
80
|
+
const count = data.count ?? data.particleCount;
|
|
81
|
+
if (count !== undefined) {
|
|
82
|
+
this.count = count;
|
|
83
|
+
}
|
|
84
|
+
if (data.spread !== undefined) {
|
|
85
|
+
this.spread = data.spread;
|
|
86
|
+
}
|
|
87
|
+
if (data.drift !== undefined) {
|
|
88
|
+
this.drift = data.drift;
|
|
89
|
+
}
|
|
90
|
+
if (data.ticks !== undefined) {
|
|
91
|
+
this.ticks = data.ticks;
|
|
92
|
+
}
|
|
93
|
+
if (data.emitterSize) {
|
|
94
|
+
if (data.emitterSize.width !== undefined) {
|
|
95
|
+
this.emitterSize.width = data.emitterSize.width;
|
|
96
|
+
}
|
|
97
|
+
if (data.emitterSize.height !== undefined) {
|
|
98
|
+
this.emitterSize.height = data.emitterSize.height;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const origin = data.origin;
|
|
102
|
+
if (origin && !data.position) {
|
|
103
|
+
data.position = {
|
|
104
|
+
x: origin.x === undefined ? undefined : origin.x * percentDenominator,
|
|
105
|
+
y: origin.y === undefined ? undefined : origin.y * percentDenominator,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const position = data.position;
|
|
109
|
+
if (position) {
|
|
110
|
+
if (position.x !== undefined) {
|
|
111
|
+
this.position.x = position.x;
|
|
112
|
+
}
|
|
113
|
+
if (position.y !== undefined) {
|
|
114
|
+
this.position.y = position.y;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (data.colors !== undefined) {
|
|
118
|
+
if (isArray(data.colors)) {
|
|
119
|
+
this.colors = [...data.colors];
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.colors = data.colors;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (data.ribbonOptions !== undefined) {
|
|
126
|
+
this.ribbonOptions = deepExtend({}, data.ribbonOptions);
|
|
127
|
+
}
|
|
128
|
+
if (data.scalar !== undefined) {
|
|
129
|
+
this.scalar = data.scalar;
|
|
130
|
+
}
|
|
131
|
+
if (data.zIndex !== undefined) {
|
|
132
|
+
this.zIndex = data.zIndex;
|
|
133
|
+
}
|
|
134
|
+
if (data.disableForReducedMotion !== undefined) {
|
|
135
|
+
this.disableForReducedMotion = data.disableForReducedMotion;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/browser/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ribbons.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ribbons.lazy.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "module" }
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { isString, tsParticles } from "@tsparticles/engine";
|
|
2
|
+
import { loadBasic } from "@tsparticles/basic";
|
|
3
|
+
import { loadEmittersPluginSimple } from "@tsparticles/plugin-emitters/plugin";
|
|
4
|
+
import { loadEmittersShapeSquare } from "@tsparticles/plugin-emitters-shape-square";
|
|
5
|
+
import { loadLifeUpdater } from "@tsparticles/updater-life";
|
|
6
|
+
import { loadMotionPlugin } from "@tsparticles/plugin-motion";
|
|
7
|
+
import { loadRibbonShape } from "@tsparticles/shape-ribbon";
|
|
8
|
+
import { setRibbons } from "./utils.js";
|
|
9
|
+
let initPromise = null;
|
|
10
|
+
async function doInitPlugins(engine) {
|
|
11
|
+
engine.checkVersion("4.0.5");
|
|
12
|
+
await engine.pluginManager.register(async (e) => {
|
|
13
|
+
const emittersRegister = async (engine) => {
|
|
14
|
+
await loadEmittersPluginSimple(engine);
|
|
15
|
+
await loadEmittersShapeSquare(engine);
|
|
16
|
+
};
|
|
17
|
+
await Promise.all([
|
|
18
|
+
loadBasic(e),
|
|
19
|
+
loadMotionPlugin(e),
|
|
20
|
+
emittersRegister(e),
|
|
21
|
+
loadRibbonShape(e),
|
|
22
|
+
loadLifeUpdater(e),
|
|
23
|
+
]);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async function initPlugins(engine) {
|
|
27
|
+
if (initPromise) {
|
|
28
|
+
return initPromise;
|
|
29
|
+
}
|
|
30
|
+
initPromise = doInitPlugins(engine);
|
|
31
|
+
return initPromise;
|
|
32
|
+
}
|
|
33
|
+
export async function ribbons(idOrOptions, ribbonsOptions) {
|
|
34
|
+
await initPlugins(tsParticles);
|
|
35
|
+
let options, id;
|
|
36
|
+
if (isString(idOrOptions)) {
|
|
37
|
+
id = idOrOptions;
|
|
38
|
+
options = ribbonsOptions ?? {};
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
id = "ribbons";
|
|
42
|
+
options = idOrOptions ?? {};
|
|
43
|
+
}
|
|
44
|
+
return setRibbons(tsParticles, {
|
|
45
|
+
id,
|
|
46
|
+
options,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
ribbons.create = async (canvas, options = {}) => {
|
|
50
|
+
await initPlugins(tsParticles);
|
|
51
|
+
const id = canvas?.getAttribute("id") ?? "ribbons";
|
|
52
|
+
canvas?.setAttribute("id", id);
|
|
53
|
+
await setRibbons(tsParticles, {
|
|
54
|
+
id,
|
|
55
|
+
canvas: canvas ?? undefined,
|
|
56
|
+
options,
|
|
57
|
+
});
|
|
58
|
+
return async (idOrOptions, subRibbonsOptions) => {
|
|
59
|
+
let subOptions, subId;
|
|
60
|
+
if (isString(idOrOptions)) {
|
|
61
|
+
subId = idOrOptions;
|
|
62
|
+
subOptions = subRibbonsOptions ?? options;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
subId = id;
|
|
66
|
+
subOptions = idOrOptions ?? {};
|
|
67
|
+
}
|
|
68
|
+
return setRibbons(tsParticles, {
|
|
69
|
+
id: subId,
|
|
70
|
+
canvas: canvas ?? undefined,
|
|
71
|
+
options: subOptions,
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
ribbons.init = async () => {
|
|
76
|
+
await initPlugins(tsParticles);
|
|
77
|
+
};
|
|
78
|
+
ribbons.version = "4.0.5";
|
|
79
|
+
globalThis.ribbons = ribbons;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { isString, tsParticles } from "@tsparticles/engine/lazy";
|
|
2
|
+
import { setRibbons } from "./utils.js";
|
|
3
|
+
let initPromise = null;
|
|
4
|
+
async function doInitPlugins(engine) {
|
|
5
|
+
engine.checkVersion("4.0.5");
|
|
6
|
+
await engine.pluginManager.register(async (e) => {
|
|
7
|
+
const [{ loadBasic }, { loadEmittersPluginSimple }, { loadEmittersShapeSquare }, { loadMotionPlugin }, { loadRibbonShape }, { loadLifeUpdater },] = await Promise.all([
|
|
8
|
+
import("@tsparticles/basic/lazy"),
|
|
9
|
+
import("@tsparticles/plugin-emitters/plugin/lazy"),
|
|
10
|
+
import("@tsparticles/plugin-emitters-shape-square/lazy"),
|
|
11
|
+
import("@tsparticles/plugin-motion/lazy"),
|
|
12
|
+
import("@tsparticles/shape-ribbon/lazy"),
|
|
13
|
+
import("@tsparticles/updater-life/lazy"),
|
|
14
|
+
]), emittersRegister = async (engine) => {
|
|
15
|
+
await loadEmittersPluginSimple(engine);
|
|
16
|
+
await loadEmittersShapeSquare(engine);
|
|
17
|
+
};
|
|
18
|
+
await Promise.all([
|
|
19
|
+
loadBasic(e),
|
|
20
|
+
loadMotionPlugin(e),
|
|
21
|
+
emittersRegister(e),
|
|
22
|
+
loadRibbonShape(e),
|
|
23
|
+
loadLifeUpdater(e),
|
|
24
|
+
]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async function initPlugins(engine) {
|
|
28
|
+
if (initPromise) {
|
|
29
|
+
return initPromise;
|
|
30
|
+
}
|
|
31
|
+
initPromise = doInitPlugins(engine);
|
|
32
|
+
return initPromise;
|
|
33
|
+
}
|
|
34
|
+
export async function ribbons(idOrOptions, ribbonsOptions) {
|
|
35
|
+
await initPlugins(tsParticles);
|
|
36
|
+
let options, id;
|
|
37
|
+
if (isString(idOrOptions)) {
|
|
38
|
+
id = idOrOptions;
|
|
39
|
+
options = ribbonsOptions ?? {};
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
id = "ribbons";
|
|
43
|
+
options = idOrOptions ?? {};
|
|
44
|
+
}
|
|
45
|
+
return setRibbons(tsParticles, {
|
|
46
|
+
id,
|
|
47
|
+
options,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
ribbons.create = async (canvas, options = {}) => {
|
|
51
|
+
await initPlugins(tsParticles);
|
|
52
|
+
const id = canvas?.getAttribute("id") ?? "ribbons";
|
|
53
|
+
canvas?.setAttribute("id", id);
|
|
54
|
+
await setRibbons(tsParticles, {
|
|
55
|
+
id,
|
|
56
|
+
canvas: canvas ?? undefined,
|
|
57
|
+
options,
|
|
58
|
+
});
|
|
59
|
+
return async (idOrOptions, subRibbonsOptions) => {
|
|
60
|
+
let subOptions, subId;
|
|
61
|
+
if (isString(idOrOptions)) {
|
|
62
|
+
subId = idOrOptions;
|
|
63
|
+
subOptions = subRibbonsOptions ?? options;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
subId = id;
|
|
67
|
+
subOptions = idOrOptions ?? {};
|
|
68
|
+
}
|
|
69
|
+
return setRibbons(tsParticles, {
|
|
70
|
+
id: subId,
|
|
71
|
+
canvas: canvas ?? undefined,
|
|
72
|
+
options: subOptions,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
ribbons.init = async () => {
|
|
77
|
+
await initPlugins(tsParticles);
|
|
78
|
+
};
|
|
79
|
+
ribbons.version = "4.0.5";
|
|
80
|
+
globalThis.ribbons = ribbons;
|
package/browser/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/browser/utils.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { RibbonsOptions } from "./RibbonsOptions.js";
|
|
2
|
+
const sizeFactor = 8, emitterTop = 0, ids = new Map();
|
|
3
|
+
export async function addEmitter(container, actualOptions) {
|
|
4
|
+
await container.addEmitter?.({
|
|
5
|
+
startCount: actualOptions.count,
|
|
6
|
+
position: {
|
|
7
|
+
x: actualOptions.position.x,
|
|
8
|
+
y: emitterTop,
|
|
9
|
+
},
|
|
10
|
+
shape: {
|
|
11
|
+
type: "square",
|
|
12
|
+
},
|
|
13
|
+
size: {
|
|
14
|
+
width: actualOptions.emitterSize.width,
|
|
15
|
+
height: actualOptions.emitterSize.height,
|
|
16
|
+
},
|
|
17
|
+
rate: {
|
|
18
|
+
delay: 0,
|
|
19
|
+
quantity: 0,
|
|
20
|
+
},
|
|
21
|
+
life: {
|
|
22
|
+
duration: 0.1,
|
|
23
|
+
count: 1,
|
|
24
|
+
},
|
|
25
|
+
particles: {
|
|
26
|
+
paint: {
|
|
27
|
+
fill: {
|
|
28
|
+
color: {
|
|
29
|
+
value: actualOptions.colors,
|
|
30
|
+
},
|
|
31
|
+
enable: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
shape: {
|
|
35
|
+
type: "ribbon",
|
|
36
|
+
options: {
|
|
37
|
+
ribbon: actualOptions.ribbonOptions,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
life: {
|
|
41
|
+
count: 1,
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
value: sizeFactor * actualOptions.scalar,
|
|
45
|
+
},
|
|
46
|
+
move: {
|
|
47
|
+
direction: "bottom",
|
|
48
|
+
enable: true,
|
|
49
|
+
outModes: {
|
|
50
|
+
top: "none",
|
|
51
|
+
default: "destroy",
|
|
52
|
+
},
|
|
53
|
+
speed: {
|
|
54
|
+
min: 4,
|
|
55
|
+
max: 6,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
roll: {
|
|
59
|
+
enable: false,
|
|
60
|
+
},
|
|
61
|
+
rotate: {
|
|
62
|
+
value: 0,
|
|
63
|
+
move: false,
|
|
64
|
+
animation: {
|
|
65
|
+
enable: false,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
tilt: {
|
|
69
|
+
enable: false,
|
|
70
|
+
},
|
|
71
|
+
wobble: {
|
|
72
|
+
enable: false,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
export function convertOptions(actualOptions, params) {
|
|
78
|
+
return {
|
|
79
|
+
fullScreen: {
|
|
80
|
+
enable: !params.canvas,
|
|
81
|
+
zIndex: actualOptions.zIndex,
|
|
82
|
+
},
|
|
83
|
+
fpsLimit: 120,
|
|
84
|
+
particles: {
|
|
85
|
+
number: {
|
|
86
|
+
value: 0,
|
|
87
|
+
},
|
|
88
|
+
paint: {
|
|
89
|
+
fill: {
|
|
90
|
+
color: {
|
|
91
|
+
value: actualOptions.colors,
|
|
92
|
+
},
|
|
93
|
+
enable: true,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
shape: {
|
|
97
|
+
type: "ribbon",
|
|
98
|
+
options: {
|
|
99
|
+
ribbon: actualOptions.ribbonOptions,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
size: {
|
|
103
|
+
value: sizeFactor * actualOptions.scalar,
|
|
104
|
+
},
|
|
105
|
+
links: {
|
|
106
|
+
enable: false,
|
|
107
|
+
},
|
|
108
|
+
life: {
|
|
109
|
+
count: 1,
|
|
110
|
+
},
|
|
111
|
+
move: {
|
|
112
|
+
direction: "bottom",
|
|
113
|
+
enable: true,
|
|
114
|
+
outModes: {
|
|
115
|
+
top: "none",
|
|
116
|
+
default: "destroy",
|
|
117
|
+
},
|
|
118
|
+
speed: {
|
|
119
|
+
min: 4,
|
|
120
|
+
max: 6,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
roll: {
|
|
124
|
+
enable: false,
|
|
125
|
+
},
|
|
126
|
+
rotate: {
|
|
127
|
+
value: 0,
|
|
128
|
+
move: false,
|
|
129
|
+
animation: {
|
|
130
|
+
enable: false,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
tilt: {
|
|
134
|
+
enable: false,
|
|
135
|
+
},
|
|
136
|
+
wobble: {
|
|
137
|
+
enable: false,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
motion: {
|
|
141
|
+
disable: actualOptions.disableForReducedMotion,
|
|
142
|
+
},
|
|
143
|
+
emitters: {
|
|
144
|
+
name: "ribbons",
|
|
145
|
+
startCount: actualOptions.count,
|
|
146
|
+
position: {
|
|
147
|
+
x: actualOptions.position.x,
|
|
148
|
+
y: emitterTop,
|
|
149
|
+
},
|
|
150
|
+
shape: {
|
|
151
|
+
type: "square",
|
|
152
|
+
},
|
|
153
|
+
size: {
|
|
154
|
+
width: actualOptions.emitterSize.width,
|
|
155
|
+
height: actualOptions.emitterSize.height,
|
|
156
|
+
},
|
|
157
|
+
rate: {
|
|
158
|
+
delay: 0,
|
|
159
|
+
quantity: 0,
|
|
160
|
+
},
|
|
161
|
+
life: {
|
|
162
|
+
duration: 0.1,
|
|
163
|
+
count: 1,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
export async function setRibbons(engine, params) {
|
|
169
|
+
const actualOptions = new RibbonsOptions();
|
|
170
|
+
actualOptions.load(params.options);
|
|
171
|
+
let containerOrPromise = ids.get(params.id);
|
|
172
|
+
if (containerOrPromise instanceof Promise) {
|
|
173
|
+
await containerOrPromise;
|
|
174
|
+
containerOrPromise = ids.get(params.id);
|
|
175
|
+
}
|
|
176
|
+
const container = containerOrPromise;
|
|
177
|
+
if (container && !container.destroyed) {
|
|
178
|
+
const alias = container;
|
|
179
|
+
if ("addEmitter" in alias) {
|
|
180
|
+
await addEmitter(alias, actualOptions);
|
|
181
|
+
return container;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const create = async () => {
|
|
185
|
+
const particlesOptions = convertOptions(actualOptions, params), newContainer = await engine.load({
|
|
186
|
+
id: params.id,
|
|
187
|
+
element: params.canvas,
|
|
188
|
+
options: particlesOptions,
|
|
189
|
+
});
|
|
190
|
+
ids.set(params.id, newContainer);
|
|
191
|
+
return newContainer;
|
|
192
|
+
}, createPromise = create();
|
|
193
|
+
ids.set(params.id, createPromise);
|
|
194
|
+
return createPromise;
|
|
195
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|