cursor-fx 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 cursor-fx contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,475 @@
1
+ # ✨ Cursor FX
2
+
3
+ Beautiful, customizable cursor particle effects for React and vanilla JavaScript. Create magical experiences with effects like bubbles, snow, sparkles, and more!
4
+
5
+ [![NPM Version](https://img.shields.io/npm/v/cursor-fx.svg)](https://www.npmjs.com/package/cursor-fx)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
8
+
9
+ ## ✨ Features
10
+
11
+ - 🎨 **6 Built-in Effects**: Bubbles, Snow, Fairy Dust, Sparkle, Confetti, Retro CRT
12
+ - ⚡ **High Performance**: Optimized canvas rendering with smart throttling
13
+ - 🎯 **TypeScript Support**: Full type definitions included
14
+ - 📦 **Tiny Bundle**: Lightweight with minimal dependencies
15
+ - 🎭 **Customizable**: Colors, size, speed, and behavior all configurable
16
+ - ⚛️ **React Ready**: Dedicated React components with hooks
17
+ - 🌐 **Vanilla JS**: Works with any framework or no framework
18
+ - 🖼️ **Image Support**: Use PNG assets for realistic effects
19
+
20
+ ## 📦 Installation
21
+
22
+ ```bash
23
+ # npm
24
+ npm install cursor-fx
25
+
26
+ # yarn
27
+ yarn add cursor-fx
28
+
29
+ # pnpm
30
+ pnpm add cursor-fx
31
+ ```
32
+
33
+ ## 🚀 Quick Start
34
+
35
+ ### React
36
+
37
+ ```tsx
38
+ import { CursorFX } from 'cursor-fx/react';
39
+
40
+ function App() {
41
+ return (
42
+ <>
43
+ <CursorFX effect="bubble" />
44
+ <YourContent />
45
+ </>
46
+ );
47
+ }
48
+ ```
49
+
50
+ ### Vanilla JavaScript
51
+
52
+ ```javascript
53
+ import { initCursorFX } from 'cursor-fx/vanilla';
54
+
55
+ const fx = initCursorFX({
56
+ effect: 'snow',
57
+ particleCount: 2
58
+ });
59
+
60
+ // Later, to clean up:
61
+ fx.destroy();
62
+ ```
63
+
64
+ ## 🎨 Available Effects
65
+
66
+ ### 🫧 Bubble
67
+ Floating soap bubbles that drift upward with a smooth pop-up animation.
68
+
69
+ ```tsx
70
+ <CursorFX effect="bubble" />
71
+ ```
72
+
73
+ **Features:**
74
+ - Transparent, realistic bubble rendering
75
+ - Gentle upward float with wobble physics
76
+ - Smooth scale-up animation on spawn (pops from 30% to 100% size)
77
+ - Variable bubble sizes (37-112px)
78
+
79
+ ---
80
+
81
+ ### ❄️ Snow
82
+ Delicate snowflakes that fall and drift with wind.
83
+
84
+ ```tsx
85
+ <CursorFX effect="snow" />
86
+ ```
87
+
88
+ **Features:**
89
+ - Rotating snowflakes with 6-armed crystalline structure
90
+ - Wind drift using smooth sine wave physics
91
+ - White glow for visibility
92
+ - Dual mode: PNG images or optimized canvas drawing
93
+
94
+ ---
95
+
96
+ ### ✨ Fairy Dust
97
+ Golden magical particles that float upward.
98
+
99
+ ```tsx
100
+ <CursorFX effect="fairyDust" />
101
+ ```
102
+
103
+ **Features:**
104
+ - Golden glow effect (shadowBlur: 18px)
105
+ - Cross/plus shape particles
106
+ - Upward floating motion (negative gravity)
107
+ - Perfect for magical themes
108
+
109
+ ---
110
+
111
+ ### ⭐ Sparkle
112
+ Quick, colorful sparkles that burst and fade.
113
+
114
+ ```tsx
115
+ <CursorFX effect="sparkle" />
116
+ ```
117
+
118
+ **Features:**
119
+ - Rainbow colored particles
120
+ - Fast, energetic movement
121
+ - Short lifetime (20 frames) for clean trails
122
+ - Star-shaped particles
123
+
124
+ ---
125
+
126
+ ### 🎉 Confetti
127
+ Celebratory confetti that falls from cursor.
128
+
129
+ ```tsx
130
+ <CursorFX effect="confetti" />
131
+ ```
132
+
133
+ **Features:**
134
+ - Party color palette
135
+ - Rectangle particles with rotation
136
+ - Realistic falling physics
137
+ - Perfect for celebrations
138
+
139
+ ---
140
+
141
+ ### 🖥️ Retro CRT
142
+ Phosphor green glow like old computer terminals.
143
+
144
+ ```tsx
145
+ <CursorFX effect="retroCRT" />
146
+ ```
147
+
148
+ **Features:**
149
+ - Classic phosphor green colors
150
+ - Circular particles with strong glow
151
+ - Stationary particles (zero gravity)
152
+ - Nostalgic terminal aesthetic
153
+
154
+ ## ⚙️ Configuration
155
+
156
+ All effects support extensive customization:
157
+
158
+ ```tsx
159
+ <CursorFX
160
+ effect="bubble"
161
+ particleCount={3}
162
+ colors={['#FF6B6B', '#4ECDC4', '#FFE66D']}
163
+ />
164
+ ```
165
+
166
+ ### Common Options
167
+
168
+ | Option | Type | Description | Default |
169
+ |--------|------|-------------|---------|
170
+ | `effect` | `CursorEffectType` | Effect name | Required |
171
+ | `particleCount` | `number` | Particles per spawn | Effect-specific |
172
+ | `colors` | `string[]` | Particle colors | Effect-specific |
173
+ | `particleSize` | `number` | Base particle size | Effect-specific |
174
+ | `enabled` | `boolean` | Enable/disable | `true` (React) |
175
+
176
+ ### Advanced Options
177
+
178
+ ```typescript
179
+ interface EffectOptions {
180
+ colors?: string[]; // Particle colors
181
+ particleCount?: number; // Particles per spawn
182
+ particleSize?: number; // Base size
183
+ gravity?: number; // Vertical acceleration
184
+ maxLife?: number; // Lifetime in frames
185
+ velocity?: number; // Movement speed
186
+ throttle?: number; // Ms between spawns
187
+ minMoveDistance?: number; // Min cursor movement
188
+ }
189
+ ```
190
+
191
+ ### Effect-Specific Defaults
192
+
193
+ See [EFFECT_DEFAULTS.md](./EFFECT_DEFAULTS.md) for complete default values.
194
+
195
+ **Quick Reference:**
196
+
197
+ ```typescript
198
+ // All effects work with no options:
199
+ <CursorFX effect="bubble" /> // Uses all defaults
200
+ <CursorFX effect="snow" /> // Uses all defaults
201
+
202
+ // Or customize only what you need:
203
+ <CursorFX effect="bubble" particleCount={5} />
204
+ <CursorFX effect="snow" colors={['#FFFFFF']} />
205
+ ```
206
+
207
+ ## 📚 API Reference
208
+
209
+ ### React Component
210
+
211
+ ```tsx
212
+ import { CursorFX } from 'cursor-fx/react';
213
+
214
+ <CursorFX
215
+ enabled={true}
216
+ effect="bubble"
217
+ particleCount={2}
218
+ colors={['#FFD700', '#FF69B4']}
219
+ />
220
+ ```
221
+
222
+ **Props:**
223
+ - `enabled?: boolean` - Enable/disable effect
224
+ - `effect: CursorEffectType` - Effect name
225
+ - All `EffectOptions` are also valid props
226
+
227
+ ### Vanilla JS
228
+
229
+ ```javascript
230
+ import { initCursorFX } from 'cursor-fx/vanilla';
231
+
232
+ const fx = initCursorFX({
233
+ effect: 'snow',
234
+ particleCount: 3,
235
+ colors: ['#FFFFFF', '#E0FFFF']
236
+ });
237
+
238
+ // Clean up when done
239
+ fx.destroy();
240
+ ```
241
+
242
+ ### Core Engine (Advanced)
243
+
244
+ For advanced use cases, use the core engine directly:
245
+
246
+ ```javascript
247
+ import {
248
+ CursorFXEngine,
249
+ createBubbleEffect,
250
+ ImageLoader
251
+ } from 'cursor-fx';
252
+
253
+ // Preload images (optional)
254
+ await ImageLoader.loadBubbles('/bubbles');
255
+ await ImageLoader.loadSnowflakes('/snowflakes');
256
+
257
+ // Create engine and effect
258
+ const engine = new CursorFXEngine();
259
+ const effect = createBubbleEffect({
260
+ particleCount: 2,
261
+ colors: ['#ADD8E6']
262
+ });
263
+
264
+ engine.start(effect);
265
+
266
+ // Later
267
+ engine.stop();
268
+ engine.destroy();
269
+ ```
270
+
271
+ ## 🖼️ Using Image Assets
272
+
273
+ Some effects support PNG assets for photorealistic quality:
274
+
275
+ ```javascript
276
+ import { ImageLoader } from 'cursor-fx';
277
+
278
+ // Preload before using effects
279
+ await ImageLoader.loadBubbles('/path/to/bubbles');
280
+ await ImageLoader.loadSnowflakes('/path/to/snowflakes');
281
+
282
+ // Effects will automatically use images if loaded
283
+ const bubbleEffect = createBubbleEffect();
284
+ ```
285
+
286
+ **Included Assets:**
287
+ - 3 bubble variations (~148KB total)
288
+ - 3 snowflake variations (~140KB total)
289
+
290
+ Assets are automatically copied to `dist/bubbles/` and `dist/snowflakes/` during build.
291
+
292
+ ## 🎨 Customizing Colors
293
+
294
+ Each effect has themed default colors, but you can easily customize:
295
+
296
+ ```tsx
297
+ // Transparent pink bubbles
298
+ <CursorFX
299
+ effect="bubble"
300
+ colors={[
301
+ 'rgba(255, 192, 203, 0.4)', // Pink
302
+ 'rgba(255, 182, 193, 0.4)', // Light pink
303
+ ]}
304
+ />
305
+
306
+ // Blue-tinted snow
307
+ <CursorFX
308
+ effect="snow"
309
+ colors={['#E0FFFF', '#F0F8FF', '#F5FFFA']}
310
+ />
311
+
312
+ // Custom sparkle colors
313
+ <CursorFX
314
+ effect="sparkle"
315
+ colors={['#FF0000', '#00FF00', '#0000FF']}
316
+ />
317
+ ```
318
+
319
+ ## 📱 Performance Tips
320
+
321
+ 1. **Reduce Spawn Rate**: Increase `throttle` and `minMoveDistance`
322
+
323
+ ```tsx
324
+ <CursorFX
325
+ effect="bubble"
326
+ throttle={200} // 200ms between spawns
327
+ minMoveDistance={20} // Spawn only after 20px movement
328
+ />
329
+ ```
330
+
331
+ 2. **Lower Particle Count**: Reduce particles per spawn
332
+
333
+ ```tsx
334
+ <CursorFX effect="snow" particleCount={1} />
335
+ ```
336
+
337
+ 3. **Shorter Lifetime**: Particles disappear faster
338
+
339
+ ```tsx
340
+ <CursorFX effect="sparkle" maxLife={15} />
341
+ ```
342
+
343
+ 4. **Disable on Mobile**: Conditional rendering
344
+
345
+ ```tsx
346
+ const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
347
+
348
+ <CursorFX effect="bubble" enabled={!isMobile} />
349
+ ```
350
+
351
+ ## 🔧 Advanced Usage
352
+
353
+ ### Multiple Effects with Switching
354
+
355
+ ```tsx
356
+ function App() {
357
+ const [effect, setEffect] = useState('bubble');
358
+
359
+ return (
360
+ <>
361
+ <CursorFX effect={effect} />
362
+
363
+ <button onClick={() => setEffect('snow')}>Snow</button>
364
+ <button onClick={() => setEffect('bubble')}>Bubble</button>
365
+ <button onClick={() => setEffect('confetti')}>Confetti</button>
366
+ </>
367
+ );
368
+ }
369
+ ```
370
+
371
+ ### Dynamic Configuration
372
+
373
+ ```tsx
374
+ const [config, setConfig] = useState({
375
+ particleCount: 2,
376
+ colors: ['#FFD700', '#FFC700']
377
+ });
378
+
379
+ <CursorFX effect="fairyDust" {...config} />
380
+
381
+ <button onClick={() => setConfig({...config, particleCount: 5})}>
382
+ More Particles
383
+ </button>
384
+ ```
385
+
386
+ ### Conditional Effects
387
+
388
+ ```tsx
389
+ <CursorFX
390
+ effect="confetti"
391
+ enabled={isCelebrating}
392
+ particleCount={8}
393
+ />
394
+ ```
395
+
396
+ ## 🌐 Browser Compatibility
397
+
398
+ Works in all modern browsers that support:
399
+ - Canvas API
400
+ - ES2020+
401
+ - RequestAnimationFrame
402
+
403
+ **Mobile Support:** Touch events fully supported.
404
+
405
+ **Performance Optimizations:**
406
+ - Max 500 particles to prevent lag
407
+ - Smart throttling (~60fps)
408
+ - Wind drift with smooth Perlin-like noise
409
+ - Optimized canvas rendering (single-path snowflakes = 18x faster)
410
+
411
+ ## 📦 Bundle Size
412
+
413
+ Optimized for minimal impact:
414
+ - Core: ~6KB (minified + gzipped)
415
+ - React: ~7KB (minified + gzipped)
416
+ - Vanilla: ~6KB (minified + gzipped)
417
+
418
+ **Dependencies:**
419
+ - Zero runtime dependencies
420
+ - React is a peer dependency (optional)
421
+
422
+ ## 🎯 TypeScript
423
+
424
+ Full TypeScript support included:
425
+
426
+ ```typescript
427
+ import type { CursorEffectType, EffectOptions } from 'cursor-fx';
428
+ import type { CursorFXProps } from 'cursor-fx/react';
429
+
430
+ const effect: CursorEffectType = 'bubble';
431
+
432
+ const options: EffectOptions = {
433
+ particleCount: 3,
434
+ colors: ['#FF0000']
435
+ };
436
+ ```
437
+
438
+ ## 📂 Examples
439
+
440
+ Working examples included:
441
+ - `examples/react/` - Vite + React demo
442
+ - `examples/vanilla/` - Plain HTML demo
443
+
444
+ Run examples:
445
+ ```bash
446
+ cd examples/react
447
+ npm install
448
+ npm run dev
449
+ ```
450
+
451
+ ## 🤝 Contributing
452
+
453
+ Contributions welcome! Please feel free to submit a Pull Request.
454
+
455
+ ## 📄 License
456
+
457
+ MIT © [Your Name]
458
+
459
+ ## 🙏 Acknowledgments
460
+
461
+ Built with:
462
+ - TypeScript
463
+ - React (peer dependency)
464
+ - HTML5 Canvas API
465
+ - tsup for bundling
466
+
467
+ ## 🔗 Links
468
+
469
+ - [npm Package](https://www.npmjs.com/package/cursor-fx)
470
+ - [GitHub Repository](https://github.com/antopravin-dev/cursor-fx)
471
+ - [Documentation](./EFFECT_DEFAULTS.md)
472
+
473
+ ---
474
+
475
+ **Made with ✨ by [Anto Pravin C](https://github.com/antopravin-dev)**
Binary file
Binary file
Binary file