2024年9月12日 星期四
<style>
#tz { margin: 30px 0 30px calc(50% - 730px); width: 1280px; height: 700px; background: url('https://638183.freep.cn/638183/t24/3/1001.jpg') no-repeat center/cover, url('https://638183.freep.cn/638183/t24/webp2/hrxl.webp') no-repeat center/cover, radial-gradient(orange,lightgreen, white, plum); background-blend-mode: difference; border: thick groove gray; position: relative; --state: running; --scale: 1; }
#tz:fullscreen #hsvg { --scale: 1.8;}
#hsvg { position: absolute; left: calc(50% - 160px); top: calc(50% - 160px); border-radius: 50%; filter: drop-shadow(0 0 8px green); cursor: pointer; animation: rot 30s linear infinite var(--state); }
#hsvg:hover { --state: paused; }
@keyframes rot { from { transform: rotate(0deg) scale(var(--scale)); } to { transform: rotate(360deg) scale(var(--scale)); } }
</style>
<div id="tz">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=369592" autoplay loop></audio>
<svg id="hsvg" width="320" height="320" viewBox="0 0 320 320" fill="none" stroke="plum" stroke-linecap="round"></svg>
</div>
<script>
var sc = document.createElement('script');
sc.src = 'https://638183.freep.cn/638183/web/api/fullscreen.js';
sc.charset = 'utf-8';
document.body.appendChild(sc);
sc.onload = () => FS({papa: '#tz', css: 'bottom: 20px; left: 50%; --fsBg: #eeeeee90; --color: #336699;'});
drawPolygon = (total) => {
var pathstr = '<defs>', usestr = '';
Array(total).fill(0).forEach((id,idx) => {
id = idx + 1;
var bstr = idx === 0 ? '0s' : `p1.begin+${idx}s`;
var color = '#' + Math.random().toString(16).substring(2,8) + '9d';
pathstr += `
<path id="r${id}" stroke="${color}">
<animate id="p${id}" attributeName="d" values="m160,160l0,0 0,0;m130,110l30,-17 30,17;m130,60l30,-17 30,17;m160,20l0,0 0,0" dur="12s" repeatCount="indefinite" begin="${bstr}"/>
<animate attributeName="stroke-width" values="0;4;4;4;0" dur="12s" repeatCount="indefinite" begin="${bstr}"/>
</path>`;
Array(total).fill(0).forEach((u,k) => {
u = k + 1;
var angle = id % 2 === 0 ? 360 / total * k + 360 / total / 2 : 360 / total * k;
usestr += `<use xlink:href="#r${id}" transform="rotate(${angle} 160 160)"/>`;
});
});
pathstr += '</defs>';
return pathstr + usestr;
};
hsvg.innerHTML = drawPolygon(12);
mState = () => aud.paused ? (tz.style.setProperty('--state', 'paused'), hsvg.pauseAnimations()) : (tz.style.setProperty('--state', 'running'), hsvg.unpauseAnimations());
aud.onplaying = aud.onpause = () => mState();
hsvg.onclick = (e) => aud.paused ? aud.play() : aud.pause();
</script>
|