代码:
//创建坐标轴:
//用法:Axis(所属影片,原点的x坐标,原点的y坐标,步长,刻度线长,-x轴长,+x轴长,-y轴长,+y轴长,颜色,深度)
varmy_axis1=newAxis(this,160,108,50,10,-150,300,-100,80,0x000000,1);
varmy_axis2=newAxis(this,280,255,25,4,-250,200,-100,100,0xff0000,2);
//以下是4个自定义函数:
functionfunc1(x){
return1/x;
}
functionfunc2(x){
returnMath.log(x);
}
functionfunc3(x){
returnMath.cos(x);
}
functionfunc4(x){
returnx*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);
示例: