曲線の描画

by lenonsun forked from 曲線を描く (diff: 21)
♥0 | Line 46 | Modified 2011-10-30 23:37:10 | MIT License
play

ActionScript3 source code

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

// 曲線の描画
package 
{
    import frocessing.display.F5MovieClip2D;
    /**
     * 曲線の描画
     */
    public class GraphicExample extends F5MovieClip2D
    {
        public function setup() : void
        {
            background(128);
            drawGridGuide();
            // 塗りがあると自動的に閉じる
            noFill();
            beginShape();
            curveVertex( 50,150);
            curveVertex( 75,200);
            curveVertex(100,300);
            curveVertex(150,100);
            curveVertex(200,240);
            curveVertex(250,350);
            curveVertex(300,130);
            curveVertex(350,250);
            curveVertex(400,200);
            curveVertex(450,250);
            endShape();
        }
        // 以下は,位置をわかり安くする説明のための
        // 処理なので無視してください.
        public function drawGridGuide() : void
        {
            var x : int;
            var y : int;
            stroke(192,192,192);
            for( x = 0 ; x < 465 ; x += 50 ) 
                line( x, 0, x, 465);
            for( y = 0 ; y < 465 ; y += 50 ) 
                line( 0, y, 465, y);
            stroke(0,0,0);            
            ellipse( 50, 150,5,5);
            ellipse( 75, 200,5,5);
            ellipse(100, 300,5,5);
            ellipse(150, 100,5,5);
            ellipse(200, 240,5,5);
            ellipse(250, 350,5,5);
            ellipse(300, 130,5,5);
            ellipse(350, 250,5,5);
            ellipse(400, 200,5,5);
            ellipse(450, 250,5,5);
        }
    }
}