东篱闲人 发表于 2022-8-20 22:33

学黑黑,放个烟花。。。

<style>
#papa { left: -400px; width: 1400px; height: 800px; background: gray url('https://pic.imgdb.cn/item/6300efeb16f2c2beb1f3d25b.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; }
#canv { position: absolute; }
#disc { position: absolute; width: 1px; height: 1px; left: 10px; bottom: 10px; 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; }
#lrcbox { position: absolute; left: 60px; bottom: 40px;font: bold 22px / 40px sans-serif; color: #859670; text-shadow: 2px 2px 2px #222; }
@keyframes rot { to { transform: rotate(360deg); } }
</style>

<div id="papa">
      <span id="lrcbox">东风夜放花千树。更吹落、星如雨。宝马雕车香满路。凤箫声动,玉壶光转,一夜鱼龙舞。       ——————辛弃疾《青玉案·元夕》</span>
      <canvas id="canv"></canvas>
      <span id="disc"></span>
</div>

<script>
(function() {
      let num = (min, max) => Math.floor(Math.random() * (max-min+1)) + min;
      let ctx = canv.getContext('2d');
      let w = canv.width = papa.offsetWidth, h = canv.height = papa.offsetHeight, particles = [], idx = 0, aud = new Audio();
      
      aud.src = 'https://music.163.com/song/media/outer/url?id=476031667.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, y = event.offsetY || event.layerY;
                createParticle(x, y);
      }

      function createParticle(x, y) {
                let count = 100, radius = 10;
                for (let j = 0; j < count; j ++) {
                        let p = {};
                        let angle = 360 / count * j, radian = Math.PI / 180 * angle;
                        p.radius = radius;
                        p.startX = x;
                        p.startY = y;
                        p.radian = radian;
                        p.rgb = `${num(0,255)},${num(0,255)},${num(0,255)},`;
                        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 j = 0; j < particles.length; j++) {
                        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(j, 1);
                              continue;
                        }
                        ctx.beginPath();
                        ctx.arc(p.startX, p.startY, 2, 0, 360, false);
                        ctx.closePath();
                        ctx.fillStyle = 'rgba(' + p.rgb + p.alpha + ')';
                        ctx.fill();
                }
      }

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

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

      render();
})();
</script>

小辣椒 发表于 2022-8-20 22:34

沙发我的

东篱闲人 发表于 2022-8-20 22:34

夜深了,放个烟花,睡觉去。。。{:5_117:}

小辣椒 发表于 2022-8-20 22:35

东篱闲人 发表于 2022-8-20 22:34
夜深了,放个烟花,睡觉去。。。

哈哈~~~烟花就要天黑放的

小辣椒 发表于 2022-8-20 22:36

老头的图意特别美,老头辛苦了,每天做几个图图,都那么精美{:4_199:}

东篱闲人 发表于 2022-8-20 22:36

小辣椒 发表于 2022-8-20 22:35
哈哈~~~烟花就要天黑放的

嗯嗯,白天也看不见啊。。。{:5_117:}

小辣椒 发表于 2022-8-20 22:37

别太累了,要注意身体,多保重{:4_179:}

东篱闲人 发表于 2022-8-20 22:37

小辣椒 发表于 2022-8-20 22:36
老头的图意特别美,老头辛苦了,每天做几个图图,都那么精美

这个没咋设计,随便对付的。。。{:5_106:}

小辣椒 发表于 2022-8-20 22:38

东篱闲人 发表于 2022-8-20 22:36
嗯嗯,白天也看不见啊。。。

就是,现在放烟花最合适{:4_170:}

小辣椒 发表于 2022-8-20 22:39

东篱闲人 发表于 2022-8-20 22:37
这个没咋设计,随便对付的。。。

设计不错,也是很漂亮,老头赶快下了去休息了

东篱闲人 发表于 2022-8-20 22:40

小辣椒 发表于 2022-8-20 22:39
设计不错,也是很漂亮,老头赶快下了去休息了

好的,师傅再见。。。。

小辣椒 发表于 2022-8-20 22:42

东篱闲人 发表于 2022-8-20 22:40
好的,师傅再见。。。。

我也是看看就下了,晚安

红影 发表于 2022-8-20 22:59

这个好美,用来诠释辛弃疾的词句真的太贴切了。欣赏东篱大哥好帖{:4_187:}

醉美水芙蓉 发表于 2022-8-21 09:05

加林森 发表于 2022-8-21 09:14

老兄制作得真漂亮。{:4_190:}

沐风 发表于 2022-8-21 09:15

感觉穿越到春节了。{:4_173:}

马黑黑 发表于 2022-8-21 09:54

东篱舍得让镁铝置身于爆炸之中吗{:4_170:}

东篱闲人 发表于 2022-8-21 13:35

红影 发表于 2022-8-20 22:59
这个好美,用来诠释辛弃疾的词句真的太贴切了。欣赏东篱大哥好帖

嗯嗯,很美的词境。。。

东篱闲人 发表于 2022-8-21 13:36

醉美水芙蓉 发表于 2022-8-21 09:05
欣赏东篱老师精美作品!

这也谈不上作品,玩。。。{:5_117:}

东篱闲人 发表于 2022-8-21 13:36

加林森 发表于 2022-8-21 09:14
老兄制作得真漂亮。

加加更漂亮!{:5_116:}
页: [1] 2
查看完整版本: 学黑黑,放个烟花。。。