// sphere city color[] mainColor = { 0x715F2C, 0x857031, 0x9B853B, 0x5E451D, 0x655422, 0x422B0E, 0x564520 }; float mainScale=0.5; // global variable for drawspeed float mainLen; float mainRot; int[][] usedBy;// // array that keeps track of draw-lines (who drew which pixel?) int unique_id; // unique id's for curves void setup() { size(800,400,P3D); background(255); usedBy =new int[800][400]; for (int x=0;x0.3&&random(1)<0.04) { findAndCreateCurve(mainLen); } updateCurvedrawers(); } void mousePressed() { setup(); } ////////////////////////////// class Curvedrawer ////////////////////////////// int nr_curves=1000; int maxChildren=8; Curvedrawer[] curvedrawer; void initCurves() { curvedrawer=new Curvedrawer[nr_curves]; for (int i=0;i=width) { x-=width; } while (y<0) { y+=height; } while (y>=height) { y-=height; } // check for full circle: fullrot+=rot; if (fullrot>TWO_PI) { active=false; } // draw: int sx=int(x), sy=int(y); if (sx>=0&&sx=0&sy0?1:-1; float ndir=dir+dr*HALF_PI; float nx=x+len*cos(ndir), ny=y+len*sin(ndir); float nlen=len; int ncol;//=(int)random(mainColor.length); do { ncol=colorIndex+(random(1)<0.5?-1:1); } while (ncol<0||ncol>=mainColor.length); findAndCreateCurve(nx,ny,ndir,nlen,ncol); } } ////////////////////////////// end Curvedrawer ////////////////////////////// void darken(int x,int y, color c) { set(x,y,c); } void setSmooth(int x, int y, color c1, float p1) { float p2=1.0-p1; color c2=get(x,y); int rr=int(p1*(c1>>16&255)+p2*(c2>>16&255)); int gg=int(p1*(c1>>8&255)+p2*(c2>>8&255)); int bb=int(p1*(c1&255)+p2*(c2&255)); set(x,y,rr<<16|gg<<8|bb); }