一聚教程网:一个值得你收藏的教程网站

热门教程

flash AS绘图总结及补充

时间:2022-07-02 17:18:44 编辑:袖梨 来源:一聚教程网

本次课程,对之前学过的画线方法给予总结,同时再加以补充
总结:
圆:

_root.createEmptyMovieClip("MC",1);

MC._x = 200;

MC._y = 150;

var R = 60;

MC.moveTo(R*Math.cos(0),R*Math.sin(0));

MC.lineStyle(2);

for (n=1; n<360; n++) {

var angle = n*Math.PI/180;

var tox = R*Math.cos(angle);

var toy = R*Math.sin(angle);

MC.lineTo(tox,toy);

}

椭圆:

_root.createEmptyMovieClip("MC",1);

MC._x = 200;

MC._y = 150;

var W = 50;

var H = 30;

MC.moveTo(W*Math.cos(0),H*Math.sin(0));

MC.lineStyle(2);

for (n=1; n<360; n++) {

var angle = n*Math.PI/180;

var tox = W*Math.cos(angle);

var toy = H*Math.sin(angle);

MC.lineTo(tox,toy);

}

螺旋线:
_root.createEmptyMovieClip("MC",1);

MC._x = 200;

MC._y = 150;

var R = 10;

var A = 3;

MC.moveTo(0,0);

MC.lineStyle(2);

for (n=1; n<360; n++) {

var angle = A*n*Math.PI/180;

var tox = angle*R*Math.cos(angle);

var toy = angle*R*Math.sin(angle);

MC.lineTo(tox,toy);

}

多边型:
_root.createEmptyMovieClip("MC",1);

MC._x = 200;

MC._y = 150;

var R = 50;

var sides = 5;

var angle = (360*Math.PI/180)/sides;

var MA:Array = new Array();

for (i=0; i<=sides; i++) {

MA[i] = i*angle;

}

MC.moveTo(R*Math.cos(MA[0]),R*Math.sin(MA[0]));

MC.lineStyle(2);

for (n=1; n<=sides; n++) {

var tox = R*Math.cos(MA[n]);

var toy = R*Math.sin(MA[n]);

MC.lineTo(tox,toy);

}


补充:

长方形:

_root.createEmptyMovieClip("MC",1);

MC._x = 200;

MC._y = 150;

var R = 60;

MC.moveTo(0,0);

MC.lineStyle(2);

MC.lineTo(R*2,0);

MC.lineTo(R*2,R);

MC.lineTo(0,R);

MC.lineTo(0,0);

同心圆(与圆对比):
_root.createEmptyMovieClip("MC",
1);

MC._x = 200;

MC._y = 150;

var R = 30;

var layer = 5;
//圆的层数
MC.lineStyle(2);

for (i=1; i<=layer; i++) {

MC.moveTo(i*R*Math.cos(0),
i*R*Math.sin(0));

for (n=1; n<360; n++) {

  var angle = i*n*Math.PI/180;

  var tox = i*R*Math.cos(angle);

  var toy = i*R*Math.sin(angle);

  MC.lineTo(tox, toy);

}
}

蝶形(与圆对比):
_root.createEmptyMovieClip("MC",
1);

MC._x = 200;

MC._y = 150;

var R = 60;

MC.moveTo(R*Math.cos(0), R*Math.sin(0));

MC.lineStyle(2);

for (n=1; n<360; n++) {

var angle = n*Math.PI/180;

tox = R*Math.cos(angle);

toy = R*Math.sin(angle*2);

MC.lineTo(tox, toy);

}

多棱形(与圆对比):
_root.createEmptyMovieClip("MC",
1);

MC._x = 200;

MC._y = 150;

var sides = 5;
//棱数:应为奇数

var R = 100;

MC.moveTo(R*Math.cos(0), R*Math.sin(0));

MC.lineStyle(2);

for (n=1; n<360; n++) {

var angle = n*Math.PI/180;

var
r =
R*Math.cos(sides*angle);
tox =
r*Math.cos(angle);

toy = r*Math.sin(angle);

MC.lineTo(tox, toy);

}

星形(与多边形对比):
_root.createEmptyMovieClip("MC",
1);

MC._x = 200;

MC._y = 150;

var R = 50;

var sides = 5;

var angle = (360*Math.PI/180)/sides;

var MA:Array = new Array();

for (i=0; i<=sides; i++) {

MA[i] = 2*i*angle;

}

x = R*Math.cos(MA[0]);

y = R*Math.sin(MA[0]);

MC.moveTo(x, y);

MC.lineStyle(2);

for (n=1; n<=sides; n++) {

var tox = R*Math.cos(MA[n]);

var toy = R*Math.sin(MA[n]);

MC.lineTo(tox, toy);

}

心形(与圆对比):
_root.createEmptyMovieClip("MC",
1);

MC._x = 200;

MC._y = 150;

var R = 60;

MC.lineStyle(2);

for (n=1; n<360; n++) {

var angle = n*Math.PI/180;

var r =
R*Math.cos(angle)-R;
tox =
r*Math.cos(angle);

toy = r*Math.sin(angle);

MC.lineTo(tox, toy);

}

热门栏目