Forked from: fladdict's Worm Study04 diff:104 forked from: Worm Study04 Study for color generation. kefir forked:1favorite:2lines:36license : All rights reserved modified : 2009-01-01 06:48:34 Embed Tweet // forked from fladdict's Worm Study04 // forked from fladdict's Worm Study03 // forked from fladdict's Worm Study02 // forked from fladdict's Worm Study01 // forked from fladdict's code on 2008-12-17 // write as3 code here.. // Study for color generation. package { import flash.display.* import flash.events.* import flash.geom.* import flash.filters.BlurFilter; public class Sketch04_forked extends Sprite { public function Sketch04_forked():void { var bmd:BitmapData = new BitmapData( stage.stageWidth, stage.stageHeight, false, 0xffffff ); var particles:Array = []; var cnt:Number = 0; addChild( new Bitmap(bmd) ); for( var i: int = 0; i < 400; ++ i ) particles.push( { x: stage.stageWidth * 0.5 ,y: stage.stageHeight * 0.5 ,v: 0.6 + Math.random() * 0.5 ,direction: Math.random() * Math.PI * 2 ,color: 0xffffff * Math.random() ,dv: ( Math.random() - 0.5 ) * 0.03 ,tick: function():void { with( this ) direction += dv += Math.random() * 0.03 - 0.015 ,bmd.setPixel( ( x += Math.cos( direction ) * v ) % stage.stageWidth ,( y += Math.sin( direction ) * v ) % stage.stageHeight ,color ) } } ) stage.addEventListener( Event.ENTER_FRAME, function( e:Event ):void { for( var i:String in particles ) particles[i].tick(); ++cnt % 6 || bmd.applyFilter(bmd, bmd.rect, new Point(0, 0), new BlurFilter(2, 2, 1) ); } ) } // public function Sketch04_forked } // public class Sketch04_forked } // package Code Fullscreen Preview Fullscreen atsumo dbeermann : blurcolorparticlesperformance blur color particles performance direction color setPixel push addEventListener applyFilter Math.cos Math.PI addChild rect Math.random BlurFilter Math.sin Point String Event.ENTER_FRAME Array Bitmap stageWidth Event sort new page view favorite forked pv371 forked from: forked from: Worm.. hacker_b4s23qwu forked:0 favorite:0lines:36 (diff:1)