歌唱祖国(套用黑黑梦幻电音效果)
<style>
#papa { left:-384px; width: 1318px; height: 712px; top:150px; background: #000 url('https://wj.zp68.com/lxx/yunhua/20210612/hc.gif') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; }
#canv { position: absolute; left: 420px; top: 10px; }
#disc { position: absolute; width:60px; height: 60px; left: 50px; top:600px; 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; }
#tit { position: absolute; left: 150px; top: 610px;font: bold 30px / 40px sans-serif; color: snow; text-shadow: 2px 2px 4px black; }
@keyframes rot { to { transform: rotate(360deg); } }
</style>
<div id="papa">
<span id="tit">歌唱祖国</span>
<canvas id="canv"></canvas>
<span id="disc"></span>
</div>
<script>
(function() {
let ctx = canv.getContext('2d');
let w = canv.width = 900, h = canv.height = 600; // 自定义画布尺寸
let particles = [], idx = 0, aud = new Audio();
aud.src = 'https://music.163.com/song/media/outer/url?id=5234256.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;
let y = event.offsetY || event.layerY;
createParticle(x, y);
}
function createParticle(x, y) {
let count = 100;
let radius = 10;
let hue = Math.floor(Math.random() * 51) + 0;
let change = 30;
for (let j = 0; j < count; j ++) {
let p = {};
let angle = 360 / count * j;
let radian = Math.PI / 180 * angle;
p.radius = radius;
p.startX = x;
p.startY = y;
p.radian = radian;
p.hue = Math.floor(Math.random() * (change * 0)) + (hue - change);
p.lightness = Math.floor(Math.random() * 100);
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 i = 0; i < particles.length; i++) {
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(i, 1);
continue;
}
ctx.beginPath();
ctx.arc(p.startX, p.startY, 2, 0, 360, false);
ctx.closePath();
ctx.fillStyle = "hsla( " + p.hue + " , 100% ," + p.lightness + "% , " + p.alpha + ")";
ctx.fill();
}
}
function fade() {
ctx.globalCompositeOperation = "destination-out";
ctx.fillStyle = "rgba(0 , 0 , 0, " + 0.1 + ")";
ctx.fillRect(0, 0, w, h);
ctx.globalCompositeOperation = "lighter";
}
function render() {
idx ++;
fade();
drawParticle();
if(idx > 50) {
createParticle(Math.random() * w, Math.random() * h);
idx = 0;
}
requestAnimationFrame(render);
}
render();
})();
</script>
<br><br><br><br><br><br><br><br><br><br> @马黑黑
黑黑谢谢你讲这么清楚,直接套用了,只是这个颜色修改我以前没有碰到过,去看了网页,修改了一下 很喜欢这个烟花效果,比我以前的制作大气,亮丽{:4_178:} 现成的图图,套一个,效果出来也是开心,上班去了,今天没有午睡,昨天晚上也是没有睡好,最近睡眠不好好郁闷。。。。 烟花好漂亮哎! 小辣椒 发表于 2022-8-12 14:08
现成的图图,套一个,效果出来也是开心,上班去了,今天没有午睡,昨天晚上也是没有睡好,最近睡眠不好好郁 ...
注意调整好自己 小辣椒 发表于 2022-8-12 14:05
@马黑黑
黑黑谢谢你讲这么清楚,直接套用了,只是这个颜色修改我以前没有碰到过,去看了网页,修改了一 ...
效果很不错的{:4_187:} 小辣椒真拼命了。制作漂亮,有创新!大赞!{:4_199:} 梦油 发表于 2022-8-12 14:13
烟花好漂亮哎!
谢谢梦油欣赏{:4_187:} 马黑黑 发表于 2022-8-12 18:07
注意调整好自己
谢谢黑黑关心,不知道为什么最近睡眠不好,昨天晚上我睡不着就做这个烟花效果,加不好就上来问你了,然后还是睡不着{:4_201:}
今天白天看见你回了我,中午休息就上来了,效果做出来了,看看烟花比我以前的制作漂亮多了 马黑黑 发表于 2022-8-12 18:07
效果很不错的
我也是感觉这个烟花特别漂亮{:4_173:} 加林森 发表于 2022-8-12 18:30
小辣椒真拼命了。制作漂亮,有创新!大赞!
谢谢队长,这个没有拼命的,直接套用黑黑后面给我的提示代码,就改颜色我是开始不会,看了黑黑发的链接网页我会了。 小辣椒 发表于 2022-8-12 19:14
谢谢队长,这个没有拼命的,直接套用黑黑后面给我的提示代码,就改颜色我是开始不会,看了黑黑发的链接网 ...
你真厉害,又聪明伶俐。创新了就好,变成了自己的了。 小辣椒 发表于 2022-8-12 19:11
谢谢黑黑关心,不知道为什么最近睡眠不好,昨天晚上我睡不着就做这个烟花效果,加不好就上来问你了,然后 ...
嗯,太过执着,所以脑子兴奋,不好睡。调整一下是对的,想着今天不做,明天做 小辣椒 发表于 2022-8-12 19:12
我也是感觉这个烟花特别漂亮
感觉很惊艳的 加林森 发表于 2022-8-12 19:26
你真厉害,又聪明伶俐。创新了就好,变成了自己的了。
队长夸奖了,大家都差不多的 马黑黑 发表于 2022-8-12 19:30
嗯,太过执着,所以脑子兴奋,不好睡。调整一下是对的,想着今天不做,明天做
师父曾经说过我的脾气特别像他,倔头。。。 马黑黑 发表于 2022-8-12 19:31
感觉很惊艳的
谢谢黑黑,非常喜欢的,以后节假日可以用 小辣椒 发表于 2022-8-12 19:36
队长夸奖了,大家都差不多的
应该的。我可不行了。 加林森 发表于 2022-8-12 19:40
应该的。我可不行了。
队长不急这个你直接套用,黒黑后面有提示的,你仔细看看。。。