forked from: AA cam
AA変換お借りして、作ったやつに適用させてみた
// forked from knd's AA cam
// AA変換お借りして、作ったやつに適用させてみた
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.events.Event;
import flash.filters.ColorMatrixFilter;
import flash.filters.BlurFilter;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.display.BlendMode;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
import flash.utils.ByteArray;
import flash.display.StageAlign;
[SWF(width="465", height="465", backgroundColor="0xffffff", frameRate="18")]
public class TestAs extends Sprite
{
private var cv:BitmapData;
private var cP:Sprite;
private var gS01:Sprite;
private var mRBlur:BlurFilter;
private var txt:TextField;
private var pw:int = 58;
private var ph:int = 58;
private var ascii:Array = ["黒", "紺", "仄", "少", "三", "二", "一", " "];
private var tf:TextFormat = new TextFormat("MS ゴシック", 8, 0, false, false, false, null, null, TextFormatAlign.LEFT, 0, 0, 0, 0);
public function TestAs() {
stage.align = StageAlign.TOP_LEFT;
cv = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0xffffff);
mRBlur = new BlurFilter(16, 16);
cP = new Sprite();
cP.filters = [new ColorMatrixFilter([
// 赤:0.29891 緑:0.58661 青:0.11448)
0.29891, 0.58661, 0.11448, 0, 0,
0.29891, 0.58661, 0.11448, 0, 0,
0.29891, 0.58661, 0.11448, 0, 0,
0,0,0,1,0
])];
txt = new TextField();
txt.autoSize = TextFieldAutoSize.LEFT;
txt.text = "";
addChild(txt);
addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(e:Event):void {
var iR:uint = Math.round(Math.random()*60);
drawC(iR);
}
private function drawC(n:uint):void
{
gS01 = new Sprite();
cP.addChild(gS01);
var coC:Number = retC();
gS01.graphics.beginFill(coC, Math.round(Math.random()*100)/100);
gS01.graphics.drawCircle(-n/2, -n/2, n);
cv.draw(cP, null, null, BlendMode.SCREEN);
cv.applyFilter(cv, cv.rect, new Point(), mRBlur);
gS01.x = Math.round(Math.random()*stage.stageWidth);
gS01.y = Math.round(Math.random()*stage.stageHeight);
if(cP.numChildren==2){
var target:DisplayObject = cP.getChildAt(0);
cP.removeChildAt(0);
target = null;
}
var bts:ByteArray = cv.getPixels(new Rectangle(stage.stageWidth/2-pw/2, stage.stageHeight/2-ph/2, pw, ph));
bts.position = 0;
//txt.text = "";
var str:String = "";
var c :int;
for (var i:int = 0; i < ph; i++)
{
for (var j:int = 0; j < pw; j++)
{
c = bts.readUnsignedInt();
c &= 0xff;
c >>>= 5;
//txt.appendText(ascii[c]);
str += ascii[c];
}
//txt.appendText("\n");
str += "\n";
}
txt.text = str;
txt.setTextFormat(tf);
}
private function retC():Number
{
var coR:String= Math.round(Math.random()*255).toString(16);
var coG:String= Math.round(Math.random()*255).toString(16);
var coB:String= Math.round(Math.random()*255).toString(16);
return parseInt("0x"+coR+coG+coB, 16)
}
}
}