Perlin Noise Loop Array

Ive been stuck on the problem of drawing an array of zig-zag lines that uses Perlin Nosie to create the zig-zag. Im drawing the lines in the draw function which updates the points on the line continuously, making the lines jump around the sketch.

My problem is that I do not want the lines to animate but to use one set of points for each line continuously. The sketch can not use noLoop() as if effects other parts of the project which aren’t included here.

If anyone might be able to help I would be very appreciative.

int numLines = 10;
int noiseValues = 5;

Lines[] lines = new Lines[numLines];
float xoff = 0;
float inc = 0.1;
float[] yNoise = new float[noiseValues];

Lines l1;
Lines l2;
Lines l3;

void setup() {
size(500, 500);
frameRate(60);

l1 = new Lines(0, 0, 10);
l2 = new Lines(0, 0, 20);
l3 = new Lines(0, 0, 30);

}

void draw() {
background(0);
translate(250, 250);
l1.display();
l1.update();

//translate(250, 250);
//rotate(10);
l2.display();
l2.update();

//translate(0, 0);
//rotate(10);
l3.display();
l3.update();

}

class Lines {
float x;
float y;
float r;

Lines(float _x, float _y, float _r) {
x = _x;
y = _y;
r = _r;
}

void update(){
rotate®;
noFill();
strokeWeight(2);
stroke(255, 0, 100);
float [] n = nValues(yNoise);
println(n);

}

float[] nValues(float[] yNoise) {
for (int i = 0; i < yNoise.length; i++) {
yNoise[i] = map(noise(xoff), 0, 1, 0, 200);
xoff += inc;
//noLoop();
}
return yNoise;
}

void display() {
pushMatrix();
beginShape();
for(int j = 0; j < noiseValues; j++){
float x = j * 20;
float y = yNoise[j];
vertex(x,y);
}
endShape();
popMatrix();
}
}

Hi. Your xoff variable always increases, so the lines always change. What you could do is to initialize the xoff variable to a known value before redrawing the lines, so you get the same noise values again.

Thanks Hamoid, I finally got in working the xoff should have been in the display function right after beginShape(); that way it would have started at zero once the previous line was drawn.