Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Vojdite v zumpe do nejakej temy, ktora ma cca 50 prispevkov, inak to bude sekat
- //Vlozit do riadku, kde sa pisu adresy - pozor niektore prehliadace odmazu slovicko "javascript:", tak ho tam treba znova dopisat
- 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();
- ///////////////////////////////////////////////////
- /*
- Pre EnaXnaY
- 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.
- Cim mensie chces mat ikonky, tym viac vytiahni js konzolu, aby zakryvala zobrazovaciu plochu, potom vloz kod a zmensi konzolu alebo ju vypni...
- Velkosti ikon sa totiz automaticku zmensuju podla toho aka velka je zobrazovacia plocha..
- Ak chces mat ikonky vacsie, tak pouzi horny link bez otvorenej js konzoly...
- */
- var imageCount = document.querySelectorAll("img.clickable").length;
- var scrCenterX = window.innerWidth / 2;
- var scrCenterY = window.innerHeight / 2;
- var scrSize = (window.innerWidth < window.innerHeight) ? window.innerWidth : window.innerHeight;
- var particles = [];
- var gravity = 9.80665;
- var refresh; //timer
- function toRad(deg) {
- return deg * (Math.PI / 180)
- }
- function setPos(id, x, y) {
- document.querySelectorAll("img.clickable")[id].style.left = x + "px";
- document.querySelectorAll("img.clickable")[id].style.top = y + "px";
- }
- function setSize(id, size) {
- document.querySelectorAll("img.clickable")[id].style.width = size + "px";
- document.querySelectorAll("img.clickable")[id].style.height = size + "px";
- }
- function init() {
- var particle;
- for (i = 0; i < imageCount; i++) {
- particle = {};
- document.querySelectorAll("img.clickable")[i].style.zIndex = '1';
- document.querySelectorAll("img.clickable")[i].style.position = 'fixed';
- particle.x = scrCenterX + Math.sin(i * Math.PI * 2 / imageCount) * (scrSize - 60) / 2
- particle.y = scrCenterY + Math.cos(i * Math.PI * 2 / imageCount) * (scrSize - 60) / 2;
- particle.t = 0;
- particle.vel = 0;
- particle.angle = toRad(90);
- setSize(i, scrSize / 20);
- particles.push(particle);
- setPos(i, particles[i].x, particles[i].y);
- }
- }
- ///////////////////////////////////
- function animation() {
- var vx, vy;
- for (i = 0; i < imageCount; i++) {
- vy = -1 * (Math.sin(particles[i].angle) * particles[i].vel * particles[i].t + gravity * (particles[i].t * particles[i].t));
- vx = Math.cos(particles[i].angle) * particles[i].vel * particles[i].t;
- vy *= -1;
- particles[i].t += 0.001;
- particles[i].x += vx;
- particles[i].y += vy;
- setPos(i, particles[i].x, particles[i].y);
- if (particles[i].y > window.innerHeight || particles[i].x < 0 || particles[i].x > window.innerWidth) {
- particles[i].x = scrCenterX; //window.innerHeight;
- particles[i].y = window.innerHeight;
- particles[i].vel = (Math.random() * 4.5 + 2) * -1;
- particles[i].angle = toRad(Math.random() * 10 + 85);
- particles[i].t = 0;
- setPos(i, particles[i].x, particles[i].y);
- }
- }
- refresh = setInterval(animation, 5);
- }
- //////////////////////
- init();
- animation();
- //clearInterval(refresh);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement