// Sand Traveler // Special commission for Sónar 2004, Barcelona // sand painter implementation of City Traveler + complexification.net // j.tarbell May, 2004 // Albuquerque, New Mexico // complexification.net // Processing 0085 Beta syntax update // j.tarbell April, 2005 int dim = 500; float t; int dx, dy; int num = 100; int maxnum = 101; int cnt = 0; // minimum distance to draw connections int mind = 128; City[] cities; color[] goodcolor = {#3a242b, #3b2426, #352325, #836454, #7d5533, #8b7352, #b1a181, #a4632e, #bb6b33, #b47249, #ca7239, #d29057, #e0b87e, #d9b166, #f5eabe, #fcfadf, #d9d1b0, #fcfadf, #d1d1ca, #a7b1ac, #879a8c, #9186ad, #776a8e,#000000,#000000,#000000,#000000,#000000,#FFFFFF,#FFFFFF,#FFFFFF,#FFFFFF,#FFFFFF,#000000,#000000,#000000,#000000,#000000,#FFFFFF,#FFFFFF,#FFFFFF,#FFFFFF,#FFFFFF}; void setup() { size(500,500,P3D); // size(dim,dim,P3D); background(255); cities = new City[maxnum]; resetAll(); } void draw() { // move cities for (int c=0;c(120*30)) { cnt=0; resetAll(); } } void mousePressed() { resetAll(); } // METHODS ------------------------------------------------------------------- void resetAll() { background(255); float vt = 4.2; float vvt = 0.2; float ot = random(TWO_PI); for (int t=0;t990) { // noise dx+=random(3)-random(3); dy+=random(3)-random(3); } stroke(red(cities[friend].myc),green(cities[friend].myc),blue(cities[friend].myc),48); point(dx,dy); // draw anti-traveler dx = -1*sin(t)*(x-cities[friend].x)/2+(x+cities[friend].x)/2; dy = -1*sin(t)*(y-cities[friend].y)/2+(y+cities[friend].y)/2; if (random(1000)>990) { // noise dx+=random(3)-random(3); dy+=random(3)-random(3); } point(dx,dy); } } void drawSandPainters() { for (int s=0;smaxg) g=maxg; p+=random(-0.050,0.050); if (p<0) p=0; if (p>1.0) p=1.0; float w = g/10.0; for (int i=0;i<11;i++) { float a = 0.1-i/110.0; stroke(red(c),green(c),blue(c),a*256); point(ox+(x-ox)*sin(p + sin(i*w)),oy+(y-oy)*sin(p + sin(i*w))); point(ox+(x-ox)*sin(p - sin(i*w)),oy+(y-oy)*sin(p - sin(i*w))); } } void renderPerp(float x, float y, float ox, float oy) { // transform perpendicular float mx = (x+ox)/2; float my = (y+oy)/2; float g = 0.42; float x1 = mx + (y-my)*g; float y1 = my - (x-mx)*g; float ox1 = mx + (oy-my)*g; float oy1 = my - (ox-mx)*g; // draw painting sweeps stroke(red(c),green(c),blue(c),28); point(ox1+(x1-ox1)*sin(p),oy1+(y1-oy1)*sin(p)); g+=random(-0.050,0.050); float maxg = 0.22; if (g<-maxg) g=-maxg; if (g>maxg) g=maxg; p+=random(-0.050,0.050); if (p<0) p=0; if (p>1.0) p=1.0; float w = g/10.0; for (int i=0;i<11;i++) { float a = 0.1-i/110.0; stroke(red(c),green(c),blue(c),a*256); point(ox1+(x1-ox1)*sin(p + sin(i*w)),oy1+(y1-oy1)*sin(p + sin(i*w))); point(ox1+(x1-ox1)*sin(p - sin(i*w)),oy1+(y1-oy1)*sin(p - sin(i*w))); } } } // COLOR ROUTINES ------------------------------------------------------------- color somecolor() { // pick some random good color return goodcolor[int(random(goodcolor.length))]; } // j.tarbell May, 2004 // Albuquerque, New Mexico // complexification.net