(mouse) trail program

Hi!
I created a mouse trail program! Use it if you want!

ArrayList<Float> x = new ArrayList<Float>();
ArrayList<Float> y = new ArrayList<Float>();
ArrayList<Float> age = new ArrayList<Float>();
int n = 10, mweight = 5;

void setup() {
  size(600,600);
}

void draw() {
  background(0);
  stroke(255,0,0,50);
  fill(255,0,0);
  x.add((float)mouseX);
  y.add((float)mouseY);
  age.add((float)0);
  for(int i = 0; i < x.size()-1; i++) {
    line(x.get(i),y.get(i),x.get(i+1),y.get(i+1));
    
    stroke(255,0,0,map(n-age.get(i),0,n,0,255));
    strokeWeight( map(n-age.get(i),0,n,1,mweight  ));
    
    age.set(i,age.get(i)+1);
    if(age.get(i) > n) {
      age.remove(i);
      x.remove(i);
      y.remove(i);
    }
  }
  ellipse(mouseX,mouseY,5,5);
}

change the variable n to determine the length of the train!
Why did I use red? It’s because when I first saw it it was red (on google slides pointer)

1 Like

I made a github page! I am not sure how the whole thing works so this is my name: time-bender