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: 明るい方に向かってColorTransform

反転→.98倍→反転の方法
3回もColorTransformしてる。
原色で止まることがある
FFFF00とかなるとB要素が増えないのが原因
/**
 * Copyright cpu_t ( http://wonderfl.net/user/cpu_t )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/3LWZ
 */

// 反転→.98倍→反転の方法
// 3回もColorTransformしてる。
//
// 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);
			colortransA = new ColorTransform( -1, -1, -1, 1, 0xFF, 0xFF, 0xFF);
			colortransB = new ColorTransform(.98, .98, .98);
			stage.addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void { isStop = !isStop; } );
        }
		private var isStop:Boolean = false;
		private var colortransA:ColorTransform;
		private var colortransB: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, colortransA);
			bmpdata.colorTransform(bmpdata.rect, colortransB);
			bmpdata.colorTransform(bmpdata.rect, colortransA);
			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();
		}
    }
}