Reproducing A Clever Animation Product, Part 2

Today I did some experiments to try to figure out why the animations I’ve created seem to hitch and hiccup slightly from time to time. Again, this work is based on recreating the basic functionality of the Greensock animation product described here and especially here.

The first thing I thought of was that the drawing operations themselves might be taking long enough that they don’t complete during every animation step (about 16 ms at 60 frames per second). I therefore set the update loop to only draw the items every other scan. This approach didn’t relieve the hitching and updating at 30 fps left the animation looking slightly choppy.

The next thing I tried was recording the elapsed time for every drawing loop and displaying the value if it was greater than 16 ms. However, the value was never displayed, so it appears that the speed of the drawing isn’t an issue.

Next it occurred to me that if an element has to travel far enough and in fine enough increments that the difference between traveling three or four pixels in an update, particularly when advancing by the smaller number doesn’t happen often, might be enough to look like a hitch. I therefore set the durations of the transitions to be shorter so each increment is larger, and I also incorporated a fade-in by ramping up the opacity. The combination of these two changes made things look pretty smooth.

I also observe that the example animation in the second Greensock link, above, involves transitions that are relatively short, so there isn’t time for anything to hitch. That may be the key to the whole enterprise. That said, there’s an animation in the first link that shows a fountain of green balls. I will try to reproduce something like that and see how it looks. Most of the effects can be replicated (though perhaps not as well as the originals), and I’ll be working through duplicating some of them over the next few posts.

In the meantime, I found it necessary to add an initialization capability so rerunning the animation starts from a good place. Here’s the basic code in its entirety.

This entry was posted in Tools and methods and tagged , , . Bookmark the permalink.

Leave a Reply