For an upcoming Flash project, we’re creating a hand-drawn animation effect using the drawing API. The animation is going to achieve an illustrated look by using simple 1px-wide line drawings and fills, but to make feel as though it is animated by hand, the lines need to “jitter” randomly on every frame. Think Dr. Katz or early Home Movies, but rendering in real-time and more subtle.
To achieve the jitter, we’re going to move the control points of the illustrated lines by random amounts, which don’t have to be perfectly random but need to calculated quickly on every frame. I achieved this by writing a class which initializes a circularly-linked list with an arbitrary amount of random values, and a method that returns the next number in the list each time you call it. Linked lists are not very versatile in AS3, but they are the fastest data structure… they even beat out the new fp10-specific <Vector> class.
Using this Class, some patterns in the “random” movement may appear, but we aren’t worried about them. We’d rather have the 30%-52% increase in speed. Here are some speed test results using GSkinner’s PerformanceTest Class: