gridwalkers gws; int numgw; float sc1, sc2, sc3, sc4, t1, t2, t3, t4, cmin, cmax, zrange; float sr=1.f; int[] bkg; void setup(){ size(680,680); bkg=new int[width*height]; smooth(); //hint(NO_DEPTH_TEST); background(120); calculateBackground(); drawBackground(); numgw=50; sc1=1.f; sc2=7.f; sc3=13.f; sc4=37.f; t1=t2=t3=t4=PI/18.0f/sr; cmin=1.f; cmax=1.f; zrange=250.0f/sr; gws=new gridwalkers(width, height, numgw); } void draw(){ for(int f=0;f<5;f++){ gws.update(); } //drawFrame(); } void calculateBackground(){ int c; for(int i=0; i-1)&&(g!=i)){ gw[i].reset(); } else{ grid[int(gw[i].cx)][int(gw[i].cy)]=i; stroke(255,0,0,200); /*if ((pixels[int(gw[i].cx)+int(gw[i].cy)*width]bkg[int(gw[i].cx)+int(gw[i].cy)*width]-255))*/ point(gw[i].cx,gw[i].cy); pushMatrix(); translate(0,0);//,gw[i].cz); noStroke(); fill(200+int(55.0f*(float)Math.exp(-6.0*sr*d/w)),60*(300-gw[i].cz)/300); ellipse(lx+(gw[i].cx-lx)*dprox,ly+(gw[i].cy-ly)*dprox,r,r); fill(int(200.0f*(float)Math.exp(-6.0*sr*d/w)),60*(300-gw[i].cz)/300); ellipse(lx+(gw[i].cx-lx)*ddist,ly+(gw[i].cy-ly)*ddist,r,r); fill(int(255.0f*(float)Math.exp(-6.0*sr*d/w)),int(255.0f*(float)Math.exp(-6.0*sr*d/w)),int(255.0f*(float)Math.exp(-6.0*sr*d/w)),180*(300-gw[i].cz)/300); ellipse(gw[i].cx,gw[i].cy,r,r); popMatrix(); stroke(60,10); //if ((gw[i].cz<-50)&&(d>50)) line(gw[i].cx,gw[i].cy,gw[i].cz,gw[i].cx+(gw[i].cx-w/2)*(2*w-d)/d,gw[i].cy+(gw[i].cy-h/2)*(2*w-d)/d,gw[i].cz+gw[i].cz*(2*w-d)/d); if ((gw[i].cz<-50)&&(d>50)) line(gw[i].cx,gw[i].cy,gw[i].cx+(gw[i].cx-w/2)*(2*w-d)/d,gw[i].cy+(gw[i].cy-h/2)*(2*w-d)/d); } gw[i].update(1.0f/sr*(1.0f-(float)Math.exp(-10.0*sr*d/w) )); } } } class gridwalker{ int w,h; float cx,cy,cz,dir, dirchange; int age; float m1,m2,m3,m4; float p1,p2,p3,p4; float curvature; int index; int run; gridwalker(){ w=h=age=run=index=0; cx=cy=cz=dir=dirchange=m1=m2=m3=m4=p1=p2=p3=p4=curvature=0.0f; } gridwalker(int ww, int hh, int i){ index=i; run=0; w=ww; h=hh; init(); } void init(){ cx=int(random(w)); cy=int(random(h)); cz=random(-zrange,0); dir=random(TWO_PI); dirchange=0; age=0; m1=random(-1.0f,1.0f)*t1; m2=random(-1.0f,1.0f)*t2; m3=random(-1.0f,1.0f)*t3; m4=random(-1.0f,1.0f)*t4; p1=random(-PI,PI); p2=random(-PI,PI); p3=random(-PI,PI); p4=random(-PI,PI); curvature=random(cmin,cmax); } void update(float d){ cx+=d*cos(dir); cy+=d*sin(dir); if(random(1.0)0) cz-=0.1; if (cz<0) cz+=0.1; } void check(){ if (cx<0) cx+=w; if (cx>=w) cx-=w; if (cy<0) cy+=h; if (cy>=h) cy-=h; } void reset(){ index+=numgw; run+=1; init(); } }