Advertisement
WolfeSVK

Vyteka zumpa

May 3rd, 2016
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Vojdite v zumpe do nejakej temy, ktora ma cca 50 prispevkov, inak to bude sekat
  2. //Vlozit do riadku, kde sa pisu adresy - pozor niektore prehliadace odmazu slovicko "javascript:", tak ho tam treba znova dopisat
  3.  
  4. javascript:function toRad(i){return i*(Math.PI/180)}function setPos(i,e,t){document.querySelectorAll("img.clickable")[i].style.left=e+"px",document.querySelectorAll("img.clickable")[i].style.top=t+"px"}function setSize(i,e){document.querySelectorAll("img.clickable")[i].style.width=e+"px",document.querySelectorAll("img.clickable")[i].style.height=e+"px"}function init(){var e;for(i=0;i<imageCount;i++)e={},document.querySelectorAll("img.clickable")[i].style.zIndex="1",document.querySelectorAll("img.clickable")[i].style.position="fixed",e.x=scrCenterX+Math.sin(i*Math.PI*2/imageCount)*(scrSize-60)/2,e.y=scrCenterY+Math.cos(i*Math.PI*2/imageCount)*(scrSize-60)/2,e.t=0,e.vel=0,e.angle=toRad(90),setSize(i,scrSize/20),particles.push(e),setPos(i,particles[i].x,particles[i].y)}function animation(){var e,t;for(i=0;i<imageCount;i++)t=-1*(Math.sin(particles[i].angle)*particles[i].vel*particles[i].t+gravity*(particles[i].t*particles[i].t)),e=Math.cos(particles[i].angle)*particles[i].vel*particles[i].t,t*=-1,particles[i].t+=.001,particles[i].x+=e,particles[i].y+=t,setPos(i,particles[i].x,particles[i].y),(particles[i].y>window.innerHeight||particles[i].x<0||particles[i].x>window.innerWidth)&&(particles[i].x=scrCenterX,particles[i].y=window.innerHeight,particles[i].vel=-1*(4.5*Math.random()+2),particles[i].angle=toRad(10*Math.random()+85),particles[i].t=0,setPos(i,particles[i].x,particles[i].y));refresh=setInterval(animation,5)}var imageCount=document.querySelectorAll("img.clickable").length,scrCenterX=window.innerWidth/2,scrCenterY=window.innerHeight/2,scrSize=window.innerWidth<window.innerHeight?window.innerWidth:window.innerHeight,particles=[],gravity=9.80665,refresh;init(),animation();
  5.  
  6.  
  7.  
  8. ///////////////////////////////////////////////////
  9. /*
  10. Pre EnaXnaY
  11. Otvor si javascript konzolu (viem, ze to ma chrome, safari a asi aj firefox, neviem aky prehliadac pouzivas, ak nie tak proste pouzi horny link) a vloz tam tento kod.
  12. Cim mensie chces mat ikonky, tym viac vytiahni js konzolu, aby zakryvala zobrazovaciu plochu, potom vloz kod a zmensi konzolu alebo ju vypni...
  13. Velkosti ikon sa totiz automaticku zmensuju podla toho aka velka je zobrazovacia plocha..
  14. Ak chces mat ikonky vacsie, tak pouzi horny link bez otvorenej js konzoly...
  15. */
  16.  
  17. var imageCount = document.querySelectorAll("img.clickable").length;
  18. var scrCenterX = window.innerWidth / 2;
  19. var scrCenterY = window.innerHeight / 2;
  20. var scrSize = (window.innerWidth < window.innerHeight) ? window.innerWidth : window.innerHeight;
  21. var particles = [];
  22. var gravity = 9.80665;
  23.  
  24. var refresh; //timer
  25.  
  26. function toRad(deg) {
  27.     return deg * (Math.PI / 180)
  28. }
  29.  
  30. function setPos(id, x, y) {
  31.     document.querySelectorAll("img.clickable")[id].style.left = x + "px";
  32.     document.querySelectorAll("img.clickable")[id].style.top = y + "px";
  33. }
  34.  
  35. function setSize(id, size) {
  36.     document.querySelectorAll("img.clickable")[id].style.width = size + "px";
  37.     document.querySelectorAll("img.clickable")[id].style.height = size + "px";
  38. }
  39.  
  40. function init() {
  41.     var particle;
  42.     for (i = 0; i < imageCount; i++) {
  43.         particle = {};
  44.         document.querySelectorAll("img.clickable")[i].style.zIndex = '1';
  45.         document.querySelectorAll("img.clickable")[i].style.position = 'fixed';
  46.  
  47.  
  48.         particle.x = scrCenterX + Math.sin(i * Math.PI * 2 / imageCount) * (scrSize - 60) / 2
  49.         particle.y = scrCenterY + Math.cos(i * Math.PI * 2 / imageCount) * (scrSize - 60) / 2;
  50.         particle.t = 0;
  51.         particle.vel = 0;
  52.         particle.angle = toRad(90);
  53.         setSize(i, scrSize / 20);
  54.         particles.push(particle);
  55.         setPos(i, particles[i].x, particles[i].y);
  56.  
  57.     }
  58. }
  59. ///////////////////////////////////
  60. function animation() {
  61.  
  62.     var vx, vy;
  63.     for (i = 0; i < imageCount; i++) {
  64.  
  65.         vy = -1 * (Math.sin(particles[i].angle) * particles[i].vel * particles[i].t + gravity * (particles[i].t * particles[i].t));
  66.         vx = Math.cos(particles[i].angle) * particles[i].vel * particles[i].t;
  67.  
  68.         vy *= -1;
  69.  
  70.         particles[i].t += 0.001;
  71.  
  72.         particles[i].x += vx;
  73.         particles[i].y += vy;
  74.  
  75.  
  76.         setPos(i, particles[i].x, particles[i].y);
  77.  
  78.         if (particles[i].y > window.innerHeight || particles[i].x < 0 || particles[i].x > window.innerWidth) {
  79.  
  80.             particles[i].x = scrCenterX; //window.innerHeight;
  81.             particles[i].y = window.innerHeight;
  82.  
  83.             particles[i].vel = (Math.random() * 4.5 + 2) * -1;
  84.  
  85.             particles[i].angle = toRad(Math.random() * 10 + 85);
  86.             particles[i].t = 0;
  87.             setPos(i, particles[i].x, particles[i].y);
  88.  
  89.         }
  90.  
  91.     }
  92.  
  93.  
  94.  
  95.     refresh = setInterval(animation, 5);
  96. }
  97. //////////////////////
  98.  
  99.  
  100. init();
  101. animation();
  102. //clearInterval(refresh);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement