(function($){ $(document).ready(function() { }); $.fn.cloud_move = function(size){ var cWinWidth = $(size).width(); var cSpeed = Math.random()*0.02+0.2; var Cstep = 0; var cXpos = Math.round(Math.random()*cWinWidth); var cYpos = Math.round(Math.random()*10) - 50; var Step = Math.random()*0.015+0.01; var _this = $(this); function cMove(){ var sx = cSpeed*Math.sin(90*Math.PI/180); cXpos+=sx; if (cXpos > cWinWidth){ cXpos = -$(_this).width(); cYpos = Math.round(Math.random()*10)-50; cSpeed = Math.random()*0.02+0.2; }; $(_this).css({left:cXpos,top:cYpos}); Cstep += Step; setTimeout(cMove,20); ///var m = $('.memo').html();$('.memo').html(m +"::"+ cXpos); }; cMove(); }; $.fn.leaves_add = function(){ var grphcs=new Array(5); var Image0=new Image(); Image0.src=grphcs[0]="image/leaves/leaf_01.png"; var Image1=new Image(); Image1.src=grphcs[1]="image/leaves/leaf_02.png"; var Image2=new Image(); Image2.src=grphcs[2]="image/leaves/leaf_03.png"; var Image3=new Image(); Image3.src=grphcs[3]="image/leaves/leaf_04.png"; var Image4=new Image(); Image4.src=grphcs[4]="image/leaves/leaf_05.png"; var Amount=10; //Smoothness depends on image file size, the smaller the size the more you can use! var Ypos=new Array(); var Xpos=new Array(); var Speed=new Array(); var Step=new Array(); var Cstep=new Array(); var obj = new Array(); for (i = 0; i < Amount; i++){ var P=Math.floor(Math.random()*grphcs.length); rndPic=grphcs[P]; var img = ''; $(this).append(img); obj[i] = $(this).append(img);; } var WinHeight= 900; var WinWidth= 1100; for (i=0; i < Amount; i++){ Ypos[i] = Math.round(Math.random()*WinHeight); Xpos[i] = Math.round(Math.random()*WinWidth); Speed[i]= Math.random()*0.02+1.2; Cstep[i]=0; Step[i]=Math.random()*0.01+0.01; } function fall(){ for (i=0; i < Amount; i++){ var sy = Speed[i]*Math.sin(90*Math.PI/180); var sx = Speed[i]*Math.cos(Cstep[i]); Ypos[i]+=sy; Xpos[i]-=sx; if (Ypos[i] > WinHeight){ Ypos[i]= -60; Xpos[i]= Math.round(Math.random()*WinWidth); Speed[i]= Math.random()*0.02+1.2; } //var m = $('.memo').html();$('.memo').html(m +"--"+i); $('.si'+i).css({left:Xpos[i],top:Ypos[i]}); Cstep[i]+=Step[i]; } setTimeout(fall,20); } fall(); }; })(jQuery);