@sarthak03dot/romantic-animations 1.2.10 → 1.2.11

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
@@ -1,4 +1,4 @@
1
- # 💖 Romantic Animations v1.2.10
1
+ # 💖 Romantic Animations v1.2.11
2
2
 
3
3
  <p align="center">
4
4
  <b>A premium, lightweight, zero-dependency JavaScript canvas particle library for gorgeous romantic & celebratory effects.</b>
@@ -0,0 +1,102 @@
1
+ export interface AnimationOptions {
2
+ count?: number;
3
+ density?: number;
4
+ minSize?: number;
5
+ maxSize?: number;
6
+ minSpeed?: number;
7
+ maxSpeed?: number;
8
+ speed?: number;
9
+ colors?: string[];
10
+ glow?: boolean;
11
+ wobble?: boolean;
12
+ interval?: number;
13
+ particleCount?: number;
14
+ starCount?: number;
15
+ twinkle?: boolean;
16
+ connectDist?: number;
17
+ decay?: number;
18
+ symbols?: string[];
19
+ shapes?: string[];
20
+ }
21
+
22
+ export declare function startFloatingHearts(
23
+ containerId: string | HTMLElement,
24
+ options?: AnimationOptions
25
+ ): number;
26
+
27
+ export declare function startHeartTrail(
28
+ containerId: string | HTMLElement,
29
+ options?: AnimationOptions
30
+ ): number;
31
+
32
+ export declare function startHeartBurst(
33
+ containerId: string | HTMLElement,
34
+ options?: AnimationOptions
35
+ ): number;
36
+
37
+ export declare function startSparkles(
38
+ containerId: string | HTMLElement,
39
+ options?: AnimationOptions
40
+ ): number;
41
+
42
+ export declare function startLoveRain(
43
+ containerId: string | HTMLElement,
44
+ options?: AnimationOptions
45
+ ): number;
46
+
47
+ export declare function startConfetti(
48
+ containerId: string | HTMLElement,
49
+ options?: AnimationOptions
50
+ ): number;
51
+
52
+ export declare function startFireworks(
53
+ containerId: string | HTMLElement,
54
+ options?: AnimationOptions
55
+ ): number;
56
+
57
+ export declare function startStarField(
58
+ containerId: string | HTMLElement,
59
+ options?: AnimationOptions
60
+ ): number;
61
+
62
+ export declare function startButterflies(
63
+ containerId: string | HTMLElement,
64
+ options?: AnimationOptions
65
+ ): number;
66
+
67
+ export declare function startMagicDust(
68
+ containerId: string | HTMLElement,
69
+ options?: AnimationOptions
70
+ ): number;
71
+
72
+ export declare function startFloatingOrbs(
73
+ containerId: string | HTMLElement,
74
+ options?: AnimationOptions
75
+ ): number;
76
+
77
+ export declare function startShootingStars(
78
+ containerId: string | HTMLElement,
79
+ options?: AnimationOptions
80
+ ): number;
81
+
82
+ export declare function stopAnimation(id: number): void;
83
+ export declare function stopAll(): void;
84
+
85
+ declare const RomanticAnimations: {
86
+ startFloatingHearts: typeof startFloatingHearts;
87
+ startHeartTrail: typeof startHeartTrail;
88
+ startHeartBurst: typeof startHeartBurst;
89
+ startSparkles: typeof startSparkles;
90
+ startLoveRain: typeof startLoveRain;
91
+ startConfetti: typeof startConfetti;
92
+ startFireworks: typeof startFireworks;
93
+ startStarField: typeof startStarField;
94
+ startButterflies: typeof startButterflies;
95
+ startMagicDust: typeof startMagicDust;
96
+ startFloatingOrbs: typeof startFloatingOrbs;
97
+ startShootingStars: typeof startShootingStars;
98
+ stopAnimation: typeof stopAnimation;
99
+ stopAll: typeof stopAll;
100
+ };
101
+
102
+ export default RomanticAnimations;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarthak03dot/romantic-animations",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "description": "Romantic & celebratory canvas animations — hearts, sparkles, fireworks, confetti, star fields and more. Zero dependencies.",
5
5
  "homepage": "https://github.com/sarthak03dot/romantic-animations#readme",
6
6
  "bugs": {
@@ -39,13 +39,12 @@
39
39
  },
40
40
  "files": [
41
41
  "dist",
42
- "src",
43
42
  "README.md"
44
43
  ],
45
44
  "sideEffects": false,
46
45
  "scripts": {
47
46
  "dev": "vite",
48
- "build": "vite build",
47
+ "build": "vite build && cpy src/index.d.ts dist",
49
48
  "build:demo": "vite build --config vite.demo.config.js",
50
49
  "preview": "vite preview",
51
50
  "prepublishOnly": "npm run build",
@@ -53,8 +52,8 @@
53
52
  "deploy": "gh-pages -d demo-dist"
54
53
  },
55
54
  "devDependencies": {
55
+ "cpy-cli": "^7.0.0",
56
56
  "gh-pages": "^6.3.0",
57
- "vite": "^7.0.2",
58
- "vite-plugin-dts": "^5.0.1"
57
+ "vite": "^7.0.2"
59
58
  }
60
59
  }
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export {}
@@ -1,92 +0,0 @@
1
- import { mergeOptions } from '../core/engine.js';
2
-
3
- const DEFAULTS = {
4
- density: 0.05, // Spawn probability per frame
5
- colors: ['#c77dff', '#ff85a1', '#ffc2d1', '#48cae4', '#e7c6ff', '#fbb1bd'],
6
- minSize: 10,
7
- maxSize: 22,
8
- minSpeed: 0.8,
9
- maxSpeed: 2.2,
10
- glow: true,
11
- };
12
-
13
- export function butterflies(canvas, userOptions = {}) {
14
- const opts = mergeOptions(DEFAULTS, userOptions);
15
- const ctx = canvas.getContext('2d');
16
- const items = [];
17
- let running = true;
18
- let time = 0;
19
-
20
- function spawn() {
21
- const size = opts.minSize + Math.random() * (opts.maxSize - opts.minSize);
22
- return {
23
- x: -size * 2,
24
- y: canvas.height * 0.1 + Math.random() * (canvas.height * 0.8),
25
- size,
26
- speed: opts.minSpeed + Math.random() * (opts.maxSpeed - opts.minSpeed),
27
- color: opts.colors[Math.floor(Math.random() * opts.colors.length)],
28
- alpha: 0,
29
- flapSpeed: 0.1 + Math.random() * 0.15,
30
- flapOffset: Math.random() * Math.PI * 2,
31
- wobbleSpeed: 0.01 + Math.random() * 0.02,
32
- wobbleOffset: Math.random() * Math.PI * 2,
33
- };
34
- }
35
-
36
- function animate() {
37
- if (!running) return;
38
- time++;
39
- ctx.clearRect(0, 0, canvas.width, canvas.height);
40
-
41
- if (Math.random() < opts.density) items.push(spawn());
42
-
43
- for (let i = items.length - 1; i >= 0; i--) {
44
- const b = items[i];
45
- b.x += b.speed;
46
- b.y += Math.sin(time * b.wobbleSpeed + b.wobbleOffset) * 1.5;
47
-
48
- // Fade in smoothly
49
- if (b.alpha < 1 && b.x < canvas.width / 2) b.alpha += 0.02;
50
-
51
- // Flapping wing calculation
52
- const wingSpread = Math.abs(Math.sin(time * b.flapSpeed + b.flapOffset));
53
-
54
- ctx.save();
55
- ctx.globalAlpha = Math.min(1, b.alpha);
56
- ctx.translate(b.x, b.y);
57
- // Slight tilt upwards
58
- ctx.rotate(-0.1 - (wingSpread * 0.1));
59
-
60
- if (opts.glow) {
61
- ctx.shadowColor = b.color;
62
- ctx.shadowBlur = b.size * 1.5;
63
- }
64
- ctx.fillStyle = b.color;
65
-
66
- // Draw wings
67
- ctx.beginPath();
68
- // Left/back wing (narrower based on wingSpread)
69
- ctx.ellipse(-b.size * 0.2, 0, b.size * 0.4 * wingSpread, b.size * 0.5, 0.3, 0, Math.PI * 2);
70
- ctx.fill();
71
-
72
- ctx.beginPath();
73
- // Right/front wing
74
- ctx.ellipse(b.size * 0.3 * wingSpread, -b.size * 0.1, b.size * 0.5 * wingSpread, b.size * 0.6, -0.2, 0, Math.PI * 2);
75
- ctx.fill();
76
- ctx.restore();
77
-
78
- if (b.x > canvas.width + b.size * 2) {
79
- items.splice(i, 1);
80
- }
81
- }
82
-
83
- requestAnimationFrame(animate);
84
- }
85
-
86
- animate();
87
-
88
- return function stop() {
89
- running = false;
90
- ctx.clearRect(0, 0, canvas.width, canvas.height);
91
- };
92
- }
@@ -1,92 +0,0 @@
1
- import { mergeOptions } from '../core/engine.js';
2
-
3
- const DEFAULTS = {
4
- density: 0.18,
5
- colors: ['#ff6b8a','#ff4d6d','#ffd6ff','#e7c6ff','#c77dff','#48cae4','#ffe66d','#06d6a0'],
6
- minSize: 6,
7
- maxSize: 14,
8
- minSpeed: 1.5,
9
- maxSpeed: 4,
10
- gravity: 0.06,
11
- drag: 0.99,
12
- shapes: ['rect', 'circle', 'ribbon'],
13
- };
14
-
15
- export function confetti(canvas, userOptions = {}) {
16
- const opts = mergeOptions(DEFAULTS, userOptions);
17
- const ctx = canvas.getContext('2d');
18
- const pieces = [];
19
- let running = true;
20
-
21
- function createPiece() {
22
- const size = opts.minSize + Math.random() * (opts.maxSize - opts.minSize);
23
- const speed = opts.minSpeed + Math.random() * (opts.maxSpeed - opts.minSpeed);
24
- return {
25
- x: Math.random() * canvas.width,
26
- y: -size * 2,
27
- w: size,
28
- h: size * (0.4 + Math.random() * 0.8),
29
- vx: (Math.random() - 0.5) * 3,
30
- vy: speed,
31
- angle: Math.random() * Math.PI * 2,
32
- spin: (Math.random() - 0.5) * 0.15,
33
- color: opts.colors[Math.floor(Math.random() * opts.colors.length)],
34
- alpha: 0.8 + Math.random() * 0.2,
35
- shape: opts.shapes[Math.floor(Math.random() * opts.shapes.length)],
36
- };
37
- }
38
-
39
- function drawPiece(p) {
40
- ctx.save();
41
- ctx.globalAlpha = p.alpha;
42
- ctx.fillStyle = p.color;
43
- ctx.strokeStyle = p.color;
44
- ctx.translate(p.x, p.y);
45
- ctx.rotate(p.angle);
46
-
47
- if (p.shape === 'circle') {
48
- ctx.beginPath();
49
- ctx.ellipse(0, 0, p.w / 2, p.h / 2, 0, 0, Math.PI * 2);
50
- ctx.fill();
51
- } else if (p.shape === 'ribbon') {
52
- ctx.beginPath();
53
- ctx.moveTo(-p.w / 2, 0);
54
- ctx.quadraticCurveTo(0, -p.h, p.w / 2, 0);
55
- ctx.quadraticCurveTo(0, p.h, -p.w / 2, 0);
56
- ctx.fill();
57
- } else {
58
- ctx.fillRect(-p.w / 2, -p.h / 2, p.w, p.h);
59
- }
60
- ctx.restore();
61
- }
62
-
63
- function animate() {
64
- if (!running) return;
65
- ctx.clearRect(0, 0, canvas.width, canvas.height);
66
-
67
- if (Math.random() < opts.density) pieces.push(createPiece());
68
-
69
- for (let i = pieces.length - 1; i >= 0; i--) {
70
- const p = pieces[i];
71
- p.vy += opts.gravity;
72
- p.vx *= opts.drag;
73
- p.vy *= opts.drag;
74
- p.x += p.vx;
75
- p.y += p.vy;
76
- p.angle += p.spin;
77
-
78
- drawPiece(p);
79
-
80
- if (p.y > canvas.height + 20) pieces.splice(i, 1);
81
- }
82
-
83
- requestAnimationFrame(animate);
84
- }
85
-
86
- animate();
87
-
88
- return function stop() {
89
- running = false;
90
- ctx.clearRect(0, 0, canvas.width, canvas.height);
91
- };
92
- }
@@ -1,112 +0,0 @@
1
- import { mergeOptions } from '../core/engine.js';
2
-
3
- const DEFAULTS = {
4
- interval: 1200, // ms between auto-launches
5
- trailLength: 28,
6
- particleCount: 80,
7
- colors: ['#ff6b8a','#ff4d6d','#ffd6ff','#e7c6ff','#ffe66d','#06d6a0','#48cae4','#ffffff'],
8
- gravity: 0.09,
9
- decay: 0.014,
10
- glow: true,
11
- };
12
-
13
- export function fireworks(canvas, userOptions = {}) {
14
- const opts = mergeOptions(DEFAULTS, userOptions);
15
- const ctx = canvas.getContext('2d');
16
- let running = true;
17
-
18
- const rockets = []; // { x, y, vx, vy, trail[], color }
19
- const particles = []; // burst particles
20
-
21
- function launchRocket() {
22
- const x = canvas.width * (0.2 + Math.random() * 0.6);
23
- const targetY = canvas.height * (0.1 + Math.random() * 0.4);
24
- const dy = targetY - canvas.height;
25
- const speed = 8 + Math.random() * 5;
26
- const color = opts.colors[Math.floor(Math.random() * opts.colors.length)];
27
- rockets.push({ x, y: canvas.height, vy: -Math.abs(speed), targetY, trail: [], color });
28
- }
29
-
30
- function burst(x, y, color) {
31
- for (let i = 0; i < opts.particleCount; i++) {
32
- const angle = Math.random() * Math.PI * 2;
33
- const speed = 1 + Math.random() * 5;
34
- particles.push({
35
- x, y,
36
- vx: Math.cos(angle) * speed,
37
- vy: Math.sin(angle) * speed,
38
- alpha: 1,
39
- decay: opts.decay * (0.7 + Math.random() * 0.6),
40
- size: 2 + Math.random() * 3,
41
- color,
42
- });
43
- }
44
- }
45
-
46
- // Auto-launch interval
47
- const iv = setInterval(() => { if (running) launchRocket(); }, opts.interval);
48
- launchRocket(); // fire one immediately
49
-
50
- function animate() {
51
- if (!running) return;
52
-
53
- // Clear canvas instead of using a solid fill to keep background transparent
54
- ctx.clearRect(0, 0, canvas.width, canvas.height);
55
-
56
- // Draw rockets
57
- for (let i = rockets.length - 1; i >= 0; i--) {
58
- const r = rockets[i];
59
- r.y += r.vy;
60
- r.trail.push({ x: r.x, y: r.y });
61
- if (r.trail.length > opts.trailLength) r.trail.shift();
62
-
63
- // Draw trail
64
- for (let t = 0; t < r.trail.length; t++) {
65
- const alpha = (t / r.trail.length) * 0.8;
66
- ctx.save();
67
- ctx.globalAlpha = alpha;
68
- if (opts.glow) { ctx.shadowColor = r.color; ctx.shadowBlur = 6; }
69
- ctx.fillStyle = r.color;
70
- ctx.beginPath();
71
- ctx.arc(r.trail[t].x, r.trail[t].y, 2.5 * (t / r.trail.length), 0, Math.PI * 2);
72
- ctx.fill();
73
- ctx.restore();
74
- }
75
-
76
- if (r.y <= r.targetY) {
77
- burst(r.x, r.y, r.color);
78
- rockets.splice(i, 1);
79
- }
80
- }
81
-
82
- // Draw burst particles
83
- for (let i = particles.length - 1; i >= 0; i--) {
84
- const p = particles[i];
85
- p.x += p.vx;
86
- p.y += p.vy;
87
- p.vy += opts.gravity;
88
- p.alpha -= p.decay;
89
-
90
- ctx.save();
91
- ctx.globalAlpha = Math.max(0, p.alpha);
92
- if (opts.glow) { ctx.shadowColor = p.color; ctx.shadowBlur = p.size * 2; }
93
- ctx.fillStyle = p.color;
94
- ctx.beginPath();
95
- ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
96
- ctx.fill();
97
- ctx.restore();
98
-
99
- if (p.alpha <= 0) particles.splice(i, 1);
100
- }
101
-
102
- requestAnimationFrame(animate);
103
- }
104
-
105
- animate();
106
-
107
- return function stop() {
108
- running = false;
109
- clearInterval(iv);
110
- ctx.clearRect(0, 0, canvas.width, canvas.height);
111
- };
112
- }
@@ -1,89 +0,0 @@
1
- import { mergeOptions } from '../core/engine.js';
2
-
3
- const DEFAULTS = {
4
- count: 0.12, // hearts spawned per frame (probability)
5
- minSize: 14,
6
- maxSize: 32,
7
- minSpeed: 0.8,
8
- maxSpeed: 2.4,
9
- colors: ['#ff6b8a', '#ff4d6d', '#ff85a1', '#ffc2d1', '#ff0a54', '#ff477e'],
10
- wobble: true, // horizontal sine drift
11
- glow: true,
12
- };
13
-
14
- /**
15
- * Draw a proper heart shape centred at (cx, cy) with given radius.
16
- */
17
- function drawHeartShape(ctx, cx, cy, r, color, alpha = 1, glow = false) {
18
- ctx.save();
19
- ctx.globalAlpha = alpha;
20
- if (glow) {
21
- ctx.shadowColor = color;
22
- ctx.shadowBlur = r * 1.2;
23
- }
24
- ctx.fillStyle = color;
25
- ctx.beginPath();
26
- ctx.moveTo(cx, cy + r * 0.3);
27
- // left lobe
28
- ctx.bezierCurveTo(cx - r * 1.1, cy - r * 0.5, cx - r * 1.6, cy + r * 0.5, cx, cy + r * 1.4);
29
- // right lobe
30
- ctx.bezierCurveTo(cx + r * 1.6, cy + r * 0.5, cx + r * 1.1, cy - r * 0.5, cx, cy + r * 0.3);
31
- ctx.fill();
32
- ctx.restore();
33
- }
34
-
35
- export function floatingHearts(canvas, userOptions = {}) {
36
- const opts = mergeOptions(DEFAULTS, userOptions);
37
- const ctx = canvas.getContext('2d');
38
- const hearts = [];
39
- let running = true;
40
- let frame = 0;
41
-
42
- function createHeart() {
43
- const size = opts.minSize + Math.random() * (opts.maxSize - opts.minSize);
44
- return {
45
- x: Math.random() * canvas.width,
46
- y: canvas.height + size * 2,
47
- size,
48
- speed: opts.minSpeed + Math.random() * (opts.maxSpeed - opts.minSpeed),
49
- color: opts.colors[Math.floor(Math.random() * opts.colors.length)],
50
- alpha: 0.7 + Math.random() * 0.3,
51
- wobbleOffset: Math.random() * Math.PI * 2,
52
- wobbleSpeed: 0.02 + Math.random() * 0.03,
53
- wobbleAmount: 0.5 + Math.random() * 1.5,
54
- };
55
- }
56
-
57
- function animate() {
58
- if (!running) return;
59
- frame++;
60
- ctx.clearRect(0, 0, canvas.width, canvas.height);
61
-
62
- if (Math.random() < opts.count) hearts.push(createHeart());
63
-
64
- for (let i = hearts.length - 1; i >= 0; i--) {
65
- const h = hearts[i];
66
- h.y -= h.speed;
67
- h.wobbleOffset += h.wobbleSpeed;
68
- const xOffset = opts.wobble ? Math.sin(h.wobbleOffset) * h.wobbleAmount * h.size * 0.5 : 0;
69
-
70
- // Fade out near top
71
- const fadeAlpha = Math.min(h.alpha, h.y / (canvas.height * 0.2));
72
- if (fadeAlpha <= 0 || h.y < -h.size * 3) {
73
- hearts.splice(i, 1);
74
- continue;
75
- }
76
-
77
- drawHeartShape(ctx, h.x + xOffset, h.y, h.size, h.color, Math.max(0, fadeAlpha), opts.glow);
78
- }
79
-
80
- requestAnimationFrame(animate);
81
- }
82
-
83
- animate();
84
-
85
- return function stop() {
86
- running = false;
87
- ctx.clearRect(0, 0, canvas.width, canvas.height);
88
- };
89
- }
@@ -1,76 +0,0 @@
1
- import { mergeOptions } from '../core/engine.js';
2
-
3
- const DEFAULTS = {
4
- orbCount: 15,
5
- minSize: 50,
6
- maxSize: 150,
7
- colors: ['#ff4d6d', '#c77dff', '#48cae4', '#ffe66d'],
8
- speed: 0.5,
9
- glow: true,
10
- };
11
-
12
- export function floatingOrbs(canvas, userOptions = {}) {
13
- const opts = mergeOptions(DEFAULTS, userOptions);
14
- const ctx = canvas.getContext('2d');
15
- const orbs = [];
16
- let running = true;
17
-
18
- function createOrb() {
19
- const size = opts.minSize + Math.random() * (opts.maxSize - opts.minSize);
20
- return {
21
- x: Math.random() * canvas.width,
22
- y: Math.random() * canvas.height,
23
- size,
24
- vx: (Math.random() - 0.5) * opts.speed,
25
- vy: (Math.random() - 0.5) * opts.speed,
26
- color: opts.colors[Math.floor(Math.random() * opts.colors.length)],
27
- alpha: 0,
28
- };
29
- }
30
-
31
- for (let i = 0; i < opts.orbCount; i++) {
32
- const orb = createOrb();
33
- orb.alpha = Math.random() * 0.5 + 0.1;
34
- orbs.push(orb);
35
- }
36
-
37
- function animate() {
38
- if (!running) return;
39
- ctx.clearRect(0, 0, canvas.width, canvas.height);
40
-
41
- for (let i = 0; i < orbs.length; i++) {
42
- const b = orbs[i];
43
- b.x += b.vx;
44
- b.y += b.vy;
45
-
46
- // Bounce off walls
47
- if (b.x < -b.size) b.x = canvas.width + b.size;
48
- if (b.x > canvas.width + b.size) b.x = -b.size;
49
- if (b.y < -b.size) b.y = canvas.height + b.size;
50
- if (b.y > canvas.height + b.size) b.y = -b.size;
51
-
52
- ctx.save();
53
- ctx.globalAlpha = b.alpha;
54
- ctx.globalCompositeOperation = 'screen';
55
-
56
- const gradient = ctx.createRadialGradient(b.x, b.y, 0, b.x, b.y, b.size);
57
- gradient.addColorStop(0, b.color);
58
- gradient.addColorStop(1, 'rgba(0,0,0,0)');
59
-
60
- ctx.fillStyle = gradient;
61
- ctx.beginPath();
62
- ctx.arc(b.x, b.y, b.size, 0, Math.PI * 2);
63
- ctx.fill();
64
- ctx.restore();
65
- }
66
-
67
- requestAnimationFrame(animate);
68
- }
69
-
70
- animate();
71
-
72
- return function stop() {
73
- running = false;
74
- ctx.clearRect(0, 0, canvas.width, canvas.height);
75
- };
76
- }