Este artículo describe el Código de Efecto Especial para implementar el vuelo a las estrellas por JS., Y se comparte con usted para su referencia.
El código de implementación específico es el siguiente:
Copie el código de la siguiente manera: <html>
<Evista>
<title> Speed-Speed Flying Effect of the Starry Sky </title>
<style type = "text/css">
<!-
cuerpo {
Color de fondo: #000066;
}
->
</style>
</ablo>
<Body>
<script language = "javaScript">
xl = 8;
xh = xw = xr = xe = xmy = xmx = xwd = xhd = 0;
xf = nueva array ();
xy = new Array ();
xx = nueva array ();
xs = nueva matriz ();
xa = nueva array ();
xb = nueva array ();
ini = new Array ();
document.write ('<div id = "sdiv" style = "posición: absoluto; top: 0px; izquierda: 0px"> <div style = "posición: relativo">');
para (i = 0; i <xl; i ++) {
document.write ('<div id = "div" style = "posición: absoluto; arriba: 0; izquierda: 0; ancho: 5px; altura: 5px;'+'font-size: 10px; color: #ffffff">. </div>');
}
document.write ('</div> </div>');
función set () {
para (i = 0; i <xl; i ++) {
Transferencia (i)
xf [i] = xw/14;
}
}
función asignar () {
sdiv.style.top = document.body.scrolltop;
para (i = 0; i <xl; i ++) {
xf [i]-= xs [i]*25;
if (xf [i] <4) xf [i] = 3;
div [i] .style.top = xy [i];
div [i] .style.left = xx [i];
div [i] .style.fontSize = xf [i];
}
}
function fly () {
xmy = window.document.body.clientHeight/2;
xmx = window.document.body.clientwidth/2;
XWD = Math.round (Math.random ()*40+5);
xhd = math.round (math.random ()*30+5);
para (i = 0; i <xl; i ++) {
xy [i] = xa [i]+= (xmy-xa [i])*(xs [i]);
xx [i] = xb [i]+= (xmx-xb [i])*(xs [i]);
if ((xx [i]> xmx-xwd) && (xx [i] <xmx+xwd) && (xy [i]> xmy-xhd) && (xy [i] <xmy+xhd)) {
Transferencia (i)
}
if ((xx [i] <0) || (xx [i]> xw) || (xy [i] <0) || (xy [i]> xh)) {
xf [i] = xw/14;
}
}
Asignar();
setTimeOut ('Fly ()', 1);
}
transferencia de funciones (i) {
xh = window.document.body.offsetheight;
xw = window.document.body.offsetwidth;
xa [i] = math.round (math.random ()*xh);
xb [i] = math.round (math.random ()*xw);
xs [i] = math.random ()*0.05+0.05;
xr = Math.round (Math.random ()*3);
xe = math.round (math.random ()*50+50);
if (xr == 3) xb [i] =-xe;
if (xr == 2) xb [i] = xw+xe;
if (xr == 1) xa [i] =-xe;
if (xr == 0) xa [i] = xh;
}
Colocar();
volar();
</script>
</body>
</html> </td>
</tr>
</table>
Espero que este artículo sea útil para la programación de JavaScript de todos