|
|
本帖最后由 qifeiyu862574 于 2011-4-2 02:38 编辑
问题是在draw()中,如何控制一些数据循环的频率。
例如:
float x=0;
float y=300;
void setup(){
background(0);
size(800,600);
smooth();
}
void draw(){
float y1=random(30,80);
float y2=random(-80,-30);
float y3=random(30,80);
float y4=random(-80,-30);
float y5=random(30,80);
float y6=random(-80,-30);
float y7=random(30,80);
float y8=random(-80,-30);
float x1=random(200,250);
float x2=random(250,300);
float x3=random(300,350);
float x4=random(350,400);
float x5=random(400,450);
float x6=random(450,500);
float x7=random(500,550);
float x8=random(550,600);
fill(0,1);
rect(0,0,width,height);
noStroke();
fill(255);
x+=0.5;
if(x<200||(x>600 && x<800)){
ellipse(x,300,5,5);
}
if(x>200 && x< x1){
y+=(y1/ (x1 - 200));
ellipse(x,y,5,5);
}
if(x>x1 && xx2 && xx3 && xx4 && xx5 && xx6 && xx7 && xx8 && x<600){
y+=(-y8) / (600-x8);
ellipse(x,y,5,5);
}
if(x>800){
x=-5;
y=300;
}
}
可不可以让那些随机的数据在x从0到800后再循环生成新的数据,而不是每当x+1就改变啊。如果可以那也不用那么多随机了......
求指点啊~ |
|