This is your code, minimally modified to just record pdf.
It creates copies of lines in the same location with geometric progression, like so:
(the amount of lines visualized)
import processing.pdf.*;
ArrayList<Particle> particles;
void setup() {
size(640, 480);
noFill();
strokeWeight(2);
particles = new ArrayList<Particle>();
beginRecord(PDF, "vector.pdf");
}
void draw() {
background(255);
for(int i = particles.size() - 1; i >= 0; i--) {
Particle p = particles.get(i);
p.update();
p.present();
}
if (keyPressed) {
exit();
saveFrame();
endRecord();
}
}
void mousePressed() {
Particle p = new Particle(mouseX, mouseY);
p.addForce(random(-1, 1), random(-1, 1));
particles.add(p);
}
class Particle {
PVector pos;
PVector vel;
PVector acc;
ArrayList<PVector> history;
int maxHistory;
float maxWander;
float maxSpeed;
Particle(float x, float y) {
this.pos = new PVector(x, y);
this.vel = new PVector();
this.acc = new PVector();
this.history = new ArrayList<PVector>();
this.history.add(this.pos.copy());
this.maxHistory = 50;
this.maxWander = 45 * (PI / 180);
this.maxSpeed = 2;
}
void addForce(float fx, float fy) {
this.acc.x += fx;
this.acc.y += fy;
}
void update() {
float heading = this.vel.heading();
heading += random(-this.maxWander, this.maxWander);
this.addForce(cos(heading), sin(heading));
this.vel.add(this.acc);
this.vel.limit(this.maxSpeed);
this.acc.mult(0);
this.pos.add(this.vel);
float dist = PVector.dist(this.pos, this.history.get(this.history.size() - 1));
if(dist > 5) {
this.history.add(this.pos.copy());
if(this.history.size() > this.maxHistory) {
this.history.remove(0);
}
}
}
void present() {
float k = (float)this.history.size();
for(int i = 1; i < this.history.size(); i++) {
stroke(0, (i / k) * 255);
PVector p1 = this.history.get(i - 1);
PVector p2 = this.history.get(i);
line(p1.x, p1.y, p2.x, p2.y);
}
}
}
