Sora J.

by hemingway
illusion, animation
♥0 | Line 164 | Modified 2016-11-19 15:13:02 | MIT License
play

ActionScript3 source code

/**
 * Copyright hemingway ( http://wonderfl.net/user/hemingway )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7TAj
 */

package {
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.events.Event;
    import flash.geom.Point;
    
    public class W extends Sprite {
        public static const BACKGROUND_COLOR_A:uint = 0x0011AA;
        public static const BACKGROUND_COLOR_B:uint = 0x00EDFF;
        public static const DRAWING_COLOR:uint = 0xFFFFFF;
        
        private var _canvas:Bitmap;
        private var _canvasData:BitmapData;
        private var _canvasDrawingMap:Vector.<Vector.<int>>; //starts @ 144x144
        private var _canvasPixelGap:int;
        private var _canvasCharGap:int;
        private var _frameCount:int;
        private var _frameExit:int;
        
        public function W() {
            this._canvasData = new BitmapData(465, 465, false, 0);
            this._canvas = new Bitmap(this._canvasData);
            this._canvasDrawingMap = new Vector.<Vector.<int>>();
            this._canvasCharGap = 44;
            this._frameCount = 0;
            
            this.addEventListener(Event.ADDED_TO_STAGE, this.addedToStageHandler);
        }
        
        private function addedToStageHandler($event:Event):void {
            this.removeEventListener(Event.ADDED_TO_STAGE, this.addedToStageHandler);
            
            for (var $y:int = 0; $y < 465; $y++) {
                for (var $x:int = 0; $x < 465; $x++) {
                    if (($x % 4) == 0 && ($y % 4) == 0) {
                        this._canvasData.setPixel($x, $y, BACKGROUND_COLOR_B);
                    } else {
                        this._canvasData.setPixel($x, $y, BACKGROUND_COLOR_A);
                    }
                }
            }
            
            var x:int = 112;
            var y:int = 128;
            var i:int = 4;
            var $:int = 0;
            
            // L
            for ($=0; $<16; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            for ($=0; $<08; $++) {this._canvasDrawingMap.push(new <int> [x+=i, y])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<06; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
            for ($=0; $<13; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
            
            x += this._canvasCharGap;
            y = 128;
            
            // O
            for ($=0; $<16; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            for ($=0; $<08; $++) {this._canvasDrawingMap.push(new <int> [x+=i, y])}
            for ($=0; $<15; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<08; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
            x += i*2;
            y += i;
            for ($=0; $<12; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x+=i, y])}
            for ($=0; $<11; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])} 
            
            x += this._canvasCharGap-8;
            y = 128;
                        
            // V
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            x += i;
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            x += i;
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            x += i;
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x+=i, y])}
            for ($=0; $<03; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            x += i;
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            x += i;
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            x += i;
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
            for ($=0; $<03; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            x -= i;
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            x -= i;
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            x -= i;
            y -= i*3;
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            x -= i;
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
            
            x += this._canvasCharGap;
            y = 128;
            
            // E
            for ($=0; $<16; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            for ($=0; $<08; $++) {this._canvasDrawingMap.push(new <int> [x+=i, y])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<06; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x+=i, y])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
            for ($=0; $<05; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<06; $++) {this._canvasDrawingMap.push(new <int> [x+=i, y])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<07; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
                      
            x -= (this._canvasCharGap+4);
            y = (128 + 64 + 8);
            
            for ($=0; $<03; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            x += i;
            for ($=0; $<03; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            x += i;   
            for ($=0; $<03; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            x += i;
            for ($=0; $<07; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}     
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x+=i, y])}
            for ($=0; $<06; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            x += i;
            for ($=0; $<03; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            x += i;
            for ($=0; $<03; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            x += i;
            for ($=0; $<03; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            x -= i;
            for ($=0; $<03; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            x -= i;
            for ($=0; $<03; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            x -= i;
            y -= i*2;
            for ($=0; $<03; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            x -= i;
            for ($=0; $<03; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
            
            x += (this._canvasCharGap);
            y = (128 + 64 + 8);
            
            for ($=0; $<16; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            for ($=0; $<08; $++) {this._canvasDrawingMap.push(new <int> [x+=i, y])}
            for ($=0; $<15; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<07; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])} 
            x += i;
            y += i;
            for ($=0; $<12; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x+=i, y])}
            for ($=0; $<11; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])} 
            
            x += (this._canvasCharGap - i*2);
            y = (128 + 64 + 8);
            
            for ($=0; $<16; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            for ($=0; $<08; $++) {this._canvasDrawingMap.push(new <int> [x+=i, y])}
            for ($=0; $<15; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
            for ($=0; $<13; $++) {this._canvasDrawingMap.push(new <int> [x, y+=i])}
            for ($=0; $<04; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
            for ($=0; $<13; $++) {this._canvasDrawingMap.push(new <int> [x, y-=i])}
            for ($=0; $<02; $++) {this._canvasDrawingMap.push(new <int> [x-=i, y])}
                     
            this.addChild(this._canvas);
            
            this.addEventListener(Event.ENTER_FRAME, this.enterFrameHandler);
        }
        
        private function enterFrameHandler($event:Event):void {
            this._frameCount++;
            
            if (!(this._frameCount % 1)) {
                this._canvasData.setPixel(this._canvasDrawingMap[0][0], this._canvasDrawingMap[0][1], DRAWING_COLOR);
                this._canvasDrawingMap.shift();
            }
        }
    }
}