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 paq 04 Feb 2011
    Embed
/**
 * Copyright paq ( http://wonderfl.net/user/paq )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/pLJW
 */

package 
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BlendMode;
    import flash.display.Graphics;
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageQuality;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.filters.BlurFilter;
    import flash.geom.ColorTransform;
    import flash.geom.Point;
    import frocessing.color.ColorHSV;
    
    /**
     * ...
     * @author paq
     */
    [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="60")]
    public class TrailLines extends Sprite 
    {
        //--------------------------------------------------------------------------
        //
        // プロパティ
        //
        //--------------------------------------------------------------------------
        
        public static const ZERO_POINT:Point = new Point();
        public static const BLUE_FILTER:BlurFilter = new BlurFilter();
        public static const COLOR_TRANSFORM:ColorTransform = new ColorTransform(1, 1, 1, 1, -10, -10, -10);
        private var _lastMouseX:int = 0;
        private var _lastMouseY:int = 0;
        private var _bitmapData:BitmapData;
        private var _bitmap:Bitmap;
        private var _canvas:Sprite;
        private var _hsv:ColorHSV = new ColorHSV(40, 0.5, 3, 2);
        private var _bitmapBig:Bitmap;
        
        //--------------------------------------------------------------------------
        //
        // メソッド
        //
        //--------------------------------------------------------------------------
        
        /**
         * コンストラクタ.
         */
        public function TrailLines() 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        /**
         * 初期化します.
         * 
         * @param    event
         */
        private function init(event:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            
            initStage();
            createCanvas();
            createBitmap();
            createBackground();
            
            stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
            addEventListener(Event.RESIZE, onResize);
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
                
        /**
         * 背景を描画します.
         */
        private function createBackground():void 
        {
            var g:Graphics = this.graphics;
            g.beginFill(0);
            g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
        }
        
        /**
         * ステージを最適な設定に変更します.
         */
        private function initStage():void 
        {
            stage.quality = StageQuality.HIGH;
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
        }
        
        /**
         * アプリケーションに必要なビットマップを作成します.
         */
        private function createBitmap():void 
        {
            _bitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0x00000000);
            _bitmap = new Bitmap(_bitmapData);
            _bitmapBig = new Bitmap(_bitmapData);
            _bitmapBig.scaleX = _bitmapBig.scaleY = 3;
            _bitmapBig.x = -stage.stageWidth / 2;
            _bitmapBig.y = -stage.stageHeight / 2;
            _bitmapBig.blendMode = BlendMode.ADD;
            addChild(_bitmap);
            addChild(_bitmapBig);
        }
        
        /**
         * 描画元の Sprite を作成します.
         */
        private function createCanvas():void 
        {
            _canvas = new Sprite();
            //addChild(_canvas);
        }
        
        //--------------------------------------------------------------------------
        //
        // イベントハンドラー
        //
        //--------------------------------------------------------------------------
        
        /**
         * 毎フレーム実行される処理.
         * 
         * @param    event
         */
        private function onEnterFrame(event:Event):void 
        {
            _hsv.h++;
            _bitmapData.applyFilter(_bitmapData, _bitmapData.rect, ZERO_POINT, BLUE_FILTER);
            _bitmapData.colorTransform(_bitmapData.rect, COLOR_TRANSFORM);
        }
        
        /**
         * リサイズ時の処理.
         * @param    event
         */
        private function onResize(event:Event):void 
        {
            var g:Graphics = this.graphics;
            g.beginFill(0);
            g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
        }
        
        /**
         * マウス移動時の処理.
         * 
         * @param    event
         */
        private function onMouseMove(event:MouseEvent):void 
        {
            var mx:int = stage.mouseX;
            var my:int = stage.mouseY;
            
            var radius:Number = Math.abs(_lastMouseX - mx) - Math.abs(_lastMouseY - my) + 20;
            var g:Graphics = _canvas.graphics;
            g.clear()
            g.lineStyle(5, _hsv.value32, 1);
            g.beginFill(_hsv.value32, 0.5);
            g.drawCircle(mx, my, radius);
            //_bitmapBig.x = (mx / 20) - stage.stageWidth;
            //_bitmapBig.y = (my / 20) - stage.stageHeight;
            
            _lastMouseX = mx;
            _lastMouseY = my;
            _bitmapData.draw(_canvas, null, null, BlendMode.ADD);
        }
    }
}