We continue our popular series of particle animations with a whimsical new example. This time, the particles consist of line segments which rotate as they move. Small rectangles are drawn between the previous segment location to the new segment, thus producing the effect of ribbons being swept out in the trajectories. Click on the image below to open the applet in a new window.
- Download all the source files corresponding to this experiment: ribbons.zip
Check out other particle animations in the series:
- Rain Animation with Splashing Raindrops - AS3 Flash CS4 Effect
- Lorenz Attractor in Bubble Form - AS3 Flash Visual Effect
- A Dynamic, Interactive Fountain - Flash CS4 AS3 Effect
Comments About the Code
As the ribbons explode out from a central location, their widths increase and then later taper back to zero. This is achieved by setting some “envelope” parameters for the line segment particles. This use of an envelope is similar to the envelopes used to control the changing size of the bubbles in our earlier Lorenz in Bubble Form example linked above.
The ribbons are colored according to two randomly chosen colors which determine a gradient. To achieve a depth effect, a ColorTransform is continuously applied to the picture to darken the previous image while the new portions are drawn. This darkening filter also has the effect of fading out the old picture to black.
We have simplified the code somewhat compared to our earlier examples, and have tried to include only the variables and methods required to achieve this particular effect. We hope the result is code that is easier to understand. Still, we have tried to maintain some flexibility in the code to allow for experimentation.