// jkriss ~ 4 april 2004 Point points[] = new Point[50]; int count = 0; float mx, my; float oldMouseX, oldMouseY; float w,h; float r = 0; float g = 127; float b = 255; float arr,gee,bee; float ri = 3; float gi = 4; float bi = 5; void setup() { size(500,300); smooth(); framerate(30); w = width/2; h = height/2; } void loop() { drawStuff(); } color setAlpha(color c, float a) { arr = red(c); gee = green(c); bee = blue(c); return color(arr,gee,bee,a); } void updateColor() { if (r > 255 || r < 0) ri=-ri; if (g > 255 || g < 0) gi=-gi; if (b > 255 || b < 0) bi=-bi; r += ri; g += gi; b += bi; } void drawStuff() { background(255); mx = mouseX; my = mouseY; if (count >= 20) count = 0; for (int i=0; i<21; i++) { if (points[i+1] != null) points[i] = points[i+1]; } points[20] = new Point(mx, my, 0, (mx - oldMouseX)/2 + random(1.0) -1, (my - oldMouseY)/2 + random(1.0) - 1, random(4), random(6)+2, color(r,g,b)); updateColor(); count++; oldMouseX = mx; oldMouseY = my; Point p = null; noStroke(); beginShape(TRIANGLE_STRIP); color mainColor; for (int i=0; i<21; i++) { if (points[i] != null ) { p = points[i]; mainColor = setAlpha(p.pcolor, abs(i*p.vx*1.5)); stroke(mainColor); fill(mainColor); vertex(p.x,p.y); vertex(p.x+p.s,p.y+p.s); p.x += p.vx; p.y += p.vy; p.vx *= 1.06; p.vy *= 1.06; } } endShape(); } class Point { float x,y,z; float vx,vy,vz; float s; //size of line color pcolor; Point (float x, float y, float z, float vx, float vy, float vz, float s, color pcolor) { this.x = x; this.y = y; this.vx = vx; this.vy = vy; this.z = z; this.vz = vz; this.s = s; this.pcolor = pcolor; } }