forked from: forked from: forked from: Blobs
Blobs (1,300bytes effect)
by Mr.doob
// forked from rigard's forked from: forked from: Blobs
// forked from hacker_ipz6imuw's forked from: Blobs
// forked from mrdoob's Blobs
//
// Blobs (1,300bytes effect)
// by Mr.doob
//
package
{
import flash.display.Stage;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.utils.getTimer;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.events.Event;
[SWF( backgroundColor='0x000000', frameRate='30', width='400', height='400')]
public class Blobs extends Sprite
{
private var bl : Array = [];
private var r : Bitmap;
private var c : Sprite;
private var rect : Rectangle;
private var point : Point = new Point;
private var num:uint = 10;
public function Blobs()
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
public function init( e : Event ) : void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
stage.align = "TL";
stage.scaleMode = "noScale";
c = new Sprite();
c.filters = [new BlurFilter(30,30,1)];
addChild(c);
r = new Bitmap( new BitmapData( stage.stageWidth, stage.stageHeight, false, 0x00FFFFFF ) );
r.smoothing = true;
addChild(r);
for (var i:Number = 0; i < num; i ++)
{
bl[i] = new MovieClip();
bl[i].graphics.beginGradientFill("radial",[0x9d8324,0x000000],[0xFF,0x00],[0x00,0x80]);
bl[i].graphics.drawCircle(0,0, 100+Math.random()*50+25);
bl[i].x = Math.random() * stage.stageWidth;
bl[i].y = Math.random() * stage.stageHeight;
bl[i].cycle = Math.random() * 100000;
c.addChild(bl[i]);
}
rect = new Rectangle(0,0,stage.stageWidth, stage.stageHeight);
addEventListener( Event.ENTER_FRAME, u );
}
public function u(e : Event) : void
{
for (var i:Number = 0; i < num; i ++)
{
var blm:MovieClip = bl[i];
blm.x += Math.sin( ( getTimer() + blm.cycle ) * .001 ) * 2;
blm.y += Math.cos( ( getTimer() + blm.cycle ) * .001 ) * 2;
blm.scaleX = blm.scaleY += Math.sin( ( getTimer() + blm.cycle ) *.001 ) *.015 ;
}
//return;
var bd:BitmapData = r.bitmapData;
bd.fillRect(rect,0xff000000);
bd.draw(c);
bd.threshold(bd,rect,point,">",0x000800000,0xFFFFFFFF,0x00808080,true);
var cTransform:ColorTransform = new ColorTransform();
cTransform.alphaMultiplier = 0.99;
cTransform.greenMultiplier = 2.95;
cTransform.redMultiplier = 2.11;
bd.colorTransform(rect, cTransform);
bd.applyFilter(bd, rect, new Point(), new BlurFilter(8, 8));
}
}
}