View Full Version : Autumn Leaves

09-16-2012, 09:48 AM
1) Script Title: Autumn Leaves

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex3/leaves.htm

3) Describe problem: Is it possible to slow the rate of fall please?

Thanks :)

09-16-2012, 10:05 AM
It depends on your intent. Changing this line will be very easy:

20=20ms, so just change that to a higher or lower number for more delay (slower) or less delay (faster).
But note that this method will make the animation choppier if slowed too much, or might overload the processing in the browser if sped up too much.

Getting into the slightly more complicated math, this line can also be modified:

Speed[i]= Math.random()*5+3;
Changing 5 to another value will change the rate of random falling, and changing 3 to another value will change the default base/minimum speed.

(Note: I haven't tested any of this, but if it doesn't work just let us know.)

09-16-2012, 01:01 PM
Thanks for your reply drj33. :)

I'd like to run this code on a forum I run, so the internet speed will vary from member to member. :)

Link to my forum: http://www.wellieswheelbarrows.proboards.com/

09-16-2012, 01:08 PM
I've been running the code on my test forum - http://testingwellies.proboards.com/

I've just changed the setTimeout('fall()',20); from 20 to 50, which is much better - now to run it on my main forum.... keep your fingers crossed my members like it. :)

09-16-2012, 10:04 PM
Ok, I agree that looks a little better for your site.

The only problem is that it's now very subtly jumpy because it's now running about 20 frames per second (1000/50=20). 24 frames per second is standard for films, and 25 (Europe) to 30 (US) is standard for video/tv (which, through a complex process can actually be effectively 50-60fps). The original script is (1000/20=50) 50fps, so that's fast enough, like European TV. Basically those rates are fast enough that the eye sees it as smooth motion. Once you reach something like 15fps, it can start to look pretty choppy. Here, 20 is right on the edge.

So-- either make it go a little faster (maybe a value of 40, making it about 24fps, like a film in a theater), or try changing that other line I showed you instead. Aside from potentially making the motion not work at all, it won't do any permanent damage to the site/script-- just save a backup in case you change something the wrong way. Use some trial and error to find what you like.

Of course if you're happy with it at the moment, that's fine. In fact, some videos (on the internet) are presented at 15fps, and people don't mind too much, so 20fps should be fine. It just might be a little jumpy to some people.

09-17-2012, 06:49 AM
Thanks for your detailed and interesting reply. I've changed the value on my test forum.... how does it look to you now? Which browser are you using djr33?


09-17-2012, 06:57 AM
I think that looks pretty reasonable. I'm using Firefox 15 on a Mac. But it should render the same way on all browsers (that support the script), at least if the computer isn't too slow (or overloaded processing other things). This is just a frame-by-frame animation, so it won't look any smoother/better on a better computer, but a sluggish computer might make it look worse (although it would have to be a fairly old computer these days-- that isn't too much work for most modern machines).

If you feel like playing with the script more, something you might try doing is creating less leaves as time increases. (It wouldn't be so difficult to add this, but it would take a lot of trial and error to get the details right.) Essentially add a decay based on time so that as time goes on fewer and fewer leaves start to fall. This just would help in the case of reading long posts, where the leaves might get annoying.

Of course there's always the change that your users will simply find the script to be annoying (having things fall as they're using the forum), but just see what happens. It does add something aesthetic to the design, so it should be fine.

Another option is to disable it except on the forum index, if that's what you'd like. It wouldn't be too hard to do that (just a basic IF statement I'd think-- again some trial and error).

09-17-2012, 07:10 AM
I know nothing about writing codes, I'm a silver surfing grandmother LOL, I just know if I put them in the right place they usually work. Some of the codes I have running do require me to add image links to them, lots of links in some cases.

I'll just be running this code in my main header using it in my global header would give my members a headache when reading or replying to threads. Just wish it didn't run while I'm viewing my headers and footers - thankfully I don't need to access them very often. :)

09-17-2012, 07:20 AM
Ok, that's fine. Well, code is something you can learn just by trial and error (especially something like this with lots of numbers-- think of each number as a gas pedal in a car, that can go slower or faster-- it'll take a while to figure out exactly what each does, but it'll change something). Just save a backup first :)

Either way, that sounds fine. Good luck with it.

09-17-2012, 08:17 AM
Trust me I back up all of the codes I have running, best to be safe than sorry. :)

Thanks for your help.