@tsparticles/preset-fireworks 3.0.0-alpha.1

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/cjs/options.js ADDED
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.options = void 0;
4
+ const engine_1 = require("@tsparticles/engine");
5
+ const explodeSoundCheck = (args) => {
6
+ const data = args.data;
7
+ return data.particle.shape === "line";
8
+ };
9
+ const fixRange = (value, min, max) => {
10
+ const diffSMax = value.max > max ? value.max - max : 0;
11
+ let res = (0, engine_1.setRangeValue)(value);
12
+ if (diffSMax) {
13
+ res = (0, engine_1.setRangeValue)(value.min - diffSMax, max);
14
+ }
15
+ const diffSMin = value.min < min ? value.min : 0;
16
+ if (diffSMin) {
17
+ res = (0, engine_1.setRangeValue)(0, value.max + diffSMin);
18
+ }
19
+ return res;
20
+ };
21
+ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
22
+ .map((color) => {
23
+ const rgb = (0, engine_1.stringToRgb)(color);
24
+ if (!rgb) {
25
+ return undefined;
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);
28
+ return {
29
+ color: {
30
+ value: {
31
+ h: hsl.h,
32
+ s: sRange,
33
+ l: lRange,
34
+ },
35
+ },
36
+ stroke: {
37
+ width: 0,
38
+ },
39
+ number: {
40
+ value: 0,
41
+ },
42
+ opacity: {
43
+ value: {
44
+ min: 0.1,
45
+ max: 1,
46
+ },
47
+ animation: {
48
+ enable: true,
49
+ speed: 0.7,
50
+ sync: false,
51
+ startValue: "max",
52
+ destroy: "min",
53
+ },
54
+ },
55
+ shape: {
56
+ type: "circle",
57
+ },
58
+ size: {
59
+ value: { min: 1, max: 2 },
60
+ animation: {
61
+ enable: true,
62
+ speed: 5,
63
+ count: 1,
64
+ sync: false,
65
+ startValue: "min",
66
+ destroy: "none",
67
+ },
68
+ },
69
+ life: {
70
+ count: 1,
71
+ duration: {
72
+ value: {
73
+ min: 1,
74
+ max: 2,
75
+ },
76
+ },
77
+ },
78
+ move: {
79
+ decay: { min: 0.075, max: 0.1 },
80
+ enable: true,
81
+ gravity: {
82
+ enable: true,
83
+ inverse: false,
84
+ acceleration: 5,
85
+ },
86
+ speed: { min: 5, max: 15 },
87
+ direction: "none",
88
+ outModes: "destroy",
89
+ },
90
+ };
91
+ })
92
+ .filter((t) => t !== undefined);
93
+ exports.options = {
94
+ detectRetina: true,
95
+ background: {
96
+ color: "#000",
97
+ },
98
+ fpsLimit: 120,
99
+ emitters: {
100
+ direction: "top",
101
+ life: {
102
+ count: 0,
103
+ duration: 0.1,
104
+ delay: 0.1,
105
+ },
106
+ rate: {
107
+ delay: 0.05,
108
+ quantity: 1,
109
+ },
110
+ size: {
111
+ width: 100,
112
+ height: 0,
113
+ },
114
+ position: {
115
+ y: 100,
116
+ x: 50,
117
+ },
118
+ },
119
+ particles: {
120
+ number: {
121
+ value: 0,
122
+ },
123
+ destroy: {
124
+ mode: "split",
125
+ bounds: {
126
+ top: { min: 10, max: 30 },
127
+ },
128
+ split: {
129
+ sizeOffset: false,
130
+ count: 1,
131
+ factor: {
132
+ value: 0.333333,
133
+ },
134
+ rate: {
135
+ value: { min: 75, max: 150 },
136
+ },
137
+ particles: fireworksOptions,
138
+ },
139
+ },
140
+ life: {
141
+ count: 1,
142
+ },
143
+ shape: {
144
+ type: "line",
145
+ },
146
+ size: {
147
+ value: {
148
+ min: 0.1,
149
+ max: 50,
150
+ },
151
+ animation: {
152
+ enable: true,
153
+ sync: true,
154
+ speed: 90,
155
+ startValue: "max",
156
+ destroy: "min",
157
+ },
158
+ },
159
+ stroke: {
160
+ color: {
161
+ value: "#ffffff",
162
+ },
163
+ width: 1,
164
+ },
165
+ rotate: {
166
+ path: true,
167
+ },
168
+ move: {
169
+ enable: true,
170
+ gravity: {
171
+ acceleration: 15,
172
+ enable: true,
173
+ inverse: true,
174
+ maxSpeed: 100,
175
+ },
176
+ speed: {
177
+ min: 10,
178
+ max: 20,
179
+ },
180
+ outModes: {
181
+ default: "destroy",
182
+ top: "none",
183
+ },
184
+ trail: {
185
+ fillColor: "#000",
186
+ enable: true,
187
+ length: 10,
188
+ },
189
+ },
190
+ },
191
+ sounds: {
192
+ enable: true,
193
+ events: [
194
+ {
195
+ event: "particleRemoved",
196
+ filter: explodeSoundCheck,
197
+ audio: [
198
+ "https://particles.js.org/audio/explosion0.mp3",
199
+ "https://particles.js.org/audio/explosion1.mp3",
200
+ "https://particles.js.org/audio/explosion2.mp3",
201
+ ],
202
+ },
203
+ ],
204
+ volume: 50,
205
+ },
206
+ };
package/esm/bundle.js ADDED
@@ -0,0 +1,6 @@
1
+ import { loadFireworksPreset } from ".";
2
+ import { tsParticles } from "@tsparticles/engine";
3
+ (async () => {
4
+ await loadFireworksPreset(tsParticles);
5
+ })();
6
+ export { loadFireworksPreset, tsParticles };
package/esm/index.js ADDED
@@ -0,0 +1,30 @@
1
+ import { loadAngleUpdater } from "@tsparticles/updater-angle";
2
+ import { loadBaseMover } from "@tsparticles/move-base";
3
+ import { loadCircleShape } from "@tsparticles/shape-circle";
4
+ import { loadColorUpdater } from "@tsparticles/updater-color";
5
+ import { loadDestroyUpdater } from "@tsparticles/updater-destroy";
6
+ import { loadEmittersPlugin } from "@tsparticles/plugin-emitters";
7
+ import { loadLifeUpdater } from "@tsparticles/updater-life";
8
+ import { loadLineShape } from "@tsparticles/shape-line";
9
+ import { loadOpacityUpdater } from "@tsparticles/updater-opacity";
10
+ import { loadOutModesUpdater } from "@tsparticles/updater-out-modes";
11
+ import { loadSizeUpdater } from "@tsparticles/updater-size";
12
+ import { loadSoundsPlugin } from "@tsparticles/plugin-sounds";
13
+ import { loadStrokeColorUpdater } from "@tsparticles/updater-stroke-color";
14
+ import { options } from "./options";
15
+ export async function loadFireworksPreset(engine) {
16
+ await loadBaseMover(engine);
17
+ await loadEmittersPlugin(engine);
18
+ await loadSoundsPlugin(engine);
19
+ await loadCircleShape(engine);
20
+ await loadLineShape(engine);
21
+ await loadAngleUpdater(engine);
22
+ await loadColorUpdater(engine);
23
+ await loadDestroyUpdater(engine);
24
+ await loadLifeUpdater(engine);
25
+ await loadOpacityUpdater(engine);
26
+ await loadOutModesUpdater(engine);
27
+ await loadSizeUpdater(engine);
28
+ await loadStrokeColorUpdater(engine);
29
+ await engine.addPreset("fireworks", options);
30
+ }
package/esm/options.js ADDED
@@ -0,0 +1,203 @@
1
+ import { rgbToHsl, setRangeValue, stringToRgb, } from "@tsparticles/engine";
2
+ const explodeSoundCheck = (args) => {
3
+ const data = args.data;
4
+ return data.particle.shape === "line";
5
+ };
6
+ const fixRange = (value, min, max) => {
7
+ const diffSMax = value.max > max ? value.max - max : 0;
8
+ let res = setRangeValue(value);
9
+ if (diffSMax) {
10
+ res = setRangeValue(value.min - diffSMax, max);
11
+ }
12
+ const diffSMin = value.min < min ? value.min : 0;
13
+ if (diffSMin) {
14
+ res = setRangeValue(0, value.max + diffSMin);
15
+ }
16
+ return res;
17
+ };
18
+ const fireworksOptions = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"]
19
+ .map((color) => {
20
+ const rgb = stringToRgb(color);
21
+ if (!rgb) {
22
+ return undefined;
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);
25
+ return {
26
+ color: {
27
+ value: {
28
+ h: hsl.h,
29
+ s: sRange,
30
+ l: lRange,
31
+ },
32
+ },
33
+ stroke: {
34
+ width: 0,
35
+ },
36
+ number: {
37
+ value: 0,
38
+ },
39
+ opacity: {
40
+ value: {
41
+ min: 0.1,
42
+ max: 1,
43
+ },
44
+ animation: {
45
+ enable: true,
46
+ speed: 0.7,
47
+ sync: false,
48
+ startValue: "max",
49
+ destroy: "min",
50
+ },
51
+ },
52
+ shape: {
53
+ type: "circle",
54
+ },
55
+ size: {
56
+ value: { min: 1, max: 2 },
57
+ animation: {
58
+ enable: true,
59
+ speed: 5,
60
+ count: 1,
61
+ sync: false,
62
+ startValue: "min",
63
+ destroy: "none",
64
+ },
65
+ },
66
+ life: {
67
+ count: 1,
68
+ duration: {
69
+ value: {
70
+ min: 1,
71
+ max: 2,
72
+ },
73
+ },
74
+ },
75
+ move: {
76
+ decay: { min: 0.075, max: 0.1 },
77
+ enable: true,
78
+ gravity: {
79
+ enable: true,
80
+ inverse: false,
81
+ acceleration: 5,
82
+ },
83
+ speed: { min: 5, max: 15 },
84
+ direction: "none",
85
+ outModes: "destroy",
86
+ },
87
+ };
88
+ })
89
+ .filter((t) => t !== undefined);
90
+ export const options = {
91
+ detectRetina: true,
92
+ background: {
93
+ color: "#000",
94
+ },
95
+ fpsLimit: 120,
96
+ emitters: {
97
+ direction: "top",
98
+ life: {
99
+ count: 0,
100
+ duration: 0.1,
101
+ delay: 0.1,
102
+ },
103
+ rate: {
104
+ delay: 0.05,
105
+ quantity: 1,
106
+ },
107
+ size: {
108
+ width: 100,
109
+ height: 0,
110
+ },
111
+ position: {
112
+ y: 100,
113
+ x: 50,
114
+ },
115
+ },
116
+ particles: {
117
+ number: {
118
+ value: 0,
119
+ },
120
+ destroy: {
121
+ mode: "split",
122
+ bounds: {
123
+ top: { min: 10, max: 30 },
124
+ },
125
+ split: {
126
+ sizeOffset: false,
127
+ count: 1,
128
+ factor: {
129
+ value: 0.333333,
130
+ },
131
+ rate: {
132
+ value: { min: 75, max: 150 },
133
+ },
134
+ particles: fireworksOptions,
135
+ },
136
+ },
137
+ life: {
138
+ count: 1,
139
+ },
140
+ shape: {
141
+ type: "line",
142
+ },
143
+ size: {
144
+ value: {
145
+ min: 0.1,
146
+ max: 50,
147
+ },
148
+ animation: {
149
+ enable: true,
150
+ sync: true,
151
+ speed: 90,
152
+ startValue: "max",
153
+ destroy: "min",
154
+ },
155
+ },
156
+ stroke: {
157
+ color: {
158
+ value: "#ffffff",
159
+ },
160
+ width: 1,
161
+ },
162
+ rotate: {
163
+ path: true,
164
+ },
165
+ move: {
166
+ enable: true,
167
+ gravity: {
168
+ acceleration: 15,
169
+ enable: true,
170
+ inverse: true,
171
+ maxSpeed: 100,
172
+ },
173
+ speed: {
174
+ min: 10,
175
+ max: 20,
176
+ },
177
+ outModes: {
178
+ default: "destroy",
179
+ top: "none",
180
+ },
181
+ trail: {
182
+ fillColor: "#000",
183
+ enable: true,
184
+ length: 10,
185
+ },
186
+ },
187
+ },
188
+ sounds: {
189
+ enable: true,
190
+ events: [
191
+ {
192
+ event: "particleRemoved",
193
+ filter: explodeSoundCheck,
194
+ audio: [
195
+ "https://particles.js.org/audio/explosion0.mp3",
196
+ "https://particles.js.org/audio/explosion1.mp3",
197
+ "https://particles.js.org/audio/explosion2.mp3",
198
+ ],
199
+ },
200
+ ],
201
+ volume: 50,
202
+ },
203
+ };
package/package.json ADDED
@@ -0,0 +1,104 @@
1
+ {
2
+ "name": "@tsparticles/preset-fireworks",
3
+ "version": "3.0.0-alpha.1",
4
+ "description": "tsParticles fireworks preset",
5
+ "homepage": "https://particles.js.org",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/matteobruni/tsparticles.git",
9
+ "directory": "presets/fireworks"
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/preset"
64
+ ],
65
+ "author": "Matteo Bruni <matteo.bruni@me.com>",
66
+ "license": "MIT",
67
+ "bugs": {
68
+ "url": "https://github.com/matteobruni/tsparticles/issues"
69
+ },
70
+ "funding": [
71
+ {
72
+ "type": "github",
73
+ "url": "https://github.com/sponsors/matteobruni"
74
+ },
75
+ {
76
+ "type": "buymeacoffee",
77
+ "url": "https://www.buymeacoffee.com/matteobruni"
78
+ }
79
+ ],
80
+ "main": "cjs/index.js",
81
+ "jsdelivr": "tsparticles.preset.fireworks.min.js",
82
+ "unpkg": "tsparticles.preset.fireworks.min.js",
83
+ "module": "esm/index.js",
84
+ "types": "types/index.d.ts",
85
+ "publishConfig": {
86
+ "access": "public"
87
+ },
88
+ "dependencies": {
89
+ "@tsparticles/engine": "^3.0.0-alpha.1",
90
+ "@tsparticles/move-base": "^3.0.0-alpha.1",
91
+ "@tsparticles/plugin-emitters": "^3.0.0-alpha.1",
92
+ "@tsparticles/plugin-sounds": "^3.0.0-alpha.1",
93
+ "@tsparticles/shape-circle": "^3.0.0-alpha.1",
94
+ "@tsparticles/shape-line": "^3.0.0-alpha.1",
95
+ "@tsparticles/updater-angle": "^3.0.0-alpha.1",
96
+ "@tsparticles/updater-color": "^3.0.0-alpha.1",
97
+ "@tsparticles/updater-destroy": "^3.0.0-alpha.1",
98
+ "@tsparticles/updater-life": "^3.0.0-alpha.1",
99
+ "@tsparticles/updater-opacity": "^3.0.0-alpha.1",
100
+ "@tsparticles/updater-out-modes": "^3.0.0-alpha.1",
101
+ "@tsparticles/updater-size": "^3.0.0-alpha.1",
102
+ "@tsparticles/updater-stroke-color": "^3.0.0-alpha.1"
103
+ }
104
+ }