int pressMode = 0; int maxTrailLength = 5000; int[][] trail = new int[maxTrailLength][3]; int trailCounter = 0; int justOnce = 0; float rotation; int wobble = 0; void setup () { size(800,600, P3D); framerate(100); colorMode(RGB, 1.0); background(0); noStroke(); } void draw () { ambientLight(0.5, 0.5, 0.5); directionalLight(1, 1, 1, 200, 200, 0); translate(width/2, height/2, 0); rotateY(rotation); if( pressMode == 1 ) { if( justOnce == 0 ) { background(0); } trail[trailCounter][0] = mouseX-width/2; trail[trailCounter][1] = mouseY-height/2; trail[trailCounter][2] = int(rotation*1000); } background(0); pushMatrix(); fill(0.3); translate(0, 200, 0); box(600, 1, 600); popMatrix(); if( trail[0][0] != 0 ) { pushMatrix(); rotateY(-float(trail[0][2])/1000); translate(trail[0][0], trail[0][1], 0); fill(1); box(8); popMatrix(); pushMatrix(); rotateY(-float(trail[0][2])/1000); translate(trail[0][0], 199, 0); fill(0); box(8, 1, 8); popMatrix(); } for( int i = 1; i < trailCounter; i++ ) { //stroke(1); //strokeWeight(2); fill(1); if( trail[i][0] != 0 ) { if( trail[i-1][0] != 0 ) { pushMatrix(); rotateY(-float(trail[i][2])/1000); translate(trail[i][0], trail[i][1], 0); fill(1); box(8); popMatrix(); pushMatrix(); rotateY(-float(trail[i][2])/1000); translate(trail[i][0], 199, 0); fill(0); box(8, 1, 8); popMatrix(); stroke(1, 0.5); pushMatrix(); rotateY(-float(trail[i-1][2])/1000); beginShape(LINES); vertex(trail[i-1][0], trail[i-1][1], 0); vertex(trail[i][0], trail[i][1], 0); endShape(); popMatrix(); pushMatrix(); rotateY(-float(trail[i-1][2])/1000); stroke(0); beginShape(LINES); vertex(trail[i-1][0], 199, 0); vertex(trail[i][0], 199, 0); endShape(); popMatrix(); noStroke(); } } } for( int i = 1; i < trailCounter; i++ ) { if( trail[i][0] != 0 ) { trail[i][0] += int(random(-wobble, wobble)); trail[i][1] += int(random(-wobble, wobble)); } } trailCounter++; if( pressMode == 0 ) { justOnce = 0; } else { justOnce = 1; } rotation += 0.025; } void mousePressed() { pressMode = 1; } void mouseReleased() { pressMode = 0; }