curveToとMath.tanで円を描く
♥0 |
Line 22 |
Modified 2010-05-30 15:40:05 |
MIT License
archived:2017-03-20 13:27:23
ActionScript3 source code
/**
* Copyright hacker_szoe51ih ( http://wonderfl.net/user/hacker_szoe51ih )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/ryA8
*/
// forked from hacker_szoe51ih's forked from: forked from: forked from: flash on 2010-5-2
// forked from hacker_szoe51ih's forked from: forked from: flash on 2010-5-2
// forked from hacker_szoe51ih's forked from: flash on 2010-5-2
// forked from hacker_szoe51ih's flash on 2010-5-2
package {
import flash.display.*;
[SWF(width = "465", height = "465", frameRate = "30", backgroundColor = "#000000")]
public class DrawCircle3 extends Sprite {
public var centerX:Number=100;
public var centerY:Number=100;
public var hankei:Number=50;
public function DrawCircle3() {
//graphics.beginFill(0x2222dd);
graphics.lineStyle(2,0x00ff22);
graphics.moveTo(centerX+hankei,centerY);//描画開始位置に移動
//graphics.curveTo(hankei+centerX,Math.tan(Math.PI/8)*hankei+centerY,Math.sin(Math.PI/4)*hankei+centerX,Math.sin(Math.PI/4)*centerY)
// graphics.curveTo(400,100,400,400);コントロールポイント(400,100)アンカーポイント(400,400)
//時計回りに円を描く
//アンカーポイントの座標はsinにしても同じ
graphics.curveTo(centerX+hankei,centerY+Math.tan(Math.PI/8)*hankei,centerX+Math.cos(Math.PI/4)*hankei,centerY+Math.sin(Math.PI/4)*hankei);
graphics.curveTo(centerX+Math.tan(Math.PI/8)*hankei,centerY+hankei,centerX,centerY+hankei);
graphics.curveTo(centerX-Math.tan(Math.PI/8)*hankei,centerY+hankei,centerX-Math.cos(Math.PI/4)*hankei,centerY+Math.sin(Math.PI/4)*hankei);
graphics.curveTo(centerX-hankei,centerY+Math.tan(Math.PI/8)*hankei,centerX-hankei,centerY);
graphics.curveTo(centerX-hankei,centerY-Math.tan(Math.PI/8)*hankei,centerX-Math.cos(Math.PI/4)*hankei,centerY-Math.sin(Math.PI/4)*hankei);
graphics.curveTo(centerX-Math.tan(Math.PI/8)*hankei,centerY-hankei,centerX,centerY-hankei);
graphics.curveTo(centerX+Math.tan(Math.PI/8)*hankei,centerY-hankei,centerX+Math.cos(Math.PI/4)*hankei,centerY-Math.sin(Math.PI/4)*hankei);
graphics.curveTo(centerX+hankei,centerY-+Math.tan(Math.PI/8)*hankei,centerX+hankei,centerY);
graphics.endFill();
}
}
}