马黑黑 发表于 2022-10-6 07:31

本帖最后由 马黑黑 于 2022-10-6 07:46 编辑 <br /><br /><details>
<summary>quiet</summary>


</details>

马黑黑 发表于 2022-10-6 12:45

https://www.huachaowang.com/forum.php?mod=attachment&aid=NDM0NDZ8Mzg5M2Q0NDF8MTY2NTAzMTQ5Nnw3MTMwfDU2MzQ3

马黑黑 发表于 2022-10-6 16:04


马黑黑 发表于 2022-10-23 11:32

<style>
#papa { left: -214px; width: 1024px; height: 640px; background: url('https://638183.freep.cn/638183/t22/webp/xiyjhx.webp') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; display: grid; place-items: center; user-select: none; z-index: 1; --opt: .25;}
#papa::before { position: absolute; content: ''; width: 100%; height: 100%; background: url('https://638183.freep.cn/638183/t22/webp/124.gif') repeat; opacity: var(--opt); }
#mplayer { position: absolute; bottom: 0; z-index: 9; }
#lrc { --motion: cover1; --tt: 5s; --state: paused; position: absolute; top: 30px; font: bold 2.4em sans-serif; color: hsl(0,10%,90%); -webkit-background-clip: text; filter: drop-shadow(1px 1px 2px hsla(0,0%,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(280,100%,50%,.75),hsla(180,100%,50%,.75)); filter: inherit; -webkit-background-clip: text; animation: var(--motion) var(--tt) linear forwards; animation-play-state: var(--state); }
@keyframes cover1 { from { width: 0; } to { width: 100%; } }
@keyframes cover2 { from { width: 0; } to { width: 100%; } }
</style>

<div id="papa">
        <div id="lrc" data-lrc="花潮lrc在线">花潮lrc在线</div>
        <svg id="mplayer" width="360" height="60" style="user-select: none;">
                <rect x="50" y="25" rx="6" ry="6" width="200" height="12" stroke="hsla(280,90%,55%,.45)" fill="hsla(60,100%,92%,.35)" id="track" />
                <rect x="50" y="25" rx="6" ry="6" width="0" height="12" stroke="transparnet" fill="hsla(280,90%,55%,.45)" id="prog" />
                <text x="260" y="31" font-size="14" dominant-baseline="middle" stroke="none" fill="tan" id="audtime">00:00 | 00:00</text>
                <circle cx="25" cy="30" r="15" fill="url(#bgcolor)" id="btnplay">
                        <animateTransform attributeName="transform" dur="4s" type="rotate" from="0 25 30" to="360 25 30" repeatCount="indefinite" />
                </circle>
                <defs>
                        <linearGradient x1="0%" y1="0%" x2="100%" y2="50%" id="bgcolor">
                                <stop offset="0%" style="stop-color: pink; stop-opacity:0.8" />
                                <stop offset="100%" style="stop-color: green; stop-opacity:0.75" />
                        </linearGradient>
                </defs>
        </svg>
</div>

<script>
(function() {
        let mp = { len: track.getAttribute('width')*1, x: track.getAttribute('x')*1 }, aud = new Audio(), mKey = 0, mFlag = true;
        let lrcAr = [,,,,,,,,,,,,,];
        aud.src = 'https://music.163.com/song/media/outer/url?id=1973395208.mp3';
        aud.loop = true;
        aud.autoplay = true;
        if(aud.paused) mplayer.pauseAnimations();
        btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
        prog.onclick = track.onclick = (e) => aud.currentTime = aud.duration * (e.offsetX - mp.x) / mp.len;
        aud.addEventListener('seeked', () => calcKey());
        aud.addEventListener('pause', () =>mState());
        aud.addEventListener('play', () =>mState());
        aud.addEventListener('timeupdate', () => {prog.style.setProperty('width', aud.currentTime * 200 / aud.duration + 'px');audtime.textContent = toMin(aud.currentTime) + ' | ' + toMin(aud.duration);for(j=0; j<lrcAr.length; j++) {if(aud.currentTime >= lrcAr) {cKey = j;if(mKey === j) showLrc(lrcAr);else continue;}}});
        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 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 mState = () => aud.paused ? (mplayer.pauseAnimations(),lrc.style.setProperty('--state', 'paused'),papa.style.setProperty('--opt','0')) : (mplayer.unpauseAnimations(), lrc.style.setProperty('--state', 'running'),papa.style.setProperty('--opt','.25'));
        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>

马黑黑 发表于 2022-10-23 11:33

164#测试 svg 线性渐变按钮

马黑黑 发表于 2022-10-23 11:40

之前,纯 svg 播放控制器使用文本按钮,手机上按钮的旋转未能基于文本中心。原因:计算机上计算好的 rotate 基点,手机对svg和字体渲染问题导致中心发生不同于计算机上的变化,出现不适原处旋转,而是小范围绕圈。

svg下的文本按钮看样子存在兼容移动设备的问题,不好处理。故在164楼测试其他解决方案:用线性渐变的圆形按钮。

@小辣椒

小辣椒 发表于 2022-10-23 13:07

马黑黑 发表于 2022-10-23 11:40
之前,纯 svg 播放控制器使用文本按钮,手机上按钮的旋转未能基于文本中心。原因:计算机上计算好的 rotate ...

好的,谢谢黑黑,你是精益求精{:4_187:}

马黑黑 发表于 2022-10-23 15:21

小辣椒 发表于 2022-10-23 13:07
好的,谢谢黑黑,你是精益求精

啥呢?碰上问题,解决问题

小辣椒 发表于 2022-10-23 18:10

马黑黑 发表于 2022-10-23 15:21
啥呢?碰上问题,解决问题

啥问题对你来说一眨眼,解决了

马黑黑 发表于 2022-10-23 18:55

小辣椒 发表于 2022-10-23 18:10
啥问题对你来说一眨眼,解决了

你这一眨眼也是要一万年的{:4_173:}

马黑黑 发表于 2022-10-24 22:48

马黑黑 发表于 2022-10-24 22:48

马黑黑 发表于 2022-10-24 22:49

马黑黑 发表于 2022-10-28 12:31






马黑黑 发表于 2022-10-28 12:31

马黑黑 发表于 2022-10-28 12:33


马黑黑 发表于 2022-10-29 08:43

<style type="text/css">
      #vWindow      {
                width:500px;
                height:1000px;
                border:thick brown ridge;
                margin: 12px auto;
                background-image:url('https://s3.bmp.ovh/imgs/2022/10/25/3a5f951ab29ffec3.jpg');
                background-position: -1px -1px;
                background-size:cover;
      }
      .itemy      {
                width:500px;
                height:50px;
                background-position: 0 calc(var(--index) * 5%);
                background-image:url('https://s3.bmp.ovh/imgs/2022/10/25/3a5f951ab29ffec3.jpg');
                background-size:500px 1000px;
                transform-origin: 0%100%;
      }
</style>

<div id="vWindow"></div>

<script type="text/javascript">
(function() {
let imgSet = [
"https://s3.bmp.ovh/imgs/2022/10/26/921786027c7d70d4.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/7844960c1ea5cb20.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/5bca2b145ed6ff2a.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/452e0fe3064cb2c5.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/ae116f757cd90358.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/cce6012c9e8d5ba2.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/1179ef54c304895d.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/191afd745ff4c5b3.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/ea2f9003982d031b.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/6fa0aa5ece82295c.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/97b282a86f0c8226.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/de6f8b1503a0a9b2.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/f94be16fa70aa90e.jpg",
"https://s3.bmp.ovh/imgs/2022/10/26/736bbe28a8fd41be.jpg",
"https://s3.bmp.ovh/imgs/2022/10/25/5a9df07037122f0c.jpg",
"https://s3.bmp.ovh/imgs/2022/10/25/40461b7a1cd6c6d3.jpg",
"https://s3.bmp.ovh/imgs/2022/10/25/7a489ea1bda4aab1.jpg",
"https://s3.bmp.ovh/imgs/2022/10/25/3a5f951ab29ffec3.jpg"
];

var Keyframes = [
    [{transform: 'rotateX(90deg)', opacity: '0.3' }, {offset:0.5, transform: 'rotateX(0deg)', opacity: '1' }],
    [{opacity: '0' }, {opacity: '1'}]
];
var EffectTiming = { duration: 8000,fill: 'forwards'};
var imgIdx = 0,    lastIdx = imgSet.length - 1;
var items = new Array(), aniObj = new Array();
var vWindow = document.getElementById('vWindow');

    for (i = 0; i < 1000; i+=50) {
      let itemy = document.createElement('div');
                itemy.style.setProperty('--index',parseInt(i / 50));
                items.push(itemy);
      itemy.classList.add('itemy');
      vWindow.appendChild(itemy)
    }
      
      let chg_cur_pic = () => {
                for (i = 0; i < items.length; i++) {
                        items.style.backgroundImage = "url(" + imgSet + ")"
                }
                vWindow.style.backgroundImage = "url(" + imgSet + ")";
               
                lastIdx = imgIdx;
                imgIdx++;
                imgIdx %= imgSet.length;
                for (j = 0; j < items.length; j++) {
                        aniObj.play()
                }
      };      
      
    for (j = 0; j < items.length; j++) {
                items.style.backgroundImage = "url(" + imgSet + ")";
      aniObj = items.animate(Keyframes, EffectTiming);
    }
    aniObj.addEventListener('finish', chg_cur_pic);
})();
</script>

马黑黑 发表于 2022-10-29 08:44

没啥问题

起个网名好难 发表于 2022-10-29 09:26

马黑黑 发表于 2022-10-29 08:43
#vWindow      {
                width:500px;
                height:1000px;


我就是通不过,只能看到一个框{:5_102:}

起个网名好难 发表于 2022-10-29 09:27

马黑黑 发表于 2022-10-29 08:44
没啥问题

真怪事,谢谢。
页: 1 2 3 4 5 6 7 8 [9] 10
查看完整版本: 图图专用帖