加林森 发表于 2022-6-30 20:27

本帖最后由 加林森 于 2022-8-11 10:03 编辑 <br /><br />红影 发表于 2022-6-30 20:23
帮清舟凉快咋成减肥了
可以的。{:4_189:}

<style>
#papa { left: -214px; width: 1024px; height: 640px; background: #000 url('https://638183.freep.cn/638183/Pic/81/818.png') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; }
#canv { position: absolute; }
#disc { position: absolute; width: 40px; height: 40px; left: 10px; top: 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; }
#tit { position: absolute; left: 60px; top: 10px;font: bold 22px / 40px sans-serif; color: snow; text-shadow: 2px 2px 4px black; }
@keyframes rot { to { transform: rotate(360deg); } }
</style>

<div id="papa">
        <span id="tit">Electric Dreams</span>
        <canvas id="canv"></canvas>
        <span id="disc"></span>
</div>

<script>
(function() {
        let ctx = canv.getContext('2d');
        let w = canv.width = papa.offsetWidth, h = canv.height = papa.offsetHeight;
        let particles = [], idx = 0, aud = new Audio();
       
        aud.src = 'https://music.163.com/song/media/outer/url?id=1332849399.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) + 100;
                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 * 2)) + (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>

红影 发表于 2022-7-1 15:30

加林森 发表于 2022-6-30 20:27
可以的。

什么可以啊,清舟又不胖{:4_173:}

加林森 发表于 2022-7-1 15:57

红影 发表于 2022-7-1 15:30
什么可以啊,清舟又不胖

她自己说的长嘎嘎了的。

红影 发表于 2022-7-1 16:52

加林森 发表于 2022-7-1 15:57
她自己说的长嘎嘎了的。

然后队长就助人为乐了?{:4_173:}

加林森 发表于 2022-7-1 17:15

红影 发表于 2022-7-1 16:52
然后队长就助人为乐了?

那是必须的。{:4_189:}

红影 发表于 2022-7-1 21:40

加林森 发表于 2022-7-1 17:15
那是必须的。

清舟同意么{:4_173:}

加林森 发表于 2022-7-1 21:54

红影 发表于 2022-7-1 21:40
清舟同意么

当然同意了的。
页: 1 [2]
查看完整版本: 《大海》- 张雨生