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

色分解::テスト

Get Adobe Flash player
by szktkhr 21 Dec 2008
package {
	import flash.display.Sprite;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.BitmapDataChannel;
	import flash.display.PixelSnapping;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	[SWF(width="470", height="470", frameRate="60", backgroundColor="#ffffff")]
	public class Sketch extends Sprite {
		
		public var canvas:Bitmap;
		public var canvasD:BitmapData;
		public var originalBD:BitmapData;
		public var rgbBD:BitmapData;
		public var rBD:BitmapData;
		public var gBD:BitmapData;
		public var bBD:BitmapData;
		
		public function Sketch() {
			addEventListener(Event.ADDED_TO_STAGE, initialize);
			addEventListener(Event.REMOVED_FROM_STAGE, uninitialize);
			addEventListener(Event.ENTER_FRAME, enterframe);
		}
		private function initialize(e:Event):void {
			rgbBD = new BitmapData(stage.stageWidth, stage.stageHeight, true);
			originalBD = new BitmapData(stage.stageWidth, stage.stageHeight, true);
			rBD = new BitmapData(stage.stageWidth, stage.stageHeight, true);
			gBD = new BitmapData(stage.stageWidth, stage.stageHeight, true);
			bBD = new BitmapData(stage.stageWidth, stage.stageHeight, true);
			
			var s:Sprite = new Sprite();
			var radius:int = 100;
			s.graphics.beginFill(0x000000);
			s.graphics.drawCircle(0, 0, radius);
			s.graphics.drawCircle(0, 0, radius - radius / 5);
			s.graphics.endFill();
			s.x = 200;
			s.y = stage.stageHeight / 2;
			addChild(s);
			originalBD.draw(this);
			removeChild(s);
			rgbBD.copyPixels(originalBD, originalBD.rect, new Point(0, 0));
			canvas = new Bitmap(rgbBD, PixelSnapping.AUTO, true);
			addChild(canvas);
		}
		private function uninitialize(e:Event):void {
		}
		private function enterframe(e:Event):void {
			var p:Point = new Point();
			var rRect:Rectangle = new Rectangle(rgbBD.rect.x, rgbBD.rect.y, rgbBD.rect.width, rgbBD.rect.height);
			var gRect:Rectangle = new Rectangle(rgbBD.rect.x, rgbBD.rect.y, rgbBD.rect.width, rgbBD.rect.height);
			var bRect:Rectangle = new Rectangle(rgbBD.rect.x, rgbBD.rect.y, rgbBD.rect.width, rgbBD.rect.height);
			rRect.x += 1;
			gRect.y += 1;
			bRect.x += 1;
			bRect.y += 1;
			rgbBD.copyChannel(rgbBD, rRect, p, BitmapDataChannel.RED, BitmapDataChannel.RED);
			rgbBD.copyChannel(rgbBD, gRect, p, BitmapDataChannel.GREEN, BitmapDataChannel.GREEN);
			rgbBD.copyChannel(rgbBD, bRect, p, BitmapDataChannel.BLUE, BitmapDataChannel.BLUE);
		}
	}
}