pnoise function

double pnoise(
  1. double x,
  2. int period, [
  3. int seed = 0
])

Smooth value noise in -1, 1 repeating every period cells.

Implementation

double pnoise(double x, int period, [int seed = 0]) {
  final i = x.floor();
  final f = x - i;
  final u = f * f * (3.0 - 2.0 * f);
  final a = rand(wrapInt(i, period), seed);
  final b = rand(wrapInt(i + 1, period), seed);
  return (a + (b - a) * u) * 2.0 - 1.0;
}