Please login or register to use the full functionality of this board...

 
Thread Rating:
  • 4 Votes - 2.25 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply 
Javascript Fog Animation
02-15-2010, 07:56 PM (This post was last modified: 02-15-2010 08:39 PM by Mike.)
Post: #1
Javascript Fog Animation
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
What do you think? I hate flash and thought it'd be a cool thing to try.

Basically it works like this:
<div w/ background image> -couldn't put the background in the fog container, or else it would scroll.
<fog container> fog() scrolls this diagonally and resets the scroll to (0,0) when the "animation" is done.
<fog> Must be at least cloudwidth+containerwidth to work
</
</
</


Here's the gist of the code:

Code:
setTimeOut(fog(),25);

var fogwidth=512;
var fogheight=512;
var fogoffset = 0;
function fog() {
var fogdiv = document.getElementById('fogdiv');
fogoffset++;
if(fogoffset>fogwidth || fogoffset>fogheight) {
        fogoffset = 0;
}
        fogdiv.scrollTop = fogoffset;
        fogdiv.scrollLeft = fogoffset;
}

And here's the fog image I used: (make black and white, add transparency... save as png)
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Find all posts by this user
Quote this message in a reply
Post Reply