Flint Particle System Forum - RGB particle fun Tue, 13 Dec 2011 00:20:14 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=3#Comment_3 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=3#Comment_3 Sat, 23 Feb 2008 10:46:40 +0000 sandersnake
I experimented with it and made a nice RGB particle experiment.
Check it out at www.actionscripter.nl

I think the blur filter also could be implemented with a bitmapemitter instead of the enter frame loop.
If you got any suggestions?

Source Code:

import flash.geom.Point;
import org.flintparticles.actions.*;
import org.flintparticles.counters.*;
import org.flintparticles.displayObjects.*;
import org.flintparticles.emitters.*;
import org.flintparticles.initializers.*;
import org.flintparticles.zones.*;

import com.afcomponents.common.display.*;
import com.afcomponents.common.graphics.*;

var emitter:DisplayObjectEmitter = new DisplayObjectEmitter();
emitter.setCounter( new Blast( 50 ) );
emitter.addInitializer( new ImageClass( Dot, 1 ) );
var lz:LineZone = new LineZone( new Point( stage.stageWidth/3, 3*stage.stageHeight/4 ), new Point( 2*stage.stageWidth/3, 3*stage.stageHeight/4) );
emitter.addInitializer( new Position( lz ) );
emitter.addInitializer( new Velocity( new PointZone( new Point( 0, 25 ) ) ) );
emitter.addInitializer( new ColorInit( 0xFF00FF00, 0xFFFFFFFF ) );
emitter.addAction( new Move() );
emitter.addAction( new Accelerate(0, 0) );
emitter.addAction( new GravityWell(25, stage.stageWidth/2, 2*stage.stageHeight/3) );

addChild( emitter );
emitter.start();
emitter.runAhead( 0 );

var emitter2:DisplayObjectEmitter = new DisplayObjectEmitter();
emitter2.setCounter( new Blast( 50 ) );
emitter2.addInitializer( new ImageClass( Dot, 1 ) );
var lz2:LineZone = new LineZone( new Point( stage.stageWidth/4, stage.stageHeight/3 ), new Point( stage.stageWidth/4, stage.stageHeight/2) );
emitter2.addInitializer( new Position( lz2 ) );
emitter2.addInitializer( new Velocity( new PointZone( new Point( 50, 0 ) ) ) );
emitter2.addInitializer( new ColorInit( 0xFF0000FF, 0xFFFFFFFF ) );
emitter2.addAction( new Move() );
emitter2.addAction( new GravityWell(15, stage.stageWidth/4, stage.stageHeight/3) );

addChild( emitter2 );
emitter2.start();
emitter2.runAhead( 0 );

var emitter3:DisplayObjectEmitter = new DisplayObjectEmitter();
emitter3.setCounter( new Blast( 50 ) );
emitter3.addInitializer( new ImageClass( Dot, 1 ) );
var lz3:LineZone = new LineZone( new Point( 3*stage.stageWidth/4, stage.stageHeight/3 ), new Point( 3*stage.stageWidth/4, stage.stageHeight/2) );
emitter3.addInitializer( new Position( lz3 ) );
emitter3.addInitializer( new Velocity( new PointZone( new Point( -50, 0 ) ) ) );
emitter3.addInitializer( new ColorInit( 0xFFFF0000, 0xFFFFFFFF ) );
emitter3.addAction( new Move() );
emitter3.addAction( new GravityWell(15, 3*stage.stageWidth/4, stage.stageHeight/3) );

addChild( emitter3 );
emitter3.start();
emitter3.runAhead( 0 );

var bmd:BitmapData = new BitmapData(550, 400, true, 0xFFFFFF);
var bm:Bitmap = new Bitmap(bmd);
addChild(bm);

var bf:BlurFilter = new BlurFilter(2, 2, 1);

addEventListener(Event.ENTER_FRAME, loop);

function loop(e:Event):void
{
bmd.draw(emitter);
bmd.draw(emitter2);
bmd.draw(emitter3);
bmd.applyFilter(bmd, bmd.rect, new Point(0,0), bf);
//bmd.applyFilter(bmd, bmd.rect, new Point(0,0), cmf);
//bmd.scroll(0, 3);
}
]]>
RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=5#Comment_5 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=5#Comment_5 Sat, 23 Feb 2008 14:30:31 +0000 Richard
As you say, you could use a BitmapEmitter and place the blur inside it. The code would look like this.

import flash.geom.Point;
import org.flintparticles.actions.*;
import org.flintparticles.counters.*;
import org.flintparticles.displayObjects.*;
import org.flintparticles.emitters.*;
import org.flintparticles.initializers.*;
import org.flintparticles.zones.*;

var emitter:BitmapEmitter = new BitmapEmitter();
emitter.setCounter( new Blast( 50 ) );
emitter.addInitializer( new SharedImage( new Dot( 1 ) ) );
var lz:LineZone = new LineZone( new Point( stage.stageWidth/3, 3*stage.stageHeight/4 ), new Point( 2*stage.stageWidth/3, 3*stage.stageHeight/4) );
emitter.addInitializer( new Position( lz ) );
emitter.addInitializer( new Velocity( new PointZone( new Point( 0, 25 ) ) ) );
emitter.addInitializer( new ColorInit( 0xFF00FF00, 0xFFFFFFFF ) );
emitter.addAction( new Move() );
emitter.addAction( new Accelerate(0, 0) );
emitter.addAction( new GravityWell(25, stage.stageWidth/2, 2*stage.stageHeight/3) );
emitter.addFilter( new BlurFilter( 2, 2, 1 ) );
addChild( emitter );
emitter.start();

var emitter2:BitmapEmitter = new BitmapEmitter();
emitter2.setCounter( new Blast( 50 ) );
emitter2.addInitializer( new SharedImage( new Dot( 1 ) ) );
var lz2:LineZone = new LineZone( new Point( stage.stageWidth/4, stage.stageHeight/3 ), new Point( stage.stageWidth/4, stage.stageHeight/2) );
emitter2.addInitializer( new Position( lz2 ) );
emitter2.addInitializer( new Velocity( new PointZone( new Point( 50, 0 ) ) ) );
emitter2.addInitializer( new ColorInit( 0xFF0000FF, 0xFFFFFFFF ) );
emitter2.addAction( new Move() );
emitter2.addAction( new GravityWell(15, stage.stageWidth/4, stage.stageHeight/3) );
emitter2.addFilter( new BlurFilter( 2, 2, 1 ) );
addChild( emitter2 );
emitter2.start();

var emitter3:BitmapEmitter = new BitmapEmitter();
emitter3.setCounter( new Blast( 50 ) );
emitter3.addInitializer( new SharedImage( new Dot( 1 ) ) );
var lz3:LineZone = new LineZone( new Point( 3*stage.stageWidth/4, stage.stageHeight/3 ), new Point( 3*stage.stageWidth/4, stage.stageHeight/2) );
emitter3.addInitializer( new Position( lz3 ) );
emitter3.addInitializer( new Velocity( new PointZone( new Point( -50, 0 ) ) ) );
emitter3.addInitializer( new ColorInit( 0xFFFF0000, 0xFFFFFFFF ) );
emitter3.addAction( new Move() );
emitter3.addAction( new GravityWell(15, 3*stage.stageWidth/4, stage.stageHeight/3) );
emitter3.addFilter( new BlurFilter( 2, 2, 1 ) );
addChild( emitter3 );
emitter3.start();
]]>
RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=11#Comment_11 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=11#Comment_11 Tue, 26 Feb 2008 05:05:31 +0000 bandersen Right-clicking, then holding a bit before releasing on the GravityWells examples, I notice that the trails disappear and the number of particles decreases. Why is that? ]]> RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=18#Comment_18 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=18#Comment_18 Fri, 29 Feb 2008 19:15:06 +0000 Richard RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=23#Comment_23 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=23#Comment_23 Sun, 02 Mar 2008 22:34:53 +0000 bandersen
You can see the effect by visiting <http://ripple.ca> and looking at the Feb. 24th entry titled "Pretty Math". ]]>
RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=24#Comment_24 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=24#Comment_24 Mon, 03 Mar 2008 14:21:52 +0000 Richard RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=25#Comment_25 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=25#Comment_25 Mon, 03 Mar 2008 16:08:27 +0000 bandersen RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=26#Comment_26 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=26#Comment_26 Mon, 03 Mar 2008 16:37:53 +0000 bandersen
No need to answer, if you feel you've wasted enough time on this. :-) ]]>
RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=27#Comment_27 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=27#Comment_27 Mon, 03 Mar 2008 22:23:16 +0000 Richard RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=28#Comment_28 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=28#Comment_28 Tue, 04 Mar 2008 21:40:51 +0000 bandersen RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=1333#Comment_1333 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=1333#Comment_1333 Sat, 11 Sep 2010 21:43:26 +0100 mankica RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=1334#Comment_1334 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=1334#Comment_1334 Sun, 12 Sep 2010 11:21:06 +0100 Richard
It won't work quite the same in the current version of Flint. The relationship between emitters and renderers was changed when version 2 was released.

If you want an earlier version of Flint, all versions are available here.

If you want to create the same effect but with the latest version of Flint, this will do it.

import org.flintparticles.common.counters.Blast;
import org.flintparticles.common.displayObjects.Dot;
import org.flintparticles.common.initializers.ColorInit;
import org.flintparticles.common.initializers.SharedImage;
import org.flintparticles.twoD.actions.Accelerate;
import org.flintparticles.twoD.actions.GravityWell;
import org.flintparticles.twoD.actions.Move;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.Position;
import org.flintparticles.twoD.initializers.Velocity;
import org.flintparticles.twoD.renderers.BitmapRenderer;
import org.flintparticles.twoD.zones.LineZone;
import org.flintparticles.twoD.zones.PointZone;

import flash.display.Sprite;
import flash.filters.BlurFilter;
import flash.geom.Point;
import flash.geom.Rectangle;

var renderer : BitmapRenderer = new BitmapRenderer( new Rectangle( 0, 0, 550, 400 ), true );
renderer.addFilter( new BlurFilter( 2, 2, 1 ) );
addChild( renderer );

var emitter : Emitter2D = new Emitter2D( );
emitter.counter = new Blast( 50 );
emitter.addInitializer( new SharedImage( new Dot( 1 ) ) );
var lz : LineZone = new LineZone( new Point( stage.stageWidth / 3, 3 * stage.stageHeight / 4 ), new Point( 2 * stage.stageWidth / 3, 3 * stage.stageHeight / 4 ) );
emitter.addInitializer( new Position( lz ) );
emitter.addInitializer( new Velocity( new PointZone( new Point( 0, 25 ) ) ) );
emitter.addInitializer( new ColorInit( 0xFF00FF00, 0xFFFFFFFF ) );
emitter.addAction( new Move( ) );
emitter.addAction( new Accelerate( 0, 0 ) );
emitter.addAction( new GravityWell( 25, stage.stageWidth / 2, 2 * stage.stageHeight / 3 ) );
renderer.addEmitter( emitter );
emitter.start( );

var emitter2 : Emitter2D = new Emitter2D( );
emitter2.counter = new Blast( 50 );
emitter2.addInitializer( new SharedImage( new Dot( 1 ) ) );
var lz2 : LineZone = new LineZone( new Point( stage.stageWidth / 4, stage.stageHeight / 3 ), new Point( stage.stageWidth / 4, stage.stageHeight / 2 ) );
emitter2.addInitializer( new Position( lz2 ) );
emitter2.addInitializer( new Velocity( new PointZone( new Point( 50, 0 ) ) ) );
emitter2.addInitializer( new ColorInit( 0xFF0000FF, 0xFFFFFFFF ) );
emitter2.addAction( new Move( ) );
emitter2.addAction( new GravityWell( 15, stage.stageWidth / 4, stage.stageHeight / 3 ) );
renderer.addEmitter( emitter2 );
emitter2.start( );

var emitter3 : Emitter2D = new Emitter2D( );
emitter3.counter = new Blast( 50 );
emitter3.addInitializer( new SharedImage( new Dot( 1 ) ) );
var lz3 : LineZone = new LineZone( new Point( 3 * stage.stageWidth / 4, stage.stageHeight / 3 ), new Point( 3 * stage.stageWidth / 4, stage.stageHeight / 2 ) );
emitter3.addInitializer( new Position( lz3 ) );
emitter3.addInitializer( new Velocity( new PointZone( new Point( -50, 0 ) ) ) );
emitter3.addInitializer( new ColorInit( 0xFFFF0000, 0xFFFFFFFF ) );
emitter3.addAction( new Move( ) );
emitter3.addAction( new GravityWell( 15, 3 * stage.stageWidth / 4, stage.stageHeight / 3 ) );
renderer.addEmitter( emitter3 );
emitter3.start( );
]]>
RGB particle fun http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=1336#Comment_1336 http://flintparticles.org/forum/comments.php?DiscussionID=3&Focus=1336#Comment_1336 Sun, 12 Sep 2010 15:25:17 +0100 mankica