du
YaBB Newbies
Offline
Posts: 4
Dreamlines not showing anything drawing....
Nov 3rd , 2006, 6:10am
There isn't anything drawing in the window, odd, everything is setup fine, it executes fine, but nothing show up in the PGraphics department... Please help if you can int cant=1500; BGraphics img; BImage inimg; String id, archivo; int n, nimg, enes, trazo; float t; Dot[] dots; void setup(){ size(640, 480); colorMode(HSB,360); background(360); id=param("id"); img= new BGraphics(width,height); img.colorMode(HSB,360); trazo=int(random(8)); nimg=-1; cargarImg(); dots= new Dot[cant]; for(int i=0; i<cant; i++){ dots[i]=new Dot(); } } void loop(){ n++; if(n==500){ cargarImg(); } if(int(random(500))==1) trazo=int(random(8)); for(int i=0; i<cant; i++){ dots[i].paso(); } } void cargarImg(){ t=millis(); nimg++; n=0; String cant[]=loadStrings("imgs/"+id+".txt"); enes=Integer.parseInt(cant[0]); if(nimg==enes){nimg=0;} archivo=id+"_"+String(nimg)+".jpg"; inimg=loadImage("imgs/"+archivo); img.image(inimg,0,0,width,height); t=millis()-t; } class Dot { float ax, ay, x, y; float ang, step; float h, s, b; color pix, este; int p; Dot(){ iniciar(); ang=random(TWO_PI); step=random(3); leer(); este=(pix); } void paso(){ if(int(random(cant/2))==1) iniciar(); leer(); stroke(h, s, b, 40); switch(trazo){ case 0: ang+=radians(b-180)/5; step=(h-180)/10; break; case 1: ang+=radians(s-180)/3; step=(b-180)/25; break; case 2: ang=radians(h-180); step=(s-180)/10; break; case 3: ang=radians(s-180); step=(h-180)/12; break; case 4: ang+=radians(h-s); step=(b-h)/6; break; case 5: ang+=radians(b-h)/20; step=(s-180)/5; break; case 6: ang+=radians(h-180)/10; step=(b-180)/4; break; case 7: ang+=radians(h-180)/(constrain(b/10,1,100)); step=(b-180)/(constrain(s/10,1,100)); break; } x+=(step*sin(ang)); y-=(step*cos(ang)); line(ax, ay, x, y); ax=x; ay=y; if (x<0){ax=x=width;} if (x>width){ax=x=0;} if (y<2){ay=y=height-3;} if (y>height-2){ay=y=3;} } void leer(){ p=int(y)*img.width+int(x); pix=img.pixels[p]; b=brightness(pix); h=hue(pix); s=saturation(pix); } void iniciar(){ ax=x=random(width); ay=y=random(height); } }