//traveller, wherever I may roam... //by Aaron Steed memory mem = new memory (0.0,0.0); float m = 1.0; float m2 = 1.0; void setup() { size (400,400); background (214,196,146); stroke (160,50,70); fill (200,0,0); smooth(); mem.stack (0.0,10.0); framerate(30); } void loop() { translate (200,200); req(); }//loop; void req(){ int i = mem.x.length - 1; float theta = random(TWO_PI); float newX = mem.x[i] + (cos(theta) * (50.0 * m2)); float newY = mem.y[i] + (sin(theta) * (50.0 * m2)); if (abs(newX)*m > width / 2){ background (214,196,146); m = (width/2)/abs(newX); m2 = abs(newX)/(width); println(m2); drawIt(i); } else if (abs(newY)*m > height / 2){ background (214,196,146); m = (height/2)/abs(newY); m2 = abs(newY)/(height); println(m2); drawIt(i); } else { drawIt(i); } mem.stack(newX,newY); }//req; void drawIt(int i){ background (214,196,146); for (int i2 = 1; i2 < i+1; i2++){ line (mem.x[i2-1]*m, mem.y[i2-1]*m, mem.x[i2]*m, mem.y[i2]*m); } ellipse((mem.x[i]*m)-5, (mem.y[i]*m)-5, 10, 10); } class memory{ float [] x=new float[1]; float [] y=new float[1]; memory (float xt,float yt){ x[0]=xt; y[0]=xt; } void stack (float xa, float ya){ float[] tempx = new float[x.length + 1]; System.arraycopy(x, 0, tempx, 0, x.length); tempx[x.length] = x[x.length-1]; x = tempx; float[] tempy = new float[y.length + 1]; System.arraycopy(y, 0, tempy, 0, y.length); tempy[y.length] = y[y.length-1]; y = tempy; x[x.length-1]=xa; y[y.length-1]=ya; }//stack; }//memory;