本帖最后由 加林森 于 2022-8-12 19:05 编辑 <br /><br />上海朝阳 发表于 2022-6-16 08:17
试试看,高音部分应该能完成
期待中。。。
<style>
#papa { left: -214px; width: 1024px; height: 640px; background: #000 url('https://s1.ax1x.com/2022/08/11/v8Yyoq.png') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; }
#canv { position: absolute; }
#disc { position: absolute; width: 40px; height: 40px; left: 10px; top: 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; }
#tit { position: absolute; left: 60px; top: 10px;font: bold 22px / 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 = papa.offsetWidth, h = canv.height = papa.offsetHeight;
let particles = [], idx = 0, aud = new Audio();
aud.src = 'https://music.163.com/song/media/outer/url?id=1850278335.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) + 100;
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 * 2)) + (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>
马黑黑 发表于 2022-6-15 20:25
神鹰不飞了?
老黑上午好。我根据你的《h5选项卡》教程终于把鹰放上来了。谢谢!
加林森 发表于 2022-6-15 21:37
老梦喜欢就好!
喜欢,喜欢。你制作的作品十分吸引人哎!
梦油 发表于 2022-6-16 10:22
喜欢,喜欢。你制作的作品十分吸引人哎!
现在我把鹰放进去了,你再看看效果。
加林森 发表于 2022-6-16 10:24
现在我把鹰放进去了,你再看看效果。
不错,不错,整个画面显得更加雄姿英发,更有气魄啦。
梦油 发表于 2022-6-16 10:37
不错,不错,整个画面显得更加雄姿英发,更有气魄啦。
挺好玩的,对不对!{:4_189:}
加林森 发表于 2022-6-16 10:42
挺好玩的,对不对!
是的,你真行。
梦油 发表于 2022-6-16 10:46
是的,你真行。
喜欢你就多听听。
加林森 发表于 2022-6-16 11:08
喜欢你就多听听。
好的,谢谢你。
加林森 发表于 2022-6-16 10:16
老黑上午好。我根据你的《h5选项卡》教程终于把鹰放上来了。谢谢!
那个教程和鹰有关?
马黑黑 发表于 2022-6-16 12:14
那个教程和鹰有关?
我是在里面学习到的东西啊。
梦油 发表于 2022-6-16 11:20
好的,谢谢你。
嗯嗯
梦油 发表于 2022-6-16 11:20
好的,谢谢你。
不客气的。
加林森 发表于 2022-6-16 15:58
我是在里面学习到的东西啊。
专门讲定位的你又不是内看见过
马黑黑 发表于 2022-6-16 18:23
专门讲定位的你又不是内看见过
我是突然有了灵感就制作出来了。
欣赏队长的精美制作{:4_177:}
加林森 发表于 2022-6-16 18:26
我是突然有了灵感就制作出来了。
挺好
小辣椒 发表于 2022-6-16 18:38
欣赏队长的精美制作
谢谢小辣椒!{:4_204:}
马黑黑 发表于 2022-6-16 18:55
挺好
是的。
加林森 发表于 2022-6-16 08:19
期待中。。。
我下载了,好像有点踏不准,呵呵呵