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

円の大きさと分割数

半径が100でも分割数32で結構綺麗?
64分割なら結構なサイズでもかなり綺麗そう
Get Adobe Flash player
by zahir 01 Oct 2010
/**
 * Copyright zahir ( http://wonderfl.net/user/zahir )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/nG8O
 */

package {
    import com.bit101.components.Label;
    import flash.display.GraphicsStroke;
    import flash.display.Shape;
    import flash.events.KeyboardEvent;
    import flash.text.TextField;
    import flash.display.GraphicsSolidFill;
    import flash.display.IGraphicsData;
    import flash.display.Graphics;
    import flash.events.Event;
    import flash.display.GraphicsPath;
    import flash.display.Sprite;
    
    import com.bit101.components.NumericStepper;
    
    [SWF(width="465", height="465")]
    public class Main extends Sprite {
        private var fill:GraphicsSolidFill;
        private var stroke:GraphicsStroke;
        
        private var sizeStepper:NumericStepper;
        private var lengthStepper:NumericStepper;
        private var thicknessStepper:NumericStepper;
        
        private var s:Shape;
        
        public function Main() {
            
            addChild( (s = new Shape()) );
            
            new Label(this, 0, 0, "size :: ");
            sizeStepper = new NumericStepper( this , 30, 0, draw);
            new Label(this, 130, 0, "length :: ");
            lengthStepper = new NumericStepper( this, 170, 0, draw);
            new Label( this, 270, 0, "thickness :: ");
            thicknessStepper = new NumericStepper( this, 325, 0, draw )
            
            
            sizeStepper.maximum = 465;
            sizeStepper.minimum = 1;
            sizeStepper.value = 100;
            
            lengthStepper.maximum = 360;
            lengthStepper.minimum = 6;
            lengthStepper.value = 32;
            
            thicknessStepper.maximum = 20;
            thicknessStepper.minimum = 0;
            thicknessStepper.value = 1;
            
            fill = new GraphicsSolidFill(0x666666);
            stroke = new GraphicsStroke(1);
            stroke.fill = new GraphicsSolidFill(0x0);
            
            draw();
        }
        private function draw(e:Event = null):void
        {
            var g:Graphics = s.graphics;
            stroke.thickness = thicknessStepper.value;
            g.clear();
            g.drawGraphicsData(new <IGraphicsData>[ fill,stroke, getPath(0,0,sizeStepper.value) ]);
            //s.width = s.height = 465;
            s.x = s.y = 465 >> 1;
        }
        public function appendPath( path:GraphicsPath, cx:Number, cy:Number, r:Number):void
        {
            var n:Number = 0;
            var len:int = lengthStepper.value;
            var d:Vector.<Number> = path.data;
            var dl:int = d.length;
            var c:Vector.<int> = path.commands;
            var cl:int = c.length;
            var _cl:int = cl;
            
            n = 360 / len;
            for (var i:int = 0; i <= len; i++ )
            {
                var rad:Number = 0.01745 * ((n * i) % 360);
                c[cl++] = 2;
                d[dl++] = Math.cos( rad ) * r + cx;
                d[dl++] = Math.sin( rad ) * r + cy;
            }
            c[_cl] = 1;
        }
        public function getPath(cx:Number, cy:Number, r:Number):GraphicsPath
        {
            var path:GraphicsPath = new GraphicsPath( new <int>[], new <Number>[] );
            appendPath( path, cx, cy, r );
            return path;
        }
    }
}