Public
Edited
Mar 11, 2023
24 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
noisejs = import("https://cdn.skypack.dev/noisejs@2.1.0")
Insert cell
function noise2DOctaves(f, x, y, octaves=2, persistence=1.0) {
var total = 0;
var frequency = 1;
var amplitude = 1;
var maxValue = 0;
for (let i=0;i<octaves;i++) {
total += f(x * frequency, y * frequency) * amplitude;
maxValue += amplitude; // Keep track of the maximum amplitude that could have been achieved.
amplitude = amplitude * persistence; // For each step in frequency, increase the amplitude by a factor of the persistence.
frequency = frequency * 2; // Double the frequency
}
return total / maxValue;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more