Thursday, 26 May 2011

Free Fire Animation In JavaScript


Free Fire Animation In JavaScript. Save the blow JavaScript code with .html extension and see the 3d fire animation. If you Like My script Please do Comment.  

<html> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=ISO-

8859-1"> 
<title>ASCII Fire Animation with JavaScript</title> 
<meta name="author" content="Thiemo Mättig"> 
<style type="text/css"> 
body{
background:#000;
color:gold;
height:100%;
margin:0;
padding:0;
width:100%;
}
a{color:gold;}
a:hover{color:#FF0;}
address{
bottom:10px;
font-family:Georgia;
font-style:normal;
position:absolute;
right:10px;
text-align:right;
}
</style> 
</head><body> 

<center style="height: 100%;"> 
 <table height="100%"> 
  <tbody><tr> 
   <td> 
    <b> 
     <pre id="o">This animated fire in plain ASCII art needs 

JavaScript to run in your web browser.</pre> 
    </b> 
   </td> 
  </tr> 
 </tbody></table> 
</center> 

<script type="text/javascript"> 
var size = 80 * 25;
var b = [];
for (i = 0; i < size + 81; i++)
  b[i] = 0;
var char = " .:*sS#$".split("");
var e = document.getElementById("o").firstChild;

function f()
{
  for (i = 0; i < 10; i++)
    b[Math.floor(Math.random() * 80) + 80 * 24] = 70;
  a = "";
  for (i = 0; i < size; i++)
  {
    b[i] = Math.floor((b[i] + b[i + 1] + b[i + 80] + b[i + 81]) / 

4);
    a += char[b[i] > 7 ? 7 : b[i]];
    if (i % 80 > 78)
      a += "\r\n";
  }
  e.data = a;
  setTimeout(f, 30);
}
f();
</script> 
  
</body> 
</html>




0 comments:

Post a Comment