AA
/**
* Copyright hrtsgt ( http://wonderfl.net/user/hrtsgt )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/cG8Q
*/
package{
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
import flash.filters.*;
[SWF(width=465, height=465, backgroundColor=0xFFFFFF, frameRate=60)]
public class AA extends Sprite{
private var ary:Array;
private var _canvas:BitmapData;
private var _source:BitmapData;
private var point:Point = new Point(0, 0);
private static const W:uint = 4;
private static const H:uint = 5;
public function AA(){
Wonderfl.capture_delay(40);
setup();//
var loader:Loader = new Loader();
loader.load( new URLRequest("http://t.args.in/lab/lib/einstein.jpg"), new LoaderContext(true));
loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onComplete);//
}
private function onComplete( e:Event ):void{
var bmpd:BitmapData = Bitmap( LoaderInfo(e.target).loader.content ).bitmapData;
var m:Matrix = new Matrix();
m.scale( 1/W, 1/H);//画像を縮小
_source = new BitmapData( bmpd.width/W, bmpd.height/H, false, 0x0);
_source.draw( bmpd, m);
_source.applyFilter( _source, _source.rect, point, new ColorMatrixFilter([ 0.3, 0.6, 0.1, 0, 0, 0.3, 0.6, 0.1, 0, 0, 0.3, 0.6, 0.1, 0, 0, 0, 0, 0, 1, 0]));//モノクロ化
_canvas = new BitmapData( _source.width*W, _source.height*H, false, 0xFFFFFF);
addChild( new Bitmap(_canvas) );
this.addEventListener( Event.ENTER_FRAME, update);//
}
private function update( e:Event ):void{
number();//
number();//
number();//
number();//
number();//
}
//ナンバリング
private function number():void{
var m:Matrix = new Matrix();
m.translate( point.x*W, point.y*H);
_canvas.draw( ary[ brightness(point) ], m);
if( ++point.x > _source.width ){
point.x = 0;
if( ++point.y > _source.height ){
this.removeEventListener( Event.ENTER_FRAME, update);//
return;
}
}
}
//明度を0〜9に振り分け
private function brightness( p:Point ):uint{
var c:uint = _source.getPixel( p.x, p.y) & 0xFF;
return Math.floor( c/(25.6) );
}
//フォントを濃い順にストック
private function setup():void{
ary = [];
var bmpd:BitmapData;
var s:Shape = new Shape();
var g:Graphics = s.graphics;
//0
g.clear();
g.beginFill(0x0);
g.drawRect( 0, 0, 3, 1);
g.drawRect( 0, 1, 1, 2);
g.drawRect( 2, 1, 1, 2);
g.drawRect( 0, 3, 3, 1);
bmpd = new BitmapData( W-1, H-1, false, 0xFFFFFF);
bmpd.draw( s );
ary.push(bmpd);
//8
g.clear();
g.beginFill(0x0);
g.drawRect( 0, 0, 3, 1);
g.drawRect( 0, 3, 3, 1);
g.drawRect( 1, 1, 1, 1);
g.drawRect( 0, 2, 1, 1);
g.drawRect( 2, 2, 1, 1);
bmpd = new BitmapData( W-1, H-1, false, 0xFFFFFF);
bmpd.draw( s );
ary.push(bmpd);
//5
g.clear();
g.beginFill(0x0);
g.drawRect( 0, 0, 3, 1);
g.drawRect( 0, 3, 3, 1);
g.drawRect( 0, 1, 2, 1);
g.drawRect( 2, 2, 1, 1);
bmpd = new BitmapData( W-1, H-1, false, 0xFFFFFF);
bmpd.draw( s );
ary.push(bmpd);
//6
g.clear();
g.beginFill(0x0);
g.drawRect( 0, 0, 1, 4);
g.drawRect( 2, 1, 1, 3);
g.drawRect( 1, 1, 1, 1);
g.drawRect( 1, 3, 1, 1);
bmpd = new BitmapData( W-1, H-1, false, 0xFFFFFF);
bmpd.draw( s );
ary.push(bmpd);
//2
g.clear();
g.beginFill(0x0);
g.drawRect( 0, 0, 2, 1);
g.drawRect( 0, 3, 3, 1);
g.drawRect( 1, 1, 2, 1);
g.drawRect( 0, 2, 1, 1);
bmpd = new BitmapData( W-1, H-1, false, 0xFFFFFF);
bmpd.draw( s );
ary.push(bmpd);
//9
g.clear();
g.beginFill(0x0);
g.drawRect( 0, 0, 1, 2);
g.drawRect( 2, 0, 1, 4);
g.drawRect( 1, 0, 1, 1);
g.drawRect( 1, 2, 1, 1);
bmpd = new BitmapData( W-1, H-1, false, 0xFFFFFF);
bmpd.draw( s );
ary.push(bmpd);
//4
g.clear();
g.beginFill(0x0);
g.drawRect( 0, 0, 1, 3);
g.drawRect( 2, 0, 1, 4);
g.drawRect( 1, 2, 1, 1);
bmpd = new BitmapData( W-1, H-1, false, 0xFFFFFF);
bmpd.draw( s );
ary.push(bmpd);
//3
g.clear();
g.beginFill(0x0);
g.drawRect( 0, 0, 2, 1);
g.drawRect( 0, 3, 3, 1);
g.drawRect( 1, 1, 2, 1);
g.drawRect( 2, 2, 1, 1);
bmpd = new BitmapData( W-1, H-1, false, 0xFFFFFF);
bmpd.draw( s );
ary.push(bmpd);
//7
g.clear();
g.beginFill(0x0);
g.drawRect( 0, 0, 3, 1);
g.drawRect( 2, 1, 1, 3);
bmpd = new BitmapData( W-1, H-1, false, 0xFFFFFF);
bmpd.draw( s );
ary.push(bmpd);
//1
g.clear();
g.beginFill(0x0);
g.drawRect( 2, 0 , 1, 4);
bmpd = new BitmapData( W-1, H-1, false, 0xFFFFFF);
bmpd.draw( s );
ary.push(bmpd);
}
}
}