CreativeSpark
/**
* Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/1yIF
*/
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.geom.Point;
import idv.cjcat.stardust.common.actions.Age;
import idv.cjcat.stardust.common.actions.AlphaCurve;
import idv.cjcat.stardust.common.actions.DeathLife;
import idv.cjcat.stardust.common.actions.ScaleCurve;
import idv.cjcat.stardust.common.clocks.SteadyClock;
import idv.cjcat.stardust.common.initializers.Life;
import idv.cjcat.stardust.common.initializers.Scale;
import idv.cjcat.stardust.common.math.UniformRandom;
import idv.cjcat.stardust.twoD.actions.Accelerate;
import idv.cjcat.stardust.twoD.actions.DeathZone;
import idv.cjcat.stardust.twoD.actions.Move;
import idv.cjcat.stardust.twoD.emitters.Emitter2D;
import idv.cjcat.stardust.twoD.handlers.DisplayObjectHandler;
import idv.cjcat.stardust.twoD.initializers.DisplayObjectClass;
import idv.cjcat.stardust.twoD.initializers.Position;
import idv.cjcat.stardust.twoD.initializers.Velocity;
import idv.cjcat.stardust.twoD.zones.LazySectorZone;
import idv.cjcat.stardust.twoD.zones.SinglePoint;
import com.greensock.*;
import com.greensock.easing.*;
import net.hires.debug.Stats;
[SWF(backgroundColor=0x000000, frameRate=120)]
public class StardustSpecialBlend extends Sprite
{
public var stats:Stats = new Stats();
private var emitter:Emitter2D;
private var point:SinglePoint;
private var blur:BlurFilter = new BlurFilter(3, 3, 3);
private var canvas:Bitmap;
private var sp:Sprite = new Sprite();
public function StardustSpecialBlend()
{
addChild(stats);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
canvas = new Bitmap(new BitmapData(stage.stageWidth, stage.stageHeight, true, 0xFFFFFF));
addChild(sp);
addChild(canvas);
var clock:SteadyClock = new SteadyClock(1);
emitter = new Emitter2D(clock);
point = new SinglePoint();
emitter.addInitializer(new DisplayObjectClass(Circle));
emitter.addInitializer(new Velocity(new LazySectorZone(4, 0.5)));
emitter.addInitializer(new Life(new UniformRandom(30, 0)));
emitter.addInitializer(new Scale(new UniformRandom(1, 0.5)));
emitter.addInitializer(new Position(point));
emitter.addAction(new Age());
emitter.addAction(new DeathLife());
var alph:AlphaCurve = new AlphaCurve(0, 30);
alph.inAlpha = 1;
alph.outAlpha = 0;
emitter.addAction(alph);
emitter.addAction(new Move());
emitter.particleHandler = new DisplayObjectHandler(sp);
addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(e:Event):void
{
canvas.bitmapData.lock();
//point.x = mouseX;
//point.y = mouseY;
//point.x = stage.stageWidth / 2;
//point.y = stage.stageHeight / 2;
//var tmPoint:uint = new uint();
TweenMax.to(canvas, 1, {blurFilter:{blurX:10, blurY:10, quality:1}});
TweenMax.to(point, 2, {x:mouseX, y:mouseY, ease:Cubic.easeIn});
emitter.step();
// canvas.bitmapData.applyFilter( canvas.bitmapData, canvas.bitmapData.rect, new Point(), blur);
canvas.bitmapData.colorTransform(canvas.bitmapData.rect, new ColorTransform(1, 1, 1, 1, 0, 0, 0, -.99));
canvas.bitmapData.draw(sp, null, null);
canvas.bitmapData.unlock();
}
}
}
import flash.display.Sprite;
import frocessing.color.ColorHSV;
class Circle extends Sprite{
static private var col:int = 360;
public function Circle(){
var color:ColorHSV = new ColorHSV(col+=4, 4);
graphics.beginFill(color.value, 0.2);
graphics.drawCircle(0, 0, 10);
this.blendMode = "add";
graphics.endFill();
}
}