fn elevation(seed: f64, noise_scale: f64, z_scale: f32) -> impl Fn(f64, f64) -> f32 {
  let source = Perlin::new();
  let noisefn = Turbulence::new(source);

  move |x, y| {
    let noise = noisefn.get([x / noise_scale, y / noise_scale, seed]) as f32;
    map_range(noise, -1.0, 1.0, 0.0, z_scale)
  }
}
// Returning a closure for the elevation function rather than
// calculating it on the fly every time makes this approx. 1 billion times faster,
// presumably because it doesn't have to instantiate the noisefn every time
Returning a closure for the elevation function rather than
calculating it on the fly every time makes this approx. 1 billion times faster,
presumably because it doesn't have to instantiate the noisefn every time
Returning a closure for the elevation function rather than calculating it on the fly every time makes this approx . 1 billion times faster presumably because it doesn ' t have to instantiate the noisefn every time
fn elevation(seed: f64, noise_scale: f64, z_scale: f32) -> impl Fn(f64, f64) -> f32 {
  let source = Perlin::new();
  let noisefn = Turbulence::new(source);
  move |x, y| {
    let noise = noisefn.get([x / noise_scale, y / noise_scale, seed]) as f32;
    map_range(noise, -1.0, 1.0, 0.0, z_scale)
  }
}
fn elevation ( seed : f64 , noise_scale : f64 , z_scale : f32 ) -> impl Fn ( f64 , f64 ) -> f32 { let source = Perlin :: new ( ) ; let noisefn = Turbulence :: new ( source ) ; move | x , y | { let noise = noisefn . get ( [ x / noise_scale , y / noise_scale , seed ] ) as f32 ; map_range ( noise , - 1.0 , 1.0 , 0.0 , z_scale ) } }
Returning a closure for the elevation function rather than
calculating it on the fly every time makes this approx.
Returning a closure for the elevation function rather than calculating it on the fly every time makes this approx .
seed
f64
noise_scale
f64
z_scale
f32