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

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?

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;
}
1 Like

Hello @noa_noa!

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

1/ Turn off background in draw()

and,

2/

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.

:nerd_face:

2 Likes