亚伦影音工作室 发表于 2023-3-15 21:15

云底人间 - 程响【全图可控】

本帖最后由 亚伦影音工作室 于 2023-3-15 21:17 编辑 <br /><br /><style type="text/css">
#papa {
        margin: 10px 40px;
        width: 400px;
        height: 750px;
        background: #000078 url(https://www.kumeiwp.com/sub/filestores/2022/11/25/cc012868c435dd0107c8d5dd00af0066.gif) center/cover no-repeat;
        box-shadow: 2px 2px 2px #000;
        position: relative;
        display: grid;
        place-items: center;
        z-index: 1;
}

#mplayer {z-index: 2;
        --state: paused;
        position: absolute;top:0%; left:0%;
        bottom: 0px;
        width: 100%;
        height: 100%;
        cursor: pointer;
        border-radius: 0%;
        animation: flash .3s infinite alternate var(--state);
}
#mplayer:hover { display:block ;transform: skew(0deg);}
@keyframes flash {
        to { filter: drop-shadow(1px 1px 0px green); }
}

#mypic {
        width: 100%;
        height: 100%;
        display: none;
        position: absolute;
}

#canv {
        display: block;
        position: absolute;
}

</style>
<div id="papa">
<span id="fullscreen">全屏欣赏</span>
<div id="testImg" >
<div class='pat'>
<divclass='pa'>➣</div><divclass='pa'>➣</div><divclass='pa'>➣</div><divclass='pa'>➣</div><divclass='pa'>➣</div><divclass='pa'>➣</div><divclass='pa'>➣</div><div class='pa'>➣</div>
</div>
<div type="button" id="btn"title="暂停/播放">
<div id="mplayer"><canvas height="750" id="canv" width="400"></canvas> <img alt="" id="mypic" src="https://www.kumeiwp.com/sub/filestores/2022/11/25/cc012868c435dd0107c8d5dd00af0066.gif" />
<audio autoplay="" id="aud" loop="" src="https://aimg8.dlssyht.cn/u/0/ueditor/file/0/0/1678885716537063.mp3">&nbsp;</audio>
</div>
</div>
<div data-lrc="亚伦影音工作室" id="lrc">亚伦影音工作室</div>
</div>
<script>
(function() {
        let context = canv.getContext('2d');
        let oImg = new Image();
        oImg.src = mypic.src;
        oImg.onload = () => context.drawImage(oImg,0,0,canv.width,canv.height);
        let mState = () => aud.paused ? (canv.style.display = 'block', mypic.style.display = 'none', mplayer.style.setProperty('--state','paused')) : (canv.style.display = 'none', mypic.style.display = 'block', mplayer.style.setProperty('--state','running'));
        aud.addEventListener('play', () => mState());
        aud.addEventListener('pause', () => mState());
        mplayer.onclick = () => aud.paused ? aud.play() : aud.pause();

})();
</script>
<style type="text/css">#lrc {
        --state: paused;
        --motion: cover2;
        --tt: 2s;
        --bg: linear-gradient(180deg, #880000, #880000);
        position: absolute;z-index: 3;
        left: 50%;
        transform: translate(-50%);
        top: 80%;
        font:normal 1.8em 华文隶书;
        color: #000078;
        white-space: pre;
        -webkit-background-clip: text;
        filter:drop-shadow(#FFFFFF 1px 0 0)drop-shadow(#FFFFFF 0 1px 0)drop-shadow(#FFFFFF -1px 0 0) drop-shadow(#FFFFFF 0 -1px0);
}
#lrc::before {
        position: absolute;
        content: attr(data-lrc);
        width: 20%;
        height: 100%;
        color: transparent;
        overflow: hidden;
        white-space: pre;
        background: var(--bg);
       
        -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>
<script >
(function() {
/*原始lrc歌词*/
let lrcStr = `
云底人间 - 程响
词Lyricist:宋普照
曲Composer:杨优秀/常超凡
出品人:亚伦
OP:亚伦影音工作室
【未经许可 不得使用】
天地乾坤一道线
把混沌斩两边
谁人不是在这炉中练
苍老了容颜
人生的路突兀陷
那遗憾多绵延
倘若大梦惊醒再一遍
你想怎么演
你我苟且在这云底人间
看过千千万万真人假面
时光匆匆一晃多少年
那时的梦还剩下几分的迷恋
人生的路突兀陷
那遗憾多绵延
倘若大梦惊醒再一遍
你想怎么演
你我苟且在这云底人间
看过千千万万真人假面
时光匆匆一晃多少年
那时的梦还剩下几分的迷恋
你我苟且在这云底人间
看过千千万万真人假面
时光匆匆一晃多少年
那时的梦还剩下几分的迷恋
`;

/*变量 :mKey - 当前歌词索引;mFlag :调用关键帧动画索引;averAdd :平均值补偿*/
let mKey = 0, mFlag = true, averAdd = 0.3;

/*函数 :获取每句歌词用时,歌词用时若超过平均值则取平均值,最后一句歌词则取平均值*/
let lrcTime = (ar) => {
        let tmpAr = [];
        for(j = 0; j <ar.length - 1; j ++) {
                if(j !== ar.length - 1) tmpAr = parseFloat((ar - ar).toFixed(1));
        }
        let aver = parseInt(tmpAr.reduce((a,b) => a + b) / (tmpAr.length - 1)) + averAdd;
        tmpAr.push(aver);
        tmpAr.forEach((item,key) => {
                ar = item > aver ? aver : item;
        });
        return ar;
};

/*函数 :从原始lrc歌词获取信息并存入 n*3 数组*/
let getLrcAr = (text) => {
        let lrcAr = [];
        let calcRule = ;
        for(x of text.split('\n')) {
                let ar = [];
                let re = /\d+[\.:]\d+([\.:]\d+)?/g;
                let geci = x.replace(re,'');
                if(geci) {
                        geci = geci.replace(/[\[\]\'\"\t,]s?/g,'');
                        let time = x.match(re);
                        if(time != null) {
                                for(y of time) {
                                        let tmp = y.match(/\d+/g);
                                        let sec = 0;
                                        for(z in tmp) sec += tmp * calcRule;
                                        ar = ;
                                        lrcAr.push(ar);
                                }
                        }
                }
        }
        lrcAr.sort((a,b)=> a - b);
        return(lrcTime(lrcAr));
};

/*函数 :模拟显示同步歌词*/
let showLrc = (time) => {
        let name = mFlag ? 'cover1' : 'cover2';
        lrc.innerHTML = lrcAr;
        lrc.dataset.lrc = lrcAr;
        lrc.style.setProperty('--motion', name);
        lrc.style.setProperty('--tt', time + 's');
        lrc.style.setProperty('--state', 'running');
        mKey += 1;
        mFlag = !mFlag;
};

/*函数 :处理当前歌词索引 mKey*/
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;
}

/*函数 :关键帧动画状态切换*/
let mState = () => aud.paused ? (lrc.style.setProperty('--state','paused'),mplayer.style.animationPlayState = 'paused') : (lrc.style.setProperty('--state','running'),mplayer.style.animationPlayState = 'running');

/*监听播放进度*/
aud.addEventListener('timeupdate', () => {
        for (j = 0; j < lrcAr.length; j++) {
                if (aud.currentTime >= lrcAr) {
                        cKey = j;
                        if (mKey === j) showLrc(lrcAr);
                        else continue;
                }
        }
});
aud.addEventListener('pause', () => mState());/*监听暂停事件*/
aud.addEventListener('play', () => mState());/*监听播放事件*/
aud.addEventListener('seeked', () => calcKey());/*监听查询事件*/
let lrcAr = getLrcAr(lrcStr); /*获得歌词数组*/
})();
var image = document.getElementById("testImg"),
    button = document.getElementById("btn");
   
if (image.classList && image && button) {
    button.onclick = function() {
      if (this.value == '.') {
            image.classList.remove('stop');
          this.value = '*';
      } else {
            image.classList.add('stop');
            this.value = '.';
      }
    };
}


</script>
<style>
.pat {position: absolute; top:70%; left:35%;z-index: 3;
--tf: linear;
--effect: hover 2s var(--tf) infinite;
width: 1000px;
}
.stop .pat{
animation-play-state: paused;
}
.pa {   display: inline-block;
text-transform: uppercase;
text-align: center;
font-size: 1.8em;
color: #00ff00;
}

.pa:nth-child(1) {
animation: var(--effect);
}

.pa:nth-child(2) {
animation: var(--effect) .125s;
}

.pa:nth-child(3) {
animation: var(--effect) .25s;
}

.pa:nth-child(4) {
animation: var(--effect) .375s;
}

.pa:nth-child(5) {
animation: var(--effect) .5s;
}

.pa:nth-child(6) {
animation: var(--effect) .675s;
}

.pa:nth-child(7) {
animation: var(--effect) .75s;
}
.pa:nth-child(8) {
animation: var(--effect) 1s;
}
.stop .pa:nth-child(1) {
animation-play-state: paused;
}
.stop .pa:nth-child(2) {
animation-play-state: paused;
}
.stop .pa:nth-child(3) {
animation-play-state: paused;
}
.stop .pa:nth-child(4) {
animation-play-state: paused;
}
.stop .pa:nth-child(5) {
animation-play-state: paused;
}
.stop .pa:nth-child(6) {
animation-play-state: paused;
}
.stop .pa:nth-child(7) {
animation-play-state: paused;
}
.stop .pa:nth-child(8) {
animation-play-state: paused;
}
@keyframes hover {
0% {
    transform: scale(0);
    color: #000080;
}

20% {
    transform: scale(1);
    color: #ff0000;
}

50% {opacity: 1;
    transform: scale(1);
    color: #fff000;
   
}

80% {
    transform: scale(0);
    color: #000080;
    }
}
</style>

焱鑫磊 发表于 2023-3-15 21:25

欣赏佳作!{:4_204:}

红影 发表于 2023-3-15 21:38

这样比例的图图也挺好看的呢,的确点击图片,就能让音乐和动图都暂停了。只是动图的暂停就回到背面的样子了,不是转归来时的样子呢。欣赏亚伦老师好帖{:4_187:}

大猫咪 发表于 2023-3-15 22:19

图美歌靓! 好制作,欣赏学习!谢谢朋友好帖! 晚上好!

{:4_204:}{:4_199:}

马黑黑 发表于 2023-3-15 23:29

漂亮

庶民 发表于 2023-3-16 05:03

真美,点赞。
页: [1]
查看完整版本: 云底人间 - 程响【全图可控】