// original code by robert hodgin // see: http://processing.org/discourse/yabb/YaBB.cgi?board=Contribution_Simlation;action=display;num=1078114794 // added parts of the code are marked [toxi040303] float noiseVal; float noiseScale = 0.005; float noiseCount = 0.0; float noiseSpeed = 0.005; float xCount, xSpeed; float yCount, ySpeed; float theta; float angle; float angleDelta; float xv, yv; float speed = 10; boolean lines = false; int noiseRes = 2; Vehicle[][] vehicle; int xSize = 400; int ySize = 600; int xTotal = int(xSize / noiseRes); int yTotal = int(ySize / noiseRes); // [toxi040303] overlay image object BImage ov=new BImage(10,10); void setup(){ size(xSize,ySize); smooth(); ellipseMode(CENTER_DIAMETER); colorMode(HSB, 360); vehicle = new Vehicle[yTotal][xTotal]; for (int y=0; y width + 50){ x -= width + 100; } if (y < -50){ y += height + 100; } else if (y > height + 50){ y -= height + 100; } } void render(){ // [toxi040303] check if line's angle is currently on the bright or dark side // the light direction is set to 340 degrees // the closer the line's angle is to the light's, the brighter its colour if (angle>70 && angle<250) stroke(hue, sat,bri+angle*1.5,20); else { // find distance to light and normalize to use as impact factor float f=abs(340-(angle<90 ? angle+360 : angle))/90; // base colour on factor // colour desaturates and brightens towards the light stroke(hue, sat*(0.5+f/2),bri+angle*(2-f),20+(1-f)*20); } // draw longer lines line(x,y, x+(xv*20), y+(yv*20)); } }