xxxxxxxxxx
35
class PerlinShape {
constructor() {
this.phase = 0;
this.zoff = 0;
this.noiseMax = 1; // Initial noise scale
}
update(noiseScale) {
this.phase += 0.003;
this.zoff += 0.01;
// Update noise scale if provided
if (noiseScale !== undefined) {
this.noiseMax = noiseScale;
}
}
display() {
translate(width / 2, height / 2);
stroke(255);
strokeWeight(2);
noFill();
beginShape();
for (let a = 0; a < TWO_PI; a += radians(5)) {
let xoff = map(cos(a + this.phase), -1, 1, 0, this.noiseMax);
let yoff = map(sin(a + this.phase), -1, 1, 0, this.noiseMax);
let r = map(noise(xoff, yoff, this.zoff), 0, 1, 100, height / 2);
let x = r * cos(a);
let y = r * sin(a);
vertex(x, y);
}
endShape(CLOSE);
}
}