{"id":89,"date":"2021-05-17T22:40:23","date_gmt":"2021-05-17T14:40:23","guid":{"rendered":"http:\/\/www.lanxy.ink\/?p=89"},"modified":"2021-09-16T12:16:10","modified_gmt":"2021-09-16T04:16:10","slug":"%e6%9d%8f%e7%be%bd%e5%b0%8f%e5%b1%8b%e4%b8%ad%e7%9a%84%e9%9b%aa%e8%8a%b1%e6%95%88%e6%9e%9c","status":"publish","type":"post","link":"https:\/\/www.lanxy.ink\/?p=89","title":{"rendered":"\u674f\u7fbd\u5c0f\u5c4b\u4e2d\u7684\u96ea\u82b1\u6548\u679c"},"content":{"rendered":"\n<p>\u4e3b\u8981\u4e3a\u5b66\u4e60\u4ea4\u6d41\u76ee\u7684\uff08\u4e5f\u9632\u6b62\u81ea\u5df1\u9057\u5931\uff09<\/p>\n\n\n\n<p>\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function() {\nvar requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame ||\nfunction(callback) {\nwindow.setTimeout(callback, 1000 \/ 60);\n};\nwindow.requestAnimationFrame = requestAnimationFrame;\n};\nfunction() {\n        var flakes = &#91;],\n            canvas = document.getElementById(\"Snow\"),\n            ctx = canvas.getContext(\"2d\"),\n            flakeCount = 100,\n\n            mX = -100,\n            mY = -100;\n\n        canvas.width = window.innerWidth;\n        canvas.height = window.innerHeight;\n\n        function snow() {\n            ctx.clearRect(0, 0, canvas.width, canvas.height);\n\n            for (var i = 0; i &lt; flakeCount; i++) {\n                var flake = flakes&#91;i],\n                    x = mX,\n                    y = mY,\n                    minDist = 300,\n                    x2 = flake.x,\n                    y2 = flake.y;\n\n                var dist = Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)),\n                    dx = x2 - x,\n                    dy = y2 - y;\n\n                if (dist &lt; minDist) {\n                    var force = minDist \/ (dist * dist),\n                        xcomp = (x - x2) \/ dist,\n                        ycomp = (y - y2) \/ dist,\n                        deltaV = force \/ 2;\n\n                    flake.velX -= deltaV * xcomp;\n                    flake.velY -= deltaV * ycomp;\n\n                } else {\n                    flake.velX *= .98;\n                    if (flake.velY &lt;= flake.speed) {\n                        flake.velY = flake.speed\n                    }\n                    flake.velX += Math.cos(flake.step += .05) * flake.stepSize;\n                }\n\n                ctx.fillStyle = \"rgba(255,228,225,\" + flake.opacity + \")\";\n                flake.y += flake.velY;\n                flake.x += flake.velX;\n\n                if (flake.y >= canvas.height || flake.y &lt;= 0) {\n                    reset(flake);\n                }\n\n                if (flake.x >= canvas.width || flake.x &lt;= 0) {\n                    reset(flake);\n                }\n\n                ctx.beginPath();\n                ctx.arc(flake.x, flake.y, flake.size, 0, Math.PI * 2);\n                ctx.fill();\n            }\n            requestAnimationFrame(snow);\n        };\n\n        function reset(flake) {\n            flake.x = Math.floor(Math.random() * canvas.width);\n            flake.y = 0;\n            flake.size = (Math.random() * 3) + 2;\n            flake.speed = (Math.random() * 1) + 0.5;\n            flake.velY = flake.speed;\n            flake.velX = 0;\n            flake.opacity = (Math.random() * 0.5) + 0.4;\n        }\n            if (\/Android|webOS|iPhone|iPod|BlackBerry\/i.test(navigator.userAgent)) {\n                flakeCount = flakeCount - 75;\n            }\n        function init() {\n            for (var i = 0; i &lt; flakeCount; i++) {\n                var x = Math.floor(Math.random() * canvas.width),\n                    y = Math.floor(Math.random() * canvas.height),\n                    size = (Math.random() * 3) + 2,\n                    speed = (Math.random() * 1) + 0.5,\n                    opacity = (Math.random() * 0.5) + 0.4;\n\n                flakes.push({\n                    speed: speed,\n                    velY: speed,\n                    velX: 0,\n                    x: x,\n                    y: y,\n                    size: size,\n                    stepSize: (Math.random()) \/ 30 * 1,\n                    step: 0,\n                    angle: 180,\n                    opacity: opacity\n                });\n            }\n\n            snow();\n        };\n\n        document.addEventListener(\"mousemove\", function(e) {\n            mX = e.clientX,\n            mY = e.clientY\n        });\n        window.addEventListener(\"resize\", function() {\n            canvas.width = window.innerWidth;\n            canvas.height = window.innerHeight;\n        });\n        init();\n    };<\/code><\/pre>\n\n\n\n<p>\u5e76\u5728wordpress\u6837\u5f0f\u8868\u4e2d\u52a0\u5165\u5982\u4e0b\u8bed\u53e5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Snow {\nposition: fixed;\ntop: 0;\nleft: 0;\nwidth: 100%;\nheight: 100%;\nz-index: 99999;\npointer-events: none;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u96ea\u82b1\u7684\u6548\u679c\u4ee3\u7801(html5+CSS)<\/p>\n","protected":false},"author":311,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-89","post","type-post","status-publish","format-standard","hentry","category-common"],"_links":{"self":[{"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/posts\/89","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/users\/311"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89"}],"version-history":[{"count":6,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions"}],"predecessor-version":[{"id":753,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions\/753"}],"wp:attachment":[{"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lanxy.ink\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}