partycles 0.3.0 → 1.0.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/dist/animations/animations/bees.d.ts +8 -0
- package/dist/animations/animations/bees.d.ts.map +1 -0
- package/dist/animations/animations/butterflies.d.ts +8 -0
- package/dist/animations/animations/butterflies.d.ts.map +1 -0
- package/dist/animations/animations/candy.d.ts +8 -0
- package/dist/animations/animations/candy.d.ts.map +1 -0
- package/dist/animations/animations/champagne.d.ts +8 -0
- package/dist/animations/animations/champagne.d.ts.map +1 -0
- package/dist/animations/animations/crystals.d.ts +8 -0
- package/dist/animations/animations/crystals.d.ts.map +1 -0
- package/dist/animations/animations/dandelion.d.ts +8 -0
- package/dist/animations/animations/dandelion.d.ts.map +1 -0
- package/dist/animations/animations/dice.d.ts +8 -0
- package/dist/animations/animations/dice.d.ts.map +1 -0
- package/dist/animations/animations/donuts.d.ts +8 -0
- package/dist/animations/animations/donuts.d.ts.map +1 -0
- package/dist/animations/animations/dragons.d.ts +8 -0
- package/dist/animations/animations/dragons.d.ts.map +1 -0
- package/dist/animations/animations/galaxy.d.ts.map +1 -1
- package/dist/animations/animations/ghosts.d.ts +8 -0
- package/dist/animations/animations/ghosts.d.ts.map +1 -0
- package/dist/animations/animations/glitch.d.ts +8 -0
- package/dist/animations/animations/glitch.d.ts.map +1 -0
- package/dist/animations/animations/index.d.ts.map +1 -1
- package/dist/animations/animations/leaves.d.ts +8 -0
- package/dist/animations/animations/leaves.d.ts.map +1 -0
- package/dist/animations/animations/levelup.d.ts +8 -0
- package/dist/animations/animations/levelup.d.ts.map +1 -0
- package/dist/animations/animations/magicdust.d.ts +8 -0
- package/dist/animations/animations/magicdust.d.ts.map +1 -0
- package/dist/animations/animations/matrix.d.ts +8 -0
- package/dist/animations/animations/matrix.d.ts.map +1 -0
- package/dist/animations/animations/music.d.ts.map +1 -1
- package/dist/animations/animations/pixels.d.ts +8 -0
- package/dist/animations/animations/pixels.d.ts.map +1 -0
- package/dist/animations/animations/pizza.d.ts +8 -0
- package/dist/animations/animations/pizza.d.ts.map +1 -0
- package/dist/animations/animations/popcorn.d.ts +8 -0
- package/dist/animations/animations/popcorn.d.ts.map +1 -0
- package/dist/animations/animations/rain.d.ts +8 -0
- package/dist/animations/animations/rain.d.ts.map +1 -0
- package/dist/animations/animations/runes.d.ts +8 -0
- package/dist/animations/animations/runes.d.ts.map +1 -0
- package/dist/animations/bees.d.ts +8 -0
- package/dist/animations/bees.d.ts.map +1 -0
- package/dist/animations/bubbles.esm.js +3 -3
- package/dist/animations/bubbles.esm.js.map +1 -1
- package/dist/animations/bubbles.js +3 -3
- package/dist/animations/bubbles.js.map +1 -1
- package/dist/animations/butterflies.d.ts +8 -0
- package/dist/animations/butterflies.d.ts.map +1 -0
- package/dist/animations/candy.d.ts +8 -0
- package/dist/animations/candy.d.ts.map +1 -0
- package/dist/animations/champagne.d.ts +8 -0
- package/dist/animations/champagne.d.ts.map +1 -0
- package/dist/animations/confetti.esm.js +1 -1
- package/dist/animations/confetti.esm.js.map +1 -1
- package/dist/animations/confetti.js +1 -1
- package/dist/animations/confetti.js.map +1 -1
- package/dist/animations/crystals.d.ts +8 -0
- package/dist/animations/crystals.d.ts.map +1 -0
- package/dist/animations/dandelion.d.ts +8 -0
- package/dist/animations/dandelion.d.ts.map +1 -0
- package/dist/animations/dice.d.ts +8 -0
- package/dist/animations/dice.d.ts.map +1 -0
- package/dist/animations/donuts.d.ts +8 -0
- package/dist/animations/donuts.d.ts.map +1 -0
- package/dist/animations/dragons.d.ts +8 -0
- package/dist/animations/dragons.d.ts.map +1 -0
- package/dist/animations/emoji.esm.js.map +1 -1
- package/dist/animations/emoji.js.map +1 -1
- package/dist/animations/fireworks.esm.js +1 -1
- package/dist/animations/fireworks.esm.js.map +1 -1
- package/dist/animations/fireworks.js +1 -1
- package/dist/animations/fireworks.js.map +1 -1
- package/dist/animations/galaxy.d.ts.map +1 -1
- package/dist/animations/ghosts.d.ts +8 -0
- package/dist/animations/ghosts.d.ts.map +1 -0
- package/dist/animations/glitch.d.ts +8 -0
- package/dist/animations/glitch.d.ts.map +1 -0
- package/dist/animations/hearts.esm.js +1 -1
- package/dist/animations/hearts.esm.js.map +1 -1
- package/dist/animations/hearts.js +1 -1
- package/dist/animations/hearts.js.map +1 -1
- package/dist/animations/leaves.d.ts +8 -0
- package/dist/animations/leaves.d.ts.map +1 -0
- package/dist/animations/levelup.d.ts +8 -0
- package/dist/animations/levelup.d.ts.map +1 -0
- package/dist/animations/magicdust.d.ts +8 -0
- package/dist/animations/magicdust.d.ts.map +1 -0
- package/dist/animations/matrix.d.ts +8 -0
- package/dist/animations/matrix.d.ts.map +1 -0
- package/dist/animations/music.d.ts.map +1 -1
- package/dist/animations/pixels.d.ts +8 -0
- package/dist/animations/pixels.d.ts.map +1 -0
- package/dist/animations/pizza.d.ts +8 -0
- package/dist/animations/pizza.d.ts.map +1 -0
- package/dist/animations/popcorn.d.ts +8 -0
- package/dist/animations/popcorn.d.ts.map +1 -0
- package/dist/animations/rain.d.ts +8 -0
- package/dist/animations/rain.d.ts.map +1 -0
- package/dist/animations/runes.d.ts +8 -0
- package/dist/animations/runes.d.ts.map +1 -0
- package/dist/animations/snow.esm.js +1 -1
- package/dist/animations/snow.esm.js.map +1 -1
- package/dist/animations/snow.js +1 -1
- package/dist/animations/snow.js.map +1 -1
- package/dist/animations/sparkles.esm.js +1 -1
- package/dist/animations/sparkles.esm.js.map +1 -1
- package/dist/animations/sparkles.js +1 -1
- package/dist/animations/sparkles.js.map +1 -1
- package/dist/animations/stars.esm.js +1 -1
- package/dist/animations/stars.esm.js.map +1 -1
- package/dist/animations/stars.js +1 -1
- package/dist/animations/stars.js.map +1 -1
- package/dist/animations/types.d.ts +1 -1
- package/dist/animations/types.d.ts.map +1 -1
- package/dist/index.esm.js +301 -156
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +301 -156
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -13,7 +13,7 @@ const generateId = () => {
|
|
13
13
|
return Math.random().toString(36).substring(2, 9);
|
14
14
|
};
|
15
15
|
const getRandomColor = (colors) => {
|
16
|
-
return colors[Math.floor(Math.random() * colors.length)] || colors[0];
|
16
|
+
return colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff';
|
17
17
|
};
|
18
18
|
const createParticleStyle = (particle, containerRect) => {
|
19
19
|
return {
|
@@ -28,9 +28,9 @@ const createParticleStyle = (particle, containerRect) => {
|
|
28
28
|
};
|
29
29
|
};
|
30
30
|
|
31
|
-
const defaultColors = ['#f44336', '#e91e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3', '#03a9f4', '#00bcd4', '#009688', '#4caf50', '#8bc34a', '#cddc39', '#ffeb3b', '#ffc107', '#ff9800', '#ff5722'];
|
31
|
+
const defaultColors$3 = ['#f44336', '#e91e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3', '#03a9f4', '#00bcd4', '#009688', '#4caf50', '#8bc34a', '#cddc39', '#ffeb3b', '#ffc107', '#ff9800', '#ff5722'];
|
32
32
|
const createConfettiParticles = (origin, config) => {
|
33
|
-
const { particleCount = 50, startVelocity = 20, colors = defaultColors, elementSize = 20 } = config;
|
33
|
+
const { particleCount = 50, startVelocity = 20, colors = defaultColors$3, elementSize = 20 } = config;
|
34
34
|
const particles = [];
|
35
35
|
for (let i = 0; i < particleCount; i++) {
|
36
36
|
const angle = randomInRange(0, 360);
|
@@ -76,7 +76,7 @@ const createSparkleParticles = (origin, config) => {
|
|
76
76
|
opacity: 0,
|
77
77
|
size: randomInRange(elementSize * 0.4, elementSize * 1.2),
|
78
78
|
rotation: randomInRange(0, 360),
|
79
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
79
|
+
color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
|
80
80
|
});
|
81
81
|
}
|
82
82
|
return particles;
|
@@ -168,13 +168,13 @@ const createBubbleParticles = (origin, config) => {
|
|
168
168
|
id: generateId(),
|
169
169
|
x: origin.x + randomInRange(-spread, spread),
|
170
170
|
y: origin.y,
|
171
|
-
vx: randomInRange(-
|
172
|
-
vy: -randomInRange(startVelocity * 0.
|
171
|
+
vx: randomInRange(-3, 3),
|
172
|
+
vy: -randomInRange(startVelocity * 0.7, startVelocity * 1.2),
|
173
173
|
life: config.lifetime || 160,
|
174
174
|
opacity: 0.7,
|
175
175
|
size: randomInRange(elementSize * 0.4, elementSize * 1.2),
|
176
176
|
rotation: 0,
|
177
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
177
|
+
color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
|
178
178
|
});
|
179
179
|
}
|
180
180
|
return particles;
|
@@ -211,7 +211,7 @@ const createStarParticles = (origin, config) => {
|
|
211
211
|
opacity: 1,
|
212
212
|
size: randomInRange(elementSize * 0.5, elementSize * 1.3),
|
213
213
|
rotation: randomInRange(0, 360),
|
214
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
214
|
+
color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
|
215
215
|
});
|
216
216
|
}
|
217
217
|
return particles;
|
@@ -241,7 +241,7 @@ const createSnowParticles = (origin, config) => {
|
|
241
241
|
opacity: randomInRange(0.4, 0.9),
|
242
242
|
size: randomInRange(elementSize * 0.3, elementSize),
|
243
243
|
rotation: randomInRange(0, 360),
|
244
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
244
|
+
color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
|
245
245
|
});
|
246
246
|
}
|
247
247
|
return particles;
|
@@ -324,7 +324,7 @@ const createCoinParticles = (origin, config) => {
|
|
324
324
|
opacity: 1,
|
325
325
|
size: randomInRange(elementSize * 0.8, elementSize * 1.2),
|
326
326
|
rotation: randomInRange(0, 360),
|
327
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
327
|
+
color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
|
328
328
|
});
|
329
329
|
}
|
330
330
|
return particles;
|
@@ -361,61 +361,6 @@ const renderCoinParticle = (particle) => {
|
|
361
361
|
} }, "$")));
|
362
362
|
};
|
363
363
|
|
364
|
-
const lightningColors = ['#FFFF00', '#FFFFFF', '#00FFFF', '#FF00FF'];
|
365
|
-
const createLightningParticles = (origin, config) => {
|
366
|
-
const { particleCount = 20, spread = 360, startVelocity = 50, colors = lightningColors, elementSize = 30 } = config;
|
367
|
-
const particles = [];
|
368
|
-
for (let i = 0; i < particleCount; i++) {
|
369
|
-
const angle = randomInRange(0, spread) * (Math.PI / 180);
|
370
|
-
const velocity = randomInRange(startVelocity * 0.7, startVelocity * 1.3);
|
371
|
-
particles.push({
|
372
|
-
id: generateId(),
|
373
|
-
x: origin.x,
|
374
|
-
y: origin.y,
|
375
|
-
vx: Math.sin(angle) * velocity,
|
376
|
-
vy: -Math.abs(Math.cos(angle) * velocity * 0.5), // Mostly horizontal movement
|
377
|
-
life: config.lifetime || 60, // Quick flashes
|
378
|
-
opacity: 1,
|
379
|
-
size: randomInRange(elementSize * 0.5, elementSize * 1.5),
|
380
|
-
rotation: randomInRange(0, 360),
|
381
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
382
|
-
});
|
383
|
-
}
|
384
|
-
return particles;
|
385
|
-
};
|
386
|
-
const renderLightningParticle = (particle) => {
|
387
|
-
// Create zigzag pattern based on particle life
|
388
|
-
const zigzagOffset = Math.sin(particle.life * 0.5) * 10;
|
389
|
-
return (React.createElement("div", { key: particle.id, style: {
|
390
|
-
width: `${particle.size}px`,
|
391
|
-
height: `${particle.size * 0.3}px`,
|
392
|
-
position: 'relative',
|
393
|
-
filter: `blur(0.5px) brightness(2)`,
|
394
|
-
transform: `translateX(${zigzagOffset}px) rotate(${particle.rotation}deg)`,
|
395
|
-
} },
|
396
|
-
React.createElement("div", { style: {
|
397
|
-
position: 'absolute',
|
398
|
-
width: '100%',
|
399
|
-
height: '100%',
|
400
|
-
background: particle.color,
|
401
|
-
clipPath: 'polygon(0% 0%, 60% 0%, 40% 45%, 100% 45%, 0% 100%, 40% 55%, 20% 55%, 35% 100%)',
|
402
|
-
boxShadow: `
|
403
|
-
0 0 10px ${particle.color},
|
404
|
-
0 0 20px ${particle.color},
|
405
|
-
0 0 30px ${particle.color}
|
406
|
-
`,
|
407
|
-
} }),
|
408
|
-
React.createElement("div", { style: {
|
409
|
-
position: 'absolute',
|
410
|
-
top: '-50%',
|
411
|
-
left: '-50%',
|
412
|
-
width: '200%',
|
413
|
-
height: '200%',
|
414
|
-
background: `radial-gradient(circle, ${particle.color}88 0%, transparent 70%)`,
|
415
|
-
animation: `electricPulse ${randomInRange(100, 200)}ms infinite`,
|
416
|
-
} })));
|
417
|
-
};
|
418
|
-
|
419
364
|
const petalColors = ['#FFB6C1', '#FFC0CB', '#FF69B4', '#FF1493', '#FFF0F5'];
|
420
365
|
const createPetalParticles = (origin, config) => {
|
421
366
|
const { particleCount = 40, spread = 100, startVelocity = 8, colors = petalColors, elementSize = 20 } = config;
|
@@ -433,7 +378,7 @@ const createPetalParticles = (origin, config) => {
|
|
433
378
|
opacity: randomInRange(0.7, 1),
|
434
379
|
size: randomInRange(elementSize * 0.7, elementSize * 1.3),
|
435
380
|
rotation: randomInRange(0, 360),
|
436
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
381
|
+
color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
|
437
382
|
});
|
438
383
|
}
|
439
384
|
return particles;
|
@@ -491,7 +436,7 @@ const createAuroraParticles = (origin, config) => {
|
|
491
436
|
opacity: 0,
|
492
437
|
size: randomInRange(elementSize * 0.8, elementSize * 1.2),
|
493
438
|
rotation: randomInRange(-15, 15),
|
494
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
439
|
+
color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
|
495
440
|
});
|
496
441
|
}
|
497
442
|
return particles;
|
@@ -548,7 +493,7 @@ const createFireflyParticles = (origin, config) => {
|
|
548
493
|
opacity: 0,
|
549
494
|
size: randomInRange(elementSize * 0.6, elementSize),
|
550
495
|
rotation: randomInRange(0, 360), // Used for blink timing
|
551
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
496
|
+
color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
|
552
497
|
});
|
553
498
|
}
|
554
499
|
return particles;
|
@@ -618,7 +563,7 @@ const createPaintParticles = (origin, config) => {
|
|
618
563
|
? randomInRange(elementSize * 1.5, elementSize * 2.5)
|
619
564
|
: randomInRange(elementSize * 0.3, elementSize),
|
620
565
|
rotation: randomInRange(0, 360),
|
621
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
566
|
+
color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
|
622
567
|
});
|
623
568
|
}
|
624
569
|
return particles;
|
@@ -681,80 +626,6 @@ const renderPaintParticle = (particle) => {
|
|
681
626
|
} }))));
|
682
627
|
};
|
683
628
|
|
684
|
-
const musicColors = ['#FF006E', '#8338EC', '#3A86FF', '#FB5607', '#FFBE0B'];
|
685
|
-
const createMusicParticles = (origin, config) => {
|
686
|
-
const { particleCount = 20, spread = 100, startVelocity = 8, colors = musicColors, elementSize = 25 } = config;
|
687
|
-
const particles = [];
|
688
|
-
const notes = ['♪', '♫', '♬', '♩', '♭', '♯'];
|
689
|
-
for (let i = 0; i < particleCount; i++) {
|
690
|
-
const angle = randomInRange(-spread / 2, spread / 2) * (Math.PI / 180);
|
691
|
-
const velocity = randomInRange(startVelocity * 0.5, startVelocity);
|
692
|
-
particles.push({
|
693
|
-
id: generateId(),
|
694
|
-
x: origin.x + randomInRange(-20, 20),
|
695
|
-
y: origin.y,
|
696
|
-
vx: Math.sin(angle) * velocity * 0.3,
|
697
|
-
vy: -Math.abs(Math.cos(angle)) * velocity * 0.5, // Always go up slowly
|
698
|
-
life: config.lifetime || 200,
|
699
|
-
opacity: 1,
|
700
|
-
size: randomInRange(elementSize * 0.8, elementSize * 1.2),
|
701
|
-
rotation: i % notes.length, // Store which note to use
|
702
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
703
|
-
});
|
704
|
-
}
|
705
|
-
return particles;
|
706
|
-
};
|
707
|
-
const renderMusicParticle = (particle) => {
|
708
|
-
const notes = ['♪', '♫', '♬', '♩', '♭', '♯'];
|
709
|
-
const note = notes[Math.floor(particle.rotation)];
|
710
|
-
// Wave motion as notes float up
|
711
|
-
const waveX = Math.sin(particle.life * 0.05) * 20;
|
712
|
-
const wobble = Math.sin(particle.life * 0.1) * 10;
|
713
|
-
// Fade in/out
|
714
|
-
const maxLife = 300; // Use longer lifetime for proper fading
|
715
|
-
const fadeIn = particle.life > (maxLife - 20) ? (maxLife - particle.life) / 20 : 1;
|
716
|
-
const fadeOut = particle.life < 50 ? particle.life / 50 : 1;
|
717
|
-
const opacity = Math.min(fadeIn, fadeOut) * particle.opacity;
|
718
|
-
return (React.createElement("div", { key: particle.id, style: {
|
719
|
-
fontSize: `${particle.size}px`,
|
720
|
-
fontWeight: 'bold',
|
721
|
-
position: 'relative',
|
722
|
-
transform: `
|
723
|
-
translateX(${waveX}px)
|
724
|
-
rotate(${wobble}deg)
|
725
|
-
scale(${0.8 + opacity * 0.2})
|
726
|
-
`,
|
727
|
-
color: particle.color,
|
728
|
-
opacity,
|
729
|
-
textShadow: `
|
730
|
-
0 0 10px ${particle.color}88,
|
731
|
-
0 0 20px ${particle.color}44,
|
732
|
-
2px 2px 3px rgba(0,0,0,0.3)
|
733
|
-
`,
|
734
|
-
transition: 'transform 0.3s ease',
|
735
|
-
userSelect: 'none',
|
736
|
-
} },
|
737
|
-
note,
|
738
|
-
React.createElement("div", { style: {
|
739
|
-
position: 'absolute',
|
740
|
-
top: '40%',
|
741
|
-
left: '-20%',
|
742
|
-
width: '140%',
|
743
|
-
height: '1px',
|
744
|
-
background: `linear-gradient(90deg, transparent, ${particle.color}33, transparent)`,
|
745
|
-
opacity: opacity * 0.5,
|
746
|
-
} }),
|
747
|
-
React.createElement("div", { style: {
|
748
|
-
position: 'absolute',
|
749
|
-
top: '60%',
|
750
|
-
left: '-20%',
|
751
|
-
width: '140%',
|
752
|
-
height: '1px',
|
753
|
-
background: `linear-gradient(90deg, transparent, ${particle.color}33, transparent)`,
|
754
|
-
opacity: opacity * 0.3,
|
755
|
-
} })));
|
756
|
-
};
|
757
|
-
|
758
629
|
const balloonColors = ['#FF006E', '#FB5607', '#FFBE0B', '#8338EC', '#3A86FF', '#06FFB4', '#FF4081'];
|
759
630
|
const createBalloonParticles = (origin, config) => {
|
760
631
|
const { particleCount = 15, spread = 80, startVelocity = 10, colors = balloonColors, elementSize = 35 } = config;
|
@@ -764,15 +635,15 @@ const createBalloonParticles = (origin, config) => {
|
|
764
635
|
const velocity = randomInRange(startVelocity * 0.7, startVelocity);
|
765
636
|
particles.push({
|
766
637
|
id: generateId(),
|
767
|
-
x: origin.x + randomInRange(-
|
768
|
-
y: origin.y + randomInRange(
|
769
|
-
vx: Math.sin(angle) * velocity * 0.
|
638
|
+
x: origin.x + randomInRange(-spread * 0.8, spread * 0.8), // Spread balloons out more
|
639
|
+
y: origin.y + randomInRange(-10, 30),
|
640
|
+
vx: Math.sin(angle) * velocity * 0.3 + randomInRange(-1, 1), // Add horizontal drift
|
770
641
|
vy: -velocity * 0.4, // Balloons float up slowly
|
771
642
|
life: config.lifetime || 250,
|
772
643
|
opacity: 0.9,
|
773
644
|
size: randomInRange(elementSize * 0.8, elementSize * 1.2),
|
774
645
|
rotation: randomInRange(-10, 10),
|
775
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
646
|
+
color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
|
776
647
|
});
|
777
648
|
}
|
778
649
|
return particles;
|
@@ -868,7 +739,7 @@ const createGalaxyParticles = (origin, config) => {
|
|
868
739
|
opacity: 0,
|
869
740
|
size: randomInRange(elementSize * 0.3, elementSize) * (1 - progress * 0.5), // Smaller at edges
|
870
741
|
rotation: randomInRange(0, 360),
|
871
|
-
color: colors[Math.floor(Math.random() * colors.length)] || colors[0],
|
742
|
+
color: colors[Math.floor(Math.random() * colors.length)] || colors[0] || '#ffffff',
|
872
743
|
});
|
873
744
|
}
|
874
745
|
return particles;
|
@@ -936,6 +807,272 @@ const renderGalaxyParticle = (particle) => {
|
|
936
807
|
} }))));
|
937
808
|
};
|
938
809
|
|
810
|
+
const createGlitchParticles = (origin, config) => {
|
811
|
+
const { particleCount = 20, elementSize = 200 } = config;
|
812
|
+
const particles = [];
|
813
|
+
const channels = ['r', 'g', 'b'];
|
814
|
+
for (let i = 0; i < particleCount; i++) {
|
815
|
+
const isHorizontal = Math.random() > 0.3;
|
816
|
+
const channelIndex = i % 3;
|
817
|
+
const channel = channels[channelIndex];
|
818
|
+
// Encode all data in rotation:
|
819
|
+
// bits 0-1: channel (0=r, 1=g, 2=b)
|
820
|
+
// bit 2: isHorizontal (0=false, 1=true)
|
821
|
+
// bits 3-10: width (0-255)
|
822
|
+
// bits 11-18: height (0-255)
|
823
|
+
// bits 19-24: glitchOffset + 32 (to make positive)
|
824
|
+
const width = isHorizontal ? randomInRange(50, 200) : randomInRange(2, 8);
|
825
|
+
const height = isHorizontal ? randomInRange(2, 8) : randomInRange(50, 200);
|
826
|
+
const glitchOffset = randomInRange(-20, 20);
|
827
|
+
const encodedData = channelIndex +
|
828
|
+
(isHorizontal ? 4 : 0) +
|
829
|
+
(Math.floor(width) << 3) +
|
830
|
+
(Math.floor(height) << 11) +
|
831
|
+
((glitchOffset + 32) << 19);
|
832
|
+
particles.push({
|
833
|
+
id: generateId(),
|
834
|
+
x: origin.x + randomInRange(-elementSize / 2, elementSize / 2),
|
835
|
+
y: origin.y + randomInRange(-elementSize / 2, elementSize / 2),
|
836
|
+
vx: randomInRange(-50, 50),
|
837
|
+
vy: randomInRange(-30, 30),
|
838
|
+
life: config.lifetime || 150,
|
839
|
+
opacity: randomInRange(0.3, 1),
|
840
|
+
size: randomInRange(5, 20), // Store distortionAmount
|
841
|
+
rotation: encodedData,
|
842
|
+
color: channel === 'r' ? '#ff0000' : channel === 'g' ? '#00ff00' : '#0000ff',
|
843
|
+
});
|
844
|
+
}
|
845
|
+
return particles;
|
846
|
+
};
|
847
|
+
const renderGlitchParticle = (particle) => {
|
848
|
+
// Decode data from rotation
|
849
|
+
const channelIndex = particle.rotation & 3;
|
850
|
+
const width = (particle.rotation >> 3) & 255;
|
851
|
+
const height = (particle.rotation >> 11) & 255;
|
852
|
+
const glitchOffset = ((particle.rotation >> 19) & 63) - 32;
|
853
|
+
const channel = ['r', 'g', 'b'][channelIndex];
|
854
|
+
const distortionAmount = particle.size;
|
855
|
+
const colors = {
|
856
|
+
r: channel === 'r' ? 255 : 0,
|
857
|
+
g: channel === 'g' ? 255 : 0,
|
858
|
+
b: channel === 'b' ? 255 : 0,
|
859
|
+
};
|
860
|
+
const mixBlendMode = channel === 'r' ? 'screen' :
|
861
|
+
channel === 'g' ? 'multiply' : 'difference';
|
862
|
+
return (React.createElement("div", { key: particle.id, style: {
|
863
|
+
width: `${width}px`,
|
864
|
+
height: `${height}px`,
|
865
|
+
backgroundColor: `rgba(${colors.r}, ${colors.g}, ${colors.b}, ${particle.opacity})`,
|
866
|
+
mixBlendMode,
|
867
|
+
filter: `blur(${randomInRange(0, 2)}px)`,
|
868
|
+
boxShadow: `${glitchOffset}px 0 ${distortionAmount}px rgba(${colors.r}, ${colors.g}, ${colors.b}, ${particle.opacity * 0.5})`,
|
869
|
+
} }));
|
870
|
+
};
|
871
|
+
|
872
|
+
const defaultColors$2 = ['#9C27B0', '#E91E63', '#FF00FF', '#00FFFF', '#FFD700', '#FF69B4', '#DA70D6', '#9370DB'];
|
873
|
+
const createMagicDustParticles = (origin, config) => {
|
874
|
+
const { particleCount = 40, startVelocity = 8, colors = defaultColors$2, elementSize = 12 } = config;
|
875
|
+
const particles = [];
|
876
|
+
for (let i = 0; i < particleCount; i++) {
|
877
|
+
// Create particles in a circular pattern with some randomness
|
878
|
+
const angle = (i / particleCount) * 360 + randomInRange(-30, 30);
|
879
|
+
const velocity = randomInRange(startVelocity * 0.3, startVelocity);
|
880
|
+
const color = getRandomColor(colors);
|
881
|
+
// Add some particles that trail behind cursor movement
|
882
|
+
const offsetAngle = randomInRange(0, 360);
|
883
|
+
const offsetDistance = randomInRange(0, 30);
|
884
|
+
particles.push({
|
885
|
+
id: generateId(),
|
886
|
+
x: origin.x + Math.cos(degreesToRadians(offsetAngle)) * offsetDistance,
|
887
|
+
y: origin.y + Math.sin(degreesToRadians(offsetAngle)) * offsetDistance,
|
888
|
+
vx: Math.cos(degreesToRadians(angle)) * velocity + randomInRange(-2, 2),
|
889
|
+
vy: Math.sin(degreesToRadians(angle)) * velocity + randomInRange(-2, 2),
|
890
|
+
life: config.lifetime || 120,
|
891
|
+
opacity: randomInRange(0.4, 1),
|
892
|
+
size: randomInRange(elementSize * 0.3, elementSize),
|
893
|
+
rotation: randomInRange(0, 360),
|
894
|
+
color,
|
895
|
+
});
|
896
|
+
}
|
897
|
+
return particles;
|
898
|
+
};
|
899
|
+
const renderMagicDustParticle = (particle) => {
|
900
|
+
const sparkleSize = particle.size * 0.7;
|
901
|
+
return (React.createElement("div", { key: particle.id, style: {
|
902
|
+
width: `${particle.size}px`,
|
903
|
+
height: `${particle.size}px`,
|
904
|
+
position: 'relative',
|
905
|
+
} },
|
906
|
+
React.createElement("div", { style: {
|
907
|
+
position: 'absolute',
|
908
|
+
width: '100%',
|
909
|
+
height: '100%',
|
910
|
+
backgroundColor: particle.color,
|
911
|
+
borderRadius: '50%',
|
912
|
+
boxShadow: `0 0 ${particle.size}px ${particle.color}, 0 0 ${particle.size * 2}px ${particle.color}`,
|
913
|
+
filter: 'blur(1px)',
|
914
|
+
} }),
|
915
|
+
React.createElement("div", { style: {
|
916
|
+
position: 'absolute',
|
917
|
+
top: '50%',
|
918
|
+
left: '50%',
|
919
|
+
width: `${sparkleSize}px`,
|
920
|
+
height: `${sparkleSize}px`,
|
921
|
+
transform: `translate(-50%, -50%) rotate(${particle.rotation}deg)`,
|
922
|
+
} },
|
923
|
+
React.createElement("div", { style: {
|
924
|
+
position: 'absolute',
|
925
|
+
width: '100%',
|
926
|
+
height: '2px',
|
927
|
+
backgroundColor: 'white',
|
928
|
+
top: '50%',
|
929
|
+
left: '0',
|
930
|
+
transform: 'translateY(-50%)',
|
931
|
+
boxShadow: '0 0 4px white',
|
932
|
+
} }),
|
933
|
+
React.createElement("div", { style: {
|
934
|
+
position: 'absolute',
|
935
|
+
width: '2px',
|
936
|
+
height: '100%',
|
937
|
+
backgroundColor: 'white',
|
938
|
+
left: '50%',
|
939
|
+
top: '0',
|
940
|
+
transform: 'translateX(-50%)',
|
941
|
+
boxShadow: '0 0 4px white',
|
942
|
+
} }))));
|
943
|
+
};
|
944
|
+
|
945
|
+
const defaultColors$1 = ['#FF1493', '#00CED1', '#FFD700', '#FF69B4', '#7B68EE', '#00FA9A', '#FF6347', '#4169E1'];
|
946
|
+
const createCrystalParticles = (origin, config) => {
|
947
|
+
const { particleCount = 15, startVelocity = 15, colors = defaultColors$1, elementSize = 25 } = config;
|
948
|
+
const particles = [];
|
949
|
+
for (let i = 0; i < particleCount; i++) {
|
950
|
+
// Crystals explode outward and fall with gravity
|
951
|
+
const angle = randomInRange(0, 360);
|
952
|
+
const velocity = randomInRange(startVelocity * 0.5, startVelocity);
|
953
|
+
const color = getRandomColor(colors);
|
954
|
+
particles.push({
|
955
|
+
id: generateId(),
|
956
|
+
x: origin.x,
|
957
|
+
y: origin.y,
|
958
|
+
vx: Math.cos(degreesToRadians(angle)) * velocity,
|
959
|
+
vy: Math.sin(degreesToRadians(angle)) * velocity - 10,
|
960
|
+
life: config.lifetime || 150,
|
961
|
+
opacity: randomInRange(0.7, 1),
|
962
|
+
size: randomInRange(elementSize * 0.6, elementSize),
|
963
|
+
rotation: randomInRange(0, 360),
|
964
|
+
color,
|
965
|
+
});
|
966
|
+
}
|
967
|
+
return particles;
|
968
|
+
};
|
969
|
+
const renderCrystalParticle = (particle) => {
|
970
|
+
// Create rainbow refraction effect
|
971
|
+
const hue = (Date.now() * 0.5 + particle.x + particle.y) % 360;
|
972
|
+
return (React.createElement("div", { key: particle.id, style: {
|
973
|
+
width: `${particle.size}px`,
|
974
|
+
height: `${particle.size * 1.5}px`,
|
975
|
+
position: 'relative',
|
976
|
+
transform: `rotate(${particle.rotation}deg)`,
|
977
|
+
} },
|
978
|
+
React.createElement("div", { style: {
|
979
|
+
position: 'absolute',
|
980
|
+
width: '100%',
|
981
|
+
height: '100%',
|
982
|
+
background: `linear-gradient(135deg, ${particle.color}, ${particle.color}88, transparent)`,
|
983
|
+
clipPath: 'polygon(50% 0%, 100% 40%, 75% 100%, 25% 100%, 0% 40%)',
|
984
|
+
boxShadow: `0 0 ${particle.size}px ${particle.color}44`,
|
985
|
+
} }),
|
986
|
+
React.createElement("div", { style: {
|
987
|
+
position: 'absolute',
|
988
|
+
width: '80%',
|
989
|
+
height: '80%',
|
990
|
+
top: '10%',
|
991
|
+
left: '10%',
|
992
|
+
background: `linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.4), transparent)`,
|
993
|
+
clipPath: 'polygon(50% 10%, 90% 45%, 65% 90%, 35% 90%, 10% 45%)',
|
994
|
+
} }),
|
995
|
+
React.createElement("div", { style: {
|
996
|
+
position: 'absolute',
|
997
|
+
width: '100%',
|
998
|
+
height: '100%',
|
999
|
+
background: `linear-gradient(${hue}deg,
|
1000
|
+
hsla(${hue}, 100%, 50%, 0.3),
|
1001
|
+
hsla(${(hue + 60) % 360}, 100%, 50%, 0.3),
|
1002
|
+
hsla(${(hue + 120) % 360}, 100%, 50%, 0.3)
|
1003
|
+
)`,
|
1004
|
+
clipPath: 'polygon(50% 0%, 100% 40%, 75% 100%, 25% 100%, 0% 40%)',
|
1005
|
+
mixBlendMode: 'screen',
|
1006
|
+
} }),
|
1007
|
+
React.createElement("div", { style: {
|
1008
|
+
position: 'absolute',
|
1009
|
+
width: '30%',
|
1010
|
+
height: '30%',
|
1011
|
+
top: '20%',
|
1012
|
+
left: '35%',
|
1013
|
+
background: 'radial-gradient(circle, rgba(255, 255, 255, 0.8), transparent)',
|
1014
|
+
borderRadius: '50%',
|
1015
|
+
filter: 'blur(2px)',
|
1016
|
+
} })));
|
1017
|
+
};
|
1018
|
+
|
1019
|
+
const defaultColors = ['#D2691E', '#CD853F', '#8B4513', '#A0522D', '#FF8C00', '#FF6347'];
|
1020
|
+
const createLeafParticles = (origin, config) => {
|
1021
|
+
const { particleCount = 10, colors = defaultColors, elementSize = 25 } = config;
|
1022
|
+
const particles = [];
|
1023
|
+
for (let i = 0; i < particleCount; i++) {
|
1024
|
+
particles.push({
|
1025
|
+
id: generateId(),
|
1026
|
+
x: origin.x + randomInRange(-100, 100),
|
1027
|
+
y: origin.y + randomInRange(-50, 0),
|
1028
|
+
vx: randomInRange(-1, 1),
|
1029
|
+
vy: randomInRange(0.5, 2),
|
1030
|
+
life: config.lifetime || 300,
|
1031
|
+
opacity: 1,
|
1032
|
+
size: randomInRange(elementSize * 0.6, elementSize),
|
1033
|
+
// Encode tumble phase (0-360), sway phase (0-360), and sway amount (20-40) + rotation speed (-3 to 3)
|
1034
|
+
rotation: Math.floor(randomInRange(0, 360)) +
|
1035
|
+
(Math.floor(randomInRange(0, 360)) * 1000) +
|
1036
|
+
(Math.floor(randomInRange(20, 40)) * 1000000) +
|
1037
|
+
((Math.floor(randomInRange(-3, 3)) + 3) * 100000000),
|
1038
|
+
color: getRandomColor(colors),
|
1039
|
+
});
|
1040
|
+
}
|
1041
|
+
return particles;
|
1042
|
+
};
|
1043
|
+
const renderLeafParticle = (particle) => {
|
1044
|
+
// Extract encoded values
|
1045
|
+
const tumblePhase = particle.rotation % 1000;
|
1046
|
+
const swayPhase = Math.floor((particle.rotation % 1000000) / 1000);
|
1047
|
+
const swayAmount = Math.floor((particle.rotation % 100000000) / 1000000);
|
1048
|
+
const rotationSpeed = (Math.floor(particle.rotation / 100000000) - 3);
|
1049
|
+
// Calculate tumbling and swaying
|
1050
|
+
const tumble = Math.sin((Date.now() * 0.002 + tumblePhase) * Math.PI / 180) * 30;
|
1051
|
+
const swayX = Math.sin((Date.now() * 0.001 + swayPhase) * Math.PI / 180) * swayAmount;
|
1052
|
+
const rotation = (Date.now() * rotationSpeed * 0.01 + tumble) % 360;
|
1053
|
+
return (React.createElement("div", { key: particle.id, style: {
|
1054
|
+
width: `${particle.size}px`,
|
1055
|
+
height: `${particle.size}px`,
|
1056
|
+
position: 'relative',
|
1057
|
+
transform: `translateX(${swayX}px) rotate(${rotation}deg)`,
|
1058
|
+
} },
|
1059
|
+
React.createElement("svg", { width: particle.size, height: particle.size, viewBox: `-${particle.size / 2} -${particle.size / 2} ${particle.size} ${particle.size}`, style: {
|
1060
|
+
position: 'absolute',
|
1061
|
+
top: 0,
|
1062
|
+
left: 0,
|
1063
|
+
} },
|
1064
|
+
React.createElement("path", { d: `
|
1065
|
+
M 0,-${particle.size / 2}
|
1066
|
+
C -${particle.size / 3},-${particle.size / 3} -${particle.size / 3},${particle.size / 3} 0,${particle.size / 2}
|
1067
|
+
C ${particle.size / 3},${particle.size / 3} ${particle.size / 3},-${particle.size / 3} 0,-${particle.size / 2}
|
1068
|
+
`, fill: particle.color, opacity: "0.9" }),
|
1069
|
+
React.createElement("line", { x1: "0", y1: -particle.size / 2, x2: "0", y2: particle.size / 2, stroke: "#8B4513", strokeWidth: "1", opacity: "0.5" }),
|
1070
|
+
React.createElement("line", { x1: "0", y1: -particle.size / 4, x2: -particle.size / 4, y2: -particle.size / 8, stroke: "#8B4513", strokeWidth: "0.5", opacity: "0.5" }),
|
1071
|
+
React.createElement("line", { x1: "0", y1: -particle.size / 4, x2: particle.size / 4, y2: -particle.size / 8, stroke: "#8B4513", strokeWidth: "0.5", opacity: "0.5" }),
|
1072
|
+
React.createElement("line", { x1: "0", y1: particle.size / 4, x2: -particle.size / 4, y2: particle.size / 8, stroke: "#8B4513", strokeWidth: "0.5", opacity: "0.5" }),
|
1073
|
+
React.createElement("line", { x1: "0", y1: particle.size / 4, x2: particle.size / 4, y2: particle.size / 8, stroke: "#8B4513", strokeWidth: "0.5", opacity: "0.5" }))));
|
1074
|
+
};
|
1075
|
+
|
939
1076
|
const animations = {
|
940
1077
|
confetti: {
|
941
1078
|
createParticles: createConfettiParticles,
|
@@ -973,10 +1110,6 @@ const animations = {
|
|
973
1110
|
createParticles: createCoinParticles,
|
974
1111
|
renderParticle: renderCoinParticle,
|
975
1112
|
},
|
976
|
-
lightning: {
|
977
|
-
createParticles: createLightningParticles,
|
978
|
-
renderParticle: renderLightningParticle,
|
979
|
-
},
|
980
1113
|
petals: {
|
981
1114
|
createParticles: createPetalParticles,
|
982
1115
|
renderParticle: renderPetalParticle,
|
@@ -993,10 +1126,6 @@ const animations = {
|
|
993
1126
|
createParticles: createPaintParticles,
|
994
1127
|
renderParticle: renderPaintParticle,
|
995
1128
|
},
|
996
|
-
music: {
|
997
|
-
createParticles: createMusicParticles,
|
998
|
-
renderParticle: renderMusicParticle,
|
999
|
-
},
|
1000
1129
|
balloons: {
|
1001
1130
|
createParticles: createBalloonParticles,
|
1002
1131
|
renderParticle: renderBalloonParticle,
|
@@ -1005,6 +1134,22 @@ const animations = {
|
|
1005
1134
|
createParticles: createGalaxyParticles,
|
1006
1135
|
renderParticle: renderGalaxyParticle,
|
1007
1136
|
},
|
1137
|
+
glitch: {
|
1138
|
+
createParticles: createGlitchParticles,
|
1139
|
+
renderParticle: renderGlitchParticle,
|
1140
|
+
},
|
1141
|
+
magicdust: {
|
1142
|
+
createParticles: createMagicDustParticles,
|
1143
|
+
renderParticle: renderMagicDustParticle,
|
1144
|
+
},
|
1145
|
+
crystals: {
|
1146
|
+
createParticles: createCrystalParticles,
|
1147
|
+
renderParticle: renderCrystalParticle,
|
1148
|
+
},
|
1149
|
+
leaves: {
|
1150
|
+
createParticles: createLeafParticles,
|
1151
|
+
renderParticle: renderLeafParticle,
|
1152
|
+
},
|
1008
1153
|
};
|
1009
1154
|
|
1010
1155
|
const useReward = (elementId, animationType, config) => {
|