xxxxxxxxxx
32
let momentInTime = 0;
let xincrement = 0.01; //change this value to see the different result
function setup() {
createCanvas(560,390);
background(220);
noStroke(); //disables drawing the stroke (outline)
}
function draw() {
//draw rectangle
fill(220, 10);
rect(0,0,width,height);
// get a noise value based on a specific moment in time
// scale it to the window's width
let n = noise(momentInTime);
// re-maps a number from one range to another
// using map() to customize the range of Perlin noise
// map(value, curremtMin, currentMax, newMin, newMax)
let x = map(n,0,1,0,width);
// increment momentInTime in each cycle (move forward in time)
momentInTime += xincrement;
// draw ellipse at the value produced by perlin noise
fill(63,63,147);
ellipse(x,height/2, 64, 64);
//print(n); //print() equal to console.log()
}