# Tracking brightest point to create line

**URL:** https://discourse.processing.org/t/tracking-brightest-point-to-create-line/19918
**Category:** Libraries
**Created:** [April 19, 2020, 4:56am UTC](https://discourse.processing.org/t/tracking-brightest-point-to-create-line/19918 "2020-04-19T04:56:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![maddyna](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@maddyna](https://discourse.processing.org/u/maddyna)
#### Post date: [April 19, 2020, 4:56am UTC](https://discourse.processing.org/t/tracking-brightest-point-to-create-line/19918/1 "2020-04-19T04:56:29Z")

</div>

After getting the brightest pixel and the coordinates I intend to draw a line tracing the subsequent brightest point as the light source moves around eg the way we create tracelines using pmouseX and mouseX  
is thr a way to do that by putting the brightest points into an array  
if so how i do that or any other ways  
I am putting the code below

```auto
import processing.video.*;
Capture video;

void setup(){
  size(640,480);
  video=new Capture(this,640,480);
  video.start();  
}

void draw(){

  if(video.available()){
    video.read();  
  }

  video.loadPixels();
  image(video,0,0);
  float brighty=0;
  int Ax=0;
  int Ay=0;
  
  for(int x=0;x<video.width;x++){
    for(int y=0;y<video.height;y++){
      int loc=x+y*video.width;
      float cBright=brightness(video.pixels[loc]);
      if(cBright>brighty){
        brighty=cBright;
        Ax=x;
        Ay=y;

      }  
    }  
  }
  println(Ax,Ay);
  
  updatePixels();
}

```

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [May 2, 2020, 4:48pm UTC](https://discourse.processing.org/t/tracking-brightest-point-to-create-line/19918/2 "2020-05-02T16:48:28Z")

</div>

You can try `ArrayList<PVector> brights` and then each frame save brights.add(new PVector(Ax, Ay));

To draw your line, you can loop over brights starting at 1 and compare to the previous index to get two points for each line segment – or you can just draw the points one at a time using vertex().
