极坐标在绘画方法中的运用
话不多说,参考代码中的注释var pice = 8;
//瓣数
var amp = 180;
//半径
x0 = 550/2;
//中心X坐标
y0 = 400/2;
//中心Y坐标
degree = 0;
//初始角
speed = 2;
//画线速度
colorF = 0xFF0000;
//线条颜色
_root.createEmptyMovieClip("flower", 1);
//创建MC
with (flower) {
flower.moveTo(x0 amp, y0);
//移动起始点
flower.lineStyle(3, colorF, 100);
//定义线条样式
}
flower.onEnterFrame = function() {
//开始画线
if (degree<=360) {
for (i=1; i<=speed; i) {
radian = Math.PI/180*(degree);
p = amp*Math.cos(pice/2*radian);
x = x0 p*Math.cos(radian);
y = y0 p*Math.sin(radian);
this.lineTo(x, y);
degree;
}
}
};
页:
[1]