Drawing Flower
/**
* Copyright utabi ( http://wonderfl.net/user/utabi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/9OYn
*/
package {
import flash.display.Sprite;
import flash.geom.Point;
[SWF(width="400", height="400", backgroundColor="0x000000", frameRate="30")]
public class Flower extends Sprite {
private var circleSprite:Sprite;
private var division:int = 40; //花びらの枚数
private var centerPoint:Point = new Point(200,200); //花の中心点
private var innerRadius:int = 30; //中心の半径
private var outerRadius:int = 115; //花びらの半径
private var controlRadius:int = 111; //花びらのControll Pointの半径
private var radianControl:Number = 8 * Math.PI / 180; //花びらの膨らみ具合
private var petalColor:Number = 0xffffff; //花びらの色
private var petalAlpha:Number = .8; //花びらの透明度
private var endFillEach:Boolean = true; //一枚ごとにendFillするかどうか
public function Flower() {
this.x = centerPoint.x;
this.y = centerPoint.y;
circleSprite = new Sprite();
addChild(circleSprite);
circleSprite.graphics.beginFill(petalColor,petalAlpha);
circleSprite.graphics.lineStyle(.5, petalColor);
for(var i:int =0; i < division ; i++){
var radianStart:Number = (360/division)*i * Math.PI / 180;
var radianTop:Number = (360/division)*(i+0.5) * Math.PI / 180;
var radianFinish:Number = (360/division)*(i+1) * Math.PI / 180;
var startPoint:Point = new Point(
Math.cos(radianStart)*innerRadius,
Math.sin(radianStart)*innerRadius
)
var controlPointA:Point = new Point(
Math.cos(radianStart-radianControl)*controlRadius,
Math.sin(radianStart-radianControl)*controlRadius
)
var topPoint:Point = new Point(
Math.cos(radianTop)*outerRadius,
Math.sin(radianTop)*outerRadius
)
var controlPointB:Point = new Point(
Math.cos(radianFinish+radianControl)*controlRadius,
Math.sin(radianFinish+radianControl)*controlRadius
)
var finishPoint:Point = new Point(
Math.cos(radianFinish)*innerRadius,
Math.sin(radianFinish)*innerRadius
)
if(endFillEach){
circleSprite.graphics.beginFill(petalColor,petalAlpha);
}
circleSprite.graphics.moveTo(startPoint.x,startPoint.y);
circleSprite.graphics.curveTo(controlPointA.x, controlPointA.y,topPoint.x,topPoint.y);
circleSprite.graphics.curveTo(controlPointB.x, controlPointB.y,finishPoint.x,finishPoint.y);
if(endFillEach){
circleSprite.graphics.endFill();
}
}
circleSprite.graphics.endFill();
}
}
}