# Draw lines that go from bottom to top?

**URL:** <https://discourse.processing.org/t/draw-lines-that-go-from-bottom-to-top/5466>\
**Category:** Coding Questions\
**Created:** [November 12, 2018, 10:14am UTC](https://discourse.processing.org/t/draw-lines-that-go-from-bottom-to-top/5466 "2018-11-12T10:14:27Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [November 12, 2018, 9:26pm UTC](https://discourse.processing.org/t/draw-lines-that-go-from-bottom-to-top/5466/4 "2018-11-12T21:26:17Z")

</div>

Is this something like this you are looking for ?

```auto
final int nbOfLines = 50;
ArrayList<CustomLine> lines;

void setup() {
  size(900, 900);
  frameRate(60);
  
  lines = new ArrayList<CustomLine>();
  
  createLines();
}

void draw() {
  background(20);
  
  for (int i = 0; i < lines.size(); i++) {
    lines.get(i).run();
  }
  
  if (lines.get(lines.size() - 1).isOutOfScreen()) {
    createLines();
  }
}

void createLines() {
  lines.clear();
  int y = height;
  
  for (int i = 0; i < nbOfLines; i++) {
    y += random(10) + 1;
    lines.add(new CustomLine(y));
  }
}

class CustomLine {
  private int y;

  CustomLine(int y) {
    this.y = y;
  }
  
  void run() {
    move();
    display();
  }

  void move() {
    y -= 2;
  }

  void display() {
    stroke(200);
    line(0, y, width, y);
  }
  
  boolean isOutOfScreen() {
    return y < 0;
  }
}

```

The idea is to have a method that create as many lines as needed.  
Then in the draw loop, it first moves the lines up and then it checks if the last line is out of screen. If so, you create a new bunch of line and it starts over and over.

---

_[View the full topic](https://discourse.processing.org/t/draw-lines-that-go-from-bottom-to-top/5466)._
