|
float[] a=new float[200];
float y=0;
float x=-15;
float b=1;
int k;
int n=100;
int i=1;
int j;
float c=random(0,255);
float d=random(0,255);
float e=random(0,255);
float f=random(50,255);
void setup(){
size(600,600);
smooth();
background(0);
for(n=100;n>=0;n--){
a[n]=random(-2,2);
} //用数组存储系数
frameRate(62500);
}
void draw(){
b=1;
y=0;
strokeWeight(3);
translate(300,300); //初始化
if(i%2==1){
for(j=i;j>=0;j-=2){
for(k=1;k<=j;k++){
b=b*(x+a[i-1]/(i*a[i]));
}
y=y+a[j]*b;
}
}
else{
for(j=i;j>=0;j-=2){
for(k=1;k<=j;k++){
b=b*(x+a[i-1]/(i*a[i]));
}
y=y+a[j]*b;
}
} //求值
stroke(c,d,e,f);
point(20*x,-5*y); //绘制点
x+=0.005;
if(x>15){
x=-15;
i++;
background(0);
c=random(0,255);
d=random(0,255);
e=random(0,255);
f=random(50,255); //调整颜色、透明度
} //归零
}
结果三次函数图像画出来是四次的。。。 |
|