913868104 发表于 2016-8-28 10:36:32

新人求助!processing绘制函数图像

float[] a=new float;
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=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*a));
      }
      y=y+a*b;
    }
}
else{
    for(j=i;j>=0;j-=2){
      for(k=1;k<=j;k++){
      b=b*(x+a/(i*a));
      }
      y=y+a*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);   //调整颜色、透明度
}                     //归零
}



结果三次函数图像画出来是四次的。。。
页: [1]
查看完整版本: 新人求助!processing绘制函数图像