Gravity Wells

Flash required: You need version 9 or later of the free Flash player from Adobe to use this content. To download and install the free player from Adobe’s web site click here.

Source code

This example uses a number of gravity wells and 4000 particles. The gravity wells behave as static points of gravitational attraction. All the particles are drawn towards the five gravity wells, producing the complex pattern of motion seen above.

var emitter:Emitter2D = new Emitter2D();

emitter.counter = new Blast( 4000 );

emitter.addInitializer( new ColorInit( 0xFFFF00FF, 0xFF00FFFF ) );
emitter.addInitializer( new Position( new DiscZone( new Point( 200, 200 ), 200 ) ) );

emitter.addAction( new Move() );
emitter.addAction( new GravityWell( 25, 200, 200 ) );
emitter.addAction( new GravityWell( 25, 75, 75 ) );
emitter.addAction( new GravityWell( 25, 325, 325 ) );
emitter.addAction( new GravityWell( 25, 75, 325 ) );
emitter.addAction( new GravityWell( 25, 325, 75 ) );

var renderer:PixelRenderer = new PixelRenderer( new Rectangle( 0, 0, 400, 400 ) );
renderer.addFilter( new BlurFilter( 2, 2, 1 ) );
renderer.addFilter( new ColorMatrixFilter( [ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.99,0 ] ) );
renderer.addEmitter( emitter );
addChild( renderer );

emitter.start();