@tsparticles/preset-fireworks 3.0.0 → 3.0.2

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
@@ -56,13 +27,12 @@ A bundled script can also be used, this will include every needed plugin needed
56
27
  Once the scripts are loaded you can set up `tsParticles` like this:
57
28
 
58
29
  ```javascript
59
- (async () => {
60
- await loadFireworksPreset(tsParticles); // this is required only if you are not using the bundle script
61
-
62
- await tsParticles.load("tsparticles", {
30
+ tsParticles.load({
31
+ id: "tsparticles",
32
+ options: {
63
33
  preset: "fireworks",
64
- });
65
- })();
34
+ },
35
+ });
66
36
  ```
67
37
 
68
38
  #### Customization
@@ -71,100 +41,26 @@ Once the scripts are loaded you can set up `tsParticles` like this:
71
41
  You can override all the options defining the properties like in any standard `tsParticles` installation.
72
42
 
73
43
  ```javascript
74
- tsParticles.load("tsparticles", {
75
- particles: {
76
- shape: {
77
- type: "square", // starting from v2, this require the square shape script
44
+ tsParticles.load({
45
+ id: "tsparticles",
46
+ options: {
47
+ particles: {
48
+ shape: {
49
+ type: "square", // starting from v2, this require the square shape script
50
+ },
78
51
  },
52
+ preset: "fireworks",
79
53
  },
80
- preset: "fireworks",
81
54
  });
82
55
  ```
83
56
 
84
57
  Like in the sample above, the circles will be replaced by squares.
85
58
 
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
- ```
113
-
114
- ### Vue (2.x and 3.x)
115
-
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
- };
59
+ ### Frameworks with a tsParticles component library
126
60
 
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
- ```
61
+ Checkout the documentation in the component library repository and call the `loadFireworksPreset` function instead of `loadFull`, `loadSlim` or similar functions.
137
62
 
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
- ```
63
+ The options shown above are valid for all the component libraries.
168
64
 
169
65
  ---
170
66
 
package/browser/bundle.js CHANGED
@@ -1,4 +1,4 @@
1
- import { loadFireworksPreset } from ".";
1
+ import { loadFireworksPreset } from "./index.js";
2
2
  import { tsParticles } from "@tsparticles/engine";
3
- loadFireworksPreset(tsParticles);
3
+ void loadFireworksPreset(tsParticles);
4
4
  export { loadFireworksPreset, tsParticles };
package/browser/index.js CHANGED
@@ -7,7 +7,7 @@ import { loadLineShape } from "@tsparticles/shape-line";
7
7
  import { loadRotateUpdater } from "@tsparticles/updater-rotate";
8
8
  import { loadSoundsPlugin } from "@tsparticles/plugin-sounds";
9
9
  import { loadStrokeColorUpdater } from "@tsparticles/updater-stroke-color";
10
- import { options } from "./options";
10
+ import { options } from "./options.js";
11
11
  export async function loadFireworksPreset(engine, refresh = true) {
12
12
  await loadBasic(engine, false);
13
13
  await loadEmittersPlugin(engine, false);
@@ -4,14 +4,14 @@ const explodeSoundCheck = (args) => {
4
4
  return data.particle.shape === "line";
5
5
  };
6
6
  const fixRange = (value, min, max) => {
7
- const diffSMax = value.max > max ? value.max - max : 0;
7
+ const minValue = 0, diffSMax = value.max > max ? value.max - max : minValue;
8
8
  let res = setRangeValue(value);
9
9
  if (diffSMax) {
10
10
  res = setRangeValue(value.min - diffSMax, max);
11
11
  }
12
- const diffSMin = value.min < min ? value.min : 0;
12
+ const diffSMin = value.min < min ? value.min : minValue;
13
13
  if (diffSMin) {
14
- res = setRangeValue(0, value.max + diffSMin);
14
+ res = setRangeValue(minValue, value.max + diffSMin);
15
15
  }
16
16
  return res;
17
17
  };
@@ -21,7 +21,13 @@ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
21
21
  if (!rgb) {
22
22
  return undefined;
23
23
  }
24
- const hsl = rgbToHsl(rgb), sRange = fixRange({ min: hsl.s - 30, max: hsl.s + 30 }, 0, 100), lRange = fixRange({ min: hsl.l - 30, max: hsl.l + 30 }, 0, 100);
24
+ const hsl = rgbToHsl(rgb), sOffset = 30, lOffset = 30, sBounds = {
25
+ min: 0,
26
+ max: 100,
27
+ }, lBounds = {
28
+ min: 0,
29
+ max: 100,
30
+ }, sRange = fixRange({ min: hsl.s - sOffset, max: hsl.s + sOffset }, sBounds.min, sBounds.max), lRange = fixRange({ min: hsl.l - lOffset, max: hsl.l + lOffset }, lBounds.min, lBounds.max);
25
31
  return {
26
32
  color: {
27
33
  value: {
package/cjs/bundle.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tsParticles = exports.loadFireworksPreset = void 0;
4
- const _1 = require(".");
5
- Object.defineProperty(exports, "loadFireworksPreset", { enumerable: true, get: function () { return _1.loadFireworksPreset; } });
4
+ const index_js_1 = require("./index.js");
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
- (0, _1.loadFireworksPreset)(engine_1.tsParticles);
8
+ void (0, index_js_1.loadFireworksPreset)(engine_1.tsParticles);
package/cjs/index.js CHANGED
@@ -10,7 +10,7 @@ const shape_line_1 = require("@tsparticles/shape-line");
10
10
  const updater_rotate_1 = require("@tsparticles/updater-rotate");
11
11
  const plugin_sounds_1 = require("@tsparticles/plugin-sounds");
12
12
  const updater_stroke_color_1 = require("@tsparticles/updater-stroke-color");
13
- const options_1 = require("./options");
13
+ const options_js_1 = require("./options.js");
14
14
  async function loadFireworksPreset(engine, refresh = true) {
15
15
  await (0, basic_1.loadBasic)(engine, false);
16
16
  await (0, plugin_emitters_1.loadEmittersPlugin)(engine, false);
@@ -21,6 +21,6 @@ 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_1.options, refresh);
24
+ await engine.addPreset("fireworks", options_js_1.options, refresh);
25
25
  }
26
26
  exports.loadFireworksPreset = loadFireworksPreset;
package/cjs/options.js CHANGED
@@ -7,14 +7,14 @@ const explodeSoundCheck = (args) => {
7
7
  return data.particle.shape === "line";
8
8
  };
9
9
  const fixRange = (value, min, max) => {
10
- const diffSMax = value.max > max ? value.max - max : 0;
10
+ const minValue = 0, diffSMax = value.max > max ? value.max - max : minValue;
11
11
  let res = (0, engine_1.setRangeValue)(value);
12
12
  if (diffSMax) {
13
13
  res = (0, engine_1.setRangeValue)(value.min - diffSMax, max);
14
14
  }
15
- const diffSMin = value.min < min ? value.min : 0;
15
+ const diffSMin = value.min < min ? value.min : minValue;
16
16
  if (diffSMin) {
17
- res = (0, engine_1.setRangeValue)(0, value.max + diffSMin);
17
+ res = (0, engine_1.setRangeValue)(minValue, value.max + diffSMin);
18
18
  }
19
19
  return res;
20
20
  };
@@ -24,7 +24,13 @@ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
24
24
  if (!rgb) {
25
25
  return undefined;
26
26
  }
27
- const hsl = (0, engine_1.rgbToHsl)(rgb), sRange = fixRange({ min: hsl.s - 30, max: hsl.s + 30 }, 0, 100), lRange = fixRange({ min: hsl.l - 30, max: hsl.l + 30 }, 0, 100);
27
+ const hsl = (0, engine_1.rgbToHsl)(rgb), sOffset = 30, lOffset = 30, sBounds = {
28
+ min: 0,
29
+ max: 100,
30
+ }, lBounds = {
31
+ min: 0,
32
+ max: 100,
33
+ }, sRange = fixRange({ min: hsl.s - sOffset, max: hsl.s + sOffset }, sBounds.min, sBounds.max), lRange = fixRange({ min: hsl.l - lOffset, max: hsl.l + lOffset }, lBounds.min, lBounds.max);
28
34
  return {
29
35
  color: {
30
36
  value: {
package/esm/bundle.js CHANGED
@@ -1,4 +1,4 @@
1
- import { loadFireworksPreset } from ".";
1
+ import { loadFireworksPreset } from "./index.js";
2
2
  import { tsParticles } from "@tsparticles/engine";
3
- loadFireworksPreset(tsParticles);
3
+ void loadFireworksPreset(tsParticles);
4
4
  export { loadFireworksPreset, tsParticles };
package/esm/index.js CHANGED
@@ -7,7 +7,7 @@ import { loadLineShape } from "@tsparticles/shape-line";
7
7
  import { loadRotateUpdater } from "@tsparticles/updater-rotate";
8
8
  import { loadSoundsPlugin } from "@tsparticles/plugin-sounds";
9
9
  import { loadStrokeColorUpdater } from "@tsparticles/updater-stroke-color";
10
- import { options } from "./options";
10
+ import { options } from "./options.js";
11
11
  export async function loadFireworksPreset(engine, refresh = true) {
12
12
  await loadBasic(engine, false);
13
13
  await loadEmittersPlugin(engine, false);
package/esm/options.js CHANGED
@@ -4,14 +4,14 @@ const explodeSoundCheck = (args) => {
4
4
  return data.particle.shape === "line";
5
5
  };
6
6
  const fixRange = (value, min, max) => {
7
- const diffSMax = value.max > max ? value.max - max : 0;
7
+ const minValue = 0, diffSMax = value.max > max ? value.max - max : minValue;
8
8
  let res = setRangeValue(value);
9
9
  if (diffSMax) {
10
10
  res = setRangeValue(value.min - diffSMax, max);
11
11
  }
12
- const diffSMin = value.min < min ? value.min : 0;
12
+ const diffSMin = value.min < min ? value.min : minValue;
13
13
  if (diffSMin) {
14
- res = setRangeValue(0, value.max + diffSMin);
14
+ res = setRangeValue(minValue, value.max + diffSMin);
15
15
  }
16
16
  return res;
17
17
  };
@@ -21,7 +21,13 @@ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
21
21
  if (!rgb) {
22
22
  return undefined;
23
23
  }
24
- const hsl = rgbToHsl(rgb), sRange = fixRange({ min: hsl.s - 30, max: hsl.s + 30 }, 0, 100), lRange = fixRange({ min: hsl.l - 30, max: hsl.l + 30 }, 0, 100);
24
+ const hsl = rgbToHsl(rgb), sOffset = 30, lOffset = 30, sBounds = {
25
+ min: 0,
26
+ max: 100,
27
+ }, lBounds = {
28
+ min: 0,
29
+ max: 100,
30
+ }, sRange = fixRange({ min: hsl.s - sOffset, max: hsl.s + sOffset }, sBounds.min, sBounds.max), lRange = fixRange({ min: hsl.l - lOffset, max: hsl.l + lOffset }, lBounds.min, lBounds.max);
25
31
  return {
26
32
  color: {
27
33
  value: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/preset-fireworks",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
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.0.3",
91
+ "@tsparticles/engine": "^3.0.3",
92
+ "@tsparticles/plugin-emitters": "^3.0.3",
93
+ "@tsparticles/plugin-emitters-shape-square": "^3.0.3",
94
+ "@tsparticles/plugin-sounds": "^3.0.3",
95
+ "@tsparticles/shape-line": "^3.0.3",
96
+ "@tsparticles/updater-destroy": "^3.0.3",
97
+ "@tsparticles/updater-life": "^3.0.3",
98
+ "@tsparticles/updater-rotate": "^3.0.3",
99
+ "@tsparticles/updater-stroke-color": "^3.0.3"
100
100
  },
101
101
  "publishConfig": {
102
102
  "access": "public"