NCF参数化建筑论坛

标题: 初学者关于draw()循环的问题求助 [打印本页]

作者: qifeiyu862574    时间: 2011-4-2 02:37
标题: 初学者关于draw()循环的问题求助
本帖最后由 qifeiyu862574 于 2011-4-2 02:38 编辑
问题是在draw()中,如何控制一些数据循环的频率。 例如: [attach]16671[/attach] [attach]16672[/attach] 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; } } [attach]16672[/attach] 可不可以让那些随机的数据在x从0到800后再循环生成新的数据,而不是每当x+1就改变啊。如果可以那也不用那么多随机了...... 求指点啊~
[attach]16670[/attach]

作者: weiwei    时间: 2011-4-2 11:17
看不懂你要什麼???
作者: nxwzgng    时间: 2011-4-2 13:51
这个真的看不懂啊看不懂啊
作者: qifeiyu862574    时间: 2011-4-2 14:10
本帖最后由 qifeiyu862574 于 2011-4-2 14:12 编辑 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); 以上这些随机,随着X+1而产生新的数据,这样就不能生成像图片中的沿直线运动了,是乱的(大家可以copy到processing下试试效果)。我是想问有没有代码,让当x从0到800时,这些random不循环,当x>800,x=0时,再产生一组新的数据。。。表达能力差。。。希望大家能明白~
作者: qifeiyu862574    时间: 2011-4-2 16:16
也就是想请问一下,有什么方法可以让draw()中的语句有条件的循环,比如多久循环一次,不和x的刷新同步~
作者: claudemit    时间: 2011-4-4 05:36
你想要心电图效果?我改了一种试试 [attach]16707[/attach] [attach]16708[/attach] 回收点照度[attach]16709[/attach]
作者: 差不多先生    时间: 2011-4-4 09:13
没解释 清楚。。
作者: qifeiyu862574    时间: 2011-4-4 16:17
6# claudemit 已经超越我的水平很多了~研究之~{:3_51:}
作者: claudemit    时间: 2011-4-6 07:18
6# claudemit 已经超越我的水平很多了~研究之~{:3_51:} qifeiyu862574 发表于 2011-4-4 16:17
我也不熟悉啊,生撮的{:3_50:},多看些例子就好用了
作者: panhao1    时间: 2011-4-7 03:24
可以用sleep()嘛~ 或是frameRate() 这是玩心跳么




欢迎光临 NCF参数化建筑论坛 (http://www.ncf-china.com/) Powered by Discuz! X3.2