# (mouse) trail program

**URL:** https://discourse.processing.org/t/mouse-trail-program/26300
**Category:** Gallery
**Created:** [December 16, 2020, 12:46pm UTC](https://discourse.processing.org/t/mouse-trail-program/26300 "2020-12-16T12:46:38Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)
#### Post date: [December 16, 2020, 12:46pm UTC](https://discourse.processing.org/t/mouse-trail-program/26300/1 "2020-12-16T12:46:38Z")

</div>

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

```auto
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);
}

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a0b4fd85a8adc6069e2f233ca0cb0cb2e6187b9b.png)

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)

---

<div class="post-metadata">

### Author: ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)
#### Post date: [December 16, 2020, 1:18pm UTC](https://discourse.processing.org/t/mouse-trail-program/26300/2 "2020-12-16T13:18:31Z")

</div>

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