Ir para conteúdo
Fórum Script Brasil
  • 0

[Help] Como colocar nuvens no site


Marcelus Bill

Pergunta

1 resposta a esta questão

Posts Recomendados

  • 0

olá, eu queria algo semelhante e fiz uma adaptaçao de um cod que achei para passar um treno no meu site

salve como nuvens.js e insira o seguinte cod onde quiser as nuvens:

<script src="http://seusite/nuvens.js" type="text/javascript" ></script>

var NUVENS_Picture = "http://seusite/NUVENS.gif"; //local onde está a image de nuvens
var NUVENS_no = 1; //numero de nuvens passando

var NUVENS_browser_IE_NS = (document.body.clientHeight) ? 1 : 0;
var NUVENS_browser_MOZ = (self.innerWidth) ? 1 : 0;
var NUVENS_browser_IE7 = (document.documentElement.clientHeight) ? 1 : 0;

var NUVENS_Time;
var NUVENS_Teste;
var NUVENS_controle = 1;
var NUVENS_dx, NUVENS_xp, NUVENS_yp;
var NUVENS_am, NUVENS_stx, NUVENS_sty; 
var i, NUVENS_Browser_Width, NUVENS_Browser_Height;


function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}



if (NUVENS_browser_IE_NS)
{
    NUVENS_Browser_Width = document.body.clientWidth;
    NUVENS_Browser_Height = document.body.clientHeight;
}
else if (NUVENS_browser_MOZ)
{
    NUVENS_Browser_Width = self.innerWidth - 20;
    NUVENS_Browser_Height = self.innerHeight;
}
else if (NUVENS_browser_IE7)
{
    NUVENS_Browser_Width = document.documentElement.clientWidth;
    NUVENS_Browser_Height = document.documentElement.clientHeight;
}

NUVENS_dx = new Array();
NUVENS_xp = new Array();
NUVENS_yp = new Array();
NUVENS_am = new Array();
NUVENS_stx = new Array();
NUVENS_sty = new Array();

for (i = 0; i < NUVENS_no; ++ i) 
{ 
    NUVENS_dx[i] = 0; 
    NUVENS_xp[i] = Math.random()*(NUVENS_Browser_Height-50);
    NUVENS_yp[i] = Math.random()*NUVENS_Browser_Height*0;
    NUVENS_am[i] = Math.random()*20; 
    NUVENS_stx[i] = 0.02 + Math.random()/10;
    NUVENS_sty[i] = 0.7 + Math.random();
    document.write("<\div id=\"NUVENS_flake"+ i +"\" style=\"position: absolute; z-index: "+ i +"; visibility: visible; top: 15px; left: 15px;\"><\img src=\""+NUVENS_Picture+"\" border=\"0\"><\/div>");
}

function NUVENS_Weather() 
{ 

for (i = 0; i < NUVENS_no; ++ i) 
{
    
    NUVENS_yp[i] += NUVENS_sty[i];
    NUVENS_Teste = NUVENS_yp[i];
    if (NUVENS_yp[i] > NUVENS_Browser_Width-1) 
    {
        NUVENS_xp[i] = Math.random()*(NUVENS_Browser_Width-NUVENS_am[i]-30);
        NUVENS_yp[i] = 0;
        NUVENS_stx[i] = 0.02 + Math.random()/10;
        NUVENS_sty[i] = 0.7 + Math.random();
    }

    NUVENS_dx[i] += NUVENS_stx[i];
    if(NUVENS_Teste > NUVENS_Browser_Width-1)
    {
        document.getElementById("NUVENS_flake"+i).style.top=NUVENS_xp[i] + NUVENS_am[i]*Math.sin(NUVENS_dx[i])+"px";
        document.getElementById("NUVENS_flake"+i).style.left=NUVENS_yp[i]+"px";
        document.getElementById("NUVENS_flake"+i).style.visibility = "hidden";
    }
    else
    {
        
        document.getElementById("NUVENS_flake"+i).style.top=NUVENS_xp[i] + NUVENS_am[i]*Math.sin(NUVENS_dx[i])+"px";
        document.getElementById("NUVENS_flake"+i).style.left=NUVENS_yp[i]+"px";
        document.getElementById("NUVENS_flake"+i).style.visibility = "visible";
    }
}
if (NUVENS_Teste > NUVENS_Browser_Width-1) 
{
    NUVENS_Time = setTimeout(NUVENS_Weather, 1);
}
else
{
    NUVENS_Time = setTimeout(NUVENS_Weather, 6);
}
}
NUVENS_Weather();

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,7k
×
×
  • Criar Novo...