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

簡単に色相環 --- Easy HSV Ring

メインの関数は http://wonderfl.net/c/7Q9M より
Get Adobe Flash player
by tsu_droid 21 Aug 2015
    Embed
/**
 * Copyright tsu_droid ( http://wonderfl.net/user/tsu_droid )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/y6ae
 */

package {
    import flash.display.Sprite;
    
    public class FlashTest extends Sprite {
        
        var n0:Number, r0:Number=100;
        var xs:Number, ys:Number;
        var spr:Sprite = new Sprite();
        var gr:Graphics = spr.graphics;
        var haba:Number=10.0;

        public function FlashTest() {
            
            addChild(spr);
            spr.x = 150;
            spr.y = 150;
            spr.rotation = 180;
            
            gr.moveTo(r0, 0);
            
            for(var i0:int = 0; i0<=360; i0++ ){
                gr.lineStyle(haba, Rainbow(i0), 1);
                n0 = i0*Math.PI/180;
                xs = r0*Math.cos(n0);
                ys = r0*Math.sin(n0);
                gr.lineTo(xs, ys);
            }
    
        }
        
        // from http://wonderfl.net/c/7Q9M
        function Rainbow(ra:Number):int{// ra は0~360 で、int型で色を返す
            var colr:int, colg:int, colb:int;
            colr = (Math.sin(ra*Math.PI/180) + 1)*255/2;
            colg = (Math.sin((ra + 120)*Math.PI/180) + 1)*255/2;
            colb = (Math.sin((ra - 120)*Math.PI/180) + 1)*255/2;
            return colr*256*256 + colg*256 + colb;
        
        }
        
    }
    
}