@tsparticles/preset-fireworks 3.0.1 → 3.1.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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/preset-fireworks/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/preset-fireworks) [![npmjs](https://badge.fury.io/js/@tsparticles/preset-fireworks.svg)](https://www.npmjs.com/package/@tsparticles/preset-fireworks) [![npmjs](https://img.shields.io/npm/dt/@tsparticles/preset-fireworks)](https://www.npmjs.com/package/@tsparticles/preset-fireworks) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
6
6
 
7
- [tsParticles](https://github.com/matteobruni/tsparticles) preset for fireworks effect.
7
+ [tsParticles](https://github.com/tsparticles/tsparticles) preset for fireworks effect.
8
8
 
9
9
  [![Slack](https://particles.js.org/images/slack.png)](https://join.slack.com/t/tsparticles/shared_invite/enQtOTcxNTQxNjQ4NzkxLWE2MTZhZWExMWRmOWI5MTMxNjczOGE1Yjk0MjViYjdkYTUzODM3OTc5MGQ5MjFlODc4MzE0N2Q1OWQxZDc1YzI) [![Discord](https://particles.js.org/images/discord.png)](https://discord.gg/hACwv45Hme) [![Telegram](https://particles.js.org/images/telegram.png)](https://t.me/tsparticles)
10
10
 
@@ -12,43 +12,14 @@
12
12
 
13
13
  ## Sample
14
14
 
15
- [![demo](https://raw.githubusercontent.com/matteobruni/tsparticles/main/presets/fireworks/images/sample.png)](https://particles.js.org/samples/presets/fireworks)
15
+ [![demo](https://raw.githubusercontent.com/tsparticles/tsparticles/main/presets/fireworks/images/sample.png)](https://particles.js.org/samples/presets/fireworks)
16
16
 
17
17
  ## How to use it
18
18
 
19
19
  ### CDN / Vanilla JS / jQuery
20
20
 
21
- The first step is installing [tsParticles](https://github.com/matteobruni/tsparticles) following the instructions for
22
- vanilla javascript in the main project [here](https://github.com/matteobruni/tsparticles)
23
-
24
- Once installed you need one more script to be included in your page (or you can download that
25
- from [jsDelivr](https://www.jsdelivr.com/package/npm/@tsparticles/preset-fireworks):
26
-
27
- ```html
28
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/engine@2/tsparticles.engine.min.js"></script>
29
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/basic@2/tsparticles.basic.min.js"></script>
30
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/move-base@2/tsparticles.move.base.min.js"></script>
31
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/plugin-emitters@2/tsparticles.plugin.emitters.min.js"></script>
32
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/shape-circle@2/tsparticles.shape.circle.min.js"></script>
33
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/shape-line@2/tsparticles.shape.line.min.js"></script>
34
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-color@2/tsparticles.updater.color.min.js"></script>
35
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-life@2/tsparticles.updater.life.min.js"></script>
36
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-opacity@2/tsparticles.updater.opacity.min.js"></script>
37
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-out-modes@2/tsparticles.updater.out-modes.min.js"></script>
38
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-rotate@2/tsparticles.updater.angle.min.js"></script>
39
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-size@2/tsparticles.updater.size.min.js"></script>
40
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-stroke-color@2/tsparticles.updater.stroke-color.min.js"></script>
41
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/preset-fireworks@2/tsparticles.preset.fireworks.min.js"></script>
42
- ```
43
-
44
- This script **MUST** be placed after the `tsParticles` one.
45
-
46
- #### Bundle
47
-
48
- A bundled script can also be used, this will include every needed plugin needed by the preset.
49
-
50
21
  ```html
51
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/preset-fireworks@2/tsparticles.preset.fireworks.bundle.min.js"></script>
22
+ <script src="https://cdn.jsdelivr.net/npm/@tsparticles/preset-fireworks@3/tsparticles.preset.fireworks.bundle.min.js"></script>
52
23
  ```
53
24
 
54
25
  ### Usage
@@ -57,10 +28,13 @@ Once the scripts are loaded you can set up `tsParticles` like this:
57
28
 
58
29
  ```javascript
59
30
  (async () => {
60
- await loadFireworksPreset(tsParticles); // this is required only if you are not using the bundle script
31
+ await loadFireworksPreset(tsParticles);
61
32
 
62
- await tsParticles.load("tsparticles", {
63
- preset: "fireworks",
33
+ await tsParticles.load({
34
+ id: "tsparticles",
35
+ options: {
36
+ preset: "fireworks",
37
+ },
64
38
  });
65
39
  })();
66
40
  ```
@@ -71,100 +45,26 @@ Once the scripts are loaded you can set up `tsParticles` like this:
71
45
  You can override all the options defining the properties like in any standard `tsParticles` installation.
72
46
 
73
47
  ```javascript
74
- tsParticles.load("tsparticles", {
75
- particles: {
76
- shape: {
77
- type: "square", // starting from v2, this require the square shape script
48
+ tsParticles.load({
49
+ id: "tsparticles",
50
+ options: {
51
+ particles: {
52
+ shape: {
53
+ type: "square", // starting from v2, this require the square shape script
54
+ },
78
55
  },
56
+ preset: "fireworks",
79
57
  },
80
- preset: "fireworks",
81
58
  });
82
59
  ```
83
60
 
84
61
  Like in the sample above, the circles will be replaced by squares.
85
62
 
86
- ### React.js / Preact / Inferno
87
-
88
- _The syntax for `React.js`, `Preact` and `Inferno` is the same_.
89
-
90
- This sample uses the class component syntax, but you can use hooks as well (if the library supports it).
91
-
92
- ```typescript jsx
93
- import Particles from "react-particles";
94
- import type { Engine } from "@tsparticles/engine";
95
- import { loadFireworksPreset } from "@tsparticles/preset-fireworks";
96
-
97
- export class ParticlesContainer extends React.PureComponent<IProps> {
98
- // this customizes the component tsParticles installation
99
- async customInit(engine: Engine): Promise<void> {
100
- // this adds the preset to tsParticles, you can safely use the
101
- await loadFireworksPreset(engine);
102
- }
103
-
104
- render() {
105
- const options = {
106
- preset: "fireworks",
107
- };
108
-
109
- return <Particles options={options} init={this.customInit} />;
110
- }
111
- }
112
- ```
63
+ ### Frameworks with a tsParticles component library
113
64
 
114
- ### Vue (2.x and 3.x)
65
+ Checkout the documentation in the component library repository and call the `loadFireworksPreset` function instead of `loadFull`, `loadSlim` or similar functions.
115
66
 
116
- _The syntax for `Vue.js 2.x` and `3.x` is the same_
117
-
118
- ```vue
119
- <Particles id="tsparticles" :particlesInit="particlesInit" :options="particlesOptions" />
120
- ```
121
-
122
- ```ts
123
- const particlesOptions = {
124
- preset: "fireworks",
125
- };
126
-
127
- async function particlesInit(engine: Engine): Promise<void> {
128
- await loadFireworksPreset(engine);
129
- }
130
- ```
131
-
132
- ### Angular
133
-
134
- ```html
135
- <ng-particles [id]="id" [options]="particlesOptions" [particlesInit]="particlesInit"></ng-particles>
136
- ```
137
-
138
- ```ts
139
- const particlesOptions = {
140
- preset: "fireworks",
141
- };
142
-
143
- async function particlesInit(engine: Engine): Promise<void> {
144
- await loadFireworksPreset(engine);
145
- }
146
- ```
147
-
148
- ### Svelte
149
-
150
- ```sveltehtml
151
-
152
- <Particles
153
- id="tsparticles"
154
- options={particlesOptions}
155
- particlesInit={particlesInit}
156
- />
157
- ```
158
-
159
- ```js
160
- let particlesOptions = {
161
- preset: "fireworks",
162
- };
163
-
164
- let particlesInit = async (engine) => {
165
- await loadFireworksPreset(engine);
166
- };
167
- ```
67
+ The options shown above are valid for all the component libraries.
168
68
 
169
69
  ---
170
70
 
package/browser/bundle.js CHANGED
@@ -1,4 +1,3 @@
1
1
  import { loadFireworksPreset } from "./index.js";
2
2
  import { tsParticles } from "@tsparticles/engine";
3
- void loadFireworksPreset(tsParticles);
4
3
  export { loadFireworksPreset, tsParticles };
package/browser/index.js CHANGED
@@ -18,5 +18,6 @@ export async function loadFireworksPreset(engine, refresh = true) {
18
18
  await loadDestroyUpdater(engine, false);
19
19
  await loadLifeUpdater(engine, false);
20
20
  await loadStrokeColorUpdater(engine, false);
21
- await engine.addPreset("fireworks", options, refresh);
21
+ await engine.addPreset("fireworks", options, false);
22
+ await engine.refresh(refresh);
22
23
  }
@@ -1,4 +1,4 @@
1
- import { rgbToHsl, setRangeValue, stringToRgb, } from "@tsparticles/engine";
1
+ import { DestroyType, EventType, MoveDirection, OutMode, StartValueType, rgbToHsl, setRangeValue, stringToRgb, } from "@tsparticles/engine";
2
2
  const explodeSoundCheck = (args) => {
3
3
  const data = args.data;
4
4
  return data.particle.shape === "line";
@@ -16,7 +16,7 @@ const fixRange = (value, min, max) => {
16
16
  return res;
17
17
  };
18
18
  const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
19
- .map((color) => {
19
+ .map(color => {
20
20
  const rgb = stringToRgb(color);
21
21
  if (!rgb) {
22
22
  return undefined;
@@ -51,8 +51,8 @@ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
51
51
  enable: true,
52
52
  speed: 0.7,
53
53
  sync: false,
54
- startValue: "max",
55
- destroy: "min",
54
+ startValue: StartValueType.max,
55
+ destroy: DestroyType.min,
56
56
  },
57
57
  },
58
58
  shape: {
@@ -65,8 +65,8 @@ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
65
65
  speed: 5,
66
66
  count: 1,
67
67
  sync: false,
68
- startValue: "min",
69
- destroy: "none",
68
+ startValue: StartValueType.min,
69
+ destroy: DestroyType.none,
70
70
  },
71
71
  },
72
72
  life: {
@@ -88,11 +88,11 @@ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
88
88
  },
89
89
  speed: { min: 5, max: 15 },
90
90
  direction: "none",
91
- outModes: "destroy",
91
+ outModes: OutMode.destroy,
92
92
  },
93
93
  };
94
94
  })
95
- .filter((t) => t !== undefined);
95
+ .filter(t => t !== undefined);
96
96
  export const options = {
97
97
  detectRetina: true,
98
98
  background: {
@@ -100,7 +100,7 @@ export const options = {
100
100
  },
101
101
  fpsLimit: 120,
102
102
  emitters: {
103
- direction: "top",
103
+ direction: MoveDirection.top,
104
104
  life: {
105
105
  count: 0,
106
106
  duration: 0.1,
@@ -155,8 +155,8 @@ export const options = {
155
155
  enable: true,
156
156
  sync: true,
157
157
  speed: 90,
158
- startValue: "max",
159
- destroy: "min",
158
+ startValue: StartValueType.max,
159
+ destroy: DestroyType.min,
160
160
  },
161
161
  },
162
162
  stroke: {
@@ -181,8 +181,8 @@ export const options = {
181
181
  max: 20,
182
182
  },
183
183
  outModes: {
184
- default: "destroy",
185
- top: "none",
184
+ default: OutMode.destroy,
185
+ top: OutMode.none,
186
186
  },
187
187
  trail: {
188
188
  fill: {
@@ -197,7 +197,7 @@ export const options = {
197
197
  enable: true,
198
198
  events: [
199
199
  {
200
- event: "particleRemoved",
200
+ event: EventType.particleRemoved,
201
201
  filter: explodeSoundCheck,
202
202
  audio: [
203
203
  "https://particles.js.org/audio/explosion0.mp3",
package/cjs/bundle.js CHANGED
@@ -5,4 +5,3 @@ const index_js_1 = require("./index.js");
5
5
  Object.defineProperty(exports, "loadFireworksPreset", { enumerable: true, get: function () { return index_js_1.loadFireworksPreset; } });
6
6
  const engine_1 = require("@tsparticles/engine");
7
7
  Object.defineProperty(exports, "tsParticles", { enumerable: true, get: function () { return engine_1.tsParticles; } });
8
- void (0, index_js_1.loadFireworksPreset)(engine_1.tsParticles);
package/cjs/index.js CHANGED
@@ -21,6 +21,7 @@ async function loadFireworksPreset(engine, refresh = true) {
21
21
  await (0, updater_destroy_1.loadDestroyUpdater)(engine, false);
22
22
  await (0, updater_life_1.loadLifeUpdater)(engine, false);
23
23
  await (0, updater_stroke_color_1.loadStrokeColorUpdater)(engine, false);
24
- await engine.addPreset("fireworks", options_js_1.options, refresh);
24
+ await engine.addPreset("fireworks", options_js_1.options, false);
25
+ await engine.refresh(refresh);
25
26
  }
26
27
  exports.loadFireworksPreset = loadFireworksPreset;
package/cjs/options.js CHANGED
@@ -19,7 +19,7 @@ const fixRange = (value, min, max) => {
19
19
  return res;
20
20
  };
21
21
  const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
22
- .map((color) => {
22
+ .map(color => {
23
23
  const rgb = (0, engine_1.stringToRgb)(color);
24
24
  if (!rgb) {
25
25
  return undefined;
@@ -54,8 +54,8 @@ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
54
54
  enable: true,
55
55
  speed: 0.7,
56
56
  sync: false,
57
- startValue: "max",
58
- destroy: "min",
57
+ startValue: engine_1.StartValueType.max,
58
+ destroy: engine_1.DestroyType.min,
59
59
  },
60
60
  },
61
61
  shape: {
@@ -68,8 +68,8 @@ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
68
68
  speed: 5,
69
69
  count: 1,
70
70
  sync: false,
71
- startValue: "min",
72
- destroy: "none",
71
+ startValue: engine_1.StartValueType.min,
72
+ destroy: engine_1.DestroyType.none,
73
73
  },
74
74
  },
75
75
  life: {
@@ -91,11 +91,11 @@ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
91
91
  },
92
92
  speed: { min: 5, max: 15 },
93
93
  direction: "none",
94
- outModes: "destroy",
94
+ outModes: engine_1.OutMode.destroy,
95
95
  },
96
96
  };
97
97
  })
98
- .filter((t) => t !== undefined);
98
+ .filter(t => t !== undefined);
99
99
  exports.options = {
100
100
  detectRetina: true,
101
101
  background: {
@@ -103,7 +103,7 @@ exports.options = {
103
103
  },
104
104
  fpsLimit: 120,
105
105
  emitters: {
106
- direction: "top",
106
+ direction: engine_1.MoveDirection.top,
107
107
  life: {
108
108
  count: 0,
109
109
  duration: 0.1,
@@ -158,8 +158,8 @@ exports.options = {
158
158
  enable: true,
159
159
  sync: true,
160
160
  speed: 90,
161
- startValue: "max",
162
- destroy: "min",
161
+ startValue: engine_1.StartValueType.max,
162
+ destroy: engine_1.DestroyType.min,
163
163
  },
164
164
  },
165
165
  stroke: {
@@ -184,8 +184,8 @@ exports.options = {
184
184
  max: 20,
185
185
  },
186
186
  outModes: {
187
- default: "destroy",
188
- top: "none",
187
+ default: engine_1.OutMode.destroy,
188
+ top: engine_1.OutMode.none,
189
189
  },
190
190
  trail: {
191
191
  fill: {
@@ -200,7 +200,7 @@ exports.options = {
200
200
  enable: true,
201
201
  events: [
202
202
  {
203
- event: "particleRemoved",
203
+ event: engine_1.EventType.particleRemoved,
204
204
  filter: explodeSoundCheck,
205
205
  audio: [
206
206
  "https://particles.js.org/audio/explosion0.mp3",
package/esm/bundle.js CHANGED
@@ -1,4 +1,3 @@
1
1
  import { loadFireworksPreset } from "./index.js";
2
2
  import { tsParticles } from "@tsparticles/engine";
3
- void loadFireworksPreset(tsParticles);
4
3
  export { loadFireworksPreset, tsParticles };
package/esm/index.js CHANGED
@@ -18,5 +18,6 @@ export async function loadFireworksPreset(engine, refresh = true) {
18
18
  await loadDestroyUpdater(engine, false);
19
19
  await loadLifeUpdater(engine, false);
20
20
  await loadStrokeColorUpdater(engine, false);
21
- await engine.addPreset("fireworks", options, refresh);
21
+ await engine.addPreset("fireworks", options, false);
22
+ await engine.refresh(refresh);
22
23
  }
package/esm/options.js CHANGED
@@ -1,4 +1,4 @@
1
- import { rgbToHsl, setRangeValue, stringToRgb, } from "@tsparticles/engine";
1
+ import { DestroyType, EventType, MoveDirection, OutMode, StartValueType, rgbToHsl, setRangeValue, stringToRgb, } from "@tsparticles/engine";
2
2
  const explodeSoundCheck = (args) => {
3
3
  const data = args.data;
4
4
  return data.particle.shape === "line";
@@ -16,7 +16,7 @@ const fixRange = (value, min, max) => {
16
16
  return res;
17
17
  };
18
18
  const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
19
- .map((color) => {
19
+ .map(color => {
20
20
  const rgb = stringToRgb(color);
21
21
  if (!rgb) {
22
22
  return undefined;
@@ -51,8 +51,8 @@ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
51
51
  enable: true,
52
52
  speed: 0.7,
53
53
  sync: false,
54
- startValue: "max",
55
- destroy: "min",
54
+ startValue: StartValueType.max,
55
+ destroy: DestroyType.min,
56
56
  },
57
57
  },
58
58
  shape: {
@@ -65,8 +65,8 @@ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
65
65
  speed: 5,
66
66
  count: 1,
67
67
  sync: false,
68
- startValue: "min",
69
- destroy: "none",
68
+ startValue: StartValueType.min,
69
+ destroy: DestroyType.none,
70
70
  },
71
71
  },
72
72
  life: {
@@ -88,11 +88,11 @@ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
88
88
  },
89
89
  speed: { min: 5, max: 15 },
90
90
  direction: "none",
91
- outModes: "destroy",
91
+ outModes: OutMode.destroy,
92
92
  },
93
93
  };
94
94
  })
95
- .filter((t) => t !== undefined);
95
+ .filter(t => t !== undefined);
96
96
  export const options = {
97
97
  detectRetina: true,
98
98
  background: {
@@ -100,7 +100,7 @@ export const options = {
100
100
  },
101
101
  fpsLimit: 120,
102
102
  emitters: {
103
- direction: "top",
103
+ direction: MoveDirection.top,
104
104
  life: {
105
105
  count: 0,
106
106
  duration: 0.1,
@@ -155,8 +155,8 @@ export const options = {
155
155
  enable: true,
156
156
  sync: true,
157
157
  speed: 90,
158
- startValue: "max",
159
- destroy: "min",
158
+ startValue: StartValueType.max,
159
+ destroy: DestroyType.min,
160
160
  },
161
161
  },
162
162
  stroke: {
@@ -181,8 +181,8 @@ export const options = {
181
181
  max: 20,
182
182
  },
183
183
  outModes: {
184
- default: "destroy",
185
- top: "none",
184
+ default: OutMode.destroy,
185
+ top: OutMode.none,
186
186
  },
187
187
  trail: {
188
188
  fill: {
@@ -197,7 +197,7 @@ export const options = {
197
197
  enable: true,
198
198
  events: [
199
199
  {
200
- event: "particleRemoved",
200
+ event: EventType.particleRemoved,
201
201
  filter: explodeSoundCheck,
202
202
  audio: [
203
203
  "https://particles.js.org/audio/explosion0.mp3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/preset-fireworks",
3
- "version": "3.0.1",
3
+ "version": "3.1.0",
4
4
  "description": "tsParticles fireworks preset",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -87,16 +87,16 @@
87
87
  "module": "esm/index.js",
88
88
  "types": "types/index.d.ts",
89
89
  "dependencies": {
90
- "@tsparticles/basic": "^3.0.0",
91
- "@tsparticles/engine": "^3.0.0",
92
- "@tsparticles/plugin-emitters": "^3.0.0",
93
- "@tsparticles/plugin-emitters-shape-square": "^3.0.0",
94
- "@tsparticles/plugin-sounds": "^3.0.0",
95
- "@tsparticles/shape-line": "^3.0.0",
96
- "@tsparticles/updater-destroy": "^3.0.0",
97
- "@tsparticles/updater-life": "^3.0.0",
98
- "@tsparticles/updater-rotate": "^3.0.0",
99
- "@tsparticles/updater-stroke-color": "^3.0.0"
90
+ "@tsparticles/basic": "^3.4.0",
91
+ "@tsparticles/engine": "^3.4.0",
92
+ "@tsparticles/plugin-emitters": "^3.4.0",
93
+ "@tsparticles/plugin-emitters-shape-square": "^3.4.0",
94
+ "@tsparticles/plugin-sounds": "^3.4.0",
95
+ "@tsparticles/shape-line": "^3.4.0",
96
+ "@tsparticles/updater-destroy": "^3.4.0",
97
+ "@tsparticles/updater-life": "^3.4.0",
98
+ "@tsparticles/updater-rotate": "^3.4.0",
99
+ "@tsparticles/updater-stroke-color": "^3.4.0"
100
100
  },
101
101
  "publishConfig": {
102
102
  "access": "public"