# How to increase number of lines over time - till it reaches 150?

**URL:** <https://discourse.processing.org/t/how-to-increase-number-of-lines-over-time-till-it-reaches-150/20543>\
**Category:** Coding Questions\
**Created:** [May 6, 2020, 3:52pm UTC](https://discourse.processing.org/t/how-to-increase-number-of-lines-over-time-till-it-reaches-150/20543 "2020-05-06T15:52:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![noa\_noa](https://avatars.discourse-cdn.com/v4/letter/n/ecc23a/32.png) [@noa\_noa](https://discourse.processing.org/u/noa_noa)\
**Post date:** [May 6, 2020, 3:52pm UTC](https://discourse.processing.org/t/how-to-increase-number-of-lines-over-time-till-it-reaches-150/20543/1 "2020-05-06T15:52:20Z")

</div>

I understand that i need it to start drawing 1 line, and then in another section update it, so that it keeps adding 1 line - so from 1 to i, when i is the current loop, and in the loop draw the line in the coordinates i want, and update them for the next line, draw that line, until i get the i’th line, and in the end of the loop I update the i to i+1, so each time the big loop it would know to draw increasing number of lines …  
but I am not sure where to write what?

```auto
static final int NUM_LINES = 0;

float t;

void setup() {
  background(100);
  size(600, 800);
}

void draw() {
  background(255);
  stroke(0);
  strokeWeight(1.4);
  scale(0.7);

  translate(width/1.5, height/1.5);

  for (int i = 0; i < NUM_LINES; i++) {
    line(x1(t + i), y1(t + i), x2(t + i), y2(t + i));
  }
  t += 0.3;

  
//saveFrame ("frames/###.png") ;
// NEED HELP
}

float x1(float t) {
  return sin(t / -10) * 100 + sin(t / 5) * 100;
}

float y1(float t) {
  return cos(t / 10) * 20;
}

float x2(float t) {
  return sin(t / 20) * 100 + sin(-t) * 2;
}

float y2(float t) {
  return cos(-t / 20) * 500 + cos(-t / 12) * 20;
}

```

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [May 6, 2020, 5:31pm UTC](https://discourse.processing.org/t/how-to-increase-number-of-lines-over-time-till-it-reaches-150/20543/2 "2020-05-06T17:31:35Z")

</div>

Hello @noa_noa!

I just tested your code and can answer part of your question.

**1/ Turn off background in draw()**

**and,**

**2/**

> [@noa\_noa](#):
>
> `static final int NUM_LINES = 0;`

**should be initialized to equal 1.**

This will update your screen one line at a time over time.

I’m not sure about how to stop at 150 lines but perhaps try  
adding an if-statement in your code that says in effect (here in psuedocode):

**if NUM\_LINES equals 150, stop drawing.**

🤓
