1// æ 颿 2var OriginTitle = document.title; 3var titleTime; 4document.addEventListener('visibilitychange', function () { 5 if (document.hidden) { 6 document.title = 'ã½(â-`д-)ãè¡¥è¯æå¼Nknså'; 7 clearTimeout(titleTime); 8 } 9 else { 10 document.title = OriginTitle; 11 titleTime = setTimeout(function () { 12 document.title = OriginTitle; 13 }, 2000); 14 } 15}); 16 17//ä¸éªjs 18/* æ§å¶ä¸éª */ 19function snowFall(snow) { 20 /* å¯é ç½®å±æ§ */ 21 snow = snow || {}; 22 this.maxFlake = snow.maxFlake || 200; /* æå¤çæ° */ 23 this.flakeSize = snow.flakeSize || 10; /* éªè±å½¢ç¶ */ 24 this.fallSpeed = snow.fallSpeed || 1; /* å è½é度 */ 25} 26/* å ¼å®¹åæ³ */ 27requestAnimationFrame = window.requestAnimationFrame || 28 window.mozRequestAnimationFrame || 29 window.webkitRequestAnimationFrame || 30 window.msRequestAnimationFrame || 31 window.oRequestAnimationFrame || 32 function (callback) { setTimeout(callback, 1000 / 60); }; 33 34cancelAnimationFrame = window.cancelAnimationFrame || 35 window.mozCancelAnimationFrame || 36 window.webkitCancelAnimationFrame || 37 window.msCancelAnimationFrame || 38 window.oCancelAnimationFrame; 39/* å¼å§ä¸éª */ 40snowFall.prototype.start = function () { 41 /* å建ç»å¸ */ 42 snowCanvas.apply(this); 43 /* å建éªè±å½¢ç¶ */ 44 createFlakes.apply(this); 45 /* ç»éª */ 46 drawSnow.apply(this) 47} 48/* å建ç»å¸ */ 49function snowCanvas() { 50 /* æ·»å Domç»ç¹ */ 51 var snowcanvas = document.createElement("canvas"); 52 snowcanvas.id = "snowfall"; 53 snowcanvas.width = document.body.clientWidth; 54 snowcanvas.height = document.body.clientHeight; 55 if(snowcanvas.height > 6000) { 56 snowcanvas.height = 6000; 57 } 58 snowcanvas.setAttribute("style", "position:absolute; top: 0; left: 0; z-index: 1; pointer-events: none;"); 59 document.getElementsByTagName("body")[0].appendChild(snowcanvas); 60 this.canvas = snowcanvas; 61 this.ctx = snowcanvas.getContext("2d"); 62 /* çªå£å¤§å°æ¹åçå¤ç */ 63 window.onresize = function () { 64 snowcanvas.width = window.innerWidth - 20; 65 /* snowcanvas.height = window.innerHeight */ 66 } 67} 68/* éªè¿å¨å¯¹è±¡ */ 69function flakeMove(canvasWidth, canvasHeight, flakeSize, fallSpeed) { 70 this.x = Math.floor(Math.random() * canvasWidth); /* xåæ */ 71 this.y = Math.floor(Math.random() * canvasHeight); /* yåæ */ 72 this.size = Math.random() * flakeSize + 2; /* å½¢ç¶ */ 73 this.maxSize = flakeSize; /* æå¤§å½¢ç¶ */ 74 this.speed = Math.random() * 1 + fallSpeed; /* å è½é度 */ 75 this.fallSpeed = fallSpeed; /* å è½é度 */ 76 this.velY = this.speed; /* Yæ¹åé度 */ 77 this.velX = 0; /* Xæ¹åé度 */ 78 this.stepSize = Math.random() / 30; /* æ¥é¿ */ 79 this.step = 0 /* æ¥æ° */ 80} 81flakeMove.prototype.update = function () { 82 var x = this.x, 83 y = this.y; 84 /* 左峿å¨(ä½å¼¦) */ 85 this.velX *= 0.98; 86 if (this.velY <= this.speed) { 87 this.velY = this.speed 88 } 89 this.velX += Math.cos(this.step += .05) * this.stepSize; 90 91 this.y += this.velY; 92 this.x += this.velX; 93 /* é£åºè¾¹ççå¤ç */ 94 if (this.x >= canvas.width || this.x <= 0 || this.y >= canvas.height || this.y <= 0) { 95 this.reset(canvas.width, canvas.height) 96 } 97}; 98/* é£åºè¾¹ç-æ¾ç½®æé¡¶ç«¯ç»§ç»å è½ */ 99flakeMove.prototype.reset = function (width, height) { 100 this.x = Math.floor(Math.random() * width); 101 this.y = 0; 102 this.size = Math.random() * this.maxSize + 2; 103 this.speed = Math.random() * 1 + this.fallSpeed; 104 this.velY = this.speed; 105 this.velX = 0; 106}; 107// 渲æéªè±-éæºå½¢ç¶ï¼æ¤å¤å¯ä¿®æ¹éªè±é¢è²ï¼ï¼ï¼ï¼ 108flakeMove.prototype.render = function (ctx) { 109 var snowFlake = ctx.createRadialGradient(this.x, this.y, 0, this.x, this.y, this.size); 110 snowFlake.addColorStop(0, "rgba(255, 255, 255, 0.9)"); /* æ¤å¤æ¯éªè±é¢è²ï¼é»è®¤æ¯ç½è² */ 111 snowFlake.addColorStop(.5, "rgba(255, 255, 255, 0.5)"); /* è¥è¦æ¹ä¸ºå ¶ä»é¢è²ï¼è¯·èªè¡æ¥ */ 112 snowFlake.addColorStop(1, "rgba(255, 255, 255, 0)"); /* æ¾16è¿å¶çRGB é¢è²ä»£ç ã */ 113 ctx.save(); 114 ctx.fillStyle = snowFlake; 115 ctx.beginPath(); 116 ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2); 117 ctx.fill();
118 ctx.restore(); 119}; 120/* å建éªè±-å®ä¹å½¢ç¶ */ 121function createFlakes() { 122 var maxFlake = this.maxFlake, 123 flakes = this.flakes = [], 124 canvas = this.canvas; 125 for (var i = 0; i < maxFlake; i++) { 126 flakes.push(new flakeMove(canvas.width, canvas.height, this.flakeSize, this.fallSpeed)) 127 } 128} 129/* ç»éª */ 130function drawSnow() { 131 var maxFlake = this.maxFlake, 132 flakes = this.flakes; 133 ctx = this.ctx, canvas = this.canvas, that = this; 134 /* æ¸ ç©ºéªè± */ 135 ctx.clearRect(0, 0, canvas.width, canvas.height); 136 for (var e = 0; e < maxFlake; e++) { 137 flakes[e].update(); 138 flakes[e].render(ctx); 139 } 140 /* ä¸å¸§ä¸å¸§çç» */ 141 this.loop = requestAnimationFrame(function () { 142 drawSnow.apply(that); 143 }); 144} 145/* è°ç¨åæ§å¶æ¹æ³ */ 146var snow = new snowFall({ maxFlake: 60 }); 147snow.start();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.