I have a sketch that makes a multiple of vertex lines using beginShape(); and endShape();. They move using Perlin Noise. My problem is that I want each line to move differently while at this moment they all have the same movement.
Ive made a sketch originally in Processing and have been migrating it over to P5. It works as I want it to in Processing but not in p5.
Thanks in advance.
var lineCount = 10;
var lines = [];
function setup() {
createCanvas(720, 720);
for (var i = 0; i < lineCount; i++) {
lines[i] = new Lines(i, 0.5, 255, 0, 100, 255);
}
}
function draw () {
background(0);
translate(height/2, width/2);
for (var i = 0; i < lineCount; i++) {
lines[i].display();
}
}
function Lines(_rot, _inc, _r, _g, _b, _a) {
this.rot = _rot;
this.inc = _inc;
this.r = _r;
this.g = _g;
this.b = _b;
this.a = _a;
this.yoff = 0.0;
}
Lines.prototype.display = function() {
rotate(this.rot);
strokeWeight(2);
noFill();
this.c = color(this.r, this.g, this.b, this.a);
stroke(this.c);
beginShape();
this.xoff = 0.0;
for(this.x = 50; this.x < 250; this.x += 20){
this.y = map(noise(this.xoff+this.yoff), 0, 1, 50, 150);
vertex(this.x, this.y);
this.xoff += this.inc;
}
endShape();
this.yoff += 0.01;
}