我也来放烟花玩!辛弃疾《破阵子 · 为陈同甫赋壮词以寄》
本帖最后由 加林森 于 2022-8-21 20:51 编辑 <br /><br /><style>#papa { left: -214px; width: 1024px; height: 796px; background: gray url('https://pic.imgdb.cn/item/6302130f16f2c2beb16cd8d5.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; }
#canv { position: absolute; }
#disc { position: absolute; width: 1px; height: 1px; left: 10px; bottom: 10px; background: conic-gradient(red,orange,yellow,green,teal,blue,purple); mask: radial-gradient(transparent 4px,red 0); -webkit-mask: radial-gradient(transparent 4px,red 0); border-radius: 50%; cursor: pointer; animation: rot 2s linear infinite; }
#lrcbox { position: absolute; left: 60px; bottom: 40px;font: bold 22px / 40px sans-serif; color: #ff461f; text-shadow: 2px 2px 2px #222; }
@keyframes rot { to { transform: rotate(360deg); } }
</style>
<div id="papa">
<span id="lrcbox">醉里挑灯看剑、梦回吹角连营。八百里分麾下炙。五十弦翻塞外声,沙场秋点兵。 —————— 辛弃疾《破阵子 · 为陈同甫赋壮词以寄》</span>
<canvas id="canv"></canvas>
<span id="disc"></span>
</div>
<script>
(function() {
let num = (min, max) => Math.floor(Math.random() * (max-min+1)) + min;
let ctx = canv.getContext('2d');
let w = canv.width = papa.offsetWidth, h = canv.height = papa.offsetHeight, particles = [], idx = 0, aud = new Audio();
aud.src = 'https://music.163.com/song/media/outer/url?id=536907188.mp3';
aud.loop = true;
aud.autoplay = true;
disc.style.animationPlayState = aud.paused ? 'paused' : 'running';
disc.onclick = () => aud.paused ? aud.play() : aud.pause();
aud.addEventListener('playing',()=> disc.style.animationPlayState = 'running');
aud.addEventListener('pause',()=> disc.style.animationPlayState = 'paused');
canv.onclick = function(event) {
let x = event.offsetX || event.layerX, y = event.offsetY || event.layerY;
createParticle(x, y);
}
function createParticle(x, y) {
let count = 100, radius = 10;
for (let j = 0; j < count; j ++) {
let p = {};
let angle = 360 / count * j, radian = Math.PI / 180 * angle;
p.radius = radius;
p.startX = x;
p.startY = y;
p.radian = radian;
p.rgb = `${num(0,255)},${num(0,255)},${num(0,255)},`;
p.alpha = (Math.floor(Math.random() * 101)) / 100;
p.speed = (Math.random() * 5) + 0.4;
p.radius = p.speed;
particles.push(p);
}
}
function drawParticle() {
ctx.fillStyle = 'transparent';
ctx.fillRect(0, 0, w, h);
for (let j = 0; j < particles.length; j++) {
let p = particles;
let resultX = Math.cos(p.radian) * p.radius;
let resultY = Math.sin(p.radian) * p.radius + 0.4;
p.startX += resultX;
p.startY += resultY;
p.radius *= 1 - p.speed / 100;
p.alpha -= 0.005;
if (p.alpha <= 0) {
particles.splice(j, 1);
continue;
}
ctx.beginPath();
ctx.arc(p.startX, p.startY, 2, 0, 360, false);
ctx.closePath();
ctx.fillStyle = 'rgba(' + p.rgb + p.alpha + ')';
ctx.fill();
}
}
function fade() {
ctx.globalCompositeOperation = 'destination-out';
ctx.fillStyle = 'rgba(0, 0, 0, .1)';
ctx.fillRect(0, 0, w, h);
ctx.globalCompositeOperation = 'lighter';
}
function render() {
idx ++;
fade();
drawParticle();
if(idx > 20) {
createParticle(Math.random() * w, Math.random() * h/2);
idx = 0;
}
requestAnimationFrame(render);
}
render();
})();
</script>
放着烟花打仗,加加真浪漫!{:5_116:} 东篱闲人 发表于 2022-8-21 20:50
放着烟花打仗,加加真浪漫!
庆祝英雄打胜仗!{:4_205:} 加林森 发表于 2022-8-21 20:53
庆祝英雄打胜仗!
打完了啊? 欣赏队长佳作 东篱闲人 发表于 2022-8-21 21:38
打完了啊?
当然了啊。 马黑黑 发表于 2022-8-21 21:41
欣赏队长佳作
谢谢老黑! 加林森 发表于 2022-8-21 21:51
谢谢老黑!
{:4_191:} 加林森友友,又一次惊艳了俺,音乐选择和吟诵都很有战场霸气。。。。还有礼花,可能是冲锋号{:4_173:} 马黑黑 发表于 2022-8-21 21:57
{:4_191:} 青青子衿 发表于 2022-8-21 21:57
加林森友友,又一次惊艳了俺,音乐选择和吟诵都很有战场霸气。。。。还有礼花,可能是冲锋号
是的是的。战场必须要有霸气的。 小马黑黑,好好教教我们,什么时候,我们出个新时期战场的动画片 青青子衿 发表于 2022-8-21 22:00
小马黑黑,好好教教我们,什么时候,我们出个新时期战场的动画片
好主意。支持!{:4_199:} 加林森 发表于 2022-8-21 21:51
当然了啊。
俺以为刚去呢。。。{:5_117:} 东篱闲人 发表于 2022-8-21 22:13
俺以为刚去呢。。。
哈哈,就是玩玩。我在跟着你学习呢! 加林森 发表于 2022-8-21 22:19
哈哈,就是玩玩。我在跟着你学习呢!
别闹,你是教授。。。{:4_186:} 东篱闲人 发表于 2022-8-21 22:20
别闹,你是教授。。。
我说的是真话啊。{:5_158:} 这个有趣,烟花被这样用没想到{:4_173:} 红影 发表于 2022-8-21 22:37
这个有趣,烟花被这样用没想到
热闹热闹!{:4_189:} 加林森 发表于 2022-8-21 22:38
热闹热闹!
这图图制作很漂亮{:4_187:}
页:
[1]
2