创建|函数
代码:
//创建坐标轴:
//用法:Axis(所属影片,原点的x坐标,原点的y坐标,步长,刻度线长,-x轴长,+x轴长,-y轴长,+y轴长,颜色,深度)
var my_axis1 = new Axis(this, 160, 108, 50, 10, -150, 300, -100, 80, 0x000000, 1);
var my_axis2 = new Axis(this, 280, 255, 25, 4, -250, 200, -100, 100, 0xff0000, 2);
//以下是4个自定义函数:
function func1(x) {
return 1/x;
}
function func2(x) {
return Math.log(x);
}
function func3(x) {
return Math.cos(x);
}
function func4(x) {
return x*x-3;
}
//画函数:
//用法:drawFunction(函数,线粗,颜色)
my_axis1.drawFunction(func1, 2, 0xff0000);
my_axis1.drawFunction(func2, 1, 0x003366);
my_axis2.drawFunction(func3, 3, 0x0000ff);
my_axis2.drawFunction(func4, 4, 0xff6600);
示例:
fla源文件与相关类文件打包下载:点击这里下载源文件
时间: 2024-10-07 03:41:23