flash on 2014-2-16

by pseudoDust
♥0 | Line 38 | Modified 2014-02-16 02:38:18 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Graphics;
    import flash.display.Sprite;
    import flash.geom.Point;
    public class FlashTest extends Sprite {
        private const vCount : int = 10;
        private const eCount : int = 30;
        private var V : Vector.<Point>;
        private var E : Vector.<Point>;
        
        public function FlashTest() 
        {
            V = getRandPointVector(vCount, 0, 400, 0, 400);
            E = getRandPointVector(eCount, 0, vCount, 0, vCount, true);
            printGraph(V, E, this.graphics);
        }
        
        private function printGraph(v : Vector.<Point>, e : Vector.<Point>, g : Graphics) : void
        {
            
        }

        
        private function getRandPointVector(count : int, 
                                   xMin : Number, xMax : Number, 
                                   yMin : Number, yMax : Number,
                                   round : Boolean = false) : Vector.<Point>
        {
            var v : Vector.<Point> = new Vector.<Point>();
            for(var i : int = 0 ; i < count ; ++i)
            {
                v[i] = new Point(randRange(xMin, xMax, round), 
                                 randRange(yMin, yMax, round));
            }
            return v;

        }
        
        private function randRange(min : Number, max : Number, round : Boolean = false) : Number
        {
            var ret : Number = (Math.random()*(max-min))+min;
            return round?Math.floor(ret):ret;
        }


    }
}