domma-cms 0.2.1 → 0.5.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/README.md +3 -3
- package/admin/css/admin.css +1 -1200
- package/admin/dist/domma/domma-tools.css +2313 -0
- package/admin/dist/domma/domma-tools.min.js +10 -0
- package/admin/index.html +4 -0
- package/admin/js/api.js +1 -242
- package/admin/js/app.js +9 -279
- package/admin/js/config/sidebar-config.js +1 -115
- package/admin/js/lib/card.js +1 -63
- package/admin/js/lib/image-editor.js +1 -869
- package/admin/js/lib/markdown-toolbar.js +54 -421
- package/admin/js/templates/action-editor.html +171 -0
- package/admin/js/templates/actions-list.html +19 -0
- package/admin/js/templates/api-reference.html +1411 -0
- package/admin/js/templates/block-editor.html +158 -0
- package/admin/js/templates/blocks.html +8 -0
- package/admin/js/templates/collection-editor.html +47 -0
- package/admin/js/templates/collection-entries.html +3 -0
- package/admin/js/templates/collections.html +51 -4
- package/admin/js/templates/documentation.html +258 -0
- package/admin/js/templates/form-editor.html +238 -0
- package/{plugins/form-builder/admin → admin/js}/templates/form-submissions.html +30 -30
- package/{plugins/form-builder/admin/templates/forms-list.html → admin/js/templates/forms.html} +17 -17
- package/admin/js/templates/layouts.html +44 -7
- package/admin/js/templates/login.html +29 -4
- package/admin/js/templates/my-profile.html +17 -0
- package/admin/js/templates/page-editor.html +48 -0
- package/admin/js/templates/pages.html +6 -1
- package/admin/js/templates/pro-docs.html +259 -0
- package/admin/js/templates/role-editor.html +59 -0
- package/admin/js/templates/roles.html +10 -0
- package/admin/js/templates/settings.html +137 -18
- package/admin/js/templates/tutorials.html +81 -0
- package/admin/js/templates/user-editor.html +7 -0
- package/admin/js/templates/users.html +3 -1
- package/admin/js/templates/view-editor.html +201 -0
- package/admin/js/templates/view-preview.html +51 -0
- package/admin/js/templates/views-list.html +19 -0
- package/admin/js/views/action-editor.js +1 -0
- package/admin/js/views/actions-list.js +1 -0
- package/admin/js/views/api-reference.js +1 -0
- package/admin/js/views/block-editor.js +8 -0
- package/admin/js/views/blocks.js +4 -0
- package/admin/js/views/collection-editor.js +3 -487
- package/admin/js/views/collection-entries.js +1 -484
- package/admin/js/views/collections.js +1 -153
- package/admin/js/views/dashboard.js +1 -56
- package/admin/js/views/documentation.js +1 -12
- package/admin/js/views/form-editor.js +8 -0
- package/admin/js/views/form-submissions.js +1 -0
- package/admin/js/views/forms.js +1 -0
- package/admin/js/views/index.js +1 -39
- package/admin/js/views/layouts.js +9 -42
- package/admin/js/views/login.js +7 -251
- package/admin/js/views/media.js +1 -240
- package/admin/js/views/my-profile.js +1 -0
- package/admin/js/views/navigation.js +14 -212
- package/admin/js/views/page-editor.js +72 -661
- package/admin/js/views/pages.js +5 -72
- package/admin/js/views/plugins.js +13 -90
- package/admin/js/views/pro-docs.js +1 -0
- package/admin/js/views/role-editor.js +1 -0
- package/admin/js/views/roles.js +4 -0
- package/admin/js/views/settings.js +3 -199
- package/admin/js/views/tutorials.js +1 -12
- package/admin/js/views/user-editor.js +1 -88
- package/admin/js/views/users.js +4 -76
- package/admin/js/views/view-editor.js +1 -0
- package/admin/js/views/view-preview.js +1 -0
- package/admin/js/views/views-list.js +1 -0
- package/bin/cli.js +1 -1
- package/config/auth.json +2 -17
- package/config/connections.json.bak +9 -0
- package/config/connections.json.example +9 -0
- package/config/navigation.json +15 -0
- package/config/plugins.json +19 -29
- package/config/server.json +6 -6
- package/config/site.json +17 -6
- package/package.json +24 -10
- package/plugins/domma-effects/public/celebrations/core/canvas.js +2 -104
- package/plugins/domma-effects/public/celebrations/core/particles.js +1 -144
- package/plugins/domma-effects/public/celebrations/core/physics.js +1 -166
- package/plugins/domma-effects/public/celebrations/index.js +1 -535
- package/plugins/domma-effects/public/celebrations/themes/christmas.js +1 -1805
- package/plugins/domma-effects/public/celebrations/themes/guy-fawkes.js +1 -1477
- package/plugins/domma-effects/public/celebrations/themes/halloween.js +1 -1837
- package/plugins/domma-effects/public/celebrations/themes/st-andrews.js +1 -1175
- package/plugins/domma-effects/public/celebrations/themes/st-davids.js +1 -1258
- package/plugins/domma-effects/public/celebrations/themes/st-georges.js +1 -1754
- package/plugins/domma-effects/public/celebrations/themes/st-patricks.js +1 -1290
- package/plugins/domma-effects/public/celebrations/themes/valentines.js +1 -1361
- package/plugins/example-analytics/stats.json +21 -12
- package/plugins/theme-roller/admin/templates/theme-roller.html +71 -0
- package/plugins/theme-roller/admin/views/theme-roller-view.js +403 -0
- package/plugins/theme-roller/config.js +1 -0
- package/plugins/theme-roller/plugin.js +233 -0
- package/plugins/theme-roller/plugin.json +31 -0
- package/plugins/theme-roller/public/active-theme.css +0 -0
- package/plugins/theme-roller/public/inject-head-late.html +1 -0
- package/public/css/forms.css +1 -0
- package/public/css/site.css +1 -302
- package/public/js/btt.js +1 -90
- package/public/js/cookie-consent.js +1 -61
- package/public/js/form-logic-engine.js +1 -0
- package/public/js/forms.js +1 -0
- package/public/js/site.js +1 -204
- package/scripts/build.js +194 -129
- package/scripts/pro.js +254 -0
- package/scripts/reset.js +33 -8
- package/scripts/seed.js +343 -78
- package/scripts/setup.js +5 -4
- package/server/middleware/auth.js +136 -97
- package/server/routes/api/actions.js +200 -0
- package/server/routes/api/auth.js +292 -116
- package/server/routes/api/blocks.js +84 -0
- package/server/routes/api/collections.js +88 -23
- package/{plugins/form-builder/plugin.js → server/routes/api/forms.js} +483 -505
- package/server/routes/api/layouts.js +49 -25
- package/server/routes/api/media.js +118 -93
- package/server/routes/api/navigation.js +40 -37
- package/server/routes/api/pages.js +132 -118
- package/server/routes/api/plugins.js +6 -3
- package/server/routes/api/settings.js +104 -89
- package/server/routes/api/users.js +27 -21
- package/server/routes/api/views.js +148 -0
- package/server/routes/public.js +124 -108
- package/server/server.js +269 -173
- package/server/services/actions.js +387 -0
- package/server/services/adapterRegistry.js +98 -0
- package/server/services/adapters/FileAdapter.js +192 -0
- package/server/services/adapters/MongoAdapter.js +220 -0
- package/server/services/blocks.js +162 -0
- package/server/services/collections.js +74 -86
- package/server/services/connectionManager.js +102 -0
- package/server/services/content.js +312 -307
- package/{plugins/form-builder → server/services}/email.js +126 -103
- package/server/services/forms.js +173 -0
- package/server/services/markdown.js +1378 -648
- package/server/services/permissionRegistry.js +173 -0
- package/server/services/presetCollections.js +251 -0
- package/server/services/renderer.js +75 -1
- package/server/services/roles.js +227 -0
- package/server/services/rowAccess.js +104 -0
- package/server/services/userProfiles.js +199 -0
- package/server/services/users.js +281 -212
- package/server/services/views.js +280 -0
- package/server/templates/page.html +119 -113
- package/plugins/form-builder/admin/templates/form-editor.html +0 -171
- package/plugins/form-builder/admin/templates/form-settings.html +0 -29
- package/plugins/form-builder/admin/views/form-editor.js +0 -1442
- package/plugins/form-builder/admin/views/form-settings.js +0 -38
- package/plugins/form-builder/admin/views/form-submissions.js +0 -295
- package/plugins/form-builder/admin/views/forms-list.js +0 -164
- package/plugins/form-builder/config.js +0 -9
- package/plugins/form-builder/data/forms/consent.json +0 -104
- package/plugins/form-builder/data/forms/contact-details.json +0 -63
- package/plugins/form-builder/data/forms/contacts.json +0 -66
- package/plugins/form-builder/data/submissions/consent.json +0 -13
- package/plugins/form-builder/data/submissions/contact-details.json +0 -1
- package/plugins/form-builder/data/submissions/contacts.json +0 -26
- package/plugins/form-builder/plugin.json +0 -52
- package/plugins/form-builder/public/form-logic-engine.js +0 -568
- package/plugins/form-builder/public/inject-body.html +0 -352
- package/plugins/form-builder/public/inject-head.html +0 -58
- package/plugins/form-builder/public/package.json +0 -1
- package/scripts/copy-domma.js +0 -48
|
@@ -1,1477 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Guy Fawkes Night Theme for Domma Celebrations
|
|
3
|
-
* (Bonfire Night - November 5th, UK)
|
|
4
|
-
*
|
|
5
|
-
* Features:
|
|
6
|
-
* - Spectacular firework displays with multiple colors
|
|
7
|
-
* - Animated bonfires with crackling flames and embers
|
|
8
|
-
* - Rocket trails shooting upward before exploding
|
|
9
|
-
* - Catherine wheels spinning with colorful sparks
|
|
10
|
-
* - Roman candles shooting multiple bursts
|
|
11
|
-
* - Guy Fawkes effigy silhouette
|
|
12
|
-
* - Floating embers and ash particles
|
|
13
|
-
* - Dark night sky with dramatic pyrotechnics
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
// Import firework functions from Christmas theme (reusable!)
|
|
17
|
-
import christmas from './christmas.js';
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
name: 'guy-fawkes',
|
|
21
|
-
displayName: 'Guy Fawkes Night',
|
|
22
|
-
emoji: '🎆',
|
|
23
|
-
|
|
24
|
-
// Intensity configurations
|
|
25
|
-
intensityConfig: {
|
|
26
|
-
light: {
|
|
27
|
-
count: 60,
|
|
28
|
-
initialParticleRatio: 0.25, // Start with 25% of particles (15), build up to full count
|
|
29
|
-
speedRange: [0.5, 1.5],
|
|
30
|
-
sizeRange: [2, 4],
|
|
31
|
-
bonfires: 1,
|
|
32
|
-
fireworkChance: 0.0009, // ~1 firework every 18 seconds
|
|
33
|
-
rocketChance: 0.0007,
|
|
34
|
-
burstChance: 0.0012
|
|
35
|
-
},
|
|
36
|
-
medium: {
|
|
37
|
-
count: 120,
|
|
38
|
-
initialParticleRatio: 0.25, // Start with 25% of particles (30), build up to full count
|
|
39
|
-
speedRange: [0.5, 2.0],
|
|
40
|
-
sizeRange: [2, 5],
|
|
41
|
-
bonfires: 2,
|
|
42
|
-
fireworkChance: 0.0011, // ~1 firework every 15 seconds
|
|
43
|
-
rocketChance: 0.0009,
|
|
44
|
-
burstChance: 0.0015
|
|
45
|
-
},
|
|
46
|
-
heavy: {
|
|
47
|
-
count: 200,
|
|
48
|
-
initialParticleRatio: 0.25, // Start with 25% of particles (50), build up to full count
|
|
49
|
-
speedRange: [0.5, 2.5],
|
|
50
|
-
sizeRange: [3, 6],
|
|
51
|
-
bonfires: 3,
|
|
52
|
-
fireworkChance: 0.0014, // ~1 firework every 12 seconds
|
|
53
|
-
rocketChance: 0.0012,
|
|
54
|
-
burstChance: 0.0018
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
particles: ['ember', 'firework', 'spark', 'rocket', 'burst', 'trail'],
|
|
59
|
-
decorations: ['bonfire', 'guy-effigy', 'catherine-wheel', 'roman-candle', 'sparkler-bundle', 'moon'],
|
|
60
|
-
colors: {
|
|
61
|
-
primary: '#ff4500', // Orange-red flames
|
|
62
|
-
secondary: '#ffd700', // Gold sparks
|
|
63
|
-
accent: '#8b0000', // Deep red
|
|
64
|
-
fire: ['#ff4500', '#ffa500', '#ffff00', '#ff0000'], // Flame colors
|
|
65
|
-
firework: ['#ff0000', '#ffff00', '#00ff00', '#0000ff', '#ff00ff', '#00ffff', '#ffffff']
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
// Lightning effect properties
|
|
69
|
-
lightningChance: 0.0005, // 0.05% chance per frame to strike
|
|
70
|
-
lightningDuration: 200, // Lightning flash lasts 200ms
|
|
71
|
-
lightningTimer: 0,
|
|
72
|
-
lightningActive: false,
|
|
73
|
-
lightningColor: '#fefefe', // Bright white/blue flash
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Draw a procedurally generated lightning bolt
|
|
77
|
-
* @param {CanvasRenderingContext2D} ctx
|
|
78
|
-
* @param {number} x1 - Start X
|
|
79
|
-
* @param {number} y1 - Start Y
|
|
80
|
-
* @param {number} x2 - End X
|
|
81
|
-
* @param {number} y2 - End Y
|
|
82
|
-
* @param {number} segments - Number of segments for the bolt (controls detail)
|
|
83
|
-
* @param {number} displacement - Max displacement for forks
|
|
84
|
-
* @param {number} roughness - How jagged the line is
|
|
85
|
-
* @param {number} branchChance - Probability of branching
|
|
86
|
-
* @param {number} lineWidth - Base line width
|
|
87
|
-
* @param {string} color - Color of the lightning
|
|
88
|
-
*/
|
|
89
|
-
drawLightning(ctx, x1, y1, x2, y2, segments, displacement, roughness, branchChance, lineWidth, color) {
|
|
90
|
-
if (segments < 1) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const midpointX = (x1 + x2) / 2;
|
|
95
|
-
const midpointY = (y1 + y2) / 2;
|
|
96
|
-
|
|
97
|
-
const angle = Math.atan2(y2 - y1, x2 - x1);
|
|
98
|
-
const perpendicularAngle = angle + Math.PI / 2;
|
|
99
|
-
|
|
100
|
-
const offset = (Math.random() - 0.5) * displacement;
|
|
101
|
-
const newMidpointX = midpointX + Math.cos(perpendicularAngle) * offset;
|
|
102
|
-
const newMidpointY = midpointY + Math.sin(perpendicularAngle) * offset;
|
|
103
|
-
|
|
104
|
-
const newSegments = segments - 1;
|
|
105
|
-
const newDisplacement = displacement * roughness;
|
|
106
|
-
const newLineWidth = lineWidth * 0.8;
|
|
107
|
-
|
|
108
|
-
ctx.strokeStyle = color;
|
|
109
|
-
ctx.lineWidth = lineWidth;
|
|
110
|
-
ctx.lineCap = 'round';
|
|
111
|
-
ctx.lineJoin = 'round';
|
|
112
|
-
|
|
113
|
-
// Draw main segment
|
|
114
|
-
ctx.beginPath();
|
|
115
|
-
ctx.moveTo(x1, y1);
|
|
116
|
-
ctx.lineTo(newMidpointX, newMidpointY);
|
|
117
|
-
ctx.lineTo(x2, y2);
|
|
118
|
-
ctx.stroke();
|
|
119
|
-
|
|
120
|
-
// Recursive call for sub-segments
|
|
121
|
-
if (newSegments > 0) {
|
|
122
|
-
this.drawLightning(ctx, x1, y1, newMidpointX, newMidpointY, newSegments, newDisplacement, roughness, branchChance, newLineWidth, color);
|
|
123
|
-
this.drawLightning(ctx, newMidpointX, newMidpointY, x2, y2, newSegments, newDisplacement, roughness, branchChance, newLineWidth, color);
|
|
124
|
-
|
|
125
|
-
// Create a fork
|
|
126
|
-
if (Math.random() < branchChance && newSegments > 1) {
|
|
127
|
-
const forkLength = Math.random() * displacement * 0.5;
|
|
128
|
-
const forkAngle = (Math.random() - 0.5) * Math.PI / 3; // Max 60 degree deviation
|
|
129
|
-
const forkX = newMidpointX + Math.cos(angle + forkAngle) * forkLength;
|
|
130
|
-
const forkY = newMidpointY + Math.sin(angle + forkAngle) * forkLength;
|
|
131
|
-
this.drawLightning(ctx, newMidpointX, newMidpointY, forkX, forkY, newSegments - 1, newDisplacement * 0.5, roughness, branchChance * 0.5, newLineWidth * 0.6, color);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Create rising ember particle that will explode
|
|
138
|
-
*/
|
|
139
|
-
createEmber(canvasWidth, canvasHeight, config) {
|
|
140
|
-
// Ensure config has required properties with defaults
|
|
141
|
-
const sizeRange = config?.sizeRange || [2, 4];
|
|
142
|
-
const speedRange = config?.speedRange || [0.5, 1.5];
|
|
143
|
-
|
|
144
|
-
const emberColors = this.colors.firework;
|
|
145
|
-
const startX = Math.random() * canvasWidth;
|
|
146
|
-
const startY = canvasHeight - 50; // Start near bottom
|
|
147
|
-
const targetY = 100 + Math.random() * 300; // Explode at random height
|
|
148
|
-
|
|
149
|
-
return {
|
|
150
|
-
type: 'ember',
|
|
151
|
-
x: startX,
|
|
152
|
-
y: startY,
|
|
153
|
-
vx: (Math.random() - 0.5) * 1.5, // Horizontal drift
|
|
154
|
-
vy: -2 - Math.random() * 2, // Upward velocity
|
|
155
|
-
targetY: targetY,
|
|
156
|
-
size: sizeRange[0] + Math.random() * (sizeRange[1] - sizeRange[0]),
|
|
157
|
-
speed: speedRange[0] + Math.random() * (speedRange[1] - speedRange[0]),
|
|
158
|
-
opacity: 1,
|
|
159
|
-
color: emberColors[Math.floor(Math.random() * emberColors.length)],
|
|
160
|
-
trailColor: emberColors[Math.floor(Math.random() * emberColors.length)],
|
|
161
|
-
glowPhase: Math.random() * Math.PI * 2,
|
|
162
|
-
exploded: false,
|
|
163
|
-
explosionParticles: [],
|
|
164
|
-
active: true
|
|
165
|
-
};
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Create bonfire decoration
|
|
170
|
-
*/
|
|
171
|
-
createBonfire(canvasWidth, canvasHeight, options = {}) {
|
|
172
|
-
return {
|
|
173
|
-
type: 'bonfire',
|
|
174
|
-
x: options.x !== undefined ? options.x : Math.random() * canvasWidth * 0.6 + canvasWidth * 0.2,
|
|
175
|
-
y: options.y !== undefined ? options.y : canvasHeight - 60,
|
|
176
|
-
size: 30 + Math.random() * 20,
|
|
177
|
-
opacity: 1,
|
|
178
|
-
flames: [],
|
|
179
|
-
logs: [],
|
|
180
|
-
embers: [],
|
|
181
|
-
time: 0,
|
|
182
|
-
cracklePhase: 0,
|
|
183
|
-
active: true,
|
|
184
|
-
static: true
|
|
185
|
-
};
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Create Guy Fawkes effigy (on bonfire)
|
|
190
|
-
*/
|
|
191
|
-
createGuyEffigy(canvasWidth, canvasHeight, bonfireX, bonfireY) {
|
|
192
|
-
return {
|
|
193
|
-
type: 'guy-effigy',
|
|
194
|
-
x: bonfireX,
|
|
195
|
-
y: bonfireY - 50,
|
|
196
|
-
size: 20 + Math.random() * 10,
|
|
197
|
-
opacity: 0.8,
|
|
198
|
-
burning: false,
|
|
199
|
-
burnProgress: 0,
|
|
200
|
-
active: true,
|
|
201
|
-
static: true
|
|
202
|
-
};
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Create Catherine wheel (spinning firework)
|
|
207
|
-
*/
|
|
208
|
-
createCatherineWheel(canvasWidth, canvasHeight, options = {}) {
|
|
209
|
-
return {
|
|
210
|
-
type: 'catherine-wheel',
|
|
211
|
-
x: options.x !== undefined ? options.x : Math.random() * canvasWidth,
|
|
212
|
-
y: options.y !== undefined ? options.y : 100 + Math.random() * 200,
|
|
213
|
-
size: 15 + Math.random() * 10,
|
|
214
|
-
opacity: 1,
|
|
215
|
-
rotation: 0,
|
|
216
|
-
rotationSpeed: 0.05 + Math.random() * 0.1,
|
|
217
|
-
sparks: [], // Keep this for internal spark management
|
|
218
|
-
sparkTimer: 0, // New: timer for emitting sparks
|
|
219
|
-
sparkInterval: 50, // New: emit sparks every 50ms
|
|
220
|
-
time: 0,
|
|
221
|
-
duration: 5000 + Math.random() * 3000,
|
|
222
|
-
active: true,
|
|
223
|
-
static: true
|
|
224
|
-
};
|
|
225
|
-
},
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Create Roman candle (shoots bursts upward)
|
|
229
|
-
*/
|
|
230
|
-
createRomanCandle(canvasWidth, canvasHeight, options = {}) {
|
|
231
|
-
return {
|
|
232
|
-
type: 'roman-candle',
|
|
233
|
-
x: options.x !== undefined ? options.x : Math.random() * canvasWidth,
|
|
234
|
-
y: options.y !== undefined ? options.y : canvasHeight - 30,
|
|
235
|
-
size: 8 + Math.random() * 4,
|
|
236
|
-
opacity: 1,
|
|
237
|
-
shots: [],
|
|
238
|
-
shotInterval: 800 + Math.random() * 400,
|
|
239
|
-
lastShotTime: 0,
|
|
240
|
-
shotCount: 0,
|
|
241
|
-
maxShots: 5 + Math.floor(Math.random() * 5),
|
|
242
|
-
time: 0,
|
|
243
|
-
active: true,
|
|
244
|
-
static: true
|
|
245
|
-
};
|
|
246
|
-
},
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Create rocket particle (shoots up then explodes)
|
|
250
|
-
*/
|
|
251
|
-
createRocket(canvasWidth, canvasHeight, config) {
|
|
252
|
-
const sizeRange = config?.sizeRange || [2, 4];
|
|
253
|
-
const startX = 50 + Math.random() * (canvasWidth - 100);
|
|
254
|
-
const targetY = 80 + Math.random() * 150; // Explode in upper third
|
|
255
|
-
|
|
256
|
-
return {
|
|
257
|
-
type: 'rocket',
|
|
258
|
-
x: startX,
|
|
259
|
-
y: canvasHeight - 20,
|
|
260
|
-
vx: (Math.random() - 0.5) * 0.5, // Slight drift
|
|
261
|
-
vy: -3 - Math.random() * 2, // Fast upward
|
|
262
|
-
targetY: targetY,
|
|
263
|
-
size: sizeRange[0] + Math.random() * (sizeRange[1] - sizeRange[0]),
|
|
264
|
-
opacity: 1,
|
|
265
|
-
color: this.colors.firework[Math.floor(Math.random() * this.colors.firework.length)],
|
|
266
|
-
trail: [], // Trail particles behind rocket
|
|
267
|
-
exploded: false,
|
|
268
|
-
rotation: Math.random() * Math.PI * 2,
|
|
269
|
-
rotationSpeed: (Math.random() - 0.5) * 0.1,
|
|
270
|
-
active: true
|
|
271
|
-
};
|
|
272
|
-
},
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Create burst particle (explosion fragment)
|
|
276
|
-
*/
|
|
277
|
-
createBurst(canvasWidth, canvasHeight, config, origin) {
|
|
278
|
-
const sizeRange = config?.sizeRange || [1, 3];
|
|
279
|
-
const angle = Math.random() * Math.PI * 2;
|
|
280
|
-
const speed = 1 + Math.random() * 4;
|
|
281
|
-
|
|
282
|
-
return {
|
|
283
|
-
type: 'burst',
|
|
284
|
-
x: origin?.x || canvasWidth / 2,
|
|
285
|
-
y: origin?.y || canvasHeight / 2,
|
|
286
|
-
vx: Math.cos(angle) * speed,
|
|
287
|
-
vy: Math.sin(angle) * speed,
|
|
288
|
-
size: sizeRange[0] + Math.random() * (sizeRange[1] - sizeRange[0]),
|
|
289
|
-
opacity: 1,
|
|
290
|
-
color: this.colors.firework[Math.floor(Math.random() * this.colors.firework.length)],
|
|
291
|
-
life: 1.0, // Fades out over time
|
|
292
|
-
fadeRate: 0.015 + Math.random() * 0.015,
|
|
293
|
-
gravity: 0.05,
|
|
294
|
-
sparkle: Math.random() < 0.3, // 30% chance to sparkle
|
|
295
|
-
active: true
|
|
296
|
-
};
|
|
297
|
-
},
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Create trail particle (follows rockets)
|
|
301
|
-
*/
|
|
302
|
-
createTrail(canvasWidth, canvasHeight, config, origin) {
|
|
303
|
-
const sizeRange = config?.sizeRange || [1, 2];
|
|
304
|
-
|
|
305
|
-
return {
|
|
306
|
-
type: 'trail',
|
|
307
|
-
x: origin?.x || canvasWidth / 2,
|
|
308
|
-
y: origin?.y || canvasHeight / 2,
|
|
309
|
-
vx: (Math.random() - 0.5) * 0.3,
|
|
310
|
-
vy: (Math.random() - 0.5) * 0.3,
|
|
311
|
-
size: sizeRange[0] + Math.random() * (sizeRange[1] - sizeRange[0]),
|
|
312
|
-
opacity: 0.8,
|
|
313
|
-
color: origin?.color || '#ffd700',
|
|
314
|
-
life: 1.0,
|
|
315
|
-
fadeRate: 0.03 + Math.random() * 0.02,
|
|
316
|
-
active: true
|
|
317
|
-
};
|
|
318
|
-
},
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Create spark particle (small glowing bits)
|
|
322
|
-
*/
|
|
323
|
-
createSpark(canvasWidth, canvasHeight, config, origin) {
|
|
324
|
-
const sizeRange = config?.sizeRange || [0.5, 1.5];
|
|
325
|
-
const angle = Math.random() * Math.PI * 2;
|
|
326
|
-
const speed = 0.5 + Math.random() * 2;
|
|
327
|
-
|
|
328
|
-
return {
|
|
329
|
-
type: 'spark',
|
|
330
|
-
x: origin?.x || Math.random() * canvasWidth,
|
|
331
|
-
y: origin?.y || Math.random() * canvasHeight,
|
|
332
|
-
vx: Math.cos(angle) * speed,
|
|
333
|
-
vy: Math.sin(angle) * speed,
|
|
334
|
-
size: sizeRange[0] + Math.random() * (sizeRange[1] - sizeRange[0]),
|
|
335
|
-
opacity: 1,
|
|
336
|
-
color: this.colors.secondary, // Gold sparks
|
|
337
|
-
life: 1.0,
|
|
338
|
-
fadeRate: 0.02 + Math.random() * 0.02,
|
|
339
|
-
active: true
|
|
340
|
-
};
|
|
341
|
-
},
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Create falling particle (embers)
|
|
345
|
-
*/
|
|
346
|
-
createFallingParticle(canvasWidth, canvasHeight, config) {
|
|
347
|
-
return this.createEmber(canvasWidth, canvasHeight, config);
|
|
348
|
-
},
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Create initial static decorations (bonfires, Guy effigy, etc.)
|
|
352
|
-
*/
|
|
353
|
-
createInitialDecorations(canvasWidth, canvasHeight, config) {
|
|
354
|
-
const decorations = [];
|
|
355
|
-
|
|
356
|
-
// Create bonfires
|
|
357
|
-
const bonfireCount = config.bonfires || 2;
|
|
358
|
-
for (let i = 0; i < bonfireCount; i++) {
|
|
359
|
-
const bonfireX = (canvasWidth / (bonfireCount + 1)) * (i + 1);
|
|
360
|
-
const bonfireY = canvasHeight - 60;
|
|
361
|
-
|
|
362
|
-
decorations.push(this.createBonfire(canvasWidth, canvasHeight, {
|
|
363
|
-
x: bonfireX,
|
|
364
|
-
y: bonfireY
|
|
365
|
-
}));
|
|
366
|
-
|
|
367
|
-
// Guy effigy on top of bonfire
|
|
368
|
-
decorations.push(this.createGuyEffigy(canvasWidth, canvasHeight, bonfireX, bonfireY));
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// Catherine wheels mounted on sides
|
|
372
|
-
const wheelCount = Math.min(bonfireCount, 2);
|
|
373
|
-
for (let i = 0; i < wheelCount; i++) {
|
|
374
|
-
const side = i % 2 === 0 ? 'left' : 'right';
|
|
375
|
-
decorations.push(this.createCatherineWheel(canvasWidth, canvasHeight, {
|
|
376
|
-
x: side === 'left' ? 100 : canvasWidth - 100,
|
|
377
|
-
y: 150 + i * 100
|
|
378
|
-
}));
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Roman candles at ground level
|
|
382
|
-
const candleCount = Math.min(bonfireCount, 2);
|
|
383
|
-
for (let i = 0; i < candleCount; i++) {
|
|
384
|
-
decorations.push(this.createRomanCandle(canvasWidth, canvasHeight, {
|
|
385
|
-
x: 150 + i * ((canvasWidth - 300) / (candleCount)),
|
|
386
|
-
y: canvasHeight - 30
|
|
387
|
-
}));
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
// Sparkler bundles (decorative)
|
|
391
|
-
const sparklerCount = Math.min(bonfireCount + 1, 3);
|
|
392
|
-
for (let i = 0; i < sparklerCount; i++) {
|
|
393
|
-
decorations.push({
|
|
394
|
-
type: 'sparkler-bundle',
|
|
395
|
-
x: 80 + i * ((canvasWidth - 160) / (sparklerCount - 1)),
|
|
396
|
-
y: canvasHeight - 20,
|
|
397
|
-
size: 12 + Math.random() * 4,
|
|
398
|
-
opacity: 0.85,
|
|
399
|
-
sparklePhase: Math.random() * Math.PI * 2,
|
|
400
|
-
active: true,
|
|
401
|
-
static: true
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// Soft red moon (top right corner)
|
|
406
|
-
decorations.push({
|
|
407
|
-
type: 'moon',
|
|
408
|
-
x: canvasWidth - 120,
|
|
409
|
-
y: 100,
|
|
410
|
-
size: 60 + Math.random() * 20,
|
|
411
|
-
opacity: 0.75,
|
|
412
|
-
glowPhase: Math.random() * Math.PI * 2,
|
|
413
|
-
active: true,
|
|
414
|
-
static: true
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
return decorations;
|
|
418
|
-
},
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Spawn special Guy Fawkes particles
|
|
422
|
-
*/
|
|
423
|
-
spawnSpecialParticle(specialParticles, canvasWidth, canvasHeight, config) {
|
|
424
|
-
const choice = Math.random();
|
|
425
|
-
|
|
426
|
-
// Fireworks (uses Christmas firework code!)
|
|
427
|
-
if (choice < config.fireworkChance) {
|
|
428
|
-
// Random explosion height between 20% and 70% of screen height (always visible)
|
|
429
|
-
const targetY = canvasHeight * (0.2 + Math.random() * 0.5);
|
|
430
|
-
const startY = canvasHeight;
|
|
431
|
-
const distance = startY - targetY;
|
|
432
|
-
|
|
433
|
-
// Calculate velocity to reach target in reasonable time
|
|
434
|
-
const flightTime = 40 + Math.random() * 20; // 40-60 frames (~0.7-1 second)
|
|
435
|
-
const vy = -(distance / flightTime);
|
|
436
|
-
|
|
437
|
-
return {
|
|
438
|
-
type: 'firework',
|
|
439
|
-
x: Math.random() * canvasWidth,
|
|
440
|
-
y: startY,
|
|
441
|
-
targetY: targetY, // Explosion height
|
|
442
|
-
vx: (Math.random() - 0.5) * 3, // Slight horizontal drift
|
|
443
|
-
vy: vy, // Calculated to reach target
|
|
444
|
-
size: 2 + Math.random() * 2,
|
|
445
|
-
opacity: 1,
|
|
446
|
-
active: true,
|
|
447
|
-
static: false,
|
|
448
|
-
time: 0,
|
|
449
|
-
exploded: false,
|
|
450
|
-
explosionTime: flightTime, // Time to reach target
|
|
451
|
-
color: this.colors.firework[Math.floor(Math.random() * this.colors.firework.length)]
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// Bonfire (rare, max 3)
|
|
456
|
-
if (choice < 0.0003) {
|
|
457
|
-
const bonfireCount = specialParticles.filter(p => p.type === 'bonfire').length;
|
|
458
|
-
if (bonfireCount < config.bonfires) {
|
|
459
|
-
return this.createBonfire(canvasWidth, canvasHeight);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// Catherine wheel (rare)
|
|
464
|
-
if (choice < 0.0005) {
|
|
465
|
-
return this.createCatherineWheel(canvasWidth, canvasHeight);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
// Roman candle (rare)
|
|
469
|
-
if (choice < 0.0008) {
|
|
470
|
-
return this.createRomanCandle(canvasWidth, canvasHeight);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
return null;
|
|
474
|
-
},
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* Update special particles (fireworks, sparks, etc.)
|
|
478
|
-
*/
|
|
479
|
-
updateSpecialParticles(specialParticles, deltaTime) {
|
|
480
|
-
// Update lightning effect
|
|
481
|
-
if (this.lightningActive) {
|
|
482
|
-
this.lightningTimer += deltaTime;
|
|
483
|
-
if (this.lightningTimer >= this.lightningDuration) {
|
|
484
|
-
this.lightningActive = false;
|
|
485
|
-
this.lightningTimer = 0;
|
|
486
|
-
}
|
|
487
|
-
} else {
|
|
488
|
-
if (Math.random() < this.lightningChance) {
|
|
489
|
-
this.lightningActive = true;
|
|
490
|
-
this.lightningTimer = 0;
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
for (const particle of specialParticles) {
|
|
495
|
-
// Increment time for animated particles
|
|
496
|
-
if (particle.time !== undefined) {
|
|
497
|
-
particle.time++;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
// Check firework explosion
|
|
501
|
-
if (particle.type === 'firework' && !particle.exploded) {
|
|
502
|
-
// Explode when reached target height OR after flight time
|
|
503
|
-
const reachedTarget = particle.targetY && particle.y <= particle.targetY;
|
|
504
|
-
const timeExpired = particle.time >= particle.explosionTime;
|
|
505
|
-
|
|
506
|
-
if (reachedTarget || timeExpired) {
|
|
507
|
-
particle.exploded = true;
|
|
508
|
-
this.explodeFirework(particle, specialParticles);
|
|
509
|
-
particle.active = false; // Remove the firework itself
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
// Fade out sparks
|
|
514
|
-
if (particle.type === 'spark') {
|
|
515
|
-
particle.opacity -= 0.015;
|
|
516
|
-
particle.vy += 0.15; // Gravity
|
|
517
|
-
if (particle.opacity <= 0) {
|
|
518
|
-
particle.active = false;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
// Update Catherine Wheel
|
|
523
|
-
if (particle.type === 'catherine-wheel') {
|
|
524
|
-
particle.rotation += particle.rotationSpeed * (deltaTime / 16); // Normalize rotation speed
|
|
525
|
-
particle.time += deltaTime;
|
|
526
|
-
|
|
527
|
-
// Deactivate after duration
|
|
528
|
-
if (particle.time > particle.duration) {
|
|
529
|
-
particle.active = false;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
// Emit new sparks
|
|
533
|
-
particle.sparkTimer += deltaTime;
|
|
534
|
-
if (particle.sparkTimer >= particle.sparkInterval) {
|
|
535
|
-
particle.sparkTimer = 0;
|
|
536
|
-
// Emit multiple sparks per interval
|
|
537
|
-
const numSparks = 2 + Math.floor(Math.random() * 3); // 2-4 sparks
|
|
538
|
-
for (let i = 0; i < numSparks; i++) {
|
|
539
|
-
const angle = Math.random() * Math.PI * 2; // Random direction
|
|
540
|
-
const speed = 1 + Math.random() * 3;
|
|
541
|
-
particle.sparks.push({
|
|
542
|
-
x: 0, // Relative to wheel center
|
|
543
|
-
y: 0, // Relative to wheel center
|
|
544
|
-
vx: Math.cos(angle) * speed,
|
|
545
|
-
vy: Math.sin(angle) * speed,
|
|
546
|
-
size: 1 + Math.random() * 1.5,
|
|
547
|
-
opacity: 1,
|
|
548
|
-
life: 1.0,
|
|
549
|
-
fadeRate: 0.05 + Math.random() * 0.03,
|
|
550
|
-
color: this.colors.firework[Math.floor(Math.random() * this.colors.firework.length)]
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
// Update existing sparks
|
|
556
|
-
particle.sparks = particle.sparks.filter(spark => {
|
|
557
|
-
spark.x += spark.vx;
|
|
558
|
-
spark.y += spark.vy;
|
|
559
|
-
spark.life -= spark.fadeRate;
|
|
560
|
-
spark.opacity = Math.max(0, spark.life);
|
|
561
|
-
return spark.life > 0;
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
},
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Draw floating ember
|
|
569
|
-
*/
|
|
570
|
-
drawEmber(ctx, particle, time) {
|
|
571
|
-
// Safety check: validate particle properties
|
|
572
|
-
if (!isFinite(particle.x) || !isFinite(particle.y) || !isFinite(particle.size) ||
|
|
573
|
-
!isFinite(particle.vx) || !isFinite(particle.vy)) {
|
|
574
|
-
console.warn('[Guy Fawkes] Invalid ember particle values, deactivating:', particle);
|
|
575
|
-
particle.active = false;
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
// Update physics - rising motion
|
|
580
|
-
if (!particle.exploded) {
|
|
581
|
-
particle.x += particle.vx;
|
|
582
|
-
particle.y += particle.vy;
|
|
583
|
-
particle.vy += 0.02; // Slight gravity
|
|
584
|
-
|
|
585
|
-
// Validate after update
|
|
586
|
-
if (!isFinite(particle.x) || !isFinite(particle.y)) {
|
|
587
|
-
console.warn('[Guy Fawkes] Ember particle became non-finite after update, deactivating');
|
|
588
|
-
particle.active = false;
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// Check if reached target height
|
|
593
|
-
if (particle.y <= particle.targetY) {
|
|
594
|
-
particle.exploded = true;
|
|
595
|
-
// Create DRAMATIC explosion particles (MORE and BIGGER!)
|
|
596
|
-
const explosionCount = 50 + Math.floor(Math.random() * 40); // 50-90 particles
|
|
597
|
-
for (let i = 0; i < explosionCount; i++) {
|
|
598
|
-
const angle = (i / explosionCount) * Math.PI * 2;
|
|
599
|
-
const speed = 2 + Math.random() * 5; // Faster spread
|
|
600
|
-
const isTracer = i % 5 === 0; // Every 5th particle is a bright tracer
|
|
601
|
-
particle.explosionParticles.push({
|
|
602
|
-
x: particle.x,
|
|
603
|
-
y: particle.y,
|
|
604
|
-
vx: Math.cos(angle) * speed,
|
|
605
|
-
vy: Math.sin(angle) * speed,
|
|
606
|
-
size: isTracer ? 2 + Math.random() * 2 : 0.8 + Math.random() * 2, // Bigger particles
|
|
607
|
-
color: isTracer ? '#ffffff' : this.colors.firework[Math.floor(Math.random() * this.colors.firework.length)],
|
|
608
|
-
opacity: 1,
|
|
609
|
-
life: 1.0,
|
|
610
|
-
trail: [] // Add trail for tracer particles
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
const x = particle.x;
|
|
617
|
-
const y = particle.y;
|
|
618
|
-
const size = particle.size;
|
|
619
|
-
|
|
620
|
-
ctx.save();
|
|
621
|
-
|
|
622
|
-
if (!particle.exploded) {
|
|
623
|
-
// Rising ember with trail
|
|
624
|
-
const glowIntensity = 0.8 + (Math.sin(time * 0.01 + particle.glowPhase) + 1) * 0.2;
|
|
625
|
-
|
|
626
|
-
// Trail
|
|
627
|
-
ctx.globalAlpha = 0.3;
|
|
628
|
-
ctx.strokeStyle = particle.trailColor;
|
|
629
|
-
ctx.lineWidth = size * 0.8;
|
|
630
|
-
ctx.lineCap = 'round';
|
|
631
|
-
ctx.beginPath();
|
|
632
|
-
ctx.moveTo(x, y);
|
|
633
|
-
ctx.lineTo(x - particle.vx * 5, y - particle.vy * 5);
|
|
634
|
-
ctx.stroke();
|
|
635
|
-
|
|
636
|
-
// Glow
|
|
637
|
-
const gradient = ctx.createRadialGradient(x, y, 0, x, y, size * 4);
|
|
638
|
-
gradient.addColorStop(0, particle.color);
|
|
639
|
-
gradient.addColorStop(0.5, `${particle.color}80`);
|
|
640
|
-
gradient.addColorStop(1, 'rgba(255, 69, 0, 0)');
|
|
641
|
-
ctx.globalAlpha = glowIntensity;
|
|
642
|
-
ctx.fillStyle = gradient;
|
|
643
|
-
ctx.fillRect(x - size * 4, y - size * 4, size * 8, size * 8);
|
|
644
|
-
|
|
645
|
-
// Core
|
|
646
|
-
ctx.globalAlpha = 1;
|
|
647
|
-
ctx.fillStyle = particle.color;
|
|
648
|
-
ctx.shadowColor = particle.color;
|
|
649
|
-
ctx.shadowBlur = size * 2;
|
|
650
|
-
ctx.beginPath();
|
|
651
|
-
ctx.arc(x, y, size, 0, Math.PI * 2);
|
|
652
|
-
ctx.fill();
|
|
653
|
-
} else {
|
|
654
|
-
// Draw explosion particles
|
|
655
|
-
particle.explosionParticles = particle.explosionParticles.filter(p => {
|
|
656
|
-
p.x += p.vx;
|
|
657
|
-
p.y += p.vy;
|
|
658
|
-
p.vy += 0.05; // Gravity on explosion particles
|
|
659
|
-
p.life -= 0.015;
|
|
660
|
-
p.opacity = p.life;
|
|
661
|
-
|
|
662
|
-
if (p.life <= 0) return false;
|
|
663
|
-
|
|
664
|
-
// Draw explosion particle
|
|
665
|
-
ctx.globalAlpha = p.opacity;
|
|
666
|
-
ctx.fillStyle = p.color;
|
|
667
|
-
ctx.shadowColor = p.color;
|
|
668
|
-
ctx.shadowBlur = p.size * 3;
|
|
669
|
-
ctx.beginPath();
|
|
670
|
-
ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
|
|
671
|
-
ctx.fill();
|
|
672
|
-
|
|
673
|
-
return true;
|
|
674
|
-
});
|
|
675
|
-
|
|
676
|
-
// Deactivate when all explosion particles are gone
|
|
677
|
-
if (particle.explosionParticles.length === 0) {
|
|
678
|
-
particle.active = false;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
ctx.restore();
|
|
683
|
-
},
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* Draw bonfire with animated flames
|
|
687
|
-
*/
|
|
688
|
-
drawBonfire(ctx, particle, time) {
|
|
689
|
-
const x = particle.x;
|
|
690
|
-
const y = particle.y;
|
|
691
|
-
const size = particle.size;
|
|
692
|
-
|
|
693
|
-
ctx.save();
|
|
694
|
-
ctx.translate(x, y);
|
|
695
|
-
|
|
696
|
-
// Logs (wood pile)
|
|
697
|
-
ctx.fillStyle = '#8B4513';
|
|
698
|
-
ctx.strokeStyle = '#654321';
|
|
699
|
-
ctx.lineWidth = 2;
|
|
700
|
-
|
|
701
|
-
// Bottom log
|
|
702
|
-
ctx.fillRect(-size * 0.8, size * 0.3, size * 1.6, size * 0.3);
|
|
703
|
-
ctx.strokeRect(-size * 0.8, size * 0.3, size * 1.6, size * 0.3);
|
|
704
|
-
|
|
705
|
-
// Middle logs (crossed)
|
|
706
|
-
ctx.save();
|
|
707
|
-
ctx.rotate(-0.3);
|
|
708
|
-
ctx.fillRect(-size * 0.7, size * 0.1, size * 1.4, size * 0.25);
|
|
709
|
-
ctx.strokeRect(-size * 0.7, size * 0.1, size * 1.4, size * 0.25);
|
|
710
|
-
ctx.restore();
|
|
711
|
-
|
|
712
|
-
ctx.save();
|
|
713
|
-
ctx.rotate(0.3);
|
|
714
|
-
ctx.fillRect(-size * 0.7, size * 0.1, size * 1.4, size * 0.25);
|
|
715
|
-
ctx.strokeRect(-size * 0.7, size * 0.1, size * 1.4, size * 0.25);
|
|
716
|
-
ctx.restore();
|
|
717
|
-
|
|
718
|
-
// Animated flames (BIGGER and MORE DRAMATIC!)
|
|
719
|
-
const flameCount = 12; // More flames for fuller effect
|
|
720
|
-
for (let i = 0; i < flameCount; i++) {
|
|
721
|
-
const flameX = -size * 0.6 + (i / flameCount) * size * 1.2;
|
|
722
|
-
// Taller, more dynamic flames
|
|
723
|
-
const flameHeight = size * (1.2 + Math.sin(time * 0.006 + i) * 0.5);
|
|
724
|
-
const flameWidth = size * (0.2 + Math.sin(time * 0.01 + i * 0.5) * 0.12);
|
|
725
|
-
|
|
726
|
-
// More dramatic flame gradient with white-hot core
|
|
727
|
-
const flameGradient = ctx.createLinearGradient(flameX, 0, flameX, -flameHeight);
|
|
728
|
-
flameGradient.addColorStop(0, '#ffffff'); // White-hot base
|
|
729
|
-
flameGradient.addColorStop(0.15, '#ffff00'); // Yellow
|
|
730
|
-
flameGradient.addColorStop(0.4, '#ffa500'); // Orange
|
|
731
|
-
flameGradient.addColorStop(0.7, '#ff4500'); // Red-orange
|
|
732
|
-
flameGradient.addColorStop(0.85, '#ff0000'); // Red
|
|
733
|
-
flameGradient.addColorStop(1, 'rgba(139, 0, 0, 0)'); // Dark red fade
|
|
734
|
-
|
|
735
|
-
ctx.fillStyle = flameGradient;
|
|
736
|
-
ctx.globalAlpha = 0.85;
|
|
737
|
-
ctx.shadowColor = '#ff6600';
|
|
738
|
-
ctx.shadowBlur = size * 0.3;
|
|
739
|
-
|
|
740
|
-
ctx.beginPath();
|
|
741
|
-
ctx.moveTo(flameX, 0);
|
|
742
|
-
// More exaggerated, flickering shape
|
|
743
|
-
ctx.bezierCurveTo(
|
|
744
|
-
flameX - flameWidth, -flameHeight * 0.4,
|
|
745
|
-
flameX - flameWidth * 0.6, -flameHeight * 0.7,
|
|
746
|
-
flameX, -flameHeight
|
|
747
|
-
);
|
|
748
|
-
ctx.bezierCurveTo(
|
|
749
|
-
flameX + flameWidth * 0.6, -flameHeight * 0.7,
|
|
750
|
-
flameX + flameWidth, -flameHeight * 0.4,
|
|
751
|
-
flameX, 0
|
|
752
|
-
);
|
|
753
|
-
ctx.closePath();
|
|
754
|
-
ctx.fill();
|
|
755
|
-
}
|
|
756
|
-
ctx.shadowBlur = 0;
|
|
757
|
-
ctx.globalAlpha = 1;
|
|
758
|
-
|
|
759
|
-
// Glow
|
|
760
|
-
const glowGradient = ctx.createRadialGradient(0, 0, 0, 0, 0, size * 2);
|
|
761
|
-
glowGradient.addColorStop(0, 'rgba(255, 165, 0, 0.4)');
|
|
762
|
-
glowGradient.addColorStop(0.5, 'rgba(255, 69, 0, 0.2)');
|
|
763
|
-
glowGradient.addColorStop(1, 'rgba(255, 69, 0, 0)');
|
|
764
|
-
ctx.fillStyle = glowGradient;
|
|
765
|
-
ctx.fillRect(-size * 2, -size * 2, size * 4, size * 2);
|
|
766
|
-
|
|
767
|
-
// Sparks/embers rising from fire
|
|
768
|
-
for (let i = 0; i < 5; i++) {
|
|
769
|
-
const sparkX = (Math.random() - 0.5) * size * 0.8;
|
|
770
|
-
const sparkY = -size * Math.random() * 1.5;
|
|
771
|
-
const sparkSize = 1 + Math.random() * 2;
|
|
772
|
-
ctx.fillStyle = Math.random() < 0.5 ? '#ffa500' : '#ffff00';
|
|
773
|
-
ctx.globalAlpha = Math.random() * 0.8;
|
|
774
|
-
ctx.beginPath();
|
|
775
|
-
ctx.arc(sparkX, sparkY, sparkSize, 0, Math.PI * 2);
|
|
776
|
-
ctx.fill();
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
ctx.restore();
|
|
780
|
-
},
|
|
781
|
-
|
|
782
|
-
/**
|
|
783
|
-
* Draw Guy Fawkes effigy
|
|
784
|
-
*/
|
|
785
|
-
drawGuyEffigy(ctx, particle, time) {
|
|
786
|
-
const x = particle.x;
|
|
787
|
-
const y = particle.y;
|
|
788
|
-
const size = particle.size;
|
|
789
|
-
|
|
790
|
-
ctx.save();
|
|
791
|
-
ctx.globalAlpha = particle.opacity * (1 - particle.burnProgress);
|
|
792
|
-
ctx.translate(x, y);
|
|
793
|
-
|
|
794
|
-
// Body (straw/cloth)
|
|
795
|
-
ctx.fillStyle = '#8B7355';
|
|
796
|
-
ctx.fillRect(-size * 0.4, 0, size * 0.8, size * 1.5);
|
|
797
|
-
|
|
798
|
-
// Arms
|
|
799
|
-
ctx.fillRect(-size * 0.9, size * 0.3, size * 0.5, size * 0.2);
|
|
800
|
-
ctx.fillRect(size * 0.4, size * 0.3, size * 0.5, size * 0.2);
|
|
801
|
-
|
|
802
|
-
// Head (sack/mask)
|
|
803
|
-
ctx.fillStyle = '#D2B48C';
|
|
804
|
-
ctx.beginPath();
|
|
805
|
-
ctx.arc(0, -size * 0.3, size * 0.5, 0, Math.PI * 2);
|
|
806
|
-
ctx.fill();
|
|
807
|
-
|
|
808
|
-
// Hat
|
|
809
|
-
ctx.fillStyle = '#4a4a4a';
|
|
810
|
-
ctx.fillRect(-size * 0.6, -size * 0.8, size * 1.2, size * 0.2);
|
|
811
|
-
ctx.fillRect(-size * 0.4, -size * 1.2, size * 0.8, size * 0.4);
|
|
812
|
-
|
|
813
|
-
// Face (scary mask)
|
|
814
|
-
ctx.fillStyle = '#000000';
|
|
815
|
-
// Eyes
|
|
816
|
-
ctx.fillRect(-size * 0.25, -size * 0.4, size * 0.15, size * 0.2);
|
|
817
|
-
ctx.fillRect(size * 0.1, -size * 0.4, size * 0.15, size * 0.2);
|
|
818
|
-
|
|
819
|
-
// Mouth (grin)
|
|
820
|
-
ctx.beginPath();
|
|
821
|
-
ctx.arc(0, -size * 0.1, size * 0.25, 0, Math.PI);
|
|
822
|
-
ctx.fill();
|
|
823
|
-
|
|
824
|
-
// Burning effect if burning
|
|
825
|
-
if (particle.burning) {
|
|
826
|
-
ctx.globalAlpha = 1;
|
|
827
|
-
const fireGradient = ctx.createRadialGradient(0, 0, 0, 0, 0, size * 2);
|
|
828
|
-
fireGradient.addColorStop(0, 'rgba(255, 255, 0, 0.8)');
|
|
829
|
-
fireGradient.addColorStop(0.5, 'rgba(255, 69, 0, 0.5)');
|
|
830
|
-
fireGradient.addColorStop(1, 'rgba(255, 0, 0, 0)');
|
|
831
|
-
ctx.fillStyle = fireGradient;
|
|
832
|
-
ctx.fillRect(-size * 2, -size * 2, size * 4, size * 4);
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
ctx.restore();
|
|
836
|
-
},
|
|
837
|
-
|
|
838
|
-
/**
|
|
839
|
-
* Draw Catherine wheel (spinning firework) - IMPROVED
|
|
840
|
-
*/
|
|
841
|
-
drawCatherineWheel(ctx, particle, time) {
|
|
842
|
-
const x = particle.x;
|
|
843
|
-
const y = particle.y;
|
|
844
|
-
const size = particle.size;
|
|
845
|
-
|
|
846
|
-
ctx.save();
|
|
847
|
-
ctx.translate(x, y);
|
|
848
|
-
ctx.rotate(particle.rotation);
|
|
849
|
-
|
|
850
|
-
// Center pin/mount
|
|
851
|
-
ctx.fillStyle = '#654321'; // Dark wood/metal color
|
|
852
|
-
ctx.beginPath();
|
|
853
|
-
ctx.arc(0, 0, size * 0.1, 0, Math.PI * 2);
|
|
854
|
-
ctx.fill();
|
|
855
|
-
|
|
856
|
-
// Wheel structure (concentric circles, more defined)
|
|
857
|
-
ctx.strokeStyle = '#8B4513'; // Brownish for the cardboard/wood wheel
|
|
858
|
-
ctx.lineWidth = size * 0.15;
|
|
859
|
-
ctx.beginPath();
|
|
860
|
-
ctx.arc(0, 0, size * 0.6, 0, Math.PI * 2);
|
|
861
|
-
ctx.stroke();
|
|
862
|
-
|
|
863
|
-
ctx.strokeStyle = '#cc6600'; // Inner ring for color
|
|
864
|
-
ctx.lineWidth = size * 0.1;
|
|
865
|
-
ctx.beginPath();
|
|
866
|
-
ctx.arc(0, 0, size * 0.4, 0, Math.PI * 2);
|
|
867
|
-
ctx.stroke();
|
|
868
|
-
|
|
869
|
-
// Outer firework tubes/spokes
|
|
870
|
-
const tubeCount = 8;
|
|
871
|
-
for (let i = 0; i < tubeCount; i++) {
|
|
872
|
-
const angle = (i / tubeCount) * Math.PI * 2;
|
|
873
|
-
const tubeX = Math.cos(angle) * size * 0.7;
|
|
874
|
-
const tubeY = Math.sin(angle) * size * 0.7;
|
|
875
|
-
|
|
876
|
-
ctx.fillStyle = '#444444'; // Dark grey for tubes
|
|
877
|
-
ctx.strokeStyle = '#222222';
|
|
878
|
-
ctx.lineWidth = 1;
|
|
879
|
-
ctx.beginPath();
|
|
880
|
-
ctx.arc(tubeX, tubeY, size * 0.15, 0, Math.PI * 2);
|
|
881
|
-
ctx.fill();
|
|
882
|
-
ctx.stroke();
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
// Draw emitted sparks
|
|
886
|
-
particle.sparks.forEach(spark => {
|
|
887
|
-
ctx.save();
|
|
888
|
-
ctx.translate(spark.x, spark.y);
|
|
889
|
-
|
|
890
|
-
// Spark glow
|
|
891
|
-
const glowGradient = ctx.createRadialGradient(0, 0, 0, 0, 0, spark.size * 5);
|
|
892
|
-
glowGradient.addColorStop(0, spark.color);
|
|
893
|
-
glowGradient.addColorStop(0.5, `${spark.color}80`);
|
|
894
|
-
glowGradient.addColorStop(1, 'rgba(255, 69, 0, 0)'); // Fade to transparent orange/red
|
|
895
|
-
ctx.fillStyle = glowGradient;
|
|
896
|
-
ctx.globalAlpha = spark.opacity * 0.6;
|
|
897
|
-
ctx.fillRect(-spark.size * 5, -spark.size * 5, spark.size * 10, spark.size * 10);
|
|
898
|
-
|
|
899
|
-
// Spark core
|
|
900
|
-
ctx.globalAlpha = spark.opacity;
|
|
901
|
-
ctx.fillStyle = spark.color;
|
|
902
|
-
ctx.shadowColor = spark.color;
|
|
903
|
-
ctx.shadowBlur = spark.size * 3;
|
|
904
|
-
ctx.beginPath();
|
|
905
|
-
ctx.arc(0, 0, spark.size, 0, Math.PI * 2);
|
|
906
|
-
ctx.fill();
|
|
907
|
-
|
|
908
|
-
ctx.restore();
|
|
909
|
-
});
|
|
910
|
-
|
|
911
|
-
// Pulsing inner glow from the active wheel
|
|
912
|
-
const innerGlowIntensity = 0.6 + Math.sin(time * 0.01) * 0.4;
|
|
913
|
-
ctx.globalAlpha = innerGlowIntensity * particle.opacity;
|
|
914
|
-
const innerGlow = ctx.createRadialGradient(0, 0, 0, 0, 0, size);
|
|
915
|
-
innerGlow.addColorStop(0, 'rgba(255, 200, 0, 0.7)');
|
|
916
|
-
innerGlow.addColorStop(0.5, 'rgba(255, 100, 0, 0.4)');
|
|
917
|
-
innerGlow.addColorStop(1, 'rgba(255, 0, 0, 0)');
|
|
918
|
-
ctx.fillStyle = innerGlow;
|
|
919
|
-
ctx.beginPath();
|
|
920
|
-
ctx.arc(0, 0, size, 0, Math.PI * 2);
|
|
921
|
-
ctx.fill();
|
|
922
|
-
|
|
923
|
-
ctx.shadowBlur = 0;
|
|
924
|
-
ctx.restore();
|
|
925
|
-
},
|
|
926
|
-
|
|
927
|
-
/**
|
|
928
|
-
* Draw Roman candle
|
|
929
|
-
*/
|
|
930
|
-
drawRomanCandle(ctx, particle, time) {
|
|
931
|
-
const x = particle.x;
|
|
932
|
-
const y = particle.y;
|
|
933
|
-
const size = particle.size;
|
|
934
|
-
|
|
935
|
-
ctx.save();
|
|
936
|
-
ctx.translate(x, y);
|
|
937
|
-
|
|
938
|
-
// Candle body (tube)
|
|
939
|
-
ctx.fillStyle = '#c00';
|
|
940
|
-
ctx.strokeStyle = '#800';
|
|
941
|
-
ctx.lineWidth = 2;
|
|
942
|
-
ctx.fillRect(-size * 0.4, 0, size * 0.8, size * 2);
|
|
943
|
-
ctx.strokeRect(-size * 0.4, 0, size * 0.8, size * 2);
|
|
944
|
-
|
|
945
|
-
// Gold label
|
|
946
|
-
ctx.fillStyle = '#ffd700';
|
|
947
|
-
ctx.fillRect(-size * 0.3, size * 0.8, size * 0.6, size * 0.5);
|
|
948
|
-
|
|
949
|
-
// Fuse/top
|
|
950
|
-
ctx.fillStyle = '#654321';
|
|
951
|
-
ctx.fillRect(-size * 0.2, -size * 0.3, size * 0.4, size * 0.3);
|
|
952
|
-
|
|
953
|
-
// Spark at top when firing
|
|
954
|
-
if (particle.shotCount < particle.maxShots) {
|
|
955
|
-
const sparkIntensity = Math.sin(time * 0.05) * 0.5 + 0.5;
|
|
956
|
-
ctx.fillStyle = `rgba(255, 255, 0, ${sparkIntensity})`;
|
|
957
|
-
ctx.shadowColor = '#ffff00';
|
|
958
|
-
ctx.shadowBlur = 15;
|
|
959
|
-
ctx.beginPath();
|
|
960
|
-
ctx.arc(0, -size * 0.2, size * 0.3, 0, Math.PI * 2);
|
|
961
|
-
ctx.fill();
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
ctx.shadowBlur = 0;
|
|
965
|
-
ctx.restore();
|
|
966
|
-
|
|
967
|
-
// Draw shots in flight
|
|
968
|
-
particle.shots.forEach(shot => {
|
|
969
|
-
ctx.save();
|
|
970
|
-
ctx.globalAlpha = shot.opacity;
|
|
971
|
-
|
|
972
|
-
// Trail
|
|
973
|
-
ctx.strokeStyle = shot.color;
|
|
974
|
-
ctx.lineWidth = 3;
|
|
975
|
-
ctx.shadowColor = shot.color;
|
|
976
|
-
ctx.shadowBlur = 10;
|
|
977
|
-
ctx.beginPath();
|
|
978
|
-
ctx.moveTo(shot.x, shot.y);
|
|
979
|
-
ctx.lineTo(shot.x, shot.y + 10);
|
|
980
|
-
ctx.stroke();
|
|
981
|
-
|
|
982
|
-
// Core
|
|
983
|
-
ctx.fillStyle = shot.color;
|
|
984
|
-
ctx.beginPath();
|
|
985
|
-
ctx.arc(shot.x, shot.y, shot.size, 0, Math.PI * 2);
|
|
986
|
-
ctx.fill();
|
|
987
|
-
|
|
988
|
-
ctx.shadowBlur = 0;
|
|
989
|
-
ctx.restore();
|
|
990
|
-
});
|
|
991
|
-
},
|
|
992
|
-
|
|
993
|
-
/**
|
|
994
|
-
* Draw sparkler bundle (decorative handheld fireworks)
|
|
995
|
-
*/
|
|
996
|
-
drawSparklerBundle(ctx, particle, time) {
|
|
997
|
-
const x = particle.x;
|
|
998
|
-
const y = particle.y;
|
|
999
|
-
const size = particle.size;
|
|
1000
|
-
|
|
1001
|
-
ctx.save();
|
|
1002
|
-
ctx.globalAlpha = particle.opacity;
|
|
1003
|
-
ctx.translate(x, y);
|
|
1004
|
-
|
|
1005
|
-
// Bundle of sparklers (5 sticks)
|
|
1006
|
-
const sparklerCount = 5;
|
|
1007
|
-
const spread = size * 0.15;
|
|
1008
|
-
|
|
1009
|
-
for (let i = 0; i < sparklerCount; i++) {
|
|
1010
|
-
const offsetX = (i - 2) * spread;
|
|
1011
|
-
const tilt = (i - 2) * 0.05;
|
|
1012
|
-
|
|
1013
|
-
ctx.save();
|
|
1014
|
-
ctx.translate(offsetX, 0);
|
|
1015
|
-
ctx.rotate(tilt);
|
|
1016
|
-
|
|
1017
|
-
// Stick (metallic wire)
|
|
1018
|
-
ctx.strokeStyle = '#888888';
|
|
1019
|
-
ctx.lineWidth = size * 0.08;
|
|
1020
|
-
ctx.lineCap = 'round';
|
|
1021
|
-
ctx.beginPath();
|
|
1022
|
-
ctx.moveTo(0, 0);
|
|
1023
|
-
ctx.lineTo(0, -size * 1.8);
|
|
1024
|
-
ctx.stroke();
|
|
1025
|
-
|
|
1026
|
-
// Sparkler tip (lit)
|
|
1027
|
-
const sparkIntensity = Math.sin(time * 0.01 + particle.sparklePhase + i * 0.5) * 0.5 + 0.5;
|
|
1028
|
-
const tipGradient = ctx.createRadialGradient(0, -size * 1.8, 0, 0, -size * 1.8, size * 0.5);
|
|
1029
|
-
tipGradient.addColorStop(0, `rgba(255, 255, 255, ${sparkIntensity})`);
|
|
1030
|
-
tipGradient.addColorStop(0.4, `rgba(255, 215, 0, ${sparkIntensity * 0.8})`);
|
|
1031
|
-
tipGradient.addColorStop(0.7, `rgba(255, 140, 0, ${sparkIntensity * 0.5})`);
|
|
1032
|
-
tipGradient.addColorStop(1, 'rgba(255, 69, 0, 0)');
|
|
1033
|
-
|
|
1034
|
-
ctx.fillStyle = tipGradient;
|
|
1035
|
-
ctx.beginPath();
|
|
1036
|
-
ctx.arc(0, -size * 1.8, size * 0.5, 0, Math.PI * 2);
|
|
1037
|
-
ctx.fill();
|
|
1038
|
-
|
|
1039
|
-
// Tiny sparks flying off
|
|
1040
|
-
const sparkCount = 3;
|
|
1041
|
-
for (let j = 0; j < sparkCount; j++) {
|
|
1042
|
-
const sparkAngle = Math.random() * Math.PI * 2;
|
|
1043
|
-
const sparkDist = size * (0.6 + Math.random() * 0.4);
|
|
1044
|
-
const sparkX = Math.cos(sparkAngle) * sparkDist;
|
|
1045
|
-
const sparkY = -size * 1.8 + Math.sin(sparkAngle) * sparkDist;
|
|
1046
|
-
const sparkSize = size * (0.05 + Math.random() * 0.08);
|
|
1047
|
-
|
|
1048
|
-
ctx.fillStyle = Math.random() < 0.5 ? '#ffffff' : '#ffd700';
|
|
1049
|
-
ctx.shadowColor = ctx.fillStyle;
|
|
1050
|
-
ctx.shadowBlur = size * 0.3;
|
|
1051
|
-
ctx.globalAlpha = particle.opacity * Math.random() * 0.8;
|
|
1052
|
-
|
|
1053
|
-
ctx.beginPath();
|
|
1054
|
-
ctx.arc(sparkX, sparkY, sparkSize, 0, Math.PI * 2);
|
|
1055
|
-
ctx.fill();
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
ctx.restore();
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
// Handle/holder at bottom
|
|
1062
|
-
ctx.fillStyle = '#654321';
|
|
1063
|
-
ctx.fillRect(-size * 0.5, -size * 0.2, size, size * 0.4);
|
|
1064
|
-
|
|
1065
|
-
ctx.shadowBlur = 0;
|
|
1066
|
-
ctx.restore();
|
|
1067
|
-
},
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* Draw firework (reuses Christmas firework code)
|
|
1071
|
-
*/
|
|
1072
|
-
drawFirework(ctx, particle) {
|
|
1073
|
-
return christmas.drawFirework(ctx, particle);
|
|
1074
|
-
},
|
|
1075
|
-
|
|
1076
|
-
/**
|
|
1077
|
-
* Explode firework (reuses Christmas explosion code)
|
|
1078
|
-
*/
|
|
1079
|
-
explodeFirework(particle, specialParticles) {
|
|
1080
|
-
// Use themed colors instead of Christmas colors
|
|
1081
|
-
const sparkCount = 60 + Math.random() * 60;
|
|
1082
|
-
const colors = this.colors.firework;
|
|
1083
|
-
|
|
1084
|
-
for (let i = 0; i < sparkCount; i++) {
|
|
1085
|
-
const angle = Math.random() * Math.PI * 2;
|
|
1086
|
-
const speed = Math.random() * 6 + 3;
|
|
1087
|
-
specialParticles.push({
|
|
1088
|
-
type: 'spark',
|
|
1089
|
-
x: particle.x,
|
|
1090
|
-
y: particle.y,
|
|
1091
|
-
vx: Math.cos(angle) * speed,
|
|
1092
|
-
vy: Math.sin(angle) * speed,
|
|
1093
|
-
size: 2 + Math.random() * 2.5,
|
|
1094
|
-
opacity: 1,
|
|
1095
|
-
active: true,
|
|
1096
|
-
static: false,
|
|
1097
|
-
color: colors[Math.floor(Math.random() * colors.length)],
|
|
1098
|
-
trail: []
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
},
|
|
1102
|
-
|
|
1103
|
-
/**
|
|
1104
|
-
* Draw soft red moon (Bonfire Night atmosphere)
|
|
1105
|
-
*/
|
|
1106
|
-
drawMoon(ctx, particle, time) {
|
|
1107
|
-
const x = particle.x;
|
|
1108
|
-
const y = particle.y;
|
|
1109
|
-
const size = particle.size;
|
|
1110
|
-
|
|
1111
|
-
ctx.save();
|
|
1112
|
-
ctx.globalAlpha = particle.opacity;
|
|
1113
|
-
ctx.translate(x, y);
|
|
1114
|
-
|
|
1115
|
-
// Moon body (soft red/orange tint)
|
|
1116
|
-
const moonGradient = ctx.createRadialGradient(-size * 0.2, -size * 0.2, 0, 0, 0, size);
|
|
1117
|
-
moonGradient.addColorStop(0, '#ffb6a0'); // Soft peachy center
|
|
1118
|
-
moonGradient.addColorStop(0.5, '#ff8c66'); // Warm orange-red
|
|
1119
|
-
moonGradient.addColorStop(1, '#cc6644'); // Deeper red edge
|
|
1120
|
-
ctx.fillStyle = moonGradient;
|
|
1121
|
-
ctx.beginPath();
|
|
1122
|
-
ctx.arc(0, 0, size, 0, Math.PI * 2);
|
|
1123
|
-
ctx.fill();
|
|
1124
|
-
|
|
1125
|
-
// Craters (darker red)
|
|
1126
|
-
ctx.fillStyle = 'rgba(120, 50, 40, 0.25)';
|
|
1127
|
-
ctx.beginPath();
|
|
1128
|
-
ctx.arc(-size * 0.3, -size * 0.2, size * 0.15, 0, Math.PI * 2);
|
|
1129
|
-
ctx.fill();
|
|
1130
|
-
ctx.beginPath();
|
|
1131
|
-
ctx.arc(size * 0.25, size * 0.1, size * 0.2, 0, Math.PI * 2);
|
|
1132
|
-
ctx.fill();
|
|
1133
|
-
ctx.beginPath();
|
|
1134
|
-
ctx.arc(size * 0.1, -size * 0.4, size * 0.12, 0, Math.PI * 2);
|
|
1135
|
-
ctx.fill();
|
|
1136
|
-
|
|
1137
|
-
// Soft smoke wisps drifting across moon surface
|
|
1138
|
-
ctx.strokeStyle = 'rgba(100, 60, 50, 0.15)';
|
|
1139
|
-
ctx.lineWidth = size * 0.08;
|
|
1140
|
-
ctx.lineCap = 'round';
|
|
1141
|
-
const smokeWave = Math.sin(time * 0.001 + particle.glowPhase) * size * 0.3;
|
|
1142
|
-
for (let i = 0; i < 3; i++) {
|
|
1143
|
-
ctx.beginPath();
|
|
1144
|
-
const yPos = -size * 0.4 + i * size * 0.4;
|
|
1145
|
-
ctx.moveTo(-size * 0.8, yPos + smokeWave * (i % 2 === 0 ? 1 : -1));
|
|
1146
|
-
ctx.bezierCurveTo(
|
|
1147
|
-
-size * 0.3, yPos + smokeWave * 0.5,
|
|
1148
|
-
size * 0.3, yPos - smokeWave * 0.5,
|
|
1149
|
-
size * 0.8, yPos + smokeWave * (i % 2 === 0 ? -1 : 1)
|
|
1150
|
-
);
|
|
1151
|
-
ctx.stroke();
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
// Soft red glow (pulsing gently)
|
|
1155
|
-
const glowIntensity = 0.25 + Math.sin(time * 0.0015 + particle.glowPhase) * 0.1;
|
|
1156
|
-
ctx.globalAlpha = glowIntensity;
|
|
1157
|
-
const glowGradient = ctx.createRadialGradient(0, 0, size * 0.8, 0, 0, size * 2.0);
|
|
1158
|
-
glowGradient.addColorStop(0, 'rgba(255, 140, 100, 0.6)');
|
|
1159
|
-
glowGradient.addColorStop(0.5, 'rgba(255, 100, 80, 0.3)');
|
|
1160
|
-
glowGradient.addColorStop(1, 'rgba(255, 80, 60, 0)');
|
|
1161
|
-
ctx.fillStyle = glowGradient;
|
|
1162
|
-
ctx.beginPath();
|
|
1163
|
-
ctx.arc(0, 0, size * 2.0, 0, Math.PI * 2);
|
|
1164
|
-
ctx.fill();
|
|
1165
|
-
|
|
1166
|
-
ctx.restore();
|
|
1167
|
-
},
|
|
1168
|
-
|
|
1169
|
-
/**
|
|
1170
|
-
* Draw rocket particle (shoots up with trail, then explodes)
|
|
1171
|
-
*/
|
|
1172
|
-
drawRocket(ctx, particle, time) {
|
|
1173
|
-
ctx.save();
|
|
1174
|
-
|
|
1175
|
-
if (!particle.exploded) {
|
|
1176
|
-
// Update physics - upward flight
|
|
1177
|
-
particle.x += particle.vx;
|
|
1178
|
-
particle.y += particle.vy;
|
|
1179
|
-
particle.rotation += particle.rotationSpeed;
|
|
1180
|
-
|
|
1181
|
-
// Check if reached target explosion height
|
|
1182
|
-
if (particle.y <= particle.targetY) {
|
|
1183
|
-
particle.exploded = true;
|
|
1184
|
-
|
|
1185
|
-
// Create MASSIVE explosion - more burst particles than embers!
|
|
1186
|
-
const explosionCount = 80 + Math.floor(Math.random() * 60); // 80-140 particles!
|
|
1187
|
-
particle.explosionParticles = [];
|
|
1188
|
-
|
|
1189
|
-
for (let i = 0; i < explosionCount; i++) {
|
|
1190
|
-
const angle = (i / explosionCount) * Math.PI * 2;
|
|
1191
|
-
const speed = 2 + Math.random() * 6; // Fast explosive spread
|
|
1192
|
-
const isTracer = i % 6 === 0; // Every 6th particle is bright tracer
|
|
1193
|
-
|
|
1194
|
-
particle.explosionParticles.push({
|
|
1195
|
-
x: particle.x,
|
|
1196
|
-
y: particle.y,
|
|
1197
|
-
vx: Math.cos(angle) * speed,
|
|
1198
|
-
vy: Math.sin(angle) * speed,
|
|
1199
|
-
size: isTracer ? 2.5 + Math.random() * 2 : 1 + Math.random() * 2,
|
|
1200
|
-
color: isTracer ? '#ffffff' : this.colors.firework[Math.floor(Math.random() * this.colors.firework.length)],
|
|
1201
|
-
opacity: 1,
|
|
1202
|
-
life: 1.0,
|
|
1203
|
-
gravity: 0.05,
|
|
1204
|
-
sparkle: Math.random() < 0.3
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
const x = particle.x;
|
|
1210
|
-
const y = particle.y;
|
|
1211
|
-
const size = particle.size;
|
|
1212
|
-
|
|
1213
|
-
// Draw rocket trail
|
|
1214
|
-
const trailLength = 15;
|
|
1215
|
-
ctx.globalAlpha = 0.6;
|
|
1216
|
-
const trailGradient = ctx.createLinearGradient(x, y, x - particle.vx * trailLength, y - particle.vy * trailLength);
|
|
1217
|
-
trailGradient.addColorStop(0, particle.color);
|
|
1218
|
-
trailGradient.addColorStop(0.5, `${particle.color}80`);
|
|
1219
|
-
trailGradient.addColorStop(1, 'rgba(255, 69, 0, 0)');
|
|
1220
|
-
ctx.strokeStyle = trailGradient;
|
|
1221
|
-
ctx.lineWidth = size * 1.5;
|
|
1222
|
-
ctx.lineCap = 'round';
|
|
1223
|
-
ctx.beginPath();
|
|
1224
|
-
ctx.moveTo(x, y);
|
|
1225
|
-
ctx.lineTo(x - particle.vx * trailLength, y - particle.vy * trailLength);
|
|
1226
|
-
ctx.stroke();
|
|
1227
|
-
|
|
1228
|
-
// Rocket glow
|
|
1229
|
-
ctx.globalAlpha = 0.8;
|
|
1230
|
-
const glowGradient = ctx.createRadialGradient(x, y, 0, x, y, size * 5);
|
|
1231
|
-
glowGradient.addColorStop(0, particle.color);
|
|
1232
|
-
glowGradient.addColorStop(0.5, `${particle.color}60`);
|
|
1233
|
-
glowGradient.addColorStop(1, 'rgba(255, 69, 0, 0)');
|
|
1234
|
-
ctx.fillStyle = glowGradient;
|
|
1235
|
-
ctx.fillRect(x - size * 5, y - size * 5, size * 10, size * 10);
|
|
1236
|
-
|
|
1237
|
-
// Rocket core (bright white-hot center)
|
|
1238
|
-
ctx.globalAlpha = 1;
|
|
1239
|
-
ctx.fillStyle = '#ffffff';
|
|
1240
|
-
ctx.shadowColor = particle.color;
|
|
1241
|
-
ctx.shadowBlur = size * 3;
|
|
1242
|
-
ctx.beginPath();
|
|
1243
|
-
ctx.arc(x, y, size * 1.2, 0, Math.PI * 2);
|
|
1244
|
-
ctx.fill();
|
|
1245
|
-
|
|
1246
|
-
// Outer colored ring
|
|
1247
|
-
ctx.fillStyle = particle.color;
|
|
1248
|
-
ctx.shadowBlur = size * 2;
|
|
1249
|
-
ctx.beginPath();
|
|
1250
|
-
ctx.arc(x, y, size * 0.8, 0, Math.PI * 2);
|
|
1251
|
-
ctx.fill();
|
|
1252
|
-
} else {
|
|
1253
|
-
// Draw explosion particles (similar to ember explosions)
|
|
1254
|
-
particle.explosionParticles = particle.explosionParticles.filter(p => {
|
|
1255
|
-
p.x += p.vx;
|
|
1256
|
-
p.y += p.vy;
|
|
1257
|
-
p.vy += p.gravity; // Gravity pulls down
|
|
1258
|
-
p.life -= 0.012; // Faster fade than embers for dramatic effect
|
|
1259
|
-
p.opacity = p.life;
|
|
1260
|
-
|
|
1261
|
-
if (p.life <= 0) return false;
|
|
1262
|
-
|
|
1263
|
-
// Draw explosion particle with glow
|
|
1264
|
-
ctx.globalAlpha = p.opacity * 0.6;
|
|
1265
|
-
const glowGradient = ctx.createRadialGradient(p.x, p.y, 0, p.x, p.y, p.size * 4);
|
|
1266
|
-
glowGradient.addColorStop(0, p.color);
|
|
1267
|
-
glowGradient.addColorStop(0.5, `${p.color}60`);
|
|
1268
|
-
glowGradient.addColorStop(1, 'rgba(255, 69, 0, 0)');
|
|
1269
|
-
ctx.fillStyle = glowGradient;
|
|
1270
|
-
ctx.fillRect(p.x - p.size * 4, p.y - p.size * 4, p.size * 8, p.size * 8);
|
|
1271
|
-
|
|
1272
|
-
// Core
|
|
1273
|
-
ctx.globalAlpha = p.opacity;
|
|
1274
|
-
ctx.fillStyle = p.color;
|
|
1275
|
-
ctx.shadowColor = p.color;
|
|
1276
|
-
ctx.shadowBlur = p.size * 3;
|
|
1277
|
-
|
|
1278
|
-
// Sparkle effect
|
|
1279
|
-
if (p.sparkle && Math.random() < 0.3) {
|
|
1280
|
-
ctx.shadowBlur = p.size * 5;
|
|
1281
|
-
ctx.fillStyle = '#ffffff';
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
|
-
ctx.beginPath();
|
|
1285
|
-
ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
|
|
1286
|
-
ctx.fill();
|
|
1287
|
-
|
|
1288
|
-
return true;
|
|
1289
|
-
});
|
|
1290
|
-
|
|
1291
|
-
// Deactivate rocket when all explosion particles are gone
|
|
1292
|
-
if (particle.explosionParticles.length === 0) {
|
|
1293
|
-
particle.active = false;
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
ctx.shadowBlur = 0;
|
|
1298
|
-
ctx.restore();
|
|
1299
|
-
},
|
|
1300
|
-
|
|
1301
|
-
/**
|
|
1302
|
-
* Draw burst particle (explosion fragment)
|
|
1303
|
-
*/
|
|
1304
|
-
drawBurst(ctx, particle) {
|
|
1305
|
-
const x = particle.x;
|
|
1306
|
-
const y = particle.y;
|
|
1307
|
-
const size = particle.size;
|
|
1308
|
-
|
|
1309
|
-
ctx.save();
|
|
1310
|
-
|
|
1311
|
-
// Update physics
|
|
1312
|
-
particle.x += particle.vx;
|
|
1313
|
-
particle.y += particle.vy;
|
|
1314
|
-
particle.vy += particle.gravity; // Gravity pulls down
|
|
1315
|
-
particle.life -= particle.fadeRate;
|
|
1316
|
-
particle.opacity = Math.max(0, particle.life);
|
|
1317
|
-
|
|
1318
|
-
// Deactivate when faded out
|
|
1319
|
-
if (particle.life <= 0) {
|
|
1320
|
-
particle.active = false;
|
|
1321
|
-
ctx.restore();
|
|
1322
|
-
return;
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
// Glow effect
|
|
1326
|
-
ctx.globalAlpha = particle.opacity * 0.6;
|
|
1327
|
-
const glowGradient = ctx.createRadialGradient(x, y, 0, x, y, size * 4);
|
|
1328
|
-
glowGradient.addColorStop(0, particle.color);
|
|
1329
|
-
glowGradient.addColorStop(0.5, `${particle.color}60`);
|
|
1330
|
-
glowGradient.addColorStop(1, 'rgba(255, 69, 0, 0)');
|
|
1331
|
-
ctx.fillStyle = glowGradient;
|
|
1332
|
-
ctx.fillRect(x - size * 4, y - size * 4, size * 8, size * 8);
|
|
1333
|
-
|
|
1334
|
-
// Core particle
|
|
1335
|
-
ctx.globalAlpha = particle.opacity;
|
|
1336
|
-
ctx.fillStyle = particle.color;
|
|
1337
|
-
ctx.shadowColor = particle.color;
|
|
1338
|
-
ctx.shadowBlur = size * 2;
|
|
1339
|
-
|
|
1340
|
-
// Sparkle effect (randomly brighter)
|
|
1341
|
-
if (particle.sparkle && Math.random() < 0.3) {
|
|
1342
|
-
ctx.shadowBlur = size * 4;
|
|
1343
|
-
ctx.fillStyle = '#ffffff';
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
ctx.beginPath();
|
|
1347
|
-
ctx.arc(x, y, size, 0, Math.PI * 2);
|
|
1348
|
-
ctx.fill();
|
|
1349
|
-
|
|
1350
|
-
ctx.shadowBlur = 0;
|
|
1351
|
-
ctx.restore();
|
|
1352
|
-
},
|
|
1353
|
-
|
|
1354
|
-
/**
|
|
1355
|
-
* Draw trail particle (follows rockets)
|
|
1356
|
-
*/
|
|
1357
|
-
drawTrail(ctx, particle) {
|
|
1358
|
-
const x = particle.x;
|
|
1359
|
-
const y = particle.y;
|
|
1360
|
-
const size = particle.size;
|
|
1361
|
-
|
|
1362
|
-
ctx.save();
|
|
1363
|
-
|
|
1364
|
-
// Update physics
|
|
1365
|
-
particle.x += particle.vx;
|
|
1366
|
-
particle.y += particle.vy;
|
|
1367
|
-
particle.life -= particle.fadeRate;
|
|
1368
|
-
particle.opacity = Math.max(0, particle.life * 0.8);
|
|
1369
|
-
|
|
1370
|
-
// Deactivate when faded out
|
|
1371
|
-
if (particle.life <= 0) {
|
|
1372
|
-
particle.active = false;
|
|
1373
|
-
ctx.restore();
|
|
1374
|
-
return;
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1377
|
-
// Glow
|
|
1378
|
-
ctx.globalAlpha = particle.opacity * 0.4;
|
|
1379
|
-
const glowGradient = ctx.createRadialGradient(x, y, 0, x, y, size * 3);
|
|
1380
|
-
glowGradient.addColorStop(0, particle.color);
|
|
1381
|
-
glowGradient.addColorStop(0.6, `${particle.color}40`);
|
|
1382
|
-
glowGradient.addColorStop(1, 'rgba(255, 215, 0, 0)');
|
|
1383
|
-
ctx.fillStyle = glowGradient;
|
|
1384
|
-
ctx.fillRect(x - size * 3, y - size * 3, size * 6, size * 6);
|
|
1385
|
-
|
|
1386
|
-
// Core
|
|
1387
|
-
ctx.globalAlpha = particle.opacity;
|
|
1388
|
-
ctx.fillStyle = particle.color;
|
|
1389
|
-
ctx.shadowColor = particle.color;
|
|
1390
|
-
ctx.shadowBlur = size * 1.5;
|
|
1391
|
-
ctx.beginPath();
|
|
1392
|
-
ctx.arc(x, y, size, 0, Math.PI * 2);
|
|
1393
|
-
ctx.fill();
|
|
1394
|
-
|
|
1395
|
-
ctx.shadowBlur = 0;
|
|
1396
|
-
ctx.restore();
|
|
1397
|
-
},
|
|
1398
|
-
|
|
1399
|
-
/**
|
|
1400
|
-
* Draw spark particle (small glowing bits)
|
|
1401
|
-
*/
|
|
1402
|
-
drawSpark(ctx, particle) {
|
|
1403
|
-
const x = particle.x;
|
|
1404
|
-
const y = particle.y;
|
|
1405
|
-
const size = particle.size;
|
|
1406
|
-
|
|
1407
|
-
ctx.save();
|
|
1408
|
-
|
|
1409
|
-
// Update physics
|
|
1410
|
-
particle.x += particle.vx;
|
|
1411
|
-
particle.y += particle.vy;
|
|
1412
|
-
particle.life -= particle.fadeRate;
|
|
1413
|
-
particle.opacity = Math.max(0, particle.life);
|
|
1414
|
-
|
|
1415
|
-
// Deactivate when faded out
|
|
1416
|
-
if (particle.life <= 0) {
|
|
1417
|
-
particle.active = false;
|
|
1418
|
-
ctx.restore();
|
|
1419
|
-
return;
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
// Glow
|
|
1423
|
-
ctx.globalAlpha = particle.opacity * 0.5;
|
|
1424
|
-
const glowGradient = ctx.createRadialGradient(x, y, 0, x, y, size * 3);
|
|
1425
|
-
glowGradient.addColorStop(0, particle.color);
|
|
1426
|
-
glowGradient.addColorStop(0.5, `${particle.color}60`);
|
|
1427
|
-
glowGradient.addColorStop(1, 'rgba(255, 215, 0, 0)');
|
|
1428
|
-
ctx.fillStyle = glowGradient;
|
|
1429
|
-
ctx.fillRect(x - size * 3, y - size * 3, size * 6, size * 6);
|
|
1430
|
-
|
|
1431
|
-
// Core (very small, bright gold)
|
|
1432
|
-
ctx.globalAlpha = particle.opacity;
|
|
1433
|
-
ctx.fillStyle = particle.color;
|
|
1434
|
-
ctx.shadowColor = particle.color;
|
|
1435
|
-
ctx.shadowBlur = size * 2;
|
|
1436
|
-
ctx.beginPath();
|
|
1437
|
-
ctx.arc(x, y, size * 0.8, 0, Math.PI * 2);
|
|
1438
|
-
ctx.fill();
|
|
1439
|
-
|
|
1440
|
-
ctx.shadowBlur = 0;
|
|
1441
|
-
ctx.restore();
|
|
1442
|
-
},
|
|
1443
|
-
|
|
1444
|
-
/**
|
|
1445
|
-
* Draw global theme effects (e.g., lightning)
|
|
1446
|
-
*/
|
|
1447
|
-
drawGlobalEffects(ctx, currentTime, canvasWidth, canvasHeight) {
|
|
1448
|
-
if (this.lightningActive) {
|
|
1449
|
-
ctx.save();
|
|
1450
|
-
ctx.globalAlpha = 0.8 + Math.sin(this.lightningTimer * 0.01) * 0.2; // Pulsing effect during flash
|
|
1451
|
-
ctx.shadowColor = this.lightningColor;
|
|
1452
|
-
ctx.shadowBlur = 20;
|
|
1453
|
-
|
|
1454
|
-
// Draw main lightning bolt from top-center to random bottom position
|
|
1455
|
-
const startX = canvasWidth * (0.4 + Math.random() * 0.2); // Top middle
|
|
1456
|
-
const startY = 0;
|
|
1457
|
-
const endX = canvasWidth * Math.random();
|
|
1458
|
-
const endY = canvasHeight;
|
|
1459
|
-
|
|
1460
|
-
this.drawLightning(
|
|
1461
|
-
ctx,
|
|
1462
|
-
startX,
|
|
1463
|
-
startY,
|
|
1464
|
-
endX,
|
|
1465
|
-
endY,
|
|
1466
|
-
5 + Math.floor(Math.random() * 3), // 5-7 segments
|
|
1467
|
-
50 + Math.random() * 50, // 50-100 displacement
|
|
1468
|
-
0.7, // Roughness
|
|
1469
|
-
0.3, // Branch chance
|
|
1470
|
-
3 + Math.random() * 2, // Line width
|
|
1471
|
-
this.lightningColor
|
|
1472
|
-
);
|
|
1473
|
-
|
|
1474
|
-
ctx.restore();
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
};
|
|
1
|
+
import R from"./christmas.js";export default{name:"guy-fawkes",displayName:"Guy Fawkes Night",emoji:"\u{1F386}",intensityConfig:{light:{count:60,initialParticleRatio:.25,speedRange:[.5,1.5],sizeRange:[2,4],bonfires:1,fireworkChance:9e-4,rocketChance:7e-4,burstChance:.0012},medium:{count:120,initialParticleRatio:.25,speedRange:[.5,2],sizeRange:[2,5],bonfires:2,fireworkChance:.0011,rocketChance:9e-4,burstChance:.0015},heavy:{count:200,initialParticleRatio:.25,speedRange:[.5,2.5],sizeRange:[3,6],bonfires:3,fireworkChance:.0014,rocketChance:.0012,burstChance:.0018}},particles:["ember","firework","spark","rocket","burst","trail"],decorations:["bonfire","guy-effigy","catherine-wheel","roman-candle","sparkler-bundle","moon"],colors:{primary:"#ff4500",secondary:"#ffd700",accent:"#8b0000",fire:["#ff4500","#ffa500","#ffff00","#ff0000"],firework:["#ff0000","#ffff00","#00ff00","#0000ff","#ff00ff","#00ffff","#ffffff"]},lightningChance:5e-4,lightningDuration:200,lightningTimer:0,lightningActive:!1,lightningColor:"#fefefe",drawLightning(o,e,n,r,l,a,t,f,i,s,h){if(a<1)return;const d=(e+r)/2,y=(n+l)/2,g=Math.atan2(l-n,r-e),b=g+Math.PI/2,S=(Math.random()-.5)*t,M=d+Math.cos(b)*S,m=y+Math.sin(b)*S,u=a-1,w=t*f,C=s*.8;if(o.strokeStyle=h,o.lineWidth=s,o.lineCap="round",o.lineJoin="round",o.beginPath(),o.moveTo(e,n),o.lineTo(M,m),o.lineTo(r,l),o.stroke(),u>0&&(this.drawLightning(o,e,n,M,m,u,w,f,i,C,h),this.drawLightning(o,M,m,r,l,u,w,f,i,C,h),Math.random()<i&&u>1)){const P=Math.random()*t*.5,v=(Math.random()-.5)*Math.PI/3,k=M+Math.cos(g+v)*P,z=m+Math.sin(g+v)*P;this.drawLightning(o,M,m,k,z,u-1,w*.5,f,i*.5,C*.6,h)}},createEmber(o,e,n){const r=n?.sizeRange||[2,4],l=n?.speedRange||[.5,1.5],a=this.colors.firework,t=Math.random()*o,f=e-50,i=100+Math.random()*300;return{type:"ember",x:t,y:f,vx:(Math.random()-.5)*1.5,vy:-2-Math.random()*2,targetY:i,size:r[0]+Math.random()*(r[1]-r[0]),speed:l[0]+Math.random()*(l[1]-l[0]),opacity:1,color:a[Math.floor(Math.random()*a.length)],trailColor:a[Math.floor(Math.random()*a.length)],glowPhase:Math.random()*Math.PI*2,exploded:!1,explosionParticles:[],active:!0}},createBonfire(o,e,n={}){return{type:"bonfire",x:n.x!==void 0?n.x:Math.random()*o*.6+o*.2,y:n.y!==void 0?n.y:e-60,size:30+Math.random()*20,opacity:1,flames:[],logs:[],embers:[],time:0,cracklePhase:0,active:!0,static:!0}},createGuyEffigy(o,e,n,r){return{type:"guy-effigy",x:n,y:r-50,size:20+Math.random()*10,opacity:.8,burning:!1,burnProgress:0,active:!0,static:!0}},createCatherineWheel(o,e,n={}){return{type:"catherine-wheel",x:n.x!==void 0?n.x:Math.random()*o,y:n.y!==void 0?n.y:100+Math.random()*200,size:15+Math.random()*10,opacity:1,rotation:0,rotationSpeed:.05+Math.random()*.1,sparks:[],sparkTimer:0,sparkInterval:50,time:0,duration:5e3+Math.random()*3e3,active:!0,static:!0}},createRomanCandle(o,e,n={}){return{type:"roman-candle",x:n.x!==void 0?n.x:Math.random()*o,y:n.y!==void 0?n.y:e-30,size:8+Math.random()*4,opacity:1,shots:[],shotInterval:800+Math.random()*400,lastShotTime:0,shotCount:0,maxShots:5+Math.floor(Math.random()*5),time:0,active:!0,static:!0}},createRocket(o,e,n){const r=n?.sizeRange||[2,4],l=50+Math.random()*(o-100),a=80+Math.random()*150;return{type:"rocket",x:l,y:e-20,vx:(Math.random()-.5)*.5,vy:-3-Math.random()*2,targetY:a,size:r[0]+Math.random()*(r[1]-r[0]),opacity:1,color:this.colors.firework[Math.floor(Math.random()*this.colors.firework.length)],trail:[],exploded:!1,rotation:Math.random()*Math.PI*2,rotationSpeed:(Math.random()-.5)*.1,active:!0}},createBurst(o,e,n,r){const l=n?.sizeRange||[1,3],a=Math.random()*Math.PI*2,t=1+Math.random()*4;return{type:"burst",x:r?.x||o/2,y:r?.y||e/2,vx:Math.cos(a)*t,vy:Math.sin(a)*t,size:l[0]+Math.random()*(l[1]-l[0]),opacity:1,color:this.colors.firework[Math.floor(Math.random()*this.colors.firework.length)],life:1,fadeRate:.015+Math.random()*.015,gravity:.05,sparkle:Math.random()<.3,active:!0}},createTrail(o,e,n,r){const l=n?.sizeRange||[1,2];return{type:"trail",x:r?.x||o/2,y:r?.y||e/2,vx:(Math.random()-.5)*.3,vy:(Math.random()-.5)*.3,size:l[0]+Math.random()*(l[1]-l[0]),opacity:.8,color:r?.color||"#ffd700",life:1,fadeRate:.03+Math.random()*.02,active:!0}},createSpark(o,e,n,r){const l=n?.sizeRange||[.5,1.5],a=Math.random()*Math.PI*2,t=.5+Math.random()*2;return{type:"spark",x:r?.x||Math.random()*o,y:r?.y||Math.random()*e,vx:Math.cos(a)*t,vy:Math.sin(a)*t,size:l[0]+Math.random()*(l[1]-l[0]),opacity:1,color:this.colors.secondary,life:1,fadeRate:.02+Math.random()*.02,active:!0}},createFallingParticle(o,e,n){return this.createEmber(o,e,n)},createInitialDecorations(o,e,n){const r=[],l=n.bonfires||2;for(let i=0;i<l;i++){const s=o/(l+1)*(i+1),h=e-60;r.push(this.createBonfire(o,e,{x:s,y:h})),r.push(this.createGuyEffigy(o,e,s,h))}const a=Math.min(l,2);for(let i=0;i<a;i++){const s=i%2===0?"left":"right";r.push(this.createCatherineWheel(o,e,{x:s==="left"?100:o-100,y:150+i*100}))}const t=Math.min(l,2);for(let i=0;i<t;i++)r.push(this.createRomanCandle(o,e,{x:150+i*((o-300)/t),y:e-30}));const f=Math.min(l+1,3);for(let i=0;i<f;i++)r.push({type:"sparkler-bundle",x:80+i*((o-160)/(f-1)),y:e-20,size:12+Math.random()*4,opacity:.85,sparklePhase:Math.random()*Math.PI*2,active:!0,static:!0});return r.push({type:"moon",x:o-120,y:100,size:60+Math.random()*20,opacity:.75,glowPhase:Math.random()*Math.PI*2,active:!0,static:!0}),r},spawnSpecialParticle(o,e,n,r){const l=Math.random();if(l<r.fireworkChance){const a=n*(.2+Math.random()*.5),t=n,f=t-a,i=40+Math.random()*20,s=-(f/i);return{type:"firework",x:Math.random()*e,y:t,targetY:a,vx:(Math.random()-.5)*3,vy:s,size:2+Math.random()*2,opacity:1,active:!0,static:!1,time:0,exploded:!1,explosionTime:i,color:this.colors.firework[Math.floor(Math.random()*this.colors.firework.length)]}}return l<3e-4&&o.filter(t=>t.type==="bonfire").length<r.bonfires?this.createBonfire(e,n):l<5e-4?this.createCatherineWheel(e,n):l<8e-4?this.createRomanCandle(e,n):null},updateSpecialParticles(o,e){this.lightningActive?(this.lightningTimer+=e,this.lightningTimer>=this.lightningDuration&&(this.lightningActive=!1,this.lightningTimer=0)):Math.random()<this.lightningChance&&(this.lightningActive=!0,this.lightningTimer=0);for(const n of o){if(n.time!==void 0&&n.time++,n.type==="firework"&&!n.exploded){const r=n.targetY&&n.y<=n.targetY,l=n.time>=n.explosionTime;(r||l)&&(n.exploded=!0,this.explodeFirework(n,o),n.active=!1)}if(n.type==="spark"&&(n.opacity-=.015,n.vy+=.15,n.opacity<=0&&(n.active=!1)),n.type==="catherine-wheel"){if(n.rotation+=n.rotationSpeed*(e/16),n.time+=e,n.time>n.duration&&(n.active=!1),n.sparkTimer+=e,n.sparkTimer>=n.sparkInterval){n.sparkTimer=0;const r=2+Math.floor(Math.random()*3);for(let l=0;l<r;l++){const a=Math.random()*Math.PI*2,t=1+Math.random()*3;n.sparks.push({x:0,y:0,vx:Math.cos(a)*t,vy:Math.sin(a)*t,size:1+Math.random()*1.5,opacity:1,life:1,fadeRate:.05+Math.random()*.03,color:this.colors.firework[Math.floor(Math.random()*this.colors.firework.length)]})}}n.sparks=n.sparks.filter(r=>(r.x+=r.vx,r.y+=r.vy,r.life-=r.fadeRate,r.opacity=Math.max(0,r.life),r.life>0))}}},drawEmber(o,e,n){if(!isFinite(e.x)||!isFinite(e.y)||!isFinite(e.size)||!isFinite(e.vx)||!isFinite(e.vy)){console.warn("[Guy Fawkes] Invalid ember particle values, deactivating:",e),e.active=!1;return}if(!e.exploded){if(e.x+=e.vx,e.y+=e.vy,e.vy+=.02,!isFinite(e.x)||!isFinite(e.y)){console.warn("[Guy Fawkes] Ember particle became non-finite after update, deactivating"),e.active=!1;return}if(e.y<=e.targetY){e.exploded=!0;const t=50+Math.floor(Math.random()*40);for(let f=0;f<t;f++){const i=f/t*Math.PI*2,s=2+Math.random()*5,h=f%5===0;e.explosionParticles.push({x:e.x,y:e.y,vx:Math.cos(i)*s,vy:Math.sin(i)*s,size:h?2+Math.random()*2:.8+Math.random()*2,color:h?"#ffffff":this.colors.firework[Math.floor(Math.random()*this.colors.firework.length)],opacity:1,life:1,trail:[]})}}}const r=e.x,l=e.y,a=e.size;if(o.save(),e.exploded)e.explosionParticles=e.explosionParticles.filter(t=>(t.x+=t.vx,t.y+=t.vy,t.vy+=.05,t.life-=.015,t.opacity=t.life,t.life<=0?!1:(o.globalAlpha=t.opacity,o.fillStyle=t.color,o.shadowColor=t.color,o.shadowBlur=t.size*3,o.beginPath(),o.arc(t.x,t.y,t.size,0,Math.PI*2),o.fill(),!0))),e.explosionParticles.length===0&&(e.active=!1);else{const t=.8+(Math.sin(n*.01+e.glowPhase)+1)*.2;o.globalAlpha=.3,o.strokeStyle=e.trailColor,o.lineWidth=a*.8,o.lineCap="round",o.beginPath(),o.moveTo(r,l),o.lineTo(r-e.vx*5,l-e.vy*5),o.stroke();const f=o.createRadialGradient(r,l,0,r,l,a*4);f.addColorStop(0,e.color),f.addColorStop(.5,`${e.color}80`),f.addColorStop(1,"rgba(255, 69, 0, 0)"),o.globalAlpha=t,o.fillStyle=f,o.fillRect(r-a*4,l-a*4,a*8,a*8),o.globalAlpha=1,o.fillStyle=e.color,o.shadowColor=e.color,o.shadowBlur=a*2,o.beginPath(),o.arc(r,l,a,0,Math.PI*2),o.fill()}o.restore()},drawBonfire(o,e,n){const r=e.x,l=e.y,a=e.size;o.save(),o.translate(r,l),o.fillStyle="#8B4513",o.strokeStyle="#654321",o.lineWidth=2,o.fillRect(-a*.8,a*.3,a*1.6,a*.3),o.strokeRect(-a*.8,a*.3,a*1.6,a*.3),o.save(),o.rotate(-.3),o.fillRect(-a*.7,a*.1,a*1.4,a*.25),o.strokeRect(-a*.7,a*.1,a*1.4,a*.25),o.restore(),o.save(),o.rotate(.3),o.fillRect(-a*.7,a*.1,a*1.4,a*.25),o.strokeRect(-a*.7,a*.1,a*1.4,a*.25),o.restore();const t=12;for(let i=0;i<t;i++){const s=-a*.6+i/t*a*1.2,h=a*(1.2+Math.sin(n*.006+i)*.5),d=a*(.2+Math.sin(n*.01+i*.5)*.12),y=o.createLinearGradient(s,0,s,-h);y.addColorStop(0,"#ffffff"),y.addColorStop(.15,"#ffff00"),y.addColorStop(.4,"#ffa500"),y.addColorStop(.7,"#ff4500"),y.addColorStop(.85,"#ff0000"),y.addColorStop(1,"rgba(139, 0, 0, 0)"),o.fillStyle=y,o.globalAlpha=.85,o.shadowColor="#ff6600",o.shadowBlur=a*.3,o.beginPath(),o.moveTo(s,0),o.bezierCurveTo(s-d,-h*.4,s-d*.6,-h*.7,s,-h),o.bezierCurveTo(s+d*.6,-h*.7,s+d,-h*.4,s,0),o.closePath(),o.fill()}o.shadowBlur=0,o.globalAlpha=1;const f=o.createRadialGradient(0,0,0,0,0,a*2);f.addColorStop(0,"rgba(255, 165, 0, 0.4)"),f.addColorStop(.5,"rgba(255, 69, 0, 0.2)"),f.addColorStop(1,"rgba(255, 69, 0, 0)"),o.fillStyle=f,o.fillRect(-a*2,-a*2,a*4,a*2);for(let i=0;i<5;i++){const s=(Math.random()-.5)*a*.8,h=-a*Math.random()*1.5,d=1+Math.random()*2;o.fillStyle=Math.random()<.5?"#ffa500":"#ffff00",o.globalAlpha=Math.random()*.8,o.beginPath(),o.arc(s,h,d,0,Math.PI*2),o.fill()}o.restore()},drawGuyEffigy(o,e,n){const r=e.x,l=e.y,a=e.size;if(o.save(),o.globalAlpha=e.opacity*(1-e.burnProgress),o.translate(r,l),o.fillStyle="#8B7355",o.fillRect(-a*.4,0,a*.8,a*1.5),o.fillRect(-a*.9,a*.3,a*.5,a*.2),o.fillRect(a*.4,a*.3,a*.5,a*.2),o.fillStyle="#D2B48C",o.beginPath(),o.arc(0,-a*.3,a*.5,0,Math.PI*2),o.fill(),o.fillStyle="#4a4a4a",o.fillRect(-a*.6,-a*.8,a*1.2,a*.2),o.fillRect(-a*.4,-a*1.2,a*.8,a*.4),o.fillStyle="#000000",o.fillRect(-a*.25,-a*.4,a*.15,a*.2),o.fillRect(a*.1,-a*.4,a*.15,a*.2),o.beginPath(),o.arc(0,-a*.1,a*.25,0,Math.PI),o.fill(),e.burning){o.globalAlpha=1;const t=o.createRadialGradient(0,0,0,0,0,a*2);t.addColorStop(0,"rgba(255, 255, 0, 0.8)"),t.addColorStop(.5,"rgba(255, 69, 0, 0.5)"),t.addColorStop(1,"rgba(255, 0, 0, 0)"),o.fillStyle=t,o.fillRect(-a*2,-a*2,a*4,a*4)}o.restore()},drawCatherineWheel(o,e,n){const r=e.x,l=e.y,a=e.size;o.save(),o.translate(r,l),o.rotate(e.rotation),o.fillStyle="#654321",o.beginPath(),o.arc(0,0,a*.1,0,Math.PI*2),o.fill(),o.strokeStyle="#8B4513",o.lineWidth=a*.15,o.beginPath(),o.arc(0,0,a*.6,0,Math.PI*2),o.stroke(),o.strokeStyle="#cc6600",o.lineWidth=a*.1,o.beginPath(),o.arc(0,0,a*.4,0,Math.PI*2),o.stroke();const t=8;for(let s=0;s<t;s++){const h=s/t*Math.PI*2,d=Math.cos(h)*a*.7,y=Math.sin(h)*a*.7;o.fillStyle="#444444",o.strokeStyle="#222222",o.lineWidth=1,o.beginPath(),o.arc(d,y,a*.15,0,Math.PI*2),o.fill(),o.stroke()}e.sparks.forEach(s=>{o.save(),o.translate(s.x,s.y);const h=o.createRadialGradient(0,0,0,0,0,s.size*5);h.addColorStop(0,s.color),h.addColorStop(.5,`${s.color}80`),h.addColorStop(1,"rgba(255, 69, 0, 0)"),o.fillStyle=h,o.globalAlpha=s.opacity*.6,o.fillRect(-s.size*5,-s.size*5,s.size*10,s.size*10),o.globalAlpha=s.opacity,o.fillStyle=s.color,o.shadowColor=s.color,o.shadowBlur=s.size*3,o.beginPath(),o.arc(0,0,s.size,0,Math.PI*2),o.fill(),o.restore()});const f=.6+Math.sin(n*.01)*.4;o.globalAlpha=f*e.opacity;const i=o.createRadialGradient(0,0,0,0,0,a);i.addColorStop(0,"rgba(255, 200, 0, 0.7)"),i.addColorStop(.5,"rgba(255, 100, 0, 0.4)"),i.addColorStop(1,"rgba(255, 0, 0, 0)"),o.fillStyle=i,o.beginPath(),o.arc(0,0,a,0,Math.PI*2),o.fill(),o.shadowBlur=0,o.restore()},drawRomanCandle(o,e,n){const r=e.x,l=e.y,a=e.size;if(o.save(),o.translate(r,l),o.fillStyle="#c00",o.strokeStyle="#800",o.lineWidth=2,o.fillRect(-a*.4,0,a*.8,a*2),o.strokeRect(-a*.4,0,a*.8,a*2),o.fillStyle="#ffd700",o.fillRect(-a*.3,a*.8,a*.6,a*.5),o.fillStyle="#654321",o.fillRect(-a*.2,-a*.3,a*.4,a*.3),e.shotCount<e.maxShots){const t=Math.sin(n*.05)*.5+.5;o.fillStyle=`rgba(255, 255, 0, ${t})`,o.shadowColor="#ffff00",o.shadowBlur=15,o.beginPath(),o.arc(0,-a*.2,a*.3,0,Math.PI*2),o.fill()}o.shadowBlur=0,o.restore(),e.shots.forEach(t=>{o.save(),o.globalAlpha=t.opacity,o.strokeStyle=t.color,o.lineWidth=3,o.shadowColor=t.color,o.shadowBlur=10,o.beginPath(),o.moveTo(t.x,t.y),o.lineTo(t.x,t.y+10),o.stroke(),o.fillStyle=t.color,o.beginPath(),o.arc(t.x,t.y,t.size,0,Math.PI*2),o.fill(),o.shadowBlur=0,o.restore()})},drawSparklerBundle(o,e,n){const r=e.x,l=e.y,a=e.size;o.save(),o.globalAlpha=e.opacity,o.translate(r,l);const t=5,f=a*.15;for(let i=0;i<t;i++){const s=(i-2)*f,h=(i-2)*.05;o.save(),o.translate(s,0),o.rotate(h),o.strokeStyle="#888888",o.lineWidth=a*.08,o.lineCap="round",o.beginPath(),o.moveTo(0,0),o.lineTo(0,-a*1.8),o.stroke();const d=Math.sin(n*.01+e.sparklePhase+i*.5)*.5+.5,y=o.createRadialGradient(0,-a*1.8,0,0,-a*1.8,a*.5);y.addColorStop(0,`rgba(255, 255, 255, ${d})`),y.addColorStop(.4,`rgba(255, 215, 0, ${d*.8})`),y.addColorStop(.7,`rgba(255, 140, 0, ${d*.5})`),y.addColorStop(1,"rgba(255, 69, 0, 0)"),o.fillStyle=y,o.beginPath(),o.arc(0,-a*1.8,a*.5,0,Math.PI*2),o.fill();const g=3;for(let b=0;b<g;b++){const S=Math.random()*Math.PI*2,M=a*(.6+Math.random()*.4),m=Math.cos(S)*M,u=-a*1.8+Math.sin(S)*M,w=a*(.05+Math.random()*.08);o.fillStyle=Math.random()<.5?"#ffffff":"#ffd700",o.shadowColor=o.fillStyle,o.shadowBlur=a*.3,o.globalAlpha=e.opacity*Math.random()*.8,o.beginPath(),o.arc(m,u,w,0,Math.PI*2),o.fill()}o.restore()}o.fillStyle="#654321",o.fillRect(-a*.5,-a*.2,a,a*.4),o.shadowBlur=0,o.restore()},drawFirework(o,e){return R.drawFirework(o,e)},explodeFirework(o,e){const n=60+Math.random()*60,r=this.colors.firework;for(let l=0;l<n;l++){const a=Math.random()*Math.PI*2,t=Math.random()*6+3;e.push({type:"spark",x:o.x,y:o.y,vx:Math.cos(a)*t,vy:Math.sin(a)*t,size:2+Math.random()*2.5,opacity:1,active:!0,static:!1,color:r[Math.floor(Math.random()*r.length)],trail:[]})}},drawMoon(o,e,n){const r=e.x,l=e.y,a=e.size;o.save(),o.globalAlpha=e.opacity,o.translate(r,l);const t=o.createRadialGradient(-a*.2,-a*.2,0,0,0,a);t.addColorStop(0,"#ffb6a0"),t.addColorStop(.5,"#ff8c66"),t.addColorStop(1,"#cc6644"),o.fillStyle=t,o.beginPath(),o.arc(0,0,a,0,Math.PI*2),o.fill(),o.fillStyle="rgba(120, 50, 40, 0.25)",o.beginPath(),o.arc(-a*.3,-a*.2,a*.15,0,Math.PI*2),o.fill(),o.beginPath(),o.arc(a*.25,a*.1,a*.2,0,Math.PI*2),o.fill(),o.beginPath(),o.arc(a*.1,-a*.4,a*.12,0,Math.PI*2),o.fill(),o.strokeStyle="rgba(100, 60, 50, 0.15)",o.lineWidth=a*.08,o.lineCap="round";const f=Math.sin(n*.001+e.glowPhase)*a*.3;for(let h=0;h<3;h++){o.beginPath();const d=-a*.4+h*a*.4;o.moveTo(-a*.8,d+f*(h%2===0?1:-1)),o.bezierCurveTo(-a*.3,d+f*.5,a*.3,d-f*.5,a*.8,d+f*(h%2===0?-1:1)),o.stroke()}const i=.25+Math.sin(n*.0015+e.glowPhase)*.1;o.globalAlpha=i;const s=o.createRadialGradient(0,0,a*.8,0,0,a*2);s.addColorStop(0,"rgba(255, 140, 100, 0.6)"),s.addColorStop(.5,"rgba(255, 100, 80, 0.3)"),s.addColorStop(1,"rgba(255, 80, 60, 0)"),o.fillStyle=s,o.beginPath(),o.arc(0,0,a*2,0,Math.PI*2),o.fill(),o.restore()},drawRocket(o,e,n){if(o.save(),e.exploded)e.explosionParticles=e.explosionParticles.filter(r=>{if(r.x+=r.vx,r.y+=r.vy,r.vy+=r.gravity,r.life-=.012,r.opacity=r.life,r.life<=0)return!1;o.globalAlpha=r.opacity*.6;const l=o.createRadialGradient(r.x,r.y,0,r.x,r.y,r.size*4);return l.addColorStop(0,r.color),l.addColorStop(.5,`${r.color}60`),l.addColorStop(1,"rgba(255, 69, 0, 0)"),o.fillStyle=l,o.fillRect(r.x-r.size*4,r.y-r.size*4,r.size*8,r.size*8),o.globalAlpha=r.opacity,o.fillStyle=r.color,o.shadowColor=r.color,o.shadowBlur=r.size*3,r.sparkle&&Math.random()<.3&&(o.shadowBlur=r.size*5,o.fillStyle="#ffffff"),o.beginPath(),o.arc(r.x,r.y,r.size,0,Math.PI*2),o.fill(),!0}),e.explosionParticles.length===0&&(e.active=!1);else{if(e.x+=e.vx,e.y+=e.vy,e.rotation+=e.rotationSpeed,e.y<=e.targetY){e.exploded=!0;const s=80+Math.floor(Math.random()*60);e.explosionParticles=[];for(let h=0;h<s;h++){const d=h/s*Math.PI*2,y=2+Math.random()*6,g=h%6===0;e.explosionParticles.push({x:e.x,y:e.y,vx:Math.cos(d)*y,vy:Math.sin(d)*y,size:g?2.5+Math.random()*2:1+Math.random()*2,color:g?"#ffffff":this.colors.firework[Math.floor(Math.random()*this.colors.firework.length)],opacity:1,life:1,gravity:.05,sparkle:Math.random()<.3})}}const r=e.x,l=e.y,a=e.size,t=15;o.globalAlpha=.6;const f=o.createLinearGradient(r,l,r-e.vx*t,l-e.vy*t);f.addColorStop(0,e.color),f.addColorStop(.5,`${e.color}80`),f.addColorStop(1,"rgba(255, 69, 0, 0)"),o.strokeStyle=f,o.lineWidth=a*1.5,o.lineCap="round",o.beginPath(),o.moveTo(r,l),o.lineTo(r-e.vx*t,l-e.vy*t),o.stroke(),o.globalAlpha=.8;const i=o.createRadialGradient(r,l,0,r,l,a*5);i.addColorStop(0,e.color),i.addColorStop(.5,`${e.color}60`),i.addColorStop(1,"rgba(255, 69, 0, 0)"),o.fillStyle=i,o.fillRect(r-a*5,l-a*5,a*10,a*10),o.globalAlpha=1,o.fillStyle="#ffffff",o.shadowColor=e.color,o.shadowBlur=a*3,o.beginPath(),o.arc(r,l,a*1.2,0,Math.PI*2),o.fill(),o.fillStyle=e.color,o.shadowBlur=a*2,o.beginPath(),o.arc(r,l,a*.8,0,Math.PI*2),o.fill()}o.shadowBlur=0,o.restore()},drawBurst(o,e){const n=e.x,r=e.y,l=e.size;if(o.save(),e.x+=e.vx,e.y+=e.vy,e.vy+=e.gravity,e.life-=e.fadeRate,e.opacity=Math.max(0,e.life),e.life<=0){e.active=!1,o.restore();return}o.globalAlpha=e.opacity*.6;const a=o.createRadialGradient(n,r,0,n,r,l*4);a.addColorStop(0,e.color),a.addColorStop(.5,`${e.color}60`),a.addColorStop(1,"rgba(255, 69, 0, 0)"),o.fillStyle=a,o.fillRect(n-l*4,r-l*4,l*8,l*8),o.globalAlpha=e.opacity,o.fillStyle=e.color,o.shadowColor=e.color,o.shadowBlur=l*2,e.sparkle&&Math.random()<.3&&(o.shadowBlur=l*4,o.fillStyle="#ffffff"),o.beginPath(),o.arc(n,r,l,0,Math.PI*2),o.fill(),o.shadowBlur=0,o.restore()},drawTrail(o,e){const n=e.x,r=e.y,l=e.size;if(o.save(),e.x+=e.vx,e.y+=e.vy,e.life-=e.fadeRate,e.opacity=Math.max(0,e.life*.8),e.life<=0){e.active=!1,o.restore();return}o.globalAlpha=e.opacity*.4;const a=o.createRadialGradient(n,r,0,n,r,l*3);a.addColorStop(0,e.color),a.addColorStop(.6,`${e.color}40`),a.addColorStop(1,"rgba(255, 215, 0, 0)"),o.fillStyle=a,o.fillRect(n-l*3,r-l*3,l*6,l*6),o.globalAlpha=e.opacity,o.fillStyle=e.color,o.shadowColor=e.color,o.shadowBlur=l*1.5,o.beginPath(),o.arc(n,r,l,0,Math.PI*2),o.fill(),o.shadowBlur=0,o.restore()},drawSpark(o,e){const n=e.x,r=e.y,l=e.size;if(o.save(),e.x+=e.vx,e.y+=e.vy,e.life-=e.fadeRate,e.opacity=Math.max(0,e.life),e.life<=0){e.active=!1,o.restore();return}o.globalAlpha=e.opacity*.5;const a=o.createRadialGradient(n,r,0,n,r,l*3);a.addColorStop(0,e.color),a.addColorStop(.5,`${e.color}60`),a.addColorStop(1,"rgba(255, 215, 0, 0)"),o.fillStyle=a,o.fillRect(n-l*3,r-l*3,l*6,l*6),o.globalAlpha=e.opacity,o.fillStyle=e.color,o.shadowColor=e.color,o.shadowBlur=l*2,o.beginPath(),o.arc(n,r,l*.8,0,Math.PI*2),o.fill(),o.shadowBlur=0,o.restore()},drawGlobalEffects(o,e,n,r){if(this.lightningActive){o.save(),o.globalAlpha=.8+Math.sin(this.lightningTimer*.01)*.2,o.shadowColor=this.lightningColor,o.shadowBlur=20;const l=n*(.4+Math.random()*.2),a=0,t=n*Math.random(),f=r;this.drawLightning(o,l,a,t,f,5+Math.floor(Math.random()*3),50+Math.random()*50,.7,.3,3+Math.random()*2,this.lightningColor),o.restore()}}};
|