In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: forked from: 明るい方に向かってColorTransform

原色で止まることがある
FFFF00とかなるとB要素が増えないのが原因
/**
 * Copyright paq ( http://wonderfl.net/user/paq )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/lwDt
 */

// forked from cpu_t's 明るい方に向かってColorTransform
// 原色で止まることがある
// FFFF00とかなるとB要素が増えないのが原因
package {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Graphics;
	import flash.display.Shape;
    import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
    public class FlashTest extends Sprite
	{
		private var src:Shape;
		private var bmpdata:BitmapData;
        public function FlashTest()
		{
            src = new Shape;
			bmpdata = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0xFFFFFF);
			addChild(new Bitmap(bmpdata));
			addEventListener(Event.ENTER_FRAME, loop);
			colortrans = new ColorTransform(1, 1, 1, 1, 3, 3, 3);
			stage.addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void { isStop = !isStop; } );
        }
		private var isStop:Boolean = false;
		private var colortrans:ColorTransform;
		private function loop(e:Event):void
		{
			if (isStop) return;
			var g:Graphics = src.graphics;
			g.clear();
			g.beginFill(Math.random() * 0xFFFFFF);
			var a:Number = Math.random() * Math.PI * 2;
			g.moveTo(Math.cos(a) * 30, Math.sin(a) * 30);
			a += Math.PI;
			g.lineTo(Math.cos(a) * 30, Math.sin(a) * 30);
			a = Math.random() * Math.PI * 2;
			g.lineTo(Math.cos(a) * 30, Math.sin(a) * 30);
			g.endFill();
			var m:Matrix = new Matrix();
			m.translate(Math.random() * stage.stageWidth, Math.random() * stage.stageHeight);
			g.beginFill(0x000000);
			bmpdata.lock();
			bmpdata.colorTransform(bmpdata.rect, colortrans);
			bmpdata.draw(src, m);
			m.scale(-1, -1);
			m.translate(stage.stageWidth, stage.stageHeight);
			bmpdata.draw(src, m);
			m.scale(1, -1);
			m.translate(0, stage.stageHeight);
			bmpdata.draw(src, m);
			m.scale(-1, -1);
			m.translate(stage.stageWidth, stage.stageHeight);
			bmpdata.draw(src, m);
			bmpdata.unlock();
		}
    }
}