Do you have any seniors to help simulate the rain effect of Baidu Weather search page with canvas? thank you very much.

canvas simulates the rain effect of Baidu weather search page


rain.png
rain.png transparent

Jan.03,2022

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            *{margin: 0;padding: 0;}
            canvas{background: -sharpfff;}
        </style>
    </head>
    <body>
        <canvas id="canvas" width="500" height="800" ></canvas>
        <script>
            var can = document.getElementById("canvas");
            //
            var cxt = can.getContext("2d");
            //
            var w = can.width = window.innerWidth;
            var h = can.height = window.innerHeight;
            //
            window.onresize = function() {
                w = can.width = window.innerWidth;
                h = can.height = window.innerHeight;
            };
            //
            cxt.fillStyle = "aqua";
            
            var drops = [];
            // 
            function Drop() {}
            //
            Drop.prototype = {
                init: function() { // 
                    this.x = random(0, w);//
                    this.y = 0;//y
                    this.vy = random(4, 5); //
                    this.l = random(0.8 * h, 0.9 * h);
                    this.r = 1; //
                    this.vr = 1; //
                    //
                    this.a = 1; // =>0
                    this.va = 0.96; //
                },
                draw: function() { //
                    if (this.y > this.l) { // 
                        cxt.beginPath(); //
                        cxt.arc(this.x, this.y, this.r/4, 0, Math.PI * 2, false);
                        cxt.strokeStyle = "rgba(219,227,226," + this.a + ")";
                        cxt.stroke();
                    } else { //
                        cxt.fillStyle = "rgb(219,227,226)";
                        cxt.fillRect(this.x, this.y, 1, 10);
                    }
                    this.update();
                },
                update: function() { //
                    if (this.y < this.l) {
                        this.y += this.vy
                    } else { // 
                        if (this.a > 0.03) {
                            this.r += this.vr;
                            if (this.r > 50) {
                                this.a *= this.va;
                            }
                        } else {
                            //
                            this.init()
                        }
                    }
                }
            };
            for (var i = 0; i < 50; iPP) {
                setTimeout(function() {
                    var drop = new Drop();
                    drop.init();
                    drops.push(drop);
                }, i * 300)
            }
            function move() {
                //  
                // 
                cxt.fillStyle = "rgba(15,15,15,0.1)";
                cxt.fillRect(0, 0, w, h);
                for (var k = 0; k < drops.length; kPP) {
                    drops[k].draw();
                }
                requestAnimationFrame(move);
            }
            move();
            //
            function random(min, max) {
                return Math.random() * (max - min) + min; //min - max
            }
        </script>
    </body>
</html>

https://blog.csdn.net/zhuogan.


not a single high number

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb2a9b-23f3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb2a9b-23f3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?