Logo firework
Because the initial velocity for particles is based on a zone, and because we can make zones from bitmap data objects and display objects, it’s relatively easy to create effects like the one above. The initial velocity for the particles uses a zone derived from the logo image. Add a little gravity and blur and this is the result.
package { import org.flintparticles.twoD.emitters.Emitter2D; import org.flintparticles.twoD.renderers.PixelRenderer; import flash.display.Sprite; import flash.filters.BlurFilter; import flash.filters.ColorMatrixFilter; import flash.geom.Rectangle; [SWF(width='500', height='300', frameRate='60', backgroundColor='#000000')] public class Main extends Sprite { private var emitter:Emitter2D; public function Main() { emitter = new LogoFirework(); var renderer:PixelRenderer = new PixelRenderer( new Rectangle( 0, 0, 500, 300 ) ); 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.96,0 ] ) ); renderer.addEmitter( emitter ); addChild( renderer ); emitter.x = 250; emitter.y = 300; emitter.start( ); } } }
package { import org.flintparticles.common.actions.Age; import org.flintparticles.common.actions.Fade; import org.flintparticles.common.counters.Blast; import org.flintparticles.common.easing.Quadratic; import org.flintparticles.common.events.EmitterEvent; import org.flintparticles.common.initializers.ColorInit; import org.flintparticles.common.initializers.Lifetime; import org.flintparticles.twoD.actions.Accelerate; import org.flintparticles.twoD.actions.LinearDrag; 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.zones.BitmapDataZone; import org.flintparticles.twoD.zones.DiscZone; import flash.geom.Point; public class LogoFirework extends Emitter2D { public function LogoFirework() { counter = new Blast( 4000 ); addInitializer( new ColorInit( 0xFFFF3300, 0xFFFFFF00 ) ); addInitializer( new Lifetime( 6 ) ); addInitializer( new Position( new DiscZone( new Point( 0, 0 ), 10 ) ) ); addInitializer( new Velocity( new BitmapDataZone( new Logo( 265, 80 ), -132, -300 ) ) ); addAction( new Age( Quadratic.easeIn ) ); addAction( new Fade( 1.0, 0 ) ); addAction( new Move() ); addAction( new LinearDrag( 0.5 ) ); addAction( new Accelerate( 0, 70 ) ); addEventListener( EmitterEvent.EMITTER_EMPTY, restart, false, 0, true ); } public function restart( ev:EmitterEvent ):void { Emitter2D( ev.target ).start(); } } }
import org.flintparticles.common.actions.*; import org.flintparticles.common.counters.*; import org.flintparticles.common.easing.Quadratic; import org.flintparticles.common.events.EmitterEvent; import org.flintparticles.common.initializers.*; import org.flintparticles.twoD.actions.*; import org.flintparticles.twoD.emitters.Emitter2D; import org.flintparticles.twoD.initializers.*; import org.flintparticles.twoD.renderers.*; import org.flintparticles.twoD.zones.*; var emitter:Emitter2D = new Emitter2D(); emitter.counter = new Blast( 4000 ); emitter.addInitializer( new ColorInit( 0xFFFF3300, 0xFFFFFF00 ) ); emitter.addInitializer( new Lifetime( 6 ) ); emitter.addInitializer( new Position( new DiscZone( new Point( 0, 0 ), 10 ) ) ); emitter.addInitializer( new Velocity( new BitmapDataZone( new Logo( 265, 80), -132, -300 ) ) ); emitter.addAction( new Age( Quadratic.easeIn ) ); emitter.addAction( new Fade( 1.0, 0 ) ); emitter.addAction( new Move() ); emitter.addAction( new LinearDrag( 0.5 ) ); emitter.addAction( new Accelerate( 0, 70 ) ); emitter.addEventListener( EmitterEvent.EMITTER_EMPTY, restart, false, 0, true ); var renderer:PixelRenderer = new PixelRenderer( new Rectangle( 0, 0, 500, 300 ) ); 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.96,0 ] ) ); renderer.addEmitter( emitter ); addChild( renderer ); emitter.x = 250; emitter.y = 300; emitter.start( ); function restart( ev:EmitterEvent ):void { Emitter2D( ev.target ).start(); }
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:f="http://flintparticles.org/2009/flint2d" xmlns:filters="flash.filters.*" width="500" height="300" backgroundColor="#000000"> <fx:Script> <![CDATA[ import org.flintparticles.common.easing.Quadratic; ]]> </fx:Script> <f:PixelRenderer id="renderer" width="500" height="300"> <f:preFilters> <filters:BlurFilter blurX="2" blurY="2" quality="1"/> <filters:ColorMatrixFilter matrix="{[ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.96,0 ]}"/> </f:preFilters> <f:emitters> <f:Emitter id="emitter" autoStart="true" x="250" y="300" emitterEmpty="emitter.start()"> <f:counter> <f:Blast startCount="4000"/> </f:counter> <f:initializers> <f:Position> <f:DiscZone centerX="0" centerY="0" outerRadius="10"/> </f:Position> <f:ColorInit minColor="0xFFFF3300" maxColor="0xFFFFFF00"/> <f:Lifetime lifetime="6"/> <f:Velocity> <f:BitmapDataZone bitmapData="{new Logo( 265, 80 )}" offsetX="-132" offsetY="-300"/> </f:Velocity> </f:initializers> <f:actions> <f:Move/> <f:Age easing="{Quadratic.easeIn}"/> <f:Fade startAlpha="1" endAlpha="0"/> <f:LinearDrag drag="0.5"/> <f:Accelerate x="0" y="70"/> </f:actions> </f:Emitter> </f:emitters> </f:PixelRenderer> </s:Application>