小辣椒 发表于 2023-10-1 22:29

歌唱祖国

<style>
#papa { left:-320px; width: 1440px; height: 826px; top:150px; background: #000 url('https://xlaj.cn/assets/file/zp/20231001204206.gif') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; }
#canv { position: absolute; left: 0px; top: 10px; }
#disc { position: absolute; width:60px; height: 60px; left: 50px; top:700px; background: conic-gradient(red,orange,yellow,green,teal,blue,purple); mask: radial-gradient(transparent 4px,red 0); -webkit-mask: radial-gradient(transparent 4px,red 0); border-radius: 50%; cursor: pointer; animation: rot 2s linear infinite; }
#tit { position: absolute; left: 150px; top: 710px;font: bold 30px / 40px sans-serif; color: snow; text-shadow: 2px 2px 4px black; }
        @keyframes move { to { offset-distance: 100%; } }
#mpic1 {position: absolute; transform: rotateY(180deg); left: 0; top: 0; width: 100px; offset-distance: 0; offset-path: path("M 0 0 Q 300 90, 512 100 T 1394 30"); animation: move 18s linear infinite;}

#dt1{ position: absolute; width: 540px; height: 150px; top: 50px; left: 800px; }
#dt2{ position: absolute; width: 664px; height: 293px; top: 537px; left: 436px; }

</style>

<div id="papa">

<img id="mpic1" alt="" src="https://xlaj.cn/assets/file/zp/20231001204314.gif " />
   <img id="mpic" alt="" src="4233383649728593242.gif" />
   
      <img id="dt1" src="https://xlaj.cn/assets/file/zp/20231001204336.gif" alt="" />
      <img id="dt2" src="https://xlaj.cn/assets/file/zp/20231001204239.png" alt="" />



      <span id="tit">歌唱祖国</span>
      <canvas id="canv"></canvas>
      <span id="disc"></span>
</div>

<script>
(function() {
      let ctx = canv.getContext('2d');
               let w = canv.width = 1440, h = canv.height = 700; // 自定义画布尺寸
      let particles = [], idx = 0, aud = new Audio();
      
      aud.src = 'https://xlaj.cn/assets/file/zp/20231001204400.mp3';
      aud.loop = true;
      aud.autoplay = true;

      disc.style.animationPlayState = aud.paused ? 'paused' : 'running';
      disc.onclick = () => aud.paused ? aud.play() : aud.pause();
      aud.addEventListener('playing',()=> disc.style.animationPlayState = 'running');
      aud.addEventListener('pause',()=> disc.style.animationPlayState = 'paused');

      canv.onclick = function(event) {
                let x = event.offsetX || event.layerX;
                let y = event.offsetY || event.layerY;
                createParticle(x, y);
      }

      function createParticle(x, y) {
                let count = 100;
                let radius = 10;
                let hue = Math.floor(Math.random() * 51) + 0;
                let change = 30;
                for (let j = 0; j < count; j ++) {
                        let p = {};
                        let angle = 360 / count * j;
                        let radian = Math.PI / 180 * angle;
                        p.radius = radius;
                        p.startX = x;
                        p.startY = y;
                        p.radian = radian;
                        p.hue = Math.floor(Math.random() * (change * 0)) + (hue - change);
                        p.lightness = Math.floor(Math.random() * 100);
                        p.alpha = (Math.floor(Math.random() * 101)) / 100;
                        p.speed = (Math.random() * 5) + 0.4;
                        p.radius = p.speed;
                        particles.push(p);
                }
      }

      function drawParticle() {
                ctx.fillStyle = 'transparent';
                ctx.fillRect(0, 0, w, h);
                for (let i = 0; i < particles.length; i++) {
                         let p = particles;
                        let resultX = Math.cos(p.radian) * p.radius;
                        let resultY = Math.sin(p.radian) * p.radius + 0.4;
                        p.startX += resultX;
                        p.startY += resultY;
                        p.radius *= 1 - p.speed / 100;
                        p.alpha -= 0.005;
                        if (p.alpha <= 0) {
                              particles.splice(i, 1);
                              continue;
                        }

                        ctx.beginPath();
                        ctx.arc(p.startX, p.startY, 2, 0, 360, false);
                        ctx.closePath();
                        ctx.fillStyle = "hsla( " + p.hue + " , 100% ," + p.lightness + "% , " + p.alpha + ")";
                        ctx.fill();
                }
      }

      function fade() {
                ctx.globalCompositeOperation = "destination-out";
                ctx.fillStyle = "rgba(0 , 0 , 0, " + 0.1 + ")";
                ctx.fillRect(0, 0, w, h);
                ctx.globalCompositeOperation = "lighter";
      }

      function render() {
                idx ++;
                fade();
                drawParticle();
                if(idx > 50) {
                        createParticle(Math.random() * w, Math.random() * h);
                        idx = 0;
                }
                requestAnimationFrame(render);
      }
      render();
})();
</script>
<br><br><br><br><br><br><br><br><br><br>

小辣椒 发表于 2023-10-1 22:31

祝福伟大祖国生日快乐!

liumang 发表于 2023-10-1 22:33

小辣椒这个制作太漂亮了

{:5_150:}

liumang 发表于 2023-10-1 22:34

烟花效果漂亮,点击哪里就出来烟花

liumang 发表于 2023-10-1 22:35

掌声 鲜花送上
{:5_137:}

liumang 发表于 2023-10-1 22:36

{:5_147:} {:5_147:} {:5_147:}

小辣椒 发表于 2023-10-1 22:37

liumang 发表于 2023-10-1 22:33
小辣椒这个制作太漂亮了

谢谢 liumang
{:5_122:}

小辣椒 发表于 2023-10-1 22:38

liumang 发表于 2023-10-1 22:36


准备下了,明天见

liumang 发表于 2023-10-1 22:39

小辣椒 发表于 2023-10-1 22:38
准备下了,明天见

晚安{:5_127:}
页: [1]
查看完整版本: 歌唱祖国