forked from: 曲線を描く

by shmdmoto forked from 曲線を描く (diff: 51)
曲線を描く
@author shmdmoto
♥0 | Line 41 | Modified 2010-10-18 15:24:30 | MIT License
play

ActionScript3 source code

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

// forked from shmdmoto's 曲線を描く
package 
{
    import frocessing.display.F5MovieClip2D;
    /**
     * 曲線を描く
     * @author shmdmoto
     */
    public class GraphicExample extends F5MovieClip2D
    {
        public function setup() : void
        {
            var stage_width:Number = 465;
            var stage_height:Number = 465
            var i:int;
            var j:int;
            var y:Array = new Array(20);
            var ey:Array = new Array(20);
            colorMode(HSB,360, 100,100,100);
            background(0, 0, 10);
            for( i = 0 ; i < 20 ; i++ ) {
                y[i] = random(
                    stage_height/2 - 150,
                    stage_height/2 + 150 );
                ey[i] = random(
                    stage_height/2 - 150,
                    stage_height/2 + 150 );
            }

            // 塗りがあると自動的に閉じる
            noFill();
            for( i = 0 ; i < 50 ; i++) {
                beginShape();
                stroke(360*i/50,100,100,60);
                curveVertex(0, stage_height/2);
                curveVertex(0, stage_height/2);
                for( j = 1 ; j <= 20 ; j++) {
                    curveVertex( 
                        stage_width * j / 21 , 
                            y[j-1]+(ey[j-1]-y[j-1])*i/50);
                }
                curveVertex(stage_width, stage_height/2);
                curveVertex(stage_width, stage_height/2);
                endShape();
            }
        }
    }
}