Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Simplex noise functions in various dimensions.
Based on example Java code by Stefan Gustavson. Optimisations by Peter Eastman. Better rank ordering method for 4D by Stefan Gustavson in 2012.
This code was placed in the public domain by its original author, Stefan Gustavson. You may use it as you see fit, but attribution is appreciated.
(image code)
>>>
:{
haddockRender "Geometry/Algorithms/SimplexNoise/simplex_noise.svg" 500 500 $ \(Vec2 w h) -> do let (simplexNoiseColor, simplexNoiseVisibility) = runST $ MWC.withRng [] $ \gen -> do c <- simplex2 gen def { _simplexFrequency = 5/(2*w) } v <- simplex2 gen def { _simplexFrequency = 10/(2*w) } pure (c,v) cellSize = 5 hexes = hexagonsInRange 30 hexZero fitToViewport = transformBoundingBox (map (hexagonPoly cellSize) hexes) (shrinkBoundingBox 10 [zero, Vec2 w h]) def for_ hexes $ \hex -> do let polygon = hexagonPoly cellSize hex vec = toVec2 cellSize hex color = icefire (lerp (-1,1) (0,1) (simplexNoiseColor vec)) sketch (transform fitToViewport (shrinkPolygon 1 polygon)) setColor (color `withOpacity` (lerp (-1,1) (0,1) (simplexNoiseVisibility vec))) C.fillPreserve setColor (color `withOpacity` (lerp (-1,1) (1,0.2) (simplexNoiseVisibility vec))) C.stroke :} Generated file: size 1MB, crc32: 0x1e0dba00
Synopsis
- data SimplexParameters = SimplexParameters {}
- simplex1 :: PrimMonad st => Gen (PrimState st) -> SimplexParameters -> st (Double -> Double)
- simplex2 :: PrimMonad st => Gen (PrimState st) -> SimplexParameters -> st (Vec2 -> Double)
- simplex3 :: PrimMonad st => Gen (PrimState st) -> SimplexParameters -> st (Double -> Double -> Double -> Double)
- simplex4 :: PrimMonad st => Gen (PrimState st) -> SimplexParameters -> st (Double -> Double -> Double -> Double -> Double)
Documentation
data SimplexParameters Source #
SimplexParameters | |
|
Instances
Show SimplexParameters Source # | |
Defined in Geometry.Algorithms.SimplexNoise showsPrec :: Int -> SimplexParameters -> ShowS # show :: SimplexParameters -> String # showList :: [SimplexParameters] -> ShowS # | |
Default SimplexParameters Source # | |
Defined in Geometry.Algorithms.SimplexNoise | |
Eq SimplexParameters Source # | |
Defined in Geometry.Algorithms.SimplexNoise (==) :: SimplexParameters -> SimplexParameters -> Bool # (/=) :: SimplexParameters -> SimplexParameters -> Bool # | |
Ord SimplexParameters Source # | |
Defined in Geometry.Algorithms.SimplexNoise compare :: SimplexParameters -> SimplexParameters -> Ordering # (<) :: SimplexParameters -> SimplexParameters -> Bool # (<=) :: SimplexParameters -> SimplexParameters -> Bool # (>) :: SimplexParameters -> SimplexParameters -> Bool # (>=) :: SimplexParameters -> SimplexParameters -> Bool # max :: SimplexParameters -> SimplexParameters -> SimplexParameters # min :: SimplexParameters -> SimplexParameters -> SimplexParameters # |
:: PrimMonad st | |
=> Gen (PrimState st) | To initialize the permutation table |
-> SimplexParameters | |
-> st (Double -> Double) |
One-dimensional simplex noise. See simplex2
for a code example.
:: PrimMonad st | |
=> Gen (PrimState st) | To initialize the permutation table |
-> SimplexParameters | |
-> st (Vec2 -> Double) |