亦是金 发表于 2024-3-22 21:28

《最炫民族风》 - 凤凰传奇(学习黑黑老师三十里铺帖代码 )

<style>
        #papa { margin: 130px 0 20px calc(50% - 581px); width: 1200px; height: 700px; background: url('https://z4a.net/images/2023/12/27/122701.jpg') no-repeat center/cover; box-shadow: 3px 3px 6px gray; overflow: hidden; position: relative; }
        #canv { position: absolute; width: 1200px; height: 180px; left: 0%; bottom: 4px; transform: translate(0%,0); cursor: pointer; }
        .pic { position: absolute; width: 240px; mix-blend-mode: screen; offset-path: path('M-224,150 Q1250,-20 1200,460'); offset-distance: 100%; animation: fly 20s var(--delay) infinite var(--state); --delay: 0s; }
        .pic:nth-of-type(2) { --delay: -7s; }
        .pic:nth-of-type(3) { --delay: -14s; }
        @keyframes fly { to { offset-distance: 0; } }
        #vid { position: absolute; width: 120%; height: 100%; object-fit: cover; pointer-events: none; mix-blend-mode: screen; z-index: 2; opacity: .52; transform: rotateY(180deg); }
</style>

<div id="papa">
        <video id="vid" src="https://img.tukuppt.com/video_show/15653652/00/79/55/60c1c62b9766e.mp4" autoplay="" loop="" muted=""></video>
        <img class="pic" src="https://638183.freep.cn/638183/t22/gif/bird1.gif" alt="" />
        <img class="pic" src="https://638183.freep.cn/638183/t22/gif/bird1.gif" alt="" />
        <img class="pic" src="https://638183.freep.cn/638183/t22/gif/bird1.gif" alt="" />
    <canvas id="canv" width="600" height="240" title="点击播放"></canvas>
</div>

<script>
(function() {
        let aud = new Audio();
        aud.crossOrigin = '';
        aud.src = 'https://ysj147.s3-us-east-1.ossfiles.com/10nwanglouhongge/donting/CD1/dt0115.mp3';
        aud.loop = true;
        aud.load();
        aud.play();
        let AudioContext = window.AudioContext || window.webkitAudioContext;
        let Ac = new AudioContext;
        let analyser = Ac.createAnalyser();
        analyser.fftSize = 256;
        let source = Ac.createMediaElementSource(aud);
        source.connect(analyser);
        analyser.connect(Ac.destination);
        let len = analyser.frequencyBinCount - 30;
        let output = new Uint8Array(len);
        let canvctx = canv.getContext('2d');
        let ppWidth = canv.width / len;
        let ppHeight, x;
        let gradient = canvctx.createLinearGradient(0,0,0,200);
        gradient.addColorStop(0,'rgba(255,165,0');
        gradient.addColorStop(.5,'rgba(255,165,0');
        gradient.addColorStop(1,'rgba(128,128,128');
        (function draw() {
                canvctx.clearRect(0, 0, canv.width, canv.height);
                analyser.getByteFrequencyData(output);
                x = 0.5;
                for(let i = 0; i < len; i ++) {
                        ppHeight = output[ i ] * .9 + ppWidth;
                        canvctx.fillStyle = gradient;
                        canvctx.fillRect(x, canv.height - ppHeight, ppWidth - 1, ppHeight);
                        x += ppWidth;
                }
                requestAnimationFrame(draw);
        })();
        aud.onpause = aud.onplaying = () => aud.paused ?
                (canv.title = '点击播放', papa.style.setProperty('--state', 'paused')) :
                (canv.title = '点击暂停', papa.style.setProperty('--state', 'running'));
        canv.onclick = () => aud.paused ? aud.play() : aud.pause();
        papa.onclick = () => aud.paused ? (vid.pause(),vid.pause()) : (vid.play(),vid.play());
})();
</script>

liumang 发表于 2024-3-23 11:55

亦是金老师好。不知道什么原因,你上面那个帖不能回帖

liumang 发表于 2024-3-23 11:56

频谱也是漂亮的{:5_150:}{:5_150:}

liumang 发表于 2024-3-23 11:57

感谢分享{:5_124:}

liumang 发表于 2024-3-23 11:58

这个图出来也是快{:5_150:}

亦是金 发表于 2024-3-23 20:48

liumang 发表于 2024-3-23 11:55
亦是金老师好。不知道什么原因,你上面那个帖不能回帖

问好管理!我也不知道什么原因!{:5_151:}

亦是金 发表于 2024-3-23 20:49

liumang 发表于 2024-3-23 11:56
频谱也是漂亮的

谢谢欣赏点赞!{:5_147:}

亦是金 发表于 2024-3-23 20:51

liumang 发表于 2024-3-23 11:58
这个图出来也是快

晚上好!{:5_147:}

liumang 发表于 2024-3-24 20:58

亦是金 发表于 2024-3-23 20:51
晚上好!

亦是金老师,今天发的二个帖都不能回帖,我后面加了隔行码也是不成功,不知道为什么原因
页: [1]
查看完整版本: 《最炫民族风》 - 凤凰传奇(学习黑黑老师三十里铺帖代码 )