|
|
第13行: |
第13行: |
|
| |
|
| 来帮忙(死)这玩意到底怎么用{{用户:Kaltes Eis/Eine Unterschrift}} 2022年4月6日 (三) 03:31 (UTC) | | 来帮忙(死)这玩意到底怎么用{{用户:Kaltes Eis/Eine Unterschrift}} 2022年4月6日 (三) 03:31 (UTC) |
|
| |
| body,html{undefined
| |
| overflow: hidden;
| |
| }
| |
| var snowflakes = {undefined
| |
| arr:[],
| |
| snowflake : [
| |
| '❉',
| |
| '❈',
| |
| '*',
| |
| '✲',
| |
| '❀',
| |
| '❃'
| |
| ],
| |
| snowflakeColor : [
| |
| "red",
| |
| "green",
| |
| "#ccc123",
| |
| "#345232",
| |
| "#231111",
| |
| "#ab2322"
| |
| ],
| |
| random : function (num){undefined
| |
| return Math.floor(Math.random()*num);
| |
| },
| |
| init : function (num){undefined
| |
|
| |
| this.maxlength = num;
| |
|
| |
| this.maxWidth = (document.documentElement.clientWidth || document.body.clientWidth) + 20;
| |
|
| |
| this.maxHeight = (document.documentElement.clientHeight || document.body.clientHeight) + 20;
| |
| this.create();
| |
| this.move();
| |
| },
| |
|
| |
| create : function (){undefined
| |
| var that = this;
| |
| setInterval(function (){undefined
| |
|
| |
| if( that.arr.length < that.maxlength){undefined
| |
| var d = document.createElement("div");
| |
|
| |
| d.innerHTML = that.snowflake[that.random(that.snowflake.length)];
| |
| d.style.color = that.snowflakeColor[that.random(that.snowflakeColor.length)];
| |
| d.style.position = "absolute";
| |
|
| |
| top(0- -99) left (0 - that.maxWidth*2/3-1)
| |
| d.style.left = that.random(that.maxWidth*2/3) + "px";
| |
| d.style.top = -that.random(100) + "px";
| |
|
| |
| d.vx = 2+that.random(10);
| |
| d.vy = 3+that.random(10);
| |
|
| |
| document.body.appendChild(d);
| |
| that.arr.push(d)
| |
| }
| |
| },20)
| |
| },
| |
|
| |
| move : function (){undefined
| |
| var that = this;
| |
| var arr = that.arr;
| |
| setInterval(function (){undefined
| |
|
| |
| for(var i = 0 ; i < arr.length ; i ++ ){undefined
| |
|
| |
| arr[i].style.left = arr[i].offsetLeft + arr[i].vx + "px";
| |
| arr[i].style.top = arr[i].offsetTop + arr[i].vy + 'px';
| |
|
| |
| if (arr[i].offsetTop >= that.maxHeight || arr[i].offsetLeft >= that.maxWidth) {undefined
| |
| document.body.removeChild(arr[i]);
| |
| arr.splice(i,1);
| |
| }
| |
| }
| |
| },30)
| |
| }
| |
| }
| |
| window.onload = function (){undefined
| |
| snowflakes.init(100);
| |
| }
| |