小火锅餐饮加盟:flash课件中常用画图函数总结-田金-搜狐博客

来源:百度文库 编辑:偶看新闻 时间:2024/05/06 00:59:21
flash课件中常用画图函数总结 标签: flash课件中常用画图函数  flash课件中常用画图函数总结
因为课件演示时需动态过程,所以得用lineto()实现,而不能用curveto()画图
*两点间画直线
*画螺旋线
*画正方形、圆、椭圆
*抛物线
*正弦、余弦线
使用方法:加到帧中就可

// 画直线
// / x1, y1: 起点坐标
// x2, y2: 终点坐标
// k是层次
movieclip.prototype.drawline = function(x1, y1, x2, y2, k) {
this.linestyle(1);
this.moveto(x1, y1);
this.lineto(x2, y2);
};
// 从(0,0)到(100,100)画一条线
_root.createemptymovieclip("mc", 10);
mc.drawline(0, 0, 100, 100);
// 画螺旋线
// w、h为宽和高
// f控制线的长短,用弧度表示
movieclip.prototype.drawhelix = function(w, h, f) {
for (var i = 0; i this.lineto(x=math.sin(i)*i*w, y=math.cos(i)*i*h);
this.linestyle(1);
}
};
// 以(100,100)为中心画螺旋线
_root.createemptymovieclip("luo", 1);
with (luo) {
drawhelix(5, 5, 13);
_x += 100;
_y += 100;
}
// 多功能函数,可画圆,椭圆,正多边形等
// n为边数
movieclip.prototype.drawmany = function(w, h, n) {
f = 2*math.pi;
for (var i = 0; i<=f/n*(n+1); i += f/n) {
this.lineto(x=math.sin(i)*w, y=math.cos(i)*h);
this.linestyle(1);
}
};
// 画一正五边形
_root.createemptymovieclip("duobian", 2);
with (duobian) {
drawmany(50, 50, 5);
_x += 250;
_y += 100;
// 5为多边形的边数,6.3为2pai
}
// 画一椭圆
_root.createemptymovieclip("tuo", 3);
with (tuo) {
drawmany(25, 50, 100);
_x += 400;
_y += 100;
}
// 圆
_root.createemptymovieclip("yuan", 4);
with (yuan) {
drawmany(50, 50, 100);
_x += 400;
_y += 300;
}
// 抛物线
movieclip.prototype.drawparabola = function(l, r, k) {
for (var i = -l; i<=r; i += 1) {
this.lineto(x=i, y=k*i*i);
this.linestyle(1);
}
};
// 调用
_root.createemptymovieclip("parabola", 100);
with (parabola) {
drawparabola(50, 50, 0.05);
_x += 200;
_y += 200;
// 顶点坐标
}
// 正弦线,余弦类似
movieclip.prototype.drawsin = function(n, k) {
for (var i = 0; i<=90*n; i += 1) {
this.lineto(x=i, y=k*math.sin(i*math.pi/180));
this.linestyle(1);
}
};
_root.createemptymovieclip("sin", 101);
with (sin) {
drawsin(4, 50);
_x += 200;
_y += 200;
// 顶点坐标
}
movieclip.prototype.drawwave = function(w, h) {
for (var i = 0; i<=6.3; i += 0.01) {
this.lineto(x=w/math.cos(i), y=h*math.sin(i)/math.cos(i));
this.linestyle(1);
}
};
_root.createemptymovieclip("wave", 105);
with (wave) {
drawwave(100, 100);
_x += 200;
_y += 200;
// 顶点坐标
}