必须的了
是的。我这个不吓人的。{:4_189:}
<style>
#papa { left: -214px; width: 1024px; height: 640px; background: gray url('https://pic.imgdb.cn/item/62f70af816f2c2beb16c2fa1.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; }
#canv { position: absolute; }
#disc { position: absolute; width: 40px; height: 40px; 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: 10px;font: bold 22px / 40px sans-serif; color: #859670; text-shadow: 2px 2px 4px #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=1437807056.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>
千羽 发表于 2022-6-14 21:32
没找到,再找
已经被顶出来了。 加林森 发表于 2022-6-14 21:39
是的。我这个不吓人的。
知道的了,很仙的感觉 绿叶清舟 发表于 2022-6-14 21:44
知道的了,很仙的感觉
就是就是。 加林森 发表于 2022-6-14 20:56
谢谢老梦的点评!
别客气,还是你制作的好啊! 梦油 发表于 2022-6-15 10:39
别客气,还是你制作的好啊!
我还会继续努力的。 加林森 发表于 2022-6-15 11:29
我还会继续努力的。
我相信,你的制作会越来越精彩。 梦油 发表于 2022-6-15 15:15
我相信,你的制作会越来越精彩。
老梦去看<天葬>‘, 加林森 发表于 2022-6-15 15:59
老梦去看‘,
好的,谢谢你告知。 梦油 发表于 2022-6-15 16:46
好的,谢谢你告知。
嗯嗯。 加林森 发表于 2022-6-14 20:58
你喜欢就好。我试了三个背景,感觉这个挺好看的就制作出来送你了。
嗯嗯,这个非常好{:4_187:} 加林森 发表于 2022-6-14 20:59
不客气的。喜欢就好!
再谢队长好礼{:4_187:} 红影 发表于 2022-6-15 19:06
嗯嗯,这个非常好
是的。很漂亮。 红影 发表于 2022-6-15 19:07
再谢队长好礼
不客气哦。 加林森 发表于 2022-6-15 19:33
是的。很漂亮。
很赞的{:4_187:} 加林森 发表于 2022-6-14 21:41
已经被顶出来了。
那天很快就下了{:4_181:} 千羽 发表于 2022-6-16 20:26
那天很快就下了
没关系的嘛。
页:
1
[2]