Skip to content

Herteby/simplex-noise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simplex-noise

This is a library to generate simplex noise in Elm.

Interactive demo

simplex

Example usage

import Simplex exposing (PermutationTable)

--Create a permutation table, using 42 as the seed
permTable : PermutationTable
permTable =
    Simplex.permutationTableFromInt 42

-- Create a function for 2D fractal noise
noise : Float -> Float -> Float
noise =
    Simplex.fractal2d { scale = 4.0, steps = 7, stepSize = 2.0, persistence = 2.0 } permTable

-- Create a 100x100 matrix of fractal noise. 
image : List (List Float)
image =
    List.range 0 99
        |> List.map
            (\x ->
                List.range 0 99
                    |> List.map
                        (\y ->
                            noise (toFloat x) (toFloat y)
                        )
            )

Original version written by Andreas Köberle, who ported the simplex-noise.js library written by by Jonas Wagner.