WEB开发网
开发学院图形图像Flash [AS 功能代码教程06]AS绘图总结及补充 阅读

[AS 功能代码教程06]AS绘图总结及补充

 2009-05-30 12:07:22 来源:WEB开发网   
核心提示: 补充:长方形:_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(

补充:

长方形:

_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);
}

Tags:AS 功能 代码

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接