@mar7th/firework 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/404.html +25 -0
- package/LICENSE +21 -0
- package/advanced-guide.html +135 -0
- package/api-download.html +164 -0
- package/demo.html +83 -0
- package/dist-lib/spark-fireworks.js +875 -0
- package/dist-lib/spark-fireworks.umd.cjs +1 -0
- package/docs/api-guide.md +750 -0
- package/docs/performance-optimization-plan.md +396 -0
- package/examples/production.html +203 -0
- package/favicon.jpg +0 -0
- package/guide.html +89 -0
- package/index.html +60 -0
- package/package.json +38 -0
- package/script/script1.js +34 -0
- package/script/script2.js +38 -0
- package/script/script3.js +63 -0
- package/script/script4.js +51 -0
- package/script/script5.js +55 -0
- package/scripts/copy-dist-lib.mjs +4 -0
- package/src/app.js +49 -0
- package/src/config/defaults.js +302 -0
- package/src/core/Firework.js +213 -0
- package/src/core/FireworksSimulator.js +439 -0
- package/src/core/Particle.js +174 -0
- package/src/core/ParticleSystem.js +56 -0
- package/src/core/Renderer.js +44 -0
- package/src/demo.js +298 -0
- package/src/effects/BackgroundManager.js +100 -0
- package/src/pages.css +388 -0
- package/src/pages.js +1 -0
- package/src/plugin.js +9 -0
- package/src/styles.css +544 -0
- package/src/ui/ControlPanel.js +205 -0
- package/src/ui/PerformancePanel.js +23 -0
- package/src/ui/PresetManager.js +128 -0
- package/src/utils/color.js +54 -0
- package/src/utils/eventBus.js +21 -0
- package/src/utils/math.js +29 -0
- package/vite.config.js +17 -0
- package/vite.lib.config.js +19 -0
package/404.html
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<meta http-equiv="refresh" content="0; url=/" />
|
|
7
|
+
<link rel="icon" type="image/jpeg" href="/favicon.jpg" />
|
|
8
|
+
<title>页面未找到</title>
|
|
9
|
+
<script>
|
|
10
|
+
window.location.replace("/");
|
|
11
|
+
</script>
|
|
12
|
+
<script>
|
|
13
|
+
var _hmt = _hmt || [];
|
|
14
|
+
(function() {
|
|
15
|
+
var hm = document.createElement("script");
|
|
16
|
+
hm.src = "https://hm.baidu.com/hm.js?c39438c75acf24e0e70a36e03a29e613";
|
|
17
|
+
var s = document.getElementsByTagName("script")[0];
|
|
18
|
+
s.parentNode.insertBefore(hm, s);
|
|
19
|
+
})();
|
|
20
|
+
</script>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<p>页面未找到,正在返回首页。<a href="/">返回首页</a></p>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 yiguo, march7th.online
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<link rel="icon" type="image/jpeg" href="/favicon.jpg" />
|
|
7
|
+
<title>SparkFireworks 高级指导</title>
|
|
8
|
+
<script>
|
|
9
|
+
var _hmt = _hmt || [];
|
|
10
|
+
(function() {
|
|
11
|
+
var hm = document.createElement("script");
|
|
12
|
+
hm.src = "https://hm.baidu.com/hm.js?c39438c75acf24e0e70a36e03a29e613";
|
|
13
|
+
var s = document.getElementsByTagName("script")[0];
|
|
14
|
+
s.parentNode.insertBefore(hm, s);
|
|
15
|
+
})();
|
|
16
|
+
</script>
|
|
17
|
+
<script type="module" src="/src/pages.js"></script>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<main class="site-shell">
|
|
21
|
+
<nav class="site-nav" aria-label="站点导航">
|
|
22
|
+
<a class="brand" href="/">SparkFireworks</a>
|
|
23
|
+
<div class="nav-links">
|
|
24
|
+
<a href="/demo.html">功能演示</a>
|
|
25
|
+
<a href="/guide.html">使用指导</a>
|
|
26
|
+
<a href="/advanced-guide.html">高级指导</a>
|
|
27
|
+
<a href="/api-download.html">API 下载</a>
|
|
28
|
+
</div>
|
|
29
|
+
</nav>
|
|
30
|
+
|
|
31
|
+
<header class="page-title">
|
|
32
|
+
<h1>高级指导</h1>
|
|
33
|
+
<p>高级模式允许开发者完全接管粒子生成逻辑。你可以返回一组粒子,也可以返回 `{ config, particles }` 为本次爆炸指定局部运行参数。</p>
|
|
34
|
+
</header>
|
|
35
|
+
|
|
36
|
+
<section class="doc-section">
|
|
37
|
+
<h2>高级脚本入口</h2>
|
|
38
|
+
<p>脚本必须声明名为 `createParticles` 的函数。函数会收到 `canvasData`,并返回粒子数组或包含粒子数组的对象。</p>
|
|
39
|
+
<pre><code>function createParticles(canvasData) {
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
x: canvasData.x,
|
|
43
|
+
y: canvasData.y,
|
|
44
|
+
vx: 4,
|
|
45
|
+
vy: -2,
|
|
46
|
+
size: 4,
|
|
47
|
+
life: 90,
|
|
48
|
+
startColor: "#48d6c2",
|
|
49
|
+
endColor: "#ffffff",
|
|
50
|
+
textureType: "circle",
|
|
51
|
+
rotationVelocity: 0,
|
|
52
|
+
secondaryEligible: false
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
}</code></pre>
|
|
56
|
+
</section>
|
|
57
|
+
|
|
58
|
+
<section class="doc-section">
|
|
59
|
+
<h2>canvasData</h2>
|
|
60
|
+
<ul>
|
|
61
|
+
<li><code>x</code> / <code>y</code>:本次发射目标点。</li>
|
|
62
|
+
<li><code>width</code> / <code>height</code>:画布尺寸。</li>
|
|
63
|
+
<li><code>canvas</code> / <code>ctx</code>:当前画布和 2D 上下文。</li>
|
|
64
|
+
<li><code>pixelRatio</code>:当前渲染像素比。</li>
|
|
65
|
+
<li><code>config</code>:当前全局配置快照。</li>
|
|
66
|
+
<li><code>random(min, max)</code>:项目内置随机数工具。</li>
|
|
67
|
+
</ul>
|
|
68
|
+
</section>
|
|
69
|
+
|
|
70
|
+
<section class="doc-section">
|
|
71
|
+
<h2>粒子字段</h2>
|
|
72
|
+
<ul>
|
|
73
|
+
<li><code>x</code>、<code>y</code>:初始位置。</li>
|
|
74
|
+
<li><code>vx</code>、<code>vy</code>:速度。</li>
|
|
75
|
+
<li><code>size</code>:初始大小。</li>
|
|
76
|
+
<li><code>life</code>:生命周期,数值越大存活越久。</li>
|
|
77
|
+
<li><code>startColor</code>、<code>endColor</code>:颜色渐变。</li>
|
|
78
|
+
<li><code>color</code>:简写字段,同时作为起止颜色。</li>
|
|
79
|
+
<li><code>textureType</code>:<code>circle</code>、<code>square</code>、<code>star</code>、<code>heart</code>。</li>
|
|
80
|
+
<li><code>rotationVelocity</code>:旋转速度。</li>
|
|
81
|
+
<li><code>secondaryEligible</code>:该粒子是否触发二次爆炸。</li>
|
|
82
|
+
<li><code>secondaryBurstConfig</code>:该粒子的二次爆炸覆盖配置。</li>
|
|
83
|
+
</ul>
|
|
84
|
+
</section>
|
|
85
|
+
|
|
86
|
+
<section class="doc-section">
|
|
87
|
+
<h2>局部 config</h2>
|
|
88
|
+
<p>返回 `{ config, particles }` 时,`config` 只作用于本次高级脚本爆炸,不会覆盖右侧控制面板。</p>
|
|
89
|
+
<pre><code>return {
|
|
90
|
+
config: {
|
|
91
|
+
gravity: 0,
|
|
92
|
+
damping: 0.99,
|
|
93
|
+
enableTrails: true,
|
|
94
|
+
glowIntensity: 1.1,
|
|
95
|
+
textureType: "star"
|
|
96
|
+
},
|
|
97
|
+
particles
|
|
98
|
+
};</code></pre>
|
|
99
|
+
</section>
|
|
100
|
+
|
|
101
|
+
<section class="doc-section">
|
|
102
|
+
<h2>二次爆炸自定义</h2>
|
|
103
|
+
<p>默认二次爆炸会继承源粒子效果,并强制关闭三次爆炸。需要自定义时,为粒子添加 `secondaryBurstConfig`。</p>
|
|
104
|
+
<pre><code>{
|
|
105
|
+
secondaryEligible: true,
|
|
106
|
+
secondaryBurstConfig: {
|
|
107
|
+
particleCount: 36,
|
|
108
|
+
particleLife: 54,
|
|
109
|
+
initialSpeedMin: 1.7,
|
|
110
|
+
initialSpeedMax: 5.2,
|
|
111
|
+
colorStart: "#fff4a3",
|
|
112
|
+
colorEnd: "#ffffff",
|
|
113
|
+
textureType: "circle",
|
|
114
|
+
explosionShape: "sphere"
|
|
115
|
+
}
|
|
116
|
+
}</code></pre>
|
|
117
|
+
</section>
|
|
118
|
+
|
|
119
|
+
<section class="doc-section">
|
|
120
|
+
<h2>当前五个示例脚本</h2>
|
|
121
|
+
<h3>script1.js:五角星爆炸</h3>
|
|
122
|
+
<p>沿五角星轮廓调整速度,适合学习如何用角度和半径控制整体形状。</p>
|
|
123
|
+
<h3>script2.js:爱心爆炸</h3>
|
|
124
|
+
<p>使用笛卡尔心形参数方程生成速度,适合学习数学曲线到烟花形状的映射。</p>
|
|
125
|
+
<h3>script3.js:核心圆与放射线</h3>
|
|
126
|
+
<p>分两组生成粒子:内部圆形光核和外部射线,适合学习分层组合效果。</p>
|
|
127
|
+
<h3>script4.js:彩虹多层圆</h3>
|
|
128
|
+
<p>多层不同半径和颜色的粒子环,适合学习层级颜色和速度同步扩散。</p>
|
|
129
|
+
<h3>script5.js:十二方向二次爆炸</h3>
|
|
130
|
+
<p>朝钟表 12 个方向发射红蓝粒子,并为每个粒子配置黄白二次爆炸,适合学习 `secondaryBurstConfig`。</p>
|
|
131
|
+
<p class="note">这些脚本可以在功能演示页的高级脚本下拉框中直接选择,也可以复制后继续修改。</p>
|
|
132
|
+
</section>
|
|
133
|
+
</main>
|
|
134
|
+
</body>
|
|
135
|
+
</html>
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<link rel="icon" type="image/jpeg" href="/favicon.jpg" />
|
|
7
|
+
<title>SparkFireworks API 下载</title>
|
|
8
|
+
<script>
|
|
9
|
+
var _hmt = _hmt || [];
|
|
10
|
+
(function() {
|
|
11
|
+
var hm = document.createElement("script");
|
|
12
|
+
hm.src = "https://hm.baidu.com/hm.js?c39438c75acf24e0e70a36e03a29e613";
|
|
13
|
+
var s = document.getElementsByTagName("script")[0];
|
|
14
|
+
s.parentNode.insertBefore(hm, s);
|
|
15
|
+
})();
|
|
16
|
+
</script>
|
|
17
|
+
<script type="module" src="/src/pages.js"></script>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<main class="site-shell">
|
|
21
|
+
<nav class="site-nav" aria-label="站点导航">
|
|
22
|
+
<a class="brand" href="/">SparkFireworks</a>
|
|
23
|
+
<div class="nav-links">
|
|
24
|
+
<a href="/demo.html">功能演示</a>
|
|
25
|
+
<a href="/guide.html">使用指导</a>
|
|
26
|
+
<a href="/advanced-guide.html">高级指导</a>
|
|
27
|
+
<a href="/api-download.html">API 下载</a>
|
|
28
|
+
</div>
|
|
29
|
+
</nav>
|
|
30
|
+
|
|
31
|
+
<header class="page-title">
|
|
32
|
+
<h1>API 下载</h1>
|
|
33
|
+
<p>下载 `npm run build:lib` 生成的库文件,在自己的页面中通过 ESM 或 UMD 方式引入。</p>
|
|
34
|
+
</header>
|
|
35
|
+
|
|
36
|
+
<section class="doc-section">
|
|
37
|
+
<h2>构建产物</h2>
|
|
38
|
+
<div class="download-row">
|
|
39
|
+
<div>
|
|
40
|
+
<strong>ES Module</strong>
|
|
41
|
+
<p><code>dist-lib/spark-fireworks.js</code>,适合现代构建工具和 <code><script type="module"></code>。</p>
|
|
42
|
+
</div>
|
|
43
|
+
<a class="button-link primary" href="/dist-lib/spark-fireworks.js" download>下载 ESM</a>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="download-row">
|
|
46
|
+
<div>
|
|
47
|
+
<strong>UMD</strong>
|
|
48
|
+
<p><code>dist-lib/spark-fireworks.umd.cjs</code>,适合直接挂载到浏览器全局变量 `SparkFireworks`。</p>
|
|
49
|
+
</div>
|
|
50
|
+
<a class="button-link" href="/dist-lib/spark-fireworks.umd.cjs" download>下载 UMD</a>
|
|
51
|
+
</div>
|
|
52
|
+
</section>
|
|
53
|
+
|
|
54
|
+
<section class="doc-section">
|
|
55
|
+
<h2>ESM 引入示例</h2>
|
|
56
|
+
<pre><code><canvas id="fireworks" style="width:100vw;height:100vh;display:block"></canvas>
|
|
57
|
+
|
|
58
|
+
<script type="module">
|
|
59
|
+
import SparkFireworks from "./dist-lib/spark-fireworks.js";
|
|
60
|
+
|
|
61
|
+
const fireworks = SparkFireworks.create("fireworks", {
|
|
62
|
+
particleCount: 220,
|
|
63
|
+
colorStart: "#ffd166",
|
|
64
|
+
colorEnd: "#ef476f",
|
|
65
|
+
enableTrails: true
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
fireworks.launchRandom();
|
|
69
|
+
</script></code></pre>
|
|
70
|
+
</section>
|
|
71
|
+
|
|
72
|
+
<section class="doc-section">
|
|
73
|
+
<h2>UMD 引入示例</h2>
|
|
74
|
+
<pre><code><canvas id="fireworks" style="width:100vw;height:100vh;display:block"></canvas>
|
|
75
|
+
<script src="./dist-lib/spark-fireworks.umd.cjs"></script>
|
|
76
|
+
<script>
|
|
77
|
+
const fireworks = SparkFireworks.create("fireworks", {
|
|
78
|
+
autoLaunch: true,
|
|
79
|
+
autoLaunchIntervalSeconds: 0.9,
|
|
80
|
+
enableSecondaryBurst: false
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
document.addEventListener("click", () => fireworks.launchRandom());
|
|
84
|
+
</script></code></pre>
|
|
85
|
+
</section>
|
|
86
|
+
|
|
87
|
+
<section class="doc-section">
|
|
88
|
+
<h2>通过 unpkg 直接使用</h2>
|
|
89
|
+
<p>发布到 npm 后,可以不下载文件,直接从 unpkg 引入固定版本的构建产物。</p>
|
|
90
|
+
<h3>ESM</h3>
|
|
91
|
+
<pre><code><canvas id="fireworks" style="width:100vw;height:100vh;display:block"></canvas>
|
|
92
|
+
|
|
93
|
+
<script type="module">
|
|
94
|
+
import SparkFireworks from "https://unpkg.com/@mar7th/firework@1.0.0/dist-lib/spark-fireworks.js";
|
|
95
|
+
|
|
96
|
+
const fireworks = SparkFireworks.create("fireworks", {
|
|
97
|
+
autoLaunch: true,
|
|
98
|
+
enableTrails: true
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
fireworks.launchRandom();
|
|
102
|
+
</script></code></pre>
|
|
103
|
+
<h3>UMD</h3>
|
|
104
|
+
<pre><code><canvas id="fireworks" style="width:100vw;height:100vh;display:block"></canvas>
|
|
105
|
+
<script src="https://unpkg.com/@mar7th/firework@1.0.0/dist-lib/spark-fireworks.umd.cjs"></script>
|
|
106
|
+
<script>
|
|
107
|
+
const fireworks = SparkFireworks.create("fireworks", {
|
|
108
|
+
autoLaunch: true,
|
|
109
|
+
autoLaunchIntervalSeconds: 1
|
|
110
|
+
});
|
|
111
|
+
</script></code></pre>
|
|
112
|
+
<p class="note">生产页面建议固定版本号,例如 `@1.0.0`,避免后续发布新版本时页面行为意外变化。</p>
|
|
113
|
+
</section>
|
|
114
|
+
|
|
115
|
+
<section class="doc-section">
|
|
116
|
+
<h2>通过 jsDelivr 直接使用</h2>
|
|
117
|
+
<p>也可以使用 jsDelivr 的 npm CDN 地址,引入方式和 unpkg 基本一致。</p>
|
|
118
|
+
<h3>ESM</h3>
|
|
119
|
+
<pre><code><canvas id="fireworks" style="width:100vw;height:100vh;display:block"></canvas>
|
|
120
|
+
|
|
121
|
+
<script type="module">
|
|
122
|
+
import SparkFireworks from "https://cdn.jsdelivr.net/npm/@mar7th/firework@1.0.0/dist-lib/spark-fireworks.js";
|
|
123
|
+
|
|
124
|
+
const fireworks = SparkFireworks.create("fireworks", {
|
|
125
|
+
autoLaunch: true,
|
|
126
|
+
enableTrails: true
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
fireworks.launchRandom();
|
|
130
|
+
</script></code></pre>
|
|
131
|
+
<h3>UMD</h3>
|
|
132
|
+
<pre><code><canvas id="fireworks" style="width:100vw;height:100vh;display:block"></canvas>
|
|
133
|
+
<script src="https://cdn.jsdelivr.net/npm/@mar7th/firework@1.0.0/dist-lib/spark-fireworks.umd.cjs"></script>
|
|
134
|
+
<script>
|
|
135
|
+
const fireworks = SparkFireworks.create("fireworks", {
|
|
136
|
+
autoLaunch: true,
|
|
137
|
+
autoLaunchIntervalSeconds: 1
|
|
138
|
+
});
|
|
139
|
+
</script></code></pre>
|
|
140
|
+
<p class="note">jsDelivr 也建议固定版本号;如果要测试最新版本,可以把 `@1.0.0` 换成 `@latest`。</p>
|
|
141
|
+
</section>
|
|
142
|
+
|
|
143
|
+
<section class="doc-section">
|
|
144
|
+
<h2>常用 API</h2>
|
|
145
|
+
<ul>
|
|
146
|
+
<li><code>SparkFireworks.create(canvasOrId, configOrOptions)</code>:创建控制器。</li>
|
|
147
|
+
<li><code>fireworks.launch(x, y, options)</code>:在指定位置发射。</li>
|
|
148
|
+
<li><code>fireworks.launchRandom()</code>:随机位置发射。</li>
|
|
149
|
+
<li><code>fireworks.startAutoPlay(seconds)</code> / <code>stopAutoPlay()</code>:自动播放控制。</li>
|
|
150
|
+
<li><code>fireworks.setConfig(partialConfig)</code>:更新配置。</li>
|
|
151
|
+
<li><code>fireworks.setAdvancedMode(enabled, createParticles)</code>:开启或关闭高级脚本模式。</li>
|
|
152
|
+
<li><code>fireworks.destroy()</code>:销毁实例并解绑事件。</li>
|
|
153
|
+
</ul>
|
|
154
|
+
</section>
|
|
155
|
+
|
|
156
|
+
<section class="doc-section">
|
|
157
|
+
<h2>重新构建</h2>
|
|
158
|
+
<p>如果你修改了源码,需要重新生成库文件:</p>
|
|
159
|
+
<pre><code>npm run build:lib</code></pre>
|
|
160
|
+
<p class="note">普通页面构建使用 `npm run build`;库文件构建使用 `npm run build:lib`。</p>
|
|
161
|
+
</section>
|
|
162
|
+
</main>
|
|
163
|
+
</body>
|
|
164
|
+
</html>
|
package/demo.html
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<link rel="icon" type="image/jpeg" href="/favicon.jpg" />
|
|
7
|
+
<title>烟花模拟器</title>
|
|
8
|
+
<script>
|
|
9
|
+
var _hmt = _hmt || [];
|
|
10
|
+
(function() {
|
|
11
|
+
var hm = document.createElement("script");
|
|
12
|
+
hm.src = "https://hm.baidu.com/hm.js?c39438c75acf24e0e70a36e03a29e613";
|
|
13
|
+
var s = document.getElementsByTagName("script")[0];
|
|
14
|
+
s.parentNode.insertBefore(hm, s);
|
|
15
|
+
})();
|
|
16
|
+
</script>
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<main id="app" class="app-shell">
|
|
20
|
+
<section class="stage" aria-label="烟花模拟器工作区">
|
|
21
|
+
<canvas id="fireworksCanvas" aria-label="烟花模拟器画布" tabindex="0"></canvas>
|
|
22
|
+
|
|
23
|
+
<div class="top-bar">
|
|
24
|
+
<div class="action-group" aria-label="预设与配置">
|
|
25
|
+
<a class="toolbar-link" href="/">首页</a>
|
|
26
|
+
<select id="presetSelect" aria-label="选择预设"></select>
|
|
27
|
+
<button id="resetConfigButton" type="button">初始化设置</button>
|
|
28
|
+
<button id="savePresetButton" type="button">保存</button>
|
|
29
|
+
<button id="exportButton" type="button">导出</button>
|
|
30
|
+
<label class="file-button">
|
|
31
|
+
导入
|
|
32
|
+
<input id="importInput" type="file" accept="application/json" />
|
|
33
|
+
</label>
|
|
34
|
+
<button id="shareButton" type="button">分享</button>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div class="action-group" aria-label="动画控制">
|
|
38
|
+
<span id="fpsCounter" class="metric">FPS --</span>
|
|
39
|
+
<button id="advancedModeButton" type="button" aria-pressed="false">高级模式</button>
|
|
40
|
+
<button id="autoButton" type="button" aria-pressed="false">自动</button>
|
|
41
|
+
<button id="pauseButton" type="button" aria-pressed="false">暂停</button>
|
|
42
|
+
<button id="clearButton" type="button">清除</button>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div id="toast" class="toast" role="status" aria-live="polite"></div>
|
|
47
|
+
</section>
|
|
48
|
+
|
|
49
|
+
<aside class="control-panel" aria-label="烟花参数控制面板">
|
|
50
|
+
<div class="panel-header">
|
|
51
|
+
<div>
|
|
52
|
+
<h1>烟花模拟器</h1>
|
|
53
|
+
<p>点击画布发射,调整参数实时影响后续烟花与当前粒子。</p>
|
|
54
|
+
</div>
|
|
55
|
+
<button id="collapseButton" type="button" aria-expanded="true">收起</button>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div id="controls" class="controls"></div>
|
|
59
|
+
|
|
60
|
+
<details class="control-section advanced-script-section" open>
|
|
61
|
+
<summary>高级脚本</summary>
|
|
62
|
+
<div class="section-body">
|
|
63
|
+
<p class="section-hint">
|
|
64
|
+
高级脚本仅提供给开发者使用;非开发者可以先尝试预设脚本,学习后再使用。二次爆炸自定义功能需要在高级模式自定义脚本中配置。
|
|
65
|
+
</p>
|
|
66
|
+
<label class="script-preset-control">
|
|
67
|
+
示例脚本
|
|
68
|
+
<select id="advancedScriptPresetSelect" aria-label="选择高级脚本示例"></select>
|
|
69
|
+
</label>
|
|
70
|
+
<textarea id="advancedScriptInput" spellcheck="false"></textarea>
|
|
71
|
+
<div class="button-grid">
|
|
72
|
+
<button id="applyAdvancedScriptButton" type="button">应用脚本</button>
|
|
73
|
+
<button id="resetAdvancedScriptButton" type="button">恢复示例</button>
|
|
74
|
+
</div>
|
|
75
|
+
<p id="advancedScriptStatus" class="script-status">脚本仅在高级模式开启后生效。</p>
|
|
76
|
+
</div>
|
|
77
|
+
</details>
|
|
78
|
+
</aside>
|
|
79
|
+
</main>
|
|
80
|
+
|
|
81
|
+
<script type="module" src="/src/demo.js"></script>
|
|
82
|
+
</body>
|
|
83
|
+
</html>
|