@bg-effects/fireworks 1.0.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/README.md +270 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# @bg-effects/fireworks
|
|
2
|
+
|
|
3
|
+
π Beautiful, GPU-accelerated fireworks background effect for Vue 3.
|
|
4
|
+
|
|
5
|
+
  
|
|
6
|
+
|
|
7
|
+
## β¨ Features
|
|
8
|
+
|
|
9
|
+
- π **High Performance** - WebGL-based canvas rendering, GPU accelerated
|
|
10
|
+
- π¨ **Highly Customizable** - 20+ configuration options across 4 categories
|
|
11
|
+
- π **Multiple Shapes** - 18 predefined shapes (heart, star, butterfly, spiral, etc.)
|
|
12
|
+
- π **Color Modes** - Single color or multi-color randomly generated
|
|
13
|
+
- π― **Launch Modes** - 6 launch patterns (random, burst, wave, tide, etc.)
|
|
14
|
+
- π§ **Debug Panel** - Built-in configuration panel with live preview
|
|
15
|
+
- π **i18n Support** - Dual-language (Chinese/English) interface
|
|
16
|
+
- π¦ **3 Built-in Presets** - Ready-to-use configurations
|
|
17
|
+
|
|
18
|
+
## π¦ Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# pnpm
|
|
22
|
+
pnpm add @bg-effects/fireworks
|
|
23
|
+
|
|
24
|
+
# npm
|
|
25
|
+
npm install @bg-effects/fireworks
|
|
26
|
+
|
|
27
|
+
# yarn
|
|
28
|
+
yarn add @bg-effects/fireworks
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## π Quick Start
|
|
32
|
+
|
|
33
|
+
### Basic Usage
|
|
34
|
+
|
|
35
|
+
```vue
|
|
36
|
+
<script setup>
|
|
37
|
+
import { Fireworks } from '@bg-effects/fireworks'
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<div class="container">
|
|
42
|
+
<Fireworks />
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<style scoped>
|
|
47
|
+
.container {
|
|
48
|
+
width: 100vw;
|
|
49
|
+
height: 100vh;
|
|
50
|
+
position: relative;
|
|
51
|
+
}
|
|
52
|
+
</style>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### With Debug Panel
|
|
56
|
+
|
|
57
|
+
```vue
|
|
58
|
+
<template>
|
|
59
|
+
<Fireworks debug lang="en" />
|
|
60
|
+
</template>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Custom Configuration
|
|
64
|
+
|
|
65
|
+
```vue
|
|
66
|
+
<script setup>
|
|
67
|
+
import { Fireworks } from '@bg-effects/fireworks'
|
|
68
|
+
|
|
69
|
+
const config = {
|
|
70
|
+
fireworkCount: 30,
|
|
71
|
+
speed: 1.5,
|
|
72
|
+
size: 2.5,
|
|
73
|
+
shape: 'heart',
|
|
74
|
+
colorMode: 'multi',
|
|
75
|
+
launchMode: 'burst',
|
|
76
|
+
gravity: 0.8
|
|
77
|
+
}
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<template>
|
|
81
|
+
<Fireworks v-bind="config" />
|
|
82
|
+
</template>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## π API Reference
|
|
86
|
+
|
|
87
|
+
### Props
|
|
88
|
+
|
|
89
|
+
#### General Settings
|
|
90
|
+
|
|
91
|
+
| Prop | Type | Default | Range | Description |
|
|
92
|
+
|------|------|---------|-------|-------------|
|
|
93
|
+
| `fireworkCount` | `number` | `20` | 1-100 | Number of fireworks particles |
|
|
94
|
+
| `density` | `number` | `1.0` | 0.5-3.0 | Particle density |
|
|
95
|
+
| `clusterSize` | `number` | `5.0` | 1-10 | Cluster size for simultaneous mode |
|
|
96
|
+
| `gravity` | `number` | `1.0` | 0-2.0 | Gravity strength |
|
|
97
|
+
|
|
98
|
+
#### Shape Settings
|
|
99
|
+
|
|
100
|
+
| Prop | Type | Default | Options | Description |
|
|
101
|
+
|------|------|---------|---------|-------------|
|
|
102
|
+
| `shape` | `string` | `'normal'` | See below | Firework shape pattern |
|
|
103
|
+
| `rotation` | `number` | `0` | 0-360 | Static rotation angle |
|
|
104
|
+
| `rotationJitter` | `number` | `0.2` | 0-1 | Random rotation variance |
|
|
105
|
+
|
|
106
|
+
**Available Shapes:**
|
|
107
|
+
`normal`, `circular`, `heart`, `star`, `butterfly`, `spiral`, `ring`, `doubleRing`, `atom`, `trefoil`, `clover`, `cross`, `saturn`, `hexagram`, `astroid`, `gear`, `fermat`, `folium`
|
|
108
|
+
|
|
109
|
+
#### Launch Settings
|
|
110
|
+
|
|
111
|
+
| Prop | Type | Default | Options | Description |
|
|
112
|
+
|------|------|---------|---------|-------------|
|
|
113
|
+
| `launchMode` | `string` | `'random'` | See below | Launch pattern |
|
|
114
|
+
| `launchInterval` | `number` | `5.0` | 0.5-10 | Time between launches |
|
|
115
|
+
|
|
116
|
+
**Launch Modes:**
|
|
117
|
+
- `random` - Random launch timing
|
|
118
|
+
- `burst` - Rapid bursts
|
|
119
|
+
- `wave` - Wave pattern
|
|
120
|
+
- `tide` - Tide-like rhythm
|
|
121
|
+
- `simultaneous` - All at once
|
|
122
|
+
- `pendulum` - Swinging pattern
|
|
123
|
+
|
|
124
|
+
#### Visual Effects
|
|
125
|
+
|
|
126
|
+
| Prop | Type | Default | Range | Description |
|
|
127
|
+
|------|------|---------|-------|-------------|
|
|
128
|
+
| `speed` | `number` | `1.0` | 0.5-2.0 | Animation speed multiplier |
|
|
129
|
+
| `size` | `number` | `2.0` | 0.5-5.0 | Particle size |
|
|
130
|
+
| `flashIntensity` | `number` | `1.0` | 0-3.0 | Launch flash intensity |
|
|
131
|
+
| `flashOpacity` | `number` | `0.3` | 0-1.0 | Flash opacity |
|
|
132
|
+
| `colorMode` | `string` | `'multi'` | `single`, `multi` | Color selection mode |
|
|
133
|
+
| `color` | `string` | `'#ffffff'` | hex | Color for single mode |
|
|
134
|
+
|
|
135
|
+
#### System Props
|
|
136
|
+
|
|
137
|
+
| Prop | Type | Default | Description |
|
|
138
|
+
|------|------|---------|-------------|
|
|
139
|
+
| `debug` | `boolean` | `false` | Enable debug panel |
|
|
140
|
+
| `lang` | `string` | `'zh-CN'` | Debug panel language (`'zh-CN'` or `'en'`) |
|
|
141
|
+
| `className` | `string` | - | Custom CSS class |
|
|
142
|
+
|
|
143
|
+
## π¨ Presets
|
|
144
|
+
|
|
145
|
+
Three beautiful built-in presets are included:
|
|
146
|
+
|
|
147
|
+
### Midnight Bloom (εε€ηζΎ)
|
|
148
|
+
```vue
|
|
149
|
+
<Fireworks
|
|
150
|
+
:fireworkCount="30"
|
|
151
|
+
:speed="1.2"
|
|
152
|
+
:size="1.2"
|
|
153
|
+
:launchInterval="3.0"
|
|
154
|
+
colorMode="multi"
|
|
155
|
+
shape="circular"
|
|
156
|
+
/>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Golden Rain (ιθ²ι¨ι²)
|
|
160
|
+
```vue
|
|
161
|
+
<Fireworks
|
|
162
|
+
:fireworkCount="25"
|
|
163
|
+
:speed="0.8"
|
|
164
|
+
:size="1.5"
|
|
165
|
+
:launchInterval="4.0"
|
|
166
|
+
colorMode="single"
|
|
167
|
+
color="#ffcc00"
|
|
168
|
+
shape="normal"
|
|
169
|
+
:gravity="0.5"
|
|
170
|
+
/>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Rapid Sequence (θΏη―εε°)
|
|
174
|
+
```vue
|
|
175
|
+
<Fireworks
|
|
176
|
+
:fireworkCount="15"
|
|
177
|
+
:speed="1.5"
|
|
178
|
+
:size="1.8"
|
|
179
|
+
:launchInterval="1.0"
|
|
180
|
+
shape="random"
|
|
181
|
+
launchMode="random"
|
|
182
|
+
colorMode="multi"
|
|
183
|
+
:density="2.0"
|
|
184
|
+
/>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## π― Usage Tips
|
|
188
|
+
|
|
189
|
+
### Performance Optimization
|
|
190
|
+
|
|
191
|
+
```vue
|
|
192
|
+
<!-- Reduce particle count for mobile devices -->
|
|
193
|
+
<Fireworks :fireworkCount="10" :density="0.5" />
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Responsive Design
|
|
197
|
+
|
|
198
|
+
```vue
|
|
199
|
+
<template>
|
|
200
|
+
<div class="fireworks-wrapper">
|
|
201
|
+
<Fireworks v-bind="responsiveConfig" />
|
|
202
|
+
</div>
|
|
203
|
+
</template>
|
|
204
|
+
|
|
205
|
+
<script setup>
|
|
206
|
+
import { computed } from 'vue'
|
|
207
|
+
import { Fireworks } from '@bg-effects/fireworks'
|
|
208
|
+
|
|
209
|
+
const isMobile = computed(() => window.innerWidth < 768)
|
|
210
|
+
|
|
211
|
+
const responsiveConfig = computed(() => ({
|
|
212
|
+
fireworkCount: isMobile.value ? 10 : 30,
|
|
213
|
+
size: isMobile.value ? 1.5 : 2.5
|
|
214
|
+
}))
|
|
215
|
+
</script>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Event-Triggered Effects
|
|
219
|
+
|
|
220
|
+
```vue
|
|
221
|
+
<script setup>
|
|
222
|
+
import { ref } from 'vue'
|
|
223
|
+
import { Fireworks } from '@bg-effects/fireworks'
|
|
224
|
+
|
|
225
|
+
const launchMode = ref('random')
|
|
226
|
+
|
|
227
|
+
function celebrate() {
|
|
228
|
+
launchMode.value = 'burst'
|
|
229
|
+
setTimeout(() => {
|
|
230
|
+
launchMode.value = 'random'
|
|
231
|
+
}, 3000)
|
|
232
|
+
}
|
|
233
|
+
</script>
|
|
234
|
+
|
|
235
|
+
<template>
|
|
236
|
+
<Fireworks :launchMode="launchMode" />
|
|
237
|
+
<button @click="celebrate">Celebrate! π</button>
|
|
238
|
+
</template>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## π§ Development
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Install dependencies
|
|
245
|
+
pnpm install
|
|
246
|
+
|
|
247
|
+
# Build the package
|
|
248
|
+
pnpm -F @bg-effects/fireworks build
|
|
249
|
+
|
|
250
|
+
# Watch mode
|
|
251
|
+
pnpm -F @bg-effects/fireworks dev
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## π License
|
|
255
|
+
|
|
256
|
+
MIT License
|
|
257
|
+
|
|
258
|
+
## π€ Contributing
|
|
259
|
+
|
|
260
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
261
|
+
|
|
262
|
+
## π Links
|
|
263
|
+
|
|
264
|
+
- [Documentation](../../apps/docs/docs/effects/fireworks.md)
|
|
265
|
+
- [Playground Demo](../../apps/playground)
|
|
266
|
+
- [GitHub Repository](https://github.com/yourusername/bg-effects)
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
Made with β€οΈ using Vue 3 + WebGL
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bg-effects/fireworks",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"ogl": "^1.0.0",
|
|
13
|
+
"vue": "^3.3.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"ogl": "^1.0.11",
|
|
17
|
+
"unocss": "^65.4.0",
|
|
18
|
+
"vite": "^5.0.0",
|
|
19
|
+
"vite-plugin-css-injected-by-js": "^3.5.1",
|
|
20
|
+
"vite-plugin-dts": "^4.5.1",
|
|
21
|
+
"@bg-effects/configs": "1.0.0",
|
|
22
|
+
"@bg-effects/shared": "1.0.0",
|
|
23
|
+
"@bg-effects/core": "1.0.0"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@bg-effects/debug-ui": "1.0.0"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "vite build",
|
|
30
|
+
"dev": "vite build --watch"
|
|
31
|
+
}
|
|
32
|
+
}
|