小辣椒 发表于 2023-9-30 20:37

热烈祝贺祖国74周年华诞!


<style >
#papa{margin: 150px -340px ;width: 1276px;box-shadow: 0px 0px 0px 2px #cccccc, 0px 0px 0px 6px #880000; overflow: hidden;
height: 745px;
border: 1px solid;
background: #333 url('https://wj.zp68.com/lxx/yunhua/2023/09/24/28.gif') no-repeat center/cover;
position: relative;z-index: 12345;}
#img_border{position: absolute;top:10%; left:44%;width: 100%;height: 100%;z-index:3;-webkit-mask-image: radial-gradient();}
#benban{position: absolute;top:0%; left:0%;width: 100%;height: 100%;z-index:4;background:linear-gradient(0deg, #000000 2%,#000000 8%,rgba(2, 2, 2, 0) 30%,rgba(52, 152, 219, 0) 100%,rgba(2, 2, 2, 0) 100%,black 100%);}
#papa:hover #fullscreen { display:block ;}
#fullscreen { position: absolute; top:82%; left:88%;color:#FFffff; filter:drop-shadow( 1px 1px 1px #000000);font: normal 2em华文隶书; opacity: 1; cursor: pointer; z-index: 111}
#dt{position: absolute;top:0%; left:0%;z-index: 2;
        width:100%;
        height:100%; transition: .3s all ease;}
#mplayer {top:65%; left:5%;z-index: 3;
position: absolute;
font: normal 7em/0em serif;
color:#ffffff;
cursor: pointer;
animation: spin 10s infinite linear;
}
@keyframes spin {0% { transform: rotate(360deg); }
}
#audio{top:90%; left:0%;z-index: 6;
position: absolute;
width:100%;
cursor: pointer;
mix-blend-mode: lighten;filter:invert(100%)
}
#flyBox { --w: 60%; width: var(--w); overflow: hidden; color: #cccccc; position: absolute; left:20%;top:88%;font-size: 18px; z-index: 36;}
#flyBox div { word-break: keep-all; white-space: nowrap; animation: fly 40s linear infinite; background:#0000}
@keyframes fly { from { transform: translateX(100%); } to { transform: translateX(calc(0% - var(--w))); }}
</style>
<div id='papa'>
<span id="fullscreen">全屏观赏</span>
<div id='benban' ></div>
<div id="img_border"><imgsrc="https://xlaj.cn/assets/file/zp/20230927233112.gif" width="400px" height="400px"></div>
<div id='dt'><img id="testImg" src="https://wj.zp68.com/lxx/yunhua/2023/09/24/28.gif" width="100%" height="100%"></div>
<div id="lrc" data-lrc="我和我的祖国">我和我的祖国</div>
<div id="mplayer"></div>
<div id='audio'>
<audio id="aud" src="https://wj.zp68.com/lxx/yunhua/20210930/01.mp3"style="width:100%;"autoplay="autoplay" controls="controls" height="100%" loop="loop"></audio></div>
   <div id="flyBox"><div>热烈祝贺中华人民共和国成立74周年华诞!</div></div>
</div>


<script>
if ('getContext' in document.createElement('canvas')) {
    HTMLImageElement.prototype.play = function() {
      if (this.storeCanvas) {
            // 移除存储的canvas
            this.storeCanvas.parentElement.removeChild(this.storeCanvas);
            this.storeCanvas = null;
            // 透明度还原
            image.style.opacity = '';
      }
      if (this.storeUrl) {
            this.src = this.storeUrl;   
      }
    };
    HTMLImageElement.prototype.stop = function() {
      var canvas = document.createElement('canvas');
      // 尺寸
      var width = this.width, height = this.height;
      if (width && height) {
            // 存储之前的地址
            if (!this.storeUrl) {
                this.storeUrl = this.src;
            }
            // canvas大小
            canvas.width = width;
            canvas.height = height;
            // 绘制图片帧(第一帧)
            canvas.getContext('2d').drawImage(this, 0, 0, width, height);
            // 重置当前图片
            try {
                this.src = canvas.toDataURL("image/gif");
            } catch(e) {
                // 跨域
                this.removeAttribute('src');
                // 载入canvas元素
                canvas.style.position = 'absolute';
                // 前面插入图片
                this.parentElement.insertBefore(canvas, this);
                // 隐藏原图
                this.style.opacity = '0';
                // 存储canvas
                this.storeCanvas = canvas;
            }
      }
    };
}

var image = document.getElementById("testImg");
varbutton = document.getElementById("mplayer");
let mState = () => aud.paused ? image.stop() : image.play();

aud.addEventListener('play', mState,false);
aud.addEventListener('pause', mState,false);

let fs = true;
        fullscreen.onclick = () => {
                fs ? (fullscreen.innerText = '退出全屏', papa.requestFullscreen()) : (fullscreen.innerText = '全屏观赏', document.exitFullscreen());
                fs = !fs;
        };

</script>
<style>
#lrc {
        --state: paused;
        --motion: cover2;
        --tt: 2s;
        --bg: linear-gradient(180deg, #880000, #880000);
        position: absolute;
        left: 50%;z-index: 20;
        transform: translate(-50%);
        top: 70%;
        font:normal 3em 华文隶书;
        color: #0000;
        white-space: pre;
       
        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{ 0% { width: 0%;letter-spacing: 15px; color:#000090;}100% { width: 350%; letter-spacing: 0px;color:#ff0000; }   }
@keyframes cover2 {0% { width: 0%;letter-spacing: 0px; color:#00ff00;}100% { width: 350%; letter-spacing: 15px;color:#ff0000; }}

</style>


<script >
(function() {
/*原始lrc歌词*/
let lrcStr = `



廖昌永、谭晶 - 我和我的祖国
作词:张藜
作曲:秦咏诚
我和我的祖国
一刻也不能分割
无论我走到哪里
都流出一首赞歌
我歌唱每一座高山
我歌唱每一条河
袅袅炊烟
小小村落
路上一道辙
我最亲爱的祖国
我永远紧依着你的心窝
你用你那
母亲的脉搏和我诉说
我的祖国和我
像海和浪花一朵
浪是那海的赤子
海是那浪的依托
每当大海在微笑
我就是笑的旋涡
我分担着海的忧愁
分享海的欢乐
我最亲爱的祖国
你是大海永不干涸
永远给我
碧浪清波
心中的歌
我最亲爱的祖国
你是大海永不干涸
永远给我
碧浪清波
心中的歌`;

/*变量 :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());/*监听查询事件*/
mplayer.addEventListener('click', () => { aud.paused ? aud.play() : aud.pause(); });

mplayer.style.animationPlayState = aud.paused ? 'paused' : 'running';
aud.addEventListener('playing', () =>mplayer.style.animationPlayState = 'running');
aud.addEventListener('pause', () =>mplayer.style.animationPlayState = 'paused');
let lrcAr = getLrcAr(lrcStr); /*获得歌词数组*/
})();

</script>

小辣椒 发表于 2023-9-30 20:40

热烈祝贺中华人民共和国建国74周年!

小辣椒 发表于 2023-9-30 20:41

亚伦的代码谢谢亚伦@亚伦

红影 发表于 2023-9-30 20:55

亲爱的这个帖子大气而漂亮。制作很赞{:4_199:}

红影 发表于 2023-9-30 20:55

同祝伟大祖国74周年华诞{:4_374:}{:4_187:}

梦油 发表于 2023-9-30 21:13

祝伟大的祖国繁荣富强欣欣向荣!

小辣椒 发表于 2023-9-30 21:44

红影 发表于 2023-9-30 20:55
亲爱的这个帖子大气而漂亮。制作很赞

亲爱的,今天休息比上班还累。。。。。

小辣椒 发表于 2023-9-30 21:46

红影 发表于 2023-9-30 20:55
同祝伟大祖国74周年华诞

一起祝福{:4_374:}{:4_374:}

小辣椒 发表于 2023-9-30 21:50

梦油 发表于 2023-9-30 21:13
祝伟大的祖国繁荣富强欣欣向荣!

梦油我们一起同祝伟大的祖国繁荣富强欣欣向荣!

{:4_374:}{:4_374:}

马黑黑 发表于 2023-9-30 22:56

{:4_199:}

亚伦影音工作室 发表于 2023-10-1 03:28

{:4_199:}

红影 发表于 2023-10-1 09:59

小辣椒 发表于 2023-9-30 21:44
亲爱的,今天休息比上班还累。。。。。

通常是这样,难得的小长假,累就累点吧{:4_173:}

红影 发表于 2023-10-1 09:59

小辣椒 发表于 2023-9-30 21:46
一起祝福

一起祝福伟大的祖国{:4_187:}

梦油 发表于 2023-10-1 10:58

小辣椒 发表于 2023-9-30 21:50
梦油我们一起同祝伟大的祖国繁荣富强欣欣向荣!

祖国万岁!
祝小辣椒朋友节日快乐!

小辣椒 发表于 2023-10-1 21:03

梦油 发表于 2023-10-1 10:58
祖国万岁!
祝小辣椒朋友节日快乐!

梦油国庆节快乐!

小辣椒 发表于 2023-10-1 21:04

红影 发表于 2023-10-1 09:59
一起祝福伟大的祖国

祝福伟大祖国更加繁荣昌盛,越来越强大!

小辣椒 发表于 2023-10-1 21:04

红影 发表于 2023-10-1 09:59
通常是这样,难得的小长假,累就累点吧

今天上来又迟了

小辣椒 发表于 2023-10-1 21:04

亚伦影音工作室 发表于 2023-10-1 03:28


{:4_180:}

小辣椒 发表于 2023-10-1 21:05

马黑黑 发表于 2023-9-30 22:56


{:4_180:}

亚伦影音工作室 发表于 2023-10-1 21:31

小辣椒 发表于 2023-10-1 21:05


应该这个动图也同时控制https://xlaj.cn/assets/file/zp/20230927233112.gif
页: [1] 2 3
查看完整版本: 热烈祝贺祖国74周年华诞!