0 people like it.
Like the snippet!
better worley noise
1:
2:
3:
4:
5:
6:
7:
8:
|
module WorleyNoise
open System
open System.Collections.Generic
let worleyNoise width height pointCount seed (distanceFn : int * int -> int * int -> int) combinationFn =
let prng = new Random(seed)
let points = Array.init pointCount (fun _ -> prng.Next(width), prng.Next(height))
Array2D.init width height (fun x y -> points |> Array.map (distanceFn (x, y)) |> Array.sort |> combinationFn)
|
module WorleyNoise
namespace System
namespace System.Collections
namespace System.Collections.Generic
val worleyNoise : width:int -> height:int -> pointCount:int -> seed:int -> distanceFn:(int * int -> int * int -> int) -> combinationFn:(int [] -> 'a) -> 'a [,]
Full name: WorleyNoise.worleyNoise
val width : int
val height : int
val pointCount : int
val seed : int
val distanceFn : (int * int -> int * int -> int)
Multiple items
val int : value:'T -> int (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.int
--------------------
type int = int32
Full name: Microsoft.FSharp.Core.int
--------------------
type int<'Measure> = int
Full name: Microsoft.FSharp.Core.int<_>
val combinationFn : (int [] -> 'a)
val prng : Random
Multiple items
type Random =
new : unit -> Random + 1 overload
member Next : unit -> int + 2 overloads
member NextBytes : buffer:byte[] -> unit
member NextDouble : unit -> float
Full name: System.Random
--------------------
Random() : unit
Random(Seed: int) : unit
val points : (int * int) []
type Array =
member Clone : unit -> obj
member CopyTo : array:Array * index:int -> unit + 1 overload
member GetEnumerator : unit -> IEnumerator
member GetLength : dimension:int -> int
member GetLongLength : dimension:int -> int64
member GetLowerBound : dimension:int -> int
member GetUpperBound : dimension:int -> int
member GetValue : [<ParamArray>] indices:int[] -> obj + 7 overloads
member Initialize : unit -> unit
member IsFixedSize : bool
...
Full name: System.Array
val init : count:int -> initializer:(int -> 'T) -> 'T []
Full name: Microsoft.FSharp.Collections.Array.init
Random.Next() : int
Random.Next(maxValue: int) : int
Random.Next(minValue: int, maxValue: int) : int
module Array2D
from Microsoft.FSharp.Collections
val init : length1:int -> length2:int -> initializer:(int -> int -> 'T) -> 'T [,]
Full name: Microsoft.FSharp.Collections.Array2D.init
val x : int
val y : int
val map : mapping:('T -> 'U) -> array:'T [] -> 'U []
Full name: Microsoft.FSharp.Collections.Array.map
val sort : array:'T [] -> 'T [] (requires comparison)
Full name: Microsoft.FSharp.Collections.Array.sort
More information