Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: 1/4 の円弧描画クラス

クラスじゃないけど
/**
 * Copyright nutsu ( http://wonderfl.net/user/nutsu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/2IJp
 */

// forked from keno42's 1/4 の円弧描画クラス
// クラスじゃないけど
package {
    import flash.display.Sprite;
    import flash.events.Event;
    import net.hires.debug.Stats;
    import frocessing.display.F5MovieClip2D;
    import frocessing.FC;
    [SWF(width=465,height=465,backgroundColor="0")]
    public class FlashTest extends F5MovieClip2D {
        public function FlashTest() {
            // write as3 code here..
        }
        public function setup():void {
            addChild( new Stats() );
            strokeCap( FC.CAPS_STYLE_NONE );
            noFill();
        }
        public function draw():void{
            stroke( 0, 0xff, 0 );
            strokeWeight( 0 );
            pushMatrix();
            translate( mouseX, mouseY );
            line( -10, 0, 10, 0 );
            line( 0, -10, 0, 10 );
            popMatrix();
            var r1:Number = mouseX / 465;
            var r2:Number = 1 - mouseY / 465;
            translate( 0, 465 );
            /*
            strokeWeight( 30 );
            stroke( getColor( r1 ) );
            arc( 0, 0, 280*2, 280*2, 0, -HALF_PI*r1 );
            stroke( getColor( r2 ) );
            arc( 0, 0, 315*2, 315*2, 0, -HALF_PI*r2 );
            */
            noStroke();
            beginFill( getColor( r1 ) );
            moveTo( 265, 0 );
            arcTo( 0, 0, 295, 295, 0, -HALF_PI * r1 );
            arcTo( 0, 0, 265, 265, -HALF_PI * r1, 0 );
            endFill();
            beginFill( getColor( r2 ) );
            moveTo( 300, 0 );
            arcTo( 0, 0, 330, 330, 0, -HALF_PI * r2 );
            arcTo( 0, 0, 300, 300, -HALF_PI * r2, 0 );
            endFill();
        }
        private function getColor(rate:Number):int{
            var ret:int = 0;
            var temp:Number;
            if( rate < 0.5 ){
                temp = rate / 0.5;
                ret = 0xFF0000;
                ret |= int( temp * 255 ) << 8;
            } else {
                temp = (1 - rate) / 0.5;
                ret = 0x00FF00;
                ret |= int( temp * 255) << 16;
            }
            return ret;
        }
    }
}