Skip to content

Commit 86a0a1b

Browse files
committed
refactor demo website
1 parent 3960612 commit 86a0a1b

File tree

3 files changed

+92
-85
lines changed

3 files changed

+92
-85
lines changed

public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<head>
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
7-
<title>🎆 Fireworks.js</title>
8-
<link rel="icon" href="./images/fireworks_emoji.png" type="image/png">
7+
<title>fireworks-js</title>
8+
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🎆</text></svg>">
99
<link rel="stylesheet" href="./index.css">
1010
</head>
1111

src/demo/config.ts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import type { FireworksOptions } from '../fireworks'
2+
3+
export const mainContainer = document
4+
.querySelector<HTMLDivElement>('.container')!
5+
6+
export const fireworksContainer = document
7+
.querySelector<HTMLDivElement>('.fireworks-container')!
8+
9+
export const fireworksOptions: FireworksOptions = {
10+
hue: {
11+
min: 0,
12+
max: 345
13+
},
14+
delay: {
15+
min: 30,
16+
max: 60
17+
},
18+
rocketsPoint: {
19+
min: 50,
20+
max: 50
21+
},
22+
opacity: 0.5, // fillStyle
23+
acceleration: 1.02,
24+
friction: 0.97,
25+
gravity: 1.5,
26+
particles: 90,
27+
trace: 3,
28+
traceSpeed: 10,
29+
explosion: 6,
30+
intensity: 30,
31+
flickering: 50,
32+
lineStyle: 'round',
33+
lineWidth: {
34+
explosion: {
35+
min: 1,
36+
max: 4
37+
},
38+
trace: {
39+
min: 0.1,
40+
max: 1
41+
}
42+
},
43+
autoresize: true,
44+
brightness: {
45+
min: 50,
46+
max: 80,
47+
decay: {
48+
min: 0.015,
49+
max: 0.03
50+
}
51+
},
52+
boundaries: {
53+
x: 50,
54+
y: 50,
55+
width: fireworksContainer.clientWidth,
56+
height: fireworksContainer.clientHeight,
57+
visible: false
58+
},
59+
sound: {
60+
enabled: false,
61+
files: [
62+
location.href + 'sounds/explosion0.mp3',
63+
location.href + 'sounds/explosion1.mp3',
64+
location.href + 'sounds/explosion2.mp3'
65+
],
66+
volume: {
67+
min: 2,
68+
max: 4
69+
}
70+
},
71+
mouse: {
72+
click: true,
73+
move: false,
74+
max: 3
75+
}
76+
}
77+
78+
export const backgroundConfig = {
79+
color: '#000000',
80+
image: '',
81+
size: 'cover',
82+
position: '50% 50%',
83+
repeat: 'no-repeat',
84+
container: false,
85+
fps: false
86+
}

src/demo/index.ts

Lines changed: 4 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,9 @@
11
import { Pane } from 'tweakpane'
22
import * as EssentialsPlugin from '@tweakpane/plugin-essentials'
33
import { Fireworks } from '../fireworks'
4-
import type { FireworksOptions } from '../fireworks'
4+
import { fireworksContainer, fireworksOptions, backgroundConfig, mainContainer } from './config'
55
import type { FpsGraphBladeApi } from '@tweakpane/plugin-essentials/dist/types/fps-graph/api/fps-graph'
66

7-
const container = document.querySelector<HTMLDivElement>('.container')!
8-
const fireworksContainer = document.querySelector<HTMLDivElement>('.fireworks-container')!
9-
const fireworksOptions: FireworksOptions = {
10-
hue: {
11-
min: 0,
12-
max: 345
13-
},
14-
delay: {
15-
min: 30,
16-
max: 60
17-
},
18-
rocketsPoint: {
19-
min: 50,
20-
max: 50
21-
},
22-
opacity: 0.5, // fillStyle
23-
acceleration: 1.02,
24-
friction: 0.97,
25-
gravity: 1.5,
26-
particles: 90,
27-
trace: 3,
28-
traceSpeed: 10,
29-
explosion: 6,
30-
intensity: 30,
31-
flickering: 50,
32-
lineStyle: 'round',
33-
lineWidth: {
34-
explosion: {
35-
min: 1,
36-
max: 4
37-
},
38-
trace: {
39-
min: 0.1,
40-
max: 1
41-
}
42-
},
43-
autoresize: true,
44-
brightness: {
45-
min: 50,
46-
max: 80,
47-
decay: {
48-
min: 0.015,
49-
max: 0.03
50-
}
51-
},
52-
boundaries: {
53-
x: 50,
54-
y: 50,
55-
width: fireworksContainer.clientWidth,
56-
height: fireworksContainer.clientHeight,
57-
visible: false
58-
},
59-
sound: {
60-
enabled: false,
61-
files: [
62-
location.href + 'sounds/explosion0.mp3',
63-
location.href + 'sounds/explosion1.mp3',
64-
location.href + 'sounds/explosion2.mp3'
65-
],
66-
volume: {
67-
min: 2,
68-
max: 4
69-
}
70-
},
71-
mouse: {
72-
click: true,
73-
move: false,
74-
max: 10
75-
}
76-
}
77-
78-
const backgroundConfig = {
79-
color: '#000000',
80-
image: '',
81-
size: 'cover',
82-
position: '50% 50%',
83-
repeat: 'no-repeat',
84-
container: false,
85-
fps: false
86-
}
87-
887
const fireworks = new Fireworks(fireworksContainer, fireworksOptions)
898
fireworks.start()
909

@@ -246,7 +165,9 @@ const background = tweakpane.addFolder({
246165
background
247166
.addInput(backgroundConfig, 'container')
248167
.on('change', ({ value }) => {
249-
container.style.display = value ? 'none' : 'block'
168+
mainContainer.style.display = value ?
169+
'none' :
170+
'block'
250171
})
251172

252173
background

0 commit comments

Comments
 (0)