唯一
<style>#papa { left: -214px; width: 1024px; height: 640px; background: darkred url('https://638183.freep.cn/638183/t22/webp/weiyiu_1.webp') no-repeat center/cover; display: grid; place-items: center; box-shadow: 3px 3px 20px #000; user-select: none; position: relative; z-index: 1;}
#mplayer { position: absolute; left: 50%; bottom: 10px; width: 120px; height: 120px; border-radius: 50%; overflow: hidden; z-index: 3; }
#track { stroke: url(#gradient); }
#tmsg { fill: hsl(60,15%,25%); font: normal 1em sans-serif; }
#btnwrap { display: block; fill: hsla(0,100%,100%,.7); cursor: pointer; }
#btnwrap:hover { fill: hsla(0,60%,60%,.8); }
#lrc { --motion: cover1; --tt: 1.2s; --state: running; position: absolute; top: 15px; font: bold 2.4em sans-serif; color: hsl(20,10%,80%); -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px hsla(20,100%,0%,.95)); }
#lrc::before { position: absolute; content: attr(data-lrc); width: 20%; height: 100%; color: transparent; overflow: hidden; white-space: nowrap; background: linear-gradient(180deg,hsla(0,60%,100%,.95),hsla(120,90%,50%,.75)); filter: inherit; -webkit-background-clip: text; animation: var(--motion) var(--tt) linear forwards; animation-play-state: var(--state); }
.mpic { --delay: 0s; position: absolute; right: 200px; bottom: 140px; filter: blur(1px); animation: swing 2s var(--delay) infinite alternate; }
@keyframes cover1 { from { width: 0; } to { width: 100%; } }
@keyframes cover2 { from { width: 0; } to { width: 100%; } }
@keyframes swing { from { transform: rotate(-4deg); } to { transform: rotate(6deg); } }
</style>
<div id="papa">
<img src="https://638183.freep.cn/638183/t22/webp/boat.gif" alt="" class="mpic" />
<img src="https://638183.freep.cn/638183/t22/webp/boat.gif" alt="" class="mpic" style="--delay: 1s; left: 100px; bottom: 180px; width: 80px;" />
<div id="lrc" data-lrc="花潮论坛lrc在线">花潮论坛lrc在线</div>
<svg id="mplayer" width="120" height="120" shape-rendering="geometricPrecision">
<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"/>
<circle id="prog" cx="60" cy="60" r="50" fill="none" stroke-width="2" stroke="hsla(0,0%,90%,0.75)" />
</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>
<g id="btnwrap">
<path id="btnplay" d="M 50 50,50 70,70 60 z"></path>
<path id="btnmid" d="M 55 50, 55 70, 60 70, 60 50, 55 50 z" fill="transparent"></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>
</g>
<defs>
<linearGradient id="gradient" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="orange" stop-opacity="0.8" />
<stop offset="35%" stop-color="green" stop-opacity="0.8" />
<stop offset="65%" stop-color="teal" stop-opacity="0.8" />
<stop offset="100%" stop-color="darkblue" stop-opacity="0.8" />
</linearGradient>
</defs>
</svg>
</div>
<script>
(function() {
let mKey = 0, mFlag = true, aud = new Audio(), cc = { x: 1*track.getAttribute('cx'), y: 1*track.getAttribute('cy'), len: track.getTotalLength(), };
let lrcAr = [,,,,,,,,,,,,,,,,,,,,,,];
aud.src = 'https://music.163.com/song/media/outer/url?id=1807799505.mp3';
aud.autoplay = true;
aud.loop = true;
prog.style.strokeDasharray = prog.style.strokeDashoffset = cc.len;
btnwrap.onclick = () => aud.paused ? aud.play() : aud.pause();
aud.addEventListener('seeked', () => calcKey());
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;};
aud.addEventListener('pause', () => mState());
aud.addEventListener('play',() => mState());
aud.addEventListener('timeupdate', () => {prog.style.strokeDashoffset = cc.len - cc.len * aud.currentTime / aud.duration + 'px';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.setProperty('--state', 'paused')) : (btnplay.style.display = 'none', btnpause.style.display = 'block', lrc.style.setProperty('--state', 'running'));
let showLrc = (time) => {let name = mFlag ? 'cover1' : 'cover2';lrc.innerHTML = lrc.dataset.lrc = lrcAr;lrc.style.setProperty('--motion', name);lrc.style.setProperty('--tt', time + 's');lrc.style.setProperty('--state', 'running');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 time = lrcAr - (aud.currentTime - lrcAr);showLrc(time);};
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;}
mState();
}());
</script>
这两条小船体挺灵动,原来是静态图呢,是用代码让它们动起来的{:4_187:} 按视觉比例对远处的那条缩小了,而且两条船的摇动还是相差1秒,这样更有真实感。{:4_204:} 以前音画帖靠添加透明Flash,现在HTML5动画功能让音画帖灵动起来了,会应用代码真棒! 相约爱晚亭 发表于 2022-10-11 10:16
以前音画帖靠添加透明Flash,现在HTML5动画功能让音画帖灵动起来了,会应用代码真棒!
Flash不争气,没有能够解决安全隐患问题,可惜了 制作得真漂亮。赞!{:4_199:} 加林森 发表于 2022-10-11 12:36
制作得真漂亮。赞!
过得去 红影 发表于 2022-10-11 09:41
按视觉比例对远处的那条缩小了,而且两条船的摇动还是相差1秒,这样更有真实感。
小船画质偏低,低到极致,所以还用了模糊处理 红影 发表于 2022-10-11 09:39
这两条小船体挺灵动,原来是静态图呢,是用代码让它们动起来的
这个大家都会了的 马黑黑 发表于 2022-10-11 12:40
小船画质偏低,低到极致,所以还用了模糊处理
嗯嗯,朦朦胧胧的也好看{:4_204:} 马黑黑 发表于 2022-10-11 12:40
这个大家都会了的
不注意时,会以为它原本就是动态的啊{:4_173:} 马黑黑 发表于 2022-10-11 12:39
过得去
客气了。 这个小船晃动的效果很逼真,可以用大船吧,下面是大海,一首巡洋舰停在港口,这个效果肯定也是很美的 小辣椒 发表于 2022-10-11 16:25
这个小船晃动的效果很逼真,可以用大船吧,下面是大海,一首巡洋舰停在港口,这个效果肯定也是很美的
大船当然可以 红影 发表于 2022-10-11 15:32
嗯嗯,朦朦胧胧的也好看
不是好看,是为了遮丑{:4_170:} 红影 发表于 2022-10-11 15:33
不注意时,会以为它原本就是动态的啊
有点像的 加林森 发表于 2022-10-11 16:17
客气了。
客气一下应该 马黑黑 发表于 2022-10-11 18:10
不是好看,是为了遮丑
反倒得到意外效果呢{:4_204:} 马黑黑 发表于 2022-10-11 18:10
有点像的
说明动态弄得很恰当{:4_199:} 红影 发表于 2022-10-11 20:15
说明动态弄得很恰当
还行的