小辣椒 发表于 2022-9-20 22:00

何日君再来 (前段)(学习黑黑教程分享)

<img id="xx3" src="dt.jpg" alt="" /><style>
      #papa { left: -404px; width: 1400px; height: 711px;top:150px; background: #ccc url('https://wj.zp68.com/lxx/yunhua/2022/09/16/0IF.gif') no-repeat center/cover; box-shadow: 3px 3px 20px #000; display: grid; place-items: center; overflow: hidden; position: relative; z-index: 1; }
      #mplayer { position: absolute; left: 10px; bottom: 550px; }
      #btnwrap { display: block; fill: #ccc; cursor: pointer; }
      #btnwrap:hover { fill: orange; }
      #tmsg { fill: snow; stroke: gray; stroke-width: 1px; font: bold 1em sans-serif; }
      #lrc { position: absolute; bottom: 50px; left: 440px; font: bold 2em sans-serif; color: transparent; letter-spacing: 2px; background: linear-gradient(-90deg, darkgreen, orange, tomato) 100% 100% / 200% 200%; background-clip: text; -webkit-background-clip: text; }
      #xx {position: absolute; left: 0; top: 0; width: 12px;offset-distance: 0;offset-path: path("M500 -60 Q300 80, 300 200 T300 340");animation: move 8s linear infinite;}
      #xx1 {position: absolute; left: -50; top: -50; width: 12px;offset-distance: 0;offset-path: path("M500 -60 Q300 80, 300 200 T400 440");animation: move 8s linear infinite;}
      #xx2 {position: absolute; left: -10; top: 0; width: 12px;offset-distance: 0;offset-path: path("M500 -60 Q300 80, 300 200 T350 340");animation: move 8s linear infinite;}

      #xxr3 {position: absolute; left: 70; top: 20; width: 12px;offset-distance: 0;offset-path: path("M500 -60 Q300 80, 300 200 T450 440");animation: move 8s linear infinite;}
      #xx4 {position: absolute; left: 50; top: 30; width: 12px;offset-distance: 0;offset-path: path("M500 -60 Q300 80, 300 200 T200 340");animation: move 8s linear infinite;}

    #xx5 {position: absolute; left: -20; top: 50; width: 12px;offset-distance: 0;offset-path: path("M500 -60 Q300 80, 300 200 T250 340");animation: move 8s linear infinite;}
      @keyframes bgMove1 { from { background-position: 0 0; } to { background-position: -100% 0; } }
      @keyframes bgMove2 { from { background-position: 0 0; } to { background-position: -100% 0; } }
      @keyframes move { to { offset-distance: 100%;} }
</style>

<div id="papa">
      <img id="xx" src="https://wj.zp68.com/lxx/yunhua/2022/09/16/dt.jpg" alt="" />
       <img id="xx1" src="https://wj.zp68.com/lxx/yunhua/2022/09/16/dt.jpg" alt="" />
       <img id="xx2" src="https://wj.zp68.com/lxx/yunhua/2022/09/16/dt.jpg" alt="" />
       <img id="xx3" src="https://wj.zp68.com/lxx/yunhua/2022/09/16/dt.jpg" alt="" />
       <img id="xx4" src="https://wj.zp68.com/lxx/yunhua/2022/09/16/dt.jpg" alt="" />
       <img id="xx5" src="https://wj.zp68.com/lxx/yunhua/2022/09/16/dt.jpg" alt="" />
      <div id="lrc">花潮lrc在线</div>
      <svg id="mplayer" width="120" height="120">
                <g id="mama" transform="rotate(-90, 60, 60)" style="cursor: pointer;">
                        <circle id="track" cx="60" cy="60" r="50" fill="none" stroke-width="10" stroke="rgba(255,255,255,0.65)" />
                        <circle id="prog" cx="60" cy="60" r="50" fill="none" stroke-width="6" stroke="rgba(57,54,81,0.85)" />
                </g>
                <g id="btnwrap">
                        <path id="btnplay" d="M 50 50,50 70,70, 60 z"></path>
                        <path id="btnpause" d="M 52 50,52 70,57 70,57 50,52 50 z M 60 50,60 70,65 70,65 50,60 50 z"></path>
                        <path d="M 57 50,60 50,60 70,57 70 z" fill="transparent" />
                </g>
                <path id="curPath" d="M 20 70 Q 60 0 100 70" fill="none" stroke="none"/>
                <path id="durPath" d="M 20 55 Q 60 110 100 55" fill="none" stroke="none"/>
                <g id="tmsg">
                        <text x="34" y="0"><textPath id="curMsg" xlink:href="#curPath" dominant-baseline="text-after-edge">00:00</textPath></text>
                        <text x="29" y="0"><textPath id="durMsg" xlink:href="#durPath" dominant-baseline="text-before-edge">00:00</textPath></text>
                </g>
      </svg>
</div>

<script>
let lrcAr = [
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
        ,
];
let mKey = 0, mSeek = false, mFlag = true;
let aud = new Audio();
let cc = {
      x: 1*track.getAttribute('cx'),
      y: 1*track.getAttribute('cy'),
      r: 1*track.getAttribute('r'),
      sw: 1*track.getAttribute('stroke-width'),
      len: track.getTotalLength(),
};

prog.style.strokeDasharray = prog.style.strokeDashoffset =cc.len;
aud.src = 'https://wj.zp68.com/lxx/yunhua/2022/09/16/hrjzl.mp3';
aud.autoplay = true;
aud.loop = true;

mama.onclick = (e) => {
      let deg = Math.atan2(e.offsetY - cc.y, e.offsetX - cc.x) * 180 / Math.PI;
      deg += (e.offsetX < cc.x && e.offsetY < cc.y) ? 450 : 90;
      aud.currentTime = aud.duration * deg / 360;
};

btnwrap.onclick = () => aud.paused ? aud.play() : aud.pause();

aud.addEventListener('pause', () => mState());
aud.addEventListener('play', () => mState());
aud.addEventListener('seeked', () => calcKey());

aud.addEventListener('timeupdate', () => {
      prog.style.strokeDashoffset = cc.len - cc.len * aud.currentTime / aud.duration;
      curMsg.textContent = toMin(aud.currentTime);
      durMsg.textContent = toMin(aud.duration);
      for(j=0; j<lrcAr.length; j++) {
                if(aud.currentTime >= lrcAr) {
                        if(mKey === j) showLrc(lrcAr);
                        else continue;
                }
      }
});

let mState = () => aud.paused ? (btnplay.style.display = 'block', btnpause.style.display = 'none', lrc.style.animationPlayState = 'paused') : (btnplay.style.display = 'none', btnpause.style.display = 'block', lrc.style.animationPlayState = 'running');

let showLrc = (time) => {
      lrc.style.animation = (mFlag ? 'bgMove1 ' : 'bgMove2 ') + time + 's linear forwards';
      lrc.innerHTML = lrcAr;
      mKey += 1;
      mFlag = !mFlag;
}

let calcKey = () => {
      for(j = 0; j < lrcAr.length; j ++) {
                if(aud.currentTime <= lrcAr) {
                        mKey = j - 1;
                        break;
                }
      }
      if(mKey <0) mKey = 0;
      if(mKey > lrcAr.length - 1) mKey = lrcAr.length - 1;
      let mtime = lrcAr - (aud.currentTime - lrcAr);
      showLrc(mtime);
}

let toMin = (val)=> {
      if (!val) return '00:00';
      val = Math.floor(val);
      let min = parseInt(val / 60), sec = parseFloat(val % 60);
      if(min < 10) min = '0' + min;
      if(sec < 10) sec = '0' + sec;
      return min + ':' + sec;
}
</script>
<br><br><br><br><br><br><br><br><br><br>

小辣椒 发表于 2022-9-20 22:02

@马黑黑

黑黑~~我2天的作业合一起了,这个专辑我分享过的,昨天看见你的那个马上想到我有图图,有音乐的,现成的套用一个,今天的歌词颜色我用上去了


小辣椒 发表于 2022-9-20 22:03

只是这个星星路径我真的是瞎捣鼓的,就想这个效果,乱星飞舞{:4_170:}

马黑黑 发表于 2022-9-20 22:07

这么多星星,全用id标识,这是手工活啊。如果JS基础好,用JS生成就轻松多了

小辣椒 发表于 2022-9-20 22:07

黑黑我这个路径还是不会

小辣椒 发表于 2022-9-20 22:07

我预览和现在的效果不一样

小辣椒 发表于 2022-9-20 22:08

匆匆忙忙的以为赶出来一个作业,结果没有满意

小辣椒 发表于 2022-9-20 22:09

马黑黑 发表于 2022-9-20 22:07
这么多星星,全用id标识,这是手工活啊。如果JS基础好,用JS生成就轻松多了

这个我不会

小辣椒 发表于 2022-9-20 22:10

马黑黑 发表于 2022-9-20 22:07
这么多星星,全用id标识,这是手工活啊。如果JS基础好,用JS生成就轻松多了

我刚才是在想这个设置多个的,捣鼓不好

马黑黑 发表于 2022-9-20 22:10

小辣椒 发表于 2022-9-20 22:09
这个我不会

那就只能手工一个一个弄

马黑黑 发表于 2022-9-20 22:10

小辣椒 发表于 2022-9-20 22:10
我刚才是在想这个设置多个的,捣鼓不好

是的,需要大批量的,就得用JS

小辣椒 发表于 2022-9-20 22:11

马黑黑 发表于 2022-9-20 22:10
那就只能手工一个一个弄

我是主要路径不懂,我安高度修改,预览好的,结果发论坛效果不一样了

马黑黑 发表于 2022-9-20 22:12

小辣椒 发表于 2022-9-20 22:11
我是主要路径不懂,我安高度修改,预览好的,结果发论坛效果不一样了

预览环境与论坛环境多少有点区别

小辣椒 发表于 2022-9-20 22:14

马黑黑 发表于 2022-9-20 22:12
预览环境与论坛环境多少有点区别

是的,我就再自己捣鼓捣鼓{:4_189:}

一定要自己学会才会记住

马黑黑 发表于 2022-9-20 23:02

小辣椒 发表于 2022-9-20 22:14
是的,我就再自己捣鼓捣鼓

一定要自己学会才会记住

是这个道理

红影 发表于 2022-9-20 23:13

漂亮,无论是艳丽的女郎,还是闪烁的星星,都是恰到好处,亲爱的真棒{:4_199:}

梦油 发表于 2022-9-21 09:12

这星星仿佛是高速摄影的流星,真好看!

加林森 发表于 2022-9-21 11:46

真漂亮的制作。赞!{:4_199:}
页: [1]
查看完整版本: 何日君再来 (前段)(学习黑黑教程分享)