How do I make one perlin noise wave join another one underneath it, using points?

edited May 2018 in Questions about Code

So I have a noise wave, and I have used a for loop to make points that travel under it, and I want them to stop at another perlin noise wave. Btw my code is really bad because I'm just a beginner :'(

This is my code:

float inc = 0.04;

void setup() {
  size(640, 500);
}

void draw() {
  background(255);

  float xoff=0;
  float xoff2=0;

  xoff2 += inc;

  stroke(245, 10, 100);
  strokeWeight(1.5);

  for (float x = 0; x < width; x++) {

    float y = noise(xoff) * 200;
    point(x, y);

    float t = noise(xoff2) * 400;

    //i+=5 = the space between the points vertically
    for (float i = y; i < t; i+=5) {
      point(x, i);
    }

    xoff += inc;
    x = x + xoff + 4;
  }
}

Answers

  • When you mean travel like an animation

    look at lerp() command in the reference

  • Screen Shot 2018-05-02 at 10.22.09 pm

    I just mean like this^ but see at the bottom how they kind of just sit in a straight line? i want the bottom to also be curved

  • like to also be another perlin noise wave

  • where are you incrementing xoff2?

  • I thought that it would make another wave? hahah i don't really know im so lost :(

  • I don’t think you need two For loops

    You only need one for x

    both horizontal lines have the same x per column/ point

    What‘s different is the y: you have an upper y, name it y1 and a lower one y2

    your line command: line (x, y1, x, y2);

    calculate the two y values with noise and use different xoffset values

    Hit ctrl-t

    Post your entire code

  • will this work for points though? even though you are using the line command?

  • Do the line thing first

    That’s the requirement

  • Ah, you tried this already

    Also look at command lerp() in the reference

  • where are you incrementing xoff2?

    you are drawing a lines in a loop. each line goes between y and t

    float y = noise(xoff) * 200;
    float t = noise(xoff2) * 400;
    

    which is fair enough.

    so y changes when xoff changes and t changes when xoff2 changes. which brings me back to...

    where are you incrementing xoff2?

Sign In or Register to comment.