吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3257|回复: 9
收起左侧

[其他原创] 烟花特效工具(网页端+浏览器端)

[复制链接]
yibeijiu 发表于 2025-6-13 15:44
本帖最后由 yibeijiu 于 2025-6-13 16:49 编辑

烟花特效工具(网页端+浏览器端),随便玩儿的,先上图:

Snipaste_2025-06-13_15-38-28.png
说说功能(两个文件):
1. html浏览器打开可以直接点击出现多种烟花特效
2. js使用脚本管理可实现浏览器任意网页的全局烟花特效

该放文件了
1.  HTML: html.rar (1.42 KB, 下载次数: 5)
2. JS  : js.rar (1.32 KB, 下载次数: 5)
3. 汇总版: 01-烟花特效.rar (2.71 KB, 下载次数: 12)

再上代码:
[Asm] 纯文本查看 复制代码
<body>
    <canvas id="fireworksCanvas"></canvas>
    <script>
        const canvas = document.getElementById('fireworksCanvas');
        const ctx = canvas.getContext('2d');
        let fireworks = [];

        // Resize canvas to fit the window
        function resizeCanvas() {
            canvas.width = window.innerWidth;
            canvas.height = window.innerHeight;
        }
        window.addEventListener('resize', resizeCanvas);
        resizeCanvas();

        // Firework particle class
        class FireworkParticle {
            constructor(x, y, dx, dy, color, life) {
                this.x = x;
                this.y = y;
                this.dx = dx;
                this.dy = dy;
                this.color = color;
                this.life = life;
                this.opacity = 1;
            }
            update() {
                this.x += this.dx;
                this.y += this.dy;
                this.dy += 0.03; // Gravity effect
                this.life--;
                this.opacity = Math.max(this.life / 50, 0); // Fade out
            }
            draw() {
                ctx.beginPath();
                ctx.moveTo(this.x, this.y);
                ctx.lineTo(this.x - this.dx * 5, this.y - this.dy * 5); // 细条状的线条
                ctx.strokeStyle = `rgba(${this.color}, ${this.opacity})`;
                ctx.lineWidth = 2;
                ctx.stroke();
            }
        }

        // Firework class
        class Firework {
            constructor(x, y) {
                this.x = x;
                this.y = y;
                this.particles = [];
                this.createParticles();
            }
            createParticles() {
                const colors = ['255,0,0', '0,255,0', '0,0,255', '255,255,0', '255,0,255', '0,255,255'];
                const color = colors[Math.floor(Math.random() * colors.length)];
                for (let i = 0; i < 80; i++) { // 更多粒子
                    const angle = Math.random() * Math.PI * 2;
                    const speed = Math.random() * 4 + 2; // 更快的速度
                    const dx = Math.cos(angle) * speed;
                    const dy = Math.sin(angle) * speed;
                    this.particles.push(new FireworkParticle(this.x, this.y, dx, dy, color, 60));
                }
            }
            update() {
                this.particles.forEach(p => p.update());
                this.particles = this.particles.filter(p => p.life > 0);
            }
            draw() {
                this.particles.forEach(p => p.draw());
            }
        }

        // Add a firework at the mouse position
        canvas.addEventListener('click', (e) => {
            const x = e.clientX;
            const y = e.clientY;
            fireworks.push(new Firework(x, y));
        });

        // Animation loop
        function animate() {
            ctx.clearRect(0, 0, canvas.width, canvas.height);
            fireworks.forEach((fw, index) => {
                fw.update();
                fw.draw();
                if (fw.particles.length === 0) {
                    fireworks.splice(index, 1);
                }
            });
            requestAnimationFrame(animate);
        }
        animate();
    </script>
</body>
</html>



END


免费评分

参与人数 1吾爱币 +7 热心值 +1 收起 理由
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

sqzh 发表于 2025-6-13 15:57
好玩,试一下哈
xxkz 发表于 2025-6-13 16:26
本帖最后由 xxkz 于 2025-6-13 16:28 编辑

还记得十几年前 ,有个用flash做的烟花,用鼠标点击就能看到各种烟花,可惜没保存下来,后来再也没有找到,前一阵 ,突然想到黑客帝国的代码雨很漂亮,专门找了几个 ,还用AI生成了一段。
 楼主| yibeijiu 发表于 2025-6-13 16:46
xxkz 发表于 2025-6-13 16:26
还记得十几年前 ,有个用flash做的烟花,用鼠标点击就能看到各种烟花,可惜没保存下来,后来再也没有找到, ...

这个是之前想玩玩儿,试的
rjs2080 发表于 2025-6-13 17:23
你的币有点高哦
goodcash 发表于 2025-6-13 19:14
这个教学很有用,如果能显示学生名字就更好了
ericwise 发表于 2025-6-13 20:05
goodcash 发表于 2025-6-13 19:14
这个教学很有用,如果能显示学生名字就更好了

可以用AI去改
wapj2900958 发表于 2025-6-13 20:42
你的币有点高哦
hacker23 发表于 2025-6-13 22:05
学习了,试试效果,感谢
 楼主| yibeijiu 发表于 2025-6-13 22:58
rjs2080 发表于 2025-6-13 17:23
你的币有点高哦

几个还高?可以不要哦
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-10-11 16:03

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表