In the As 03 tutorial, we introduced the basic application of trigonometric functions
Now to complement and develop the content of the last lesson
Review the Circle-drawing method: x-coordinate cos (n), y-coordinate sin (n); n the radian from the 0~360
First, draw the ellipse
By contrast, we're just dividing the circle by the way R, in Split.
Divided into W and H respectively control the width and height of the ellipse.
_root.createEmptyMovieClip("MC", 1);
MC._x = 200;
MC._y = 200;
//创建一个空影片剪辑,放在舞台中央作为画线容器
var W = 50;
var H = 30;
//椭圆宽:W,椭圆高:H.
MC.moveTo(W*Math.cos(0), H*Math.sin(0));
//设置画线起点
MC.lineStyle(2);
for (n=1; n < 360; n++) {
tox = W*Math.cos(n*Math.PI/180);
toy = H*Math.sin(n*Math.PI/180);
MC.lineTo(tox, toy);
}
//当W=H的时候,画出的就是正圆。
Ii. the distribution of the ellipse
In the course of learning as 03 we introduced the multilateral style of painting, and with this foundation in the production of this example is a piece of cake. ^_^
Example 1:
Step 1:
Draw a star, Save as a movie clip, connect-> Export-> marker "star"
Step 2:
Add as code:
_root.createEmptyMovieClip("MC", 1);
MC._x = 200;
MC._y = 200;
var Num = 22;
//星星数量
var W = 200;
var H = 100;
//椭圆宽:W,椭圆高:H;当W=H时是正圆
var angle = (360*Math.PI/180)/Num;
//每等份 = 圆的弧度(360*PI/180)/num份
for (i=0; i < num; i++) {
MC.attachMovie("star", "star"+i, i);
MC["star"+i]._x = W*Math.cos(i*angle);
MC["star"+i]._y = H*Math.sin(i*angle);
}
//复制num个以ang为距离平均分散到圆中