pure-noise-0.2.1.0: High-performance composable noise generation (Perlin, Simplex, Cellular)
MaintainerJeremy Nuttall <jeremy@jeremy-nuttall.com>
Stabilityexperimental
Safe HaskellNone
LanguageGHC2021

Numeric.Noise

Description

Performant noise generation with composable noise functions.

Noise functions are built on a unified Noise type that abstracts over the seed and coordinate parameters. Noise2 and Noise3 are convenient type aliases for 2D and 3D noise. These can be composed using algebraically with minimal performance overhead.

Noise values are generally clamped to [-1, 1], though some functions may occasionally produce values slightly outside this range.

Basic Usage

Generate 2D Perlin noise:

import Numeric.Noise qualified as Noise

myNoise :: Noise.Seed -> Float -> Float -> Float
myNoise = Noise.noise2At Noise.perlin2

Compose multiple noise functions:

combined :: (RealFrac a) => Noise.Noise2 a
combined = (Noise.perlin2 + Noise.superSimplex2) / 2

myNoise2 :: Noise.Seed -> Float -> Float -> Float
myNoise2 = Noise.noise2At combined

Apply fractal Brownian motion:

fbm :: (RealFrac a) => Noise.Noise2 a
fbm = Noise.fractal2 Noise.defaultFractalConfig Noise.perlin2

Advanced Features

Generate 1D noise by slicing higher-dimensional noise:

noise1d :: Noise.Noise1 Float
noise1d = Noise.sliceY2 0.5 Noise.perlin2

evaluate :: Float -> Float
evaluate = Noise.noise1At noise1d 0

Transform coordinates with warp:

scaledAndLayered :: Noise.Noise2 Float
scaledAndLayered =
 Noise.warp (\(x, y) -> (x * 2, y * 2)) Noise.perlin2
   + fmap (logBase 2) Noise.perlin2

Layer independent noise with reseed or next2:

layered :: Noise.Noise2 Float
layered = Noise.perlin2 + Noise.next2 Noise.perlin2 / 2
Synopsis

Noise

Noise1, Noise2, and Noise3 are type aliases for 1D, 2D, and 3D noise functions built on the unified Noise type. They can be evaluated with noise1At, noise2At, and noise3At respectively.

Seed is a Word64 value used for deterministic noise generation.

data Noise p v Source #

Noise represents a function from a Seed and coordinates p to a noise value v.

For convenience, dimension-specific type aliases are provided:

Use warp to transform coordinates and remap (or fmap) to transform values.

To evaluate noise functions, use noise1At, noise2At, or noise3At

NB: Noise is a lawful Profunctor where lmap = warp and rmap = remap. There are some useful implications to this, but pure-noise is committed to a minimal dependency footprint and so will not provide this instance itself.

Algebraic composition

Expand

Noise can be composed algebraically:

combined :: Noise (Float, Float) Float
combined = (perlin2 + superSimplex2) / 2

Coordinate Transformation

Expand

This allows you to, for example, compose multiple layers of noise at different offsets.

scaled :: Noise2 Float
scaled = warp (\(x, y) -> (x * 2, y * 2)) perlin2

Instances

Instances details
Applicative (Noise p) Source #

Noise admits Applicative on the value it produces

Instance details

Defined in Numeric.Noise.Internal

Methods

pure :: a -> Noise p a #

(<*>) :: Noise p (a -> b) -> Noise p a -> Noise p b #

liftA2 :: (a -> b -> c) -> Noise p a -> Noise p b -> Noise p c #

(*>) :: Noise p a -> Noise p b -> Noise p b #

(<*) :: Noise p a -> Noise p b -> Noise p a #

Functor (Noise p) Source #

Noise admits Functor on the value it produces

Instance details

Defined in Numeric.Noise.Internal

Methods

fmap :: (a -> b) -> Noise p a -> Noise p b #

(<$) :: a -> Noise p b -> Noise p a #

Monad (Noise p) Source #

Note: The Monad instance evaluates all noise functions at the same seed and coordinate. For independent sampling at different coordinates, use warp to transform the coordinate space.

do n1 <- perlin2
   n2 <- superSimplex2
   return (n1 + n2)

is equivalent to:

perlin2 + superSimplex2

This is useful for domain warping.

Instance details

Defined in Numeric.Noise.Internal

Methods

(>>=) :: Noise p a -> (a -> Noise p b) -> Noise p b #

(>>) :: Noise p a -> Noise p b -> Noise p b #

return :: a -> Noise p a #

Floating a => Floating (Noise p a) Source # 
Instance details

Defined in Numeric.Noise.Internal

Methods

pi :: Noise p a #

exp :: Noise p a -> Noise p a #

log :: Noise p a -> Noise p a #

sqrt :: Noise p a -> Noise p a #

(**) :: Noise p a -> Noise p a -> Noise p a #

logBase :: Noise p a -> Noise p a -> Noise p a #

sin :: Noise p a -> Noise p a #

cos :: Noise p a -> Noise p a #

tan :: Noise p a -> Noise p a #

asin :: Noise p a -> Noise p a #

acos :: Noise p a -> Noise p a #

atan :: Noise p a -> Noise p a #

sinh :: Noise p a -> Noise p a #

cosh :: Noise p a -> Noise p a #

tanh :: Noise p a -> Noise p a #

asinh :: Noise p a -> Noise p a #

acosh :: Noise p a -> Noise p a #

atanh :: Noise p a -> Noise p a #

log1p :: Noise p a -> Noise p a #

expm1 :: Noise p a -> Noise p a #

log1pexp :: Noise p a -> Noise p a #

log1mexp :: Noise p a -> Noise p a #

Num a => Num (Noise p a) Source # 
Instance details

Defined in Numeric.Noise.Internal

Methods

(+) :: Noise p a -> Noise p a -> Noise p a #

(-) :: Noise p a -> Noise p a -> Noise p a #

(*) :: Noise p a -> Noise p a -> Noise p a #

negate :: Noise p a -> Noise p a #

abs :: Noise p a -> Noise p a #

signum :: Noise p a -> Noise p a #

fromInteger :: Integer -> Noise p a #

Fractional a => Fractional (Noise p a) Source # 
Instance details

Defined in Numeric.Noise.Internal

Methods

(/) :: Noise p a -> Noise p a -> Noise p a #

recip :: Noise p a -> Noise p a #

fromRational :: Rational -> Noise p a #

type Noise1 v = Noise1' v v Source #

type Noise1' p v = Noise p v Source #

type Noise2 v = Noise2' v v Source #

type Noise2' p v = Noise (p, p) v Source #

type Noise3 v = Noise3' v v Source #

type Noise3' p v = Noise (p, p, p) v Source #

type Seed = Word64 Source #

Seed value for deterministic noise generation.

Using the same Seed value will produce the same noise pattern, allowing for reproducible results. Different seed values produce different, independent noise patterns.

Accessors

noise1At :: Noise1 a -> Seed -> a -> a Source #

Evaluate a 1D noise function at the given coordinates with the given seed. Currently, you must use a slicing function like sliceX to reduce higher-dimensional noise into 1D noise.

noise2At Source #

Arguments

:: Noise2 a 
-> Seed

deterministic seed

-> a

x coordinate

-> a

y coordinate

-> a 

Evaluate a 2D noise function at the given coordinates with the given seed.

noise3At Source #

Arguments

:: Noise3 a 
-> Seed

deterministic seed

-> a

x coordinate

-> a

y coordinate

-> a

z coordinate

-> a 

Evaluate a 3D noise function at the given coordinates with the given seed.

Noise functions

Perlin

perlin2 :: RealFrac a => Noise2 a Source #

2D Perlin noise. Classic gradient noise algorithm.

perlin3 :: RealFrac a => Noise3 a Source #

3D Perlin noise. Classic gradient noise algorithm.

OpenSimplex

openSimplex2 :: RealFrac a => Noise2 a Source #

2D OpenSimplex noise. Smooth gradient noise similar to Perlin but without directional artifacts.

OpenSimplex2S

superSimplex2 :: RealFrac a => Noise2 a Source #

2D SuperSimplex noise. Improved OpenSimplex variant with better visual characteristics.

Cellular

cellular2 :: (RealFrac a, Floating a) => CellularConfig a -> Noise2 a Source #

2D Cellular (Worley) noise. Configure with CellularConfig to control distance functions and return values.

Cellular noise creates patterns based on distances to randomly distributed cell points.

Configuration

data CellularConfig a Source #

Configuration for cellular (Worley) noise generation.

Cellular noise is based on distances to randomly distributed cell points, creating a distinctive cellular or organic pattern.

Constructors

CellularConfig 

Fields

Instances

Instances details
Generic (CellularConfig a) Source # 
Instance details

Defined in Numeric.Noise.Cellular

Associated Types

type Rep (CellularConfig a) 
Instance details

Defined in Numeric.Noise.Cellular

type Rep (CellularConfig a) = D1 ('MetaData "CellularConfig" "Numeric.Noise.Cellular" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'False) (C1 ('MetaCons "CellularConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "cellularDistanceFn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 CellularDistanceFn) :*: (S1 ('MetaSel ('Just "cellularJitter") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "cellularResult") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 CellularResult))))
Show a => Show (CellularConfig a) Source # 
Instance details

Defined in Numeric.Noise.Cellular

type Rep (CellularConfig a) Source # 
Instance details

Defined in Numeric.Noise.Cellular

type Rep (CellularConfig a) = D1 ('MetaData "CellularConfig" "Numeric.Noise.Cellular" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'False) (C1 ('MetaCons "CellularConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "cellularDistanceFn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 CellularDistanceFn) :*: (S1 ('MetaSel ('Just "cellularJitter") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "cellularResult") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 CellularResult))))

defaultCellularConfig :: RealFrac a => CellularConfig a Source #

Default configuration for cellular noise generation.

data CellularDistanceFn Source #

Distance function for cellular noise calculations.

Different distance metrics produce different visual characteristics in the cellular pattern.

Constructors

DistEuclidean

\( \sqrt{dx^2 + dy^2} \) - Creates circular cells with smooth edges.

DistEuclideanSq

\( dx^2 + dy^2 \) - Faster than DistEuclidean with similar appearance.

DistManhattan

\( |dx| + |dy| \) - Creates diamond-shaped cells with sharp edges.

DistHybrid

Hybrid of Euclidean and Manhattan distances.

Instances

Instances details
Bounded CellularDistanceFn Source # 
Instance details

Defined in Numeric.Noise.Cellular

Enum CellularDistanceFn Source # 
Instance details

Defined in Numeric.Noise.Cellular

Generic CellularDistanceFn Source # 
Instance details

Defined in Numeric.Noise.Cellular

Associated Types

type Rep CellularDistanceFn 
Instance details

Defined in Numeric.Noise.Cellular

type Rep CellularDistanceFn = D1 ('MetaData "CellularDistanceFn" "Numeric.Noise.Cellular" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'False) ((C1 ('MetaCons "DistEuclidean" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DistEuclideanSq" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DistManhattan" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DistHybrid" 'PrefixI 'False) (U1 :: Type -> Type)))
Read CellularDistanceFn Source # 
Instance details

Defined in Numeric.Noise.Cellular

Show CellularDistanceFn Source # 
Instance details

Defined in Numeric.Noise.Cellular

Eq CellularDistanceFn Source # 
Instance details

Defined in Numeric.Noise.Cellular

Ord CellularDistanceFn Source # 
Instance details

Defined in Numeric.Noise.Cellular

type Rep CellularDistanceFn Source # 
Instance details

Defined in Numeric.Noise.Cellular

type Rep CellularDistanceFn = D1 ('MetaData "CellularDistanceFn" "Numeric.Noise.Cellular" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'False) ((C1 ('MetaCons "DistEuclidean" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DistEuclideanSq" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DistManhattan" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DistHybrid" 'PrefixI 'False) (U1 :: Type -> Type)))

data CellularResult Source #

What value to return from cellular noise evaluation.

These options allow for different visual effects by returning different properties of the cell structure.

Constructors

CellValue

Return the hash value of the nearest cell point. Creates discrete regions with constant values.

Distance

Return the distance to the nearest cell point. Creates a classic Worley noise pattern with cell boundaries.

Distance2

Return the distance to the second-nearest cell point. Creates larger, more organic-looking cells.

Distance2Add

Return the sum of distances to the two nearest cell points. Creates smooth, rounded cells.

Distance2Sub

Return the difference between distances to the two nearest cell points. Emphasizes cell boundaries and creates sharp edges.

Distance2Mul

Return the product of distances to the two nearest cell points. Creates cells with varying contrast.

Distance2Div

Return the ratio of nearest to second-nearest distance. Creates normalized cell patterns.

Instances

Instances details
Bounded CellularResult Source # 
Instance details

Defined in Numeric.Noise.Cellular

Enum CellularResult Source # 
Instance details

Defined in Numeric.Noise.Cellular

Generic CellularResult Source # 
Instance details

Defined in Numeric.Noise.Cellular

Associated Types

type Rep CellularResult 
Instance details

Defined in Numeric.Noise.Cellular

type Rep CellularResult = D1 ('MetaData "CellularResult" "Numeric.Noise.Cellular" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'False) ((C1 ('MetaCons "CellValue" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Distance" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Distance2" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "Distance2Add" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Distance2Sub" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Distance2Mul" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Distance2Div" 'PrefixI 'False) (U1 :: Type -> Type))))
Read CellularResult Source # 
Instance details

Defined in Numeric.Noise.Cellular

Show CellularResult Source # 
Instance details

Defined in Numeric.Noise.Cellular

Eq CellularResult Source # 
Instance details

Defined in Numeric.Noise.Cellular

Ord CellularResult Source # 
Instance details

Defined in Numeric.Noise.Cellular

type Rep CellularResult Source # 
Instance details

Defined in Numeric.Noise.Cellular

type Rep CellularResult = D1 ('MetaData "CellularResult" "Numeric.Noise.Cellular" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'False) ((C1 ('MetaCons "CellValue" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Distance" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Distance2" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "Distance2Add" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Distance2Sub" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Distance2Mul" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Distance2Div" 'PrefixI 'False) (U1 :: Type -> Type))))

Value

value2 :: RealFrac a => Noise2 a Source #

2D Value noise. Simple noise based on interpolated random values at grid points.

valueCubic2 :: RealFrac a => Noise2 a Source #

2D Value noise with cubic interpolation for smoother results.

value3 :: RealFrac a => Noise3 a Source #

3D Value noise. Simple noise based on interpolated random values at grid points.

valueCubic3 :: RealFrac a => Noise3 a Source #

3D Value noise with cubic interpolation for smoother results.

Constant fields

const2 :: a -> Noise2 a Source #

A noise function that produces the same value everywhere. Alias of pure.

const3 :: a -> Noise3 a Source #

A noise function that produces the same value everywhere. Alias of pure

Used to provide the Num instance.

Noise alteration

remap :: (a -> b) -> Noise p a -> Noise p b Source #

Transform the values produced by a noise function.

This is an alias for fmap. Use it to transform noise values after generation:

Examples

Expand
-- Scale noise from [-1, 1] to [0, 1]
normalized :: Noise2 Float
normalized = remap (\x -> (x + 1) / 2) perlin2

warp :: (p -> p') -> Noise p' v -> Noise p v Source #

Transform the coordinate space of a noise function.

This allows you to scale, rotate, or otherwise modify coordinates before they're passed to the noise function:

NB: This is contramap

Examples

Expand
-- Scale the noise frequency
scaled :: Noise2 Float
scaled = warp (\(x, y) -> (x * 2, y * 2)) perlin2

-- Rotate the noise field
rotated :: Noise2 Float
rotated = warp (\(x, y) -> (x * cos a - y * sin a, x * sin a + y * cos a)) perlin2
  where a = pi / 4

reseed :: (Seed -> Seed) -> Noise p a -> Noise p a Source #

Modify the seed used by a noise function.

This is useful for generating independent layers of noise:

See also next2 and next3 for convenient increment-by-one variants.

Examples

Expand
layer1 = perlin2
layer2 = reseed (+1) perlin2
layer3 = reseed (+2) perlin2

combined = (layer1 + layer2 + layer3) / 3

next2 :: Noise2 a -> Noise2 a Source #

Increment the seed for a 2D noise function. See reseed

next3 :: Noise3 a -> Noise3 a Source #

Increment the seed for a 3D noise function. See reseed

Slicing (projecting)

sliceX2 :: p -> Noise2' p v -> Noise1' p v Source #

Slice a 2D noise function at a fixed X coordinate to produce 1D noise.

Examples

Expand
noise1d :: Noise1 Float
noise1d = sliceX2 0.0 perlin2  -- Fix X at 0, vary Y

-- Evaluate at Y = 5.0
value = noise1At noise1d seed 5.0

sliceX3 :: p -> Noise3' p v -> Noise2' p v Source #

Slice a 3D noise function at a fixed X coordinate to produce 2D noise.

Examples

Expand
noise2d :: Noise2 Float
noise2d = sliceX3 0.0 perlin3  -- Fix X at 0, vary Y and Z

-- Evaluate at Y = 1.0, Z = 2.0
value = noise2At noise2d seed 1.0 2.0

sliceY2 :: p -> Noise2' p v -> Noise1' p v Source #

Slice a 2D noise function at a fixed Y coordinate to produce 1D noise.

Examples

Expand
noise1d :: Noise1 Float
noise1d = sliceY2 0.0 perlin2  -- Fix Y at 0, vary X

-- Evaluate at X = 5.0
value = noise1At noise1d seed 5.0

sliceY3 :: p -> Noise3' p v -> Noise2' p v Source #

Slice a 3D noise function at a fixed Y coordinate to produce 2D noise.

Examples

Expand
noise2d :: Noise2 Float
noise2d = sliceY3 0.0 perlin3  -- Fix Y at 0, vary X and Z

sliceZ3 :: p -> Noise3' p v -> Noise2' p v Source #

Slice a 3D noise function at a fixed Z coordinate to produce 2D noise.

This is useful for extracting 2D slices from 3D noise at different heights:

Examples

Expand
heightmap :: Noise2 Float
heightmap = sliceZ3 10.0 perlin3  -- Sample at Z = 10

Fractals

Fractal noise combines multiple octaves at different frequencies and amplitudes to create natural-looking, multi-scale patterns.

For custom fractal implementations using modifier functions, see Numeric.Noise.Fractal.

Fractal Brownian Motion (FBM)

fractal2 :: RealFrac a => FractalConfig a -> Noise2 a -> Noise2 a Source #

Apply Fractal Brownian Motion (FBM) to a 2D noise function.

FBM combines multiple octaves of noise at increasing frequencies and decreasing amplitudes to create natural-looking, multi-scale patterns. This is the standard fractal noise implementation.

fbm :: Noise2 Float
fbm = fractal2 defaultFractalConfig perlin2

fractal3 :: RealFrac a => FractalConfig a -> Noise3 a -> Noise3 a Source #

Apply Fractal Brownian Motion (FBM) to a 3D noise function.

3D version of fractal2. See fractal2 for details.

Fractal variants

billow2 :: RealFrac a => FractalConfig a -> Noise2 a -> Noise2 a Source #

Apply billow fractal to a 2D noise function.

Billow creates a cloud-like or billowy appearance by taking the absolute value of each octave. This produces sharp ridges in the negative regions of the noise, creating a distinct puffy or cloudy look.

clouds :: Noise2 Float
clouds = billow2 defaultFractalConfig perlin2

billow3 :: RealFrac a => FractalConfig a -> Noise3 a -> Noise3 a Source #

Apply billow fractal to a 3D noise function.

3D version of billow2. See billow2 for details.

ridged2 :: RealFrac a => FractalConfig a -> Noise2 a -> Noise2 a Source #

Apply ridged fractal to a 2D noise function.

Ridged creates sharp ridges by inverting and taking the absolute value of each octave. This is particularly useful for terrain generation, creating mountain ridges and valleys.

mountains :: Noise2 Float
mountains = ridged2 defaultFractalConfig perlin2

ridged3 :: RealFrac a => FractalConfig a -> Noise3 a -> Noise3 a Source #

Apply ridged fractal to a 3D noise function.

3D version of ridged2. See ridged2 for details.

pingPong2 :: RealFrac a => FractalConfig a -> PingPongStrength a -> Noise2 a -> Noise2 a Source #

Apply ping-pong fractal to a 2D noise function.

Ping-pong creates a wave-like pattern by folding the noise values back and forth within a range, creating a distinctive undulating appearance. The strength parameter controls the intensity of the ping-pong effect.

waves :: Noise2 Float
waves = pingPong2 defaultFractalConfig defaultPingPongStrength perlin2

pingPong3 :: RealFrac a => FractalConfig a -> PingPongStrength a -> Noise3 a -> Noise3 a Source #

Apply ping-pong fractal to a 3D noise function.

3D version of pingPong2. See pingPong2 for details.

Configuration

data FractalConfig a Source #

Configuration for fractal noise generation.

Fractal noise combines multiple octaves (layers) of noise at different frequencies and amplitudes to create more complex, natural-looking patterns.

Constructors

FractalConfig 

Fields

  • octaves :: Int

    Number of noise layers to combine. More octaves create more detail but are more expensive to compute. Must be \( >= 1 \).

  • lacunarity :: a

    Frequency multiplier between octaves. Each octave's frequency is the previous octave's frequency multiplied by lacunarity.

  • gain :: a

    Amplitude multiplier between octaves. Each octave's amplitude is the previous octave's amplitude multiplied by gain. Values \( < 1 \) create smoother noise, values \( > 1 \) create rougher noise.

  • weightedStrength :: a

    Controls how much each octave's amplitude is influenced by the previous octave's value. At 0, octaves have independent amplitudes. At 1, lower-valued areas in previous octaves reduce the amplitude of subsequent octaves. Range: \( [0, 1] \).

Instances

Instances details
Generic (FractalConfig a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

Associated Types

type Rep (FractalConfig a) 
Instance details

Defined in Numeric.Noise.Fractal

type Rep (FractalConfig a) = D1 ('MetaData "FractalConfig" "Numeric.Noise.Fractal" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'False) (C1 ('MetaCons "FractalConfig" 'PrefixI 'True) ((S1 ('MetaSel ('Just "octaves") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "lacunarity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a)) :*: (S1 ('MetaSel ('Just "gain") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "weightedStrength") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a))))
Read a => Read (FractalConfig a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

Show a => Show (FractalConfig a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

Eq a => Eq (FractalConfig a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

type Rep (FractalConfig a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

type Rep (FractalConfig a) = D1 ('MetaData "FractalConfig" "Numeric.Noise.Fractal" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'False) (C1 ('MetaCons "FractalConfig" 'PrefixI 'True) ((S1 ('MetaSel ('Just "octaves") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "lacunarity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a)) :*: (S1 ('MetaSel ('Just "gain") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "weightedStrength") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a))))

defaultFractalConfig :: RealFrac a => FractalConfig a Source #

Default configuration for fractal noise generation.

newtype PingPongStrength a Source #

Strength parameter for ping-pong fractal noise.

Controls the intensity of the ping-pong folding effect. Higher values create more frequent oscillations.

Constructors

PingPongStrength a 

Instances

Instances details
Generic (PingPongStrength a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

Associated Types

type Rep (PingPongStrength a) 
Instance details

Defined in Numeric.Noise.Fractal

type Rep (PingPongStrength a) = D1 ('MetaData "PingPongStrength" "Numeric.Noise.Fractal" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'True) (C1 ('MetaCons "PingPongStrength" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
type Rep (PingPongStrength a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

type Rep (PingPongStrength a) = D1 ('MetaData "PingPongStrength" "Numeric.Noise.Fractal" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'True) (C1 ('MetaCons "PingPongStrength" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

defaultPingPongStrength :: RealFrac a => PingPongStrength a Source #

Default ping-pong strength value.

Math utilities

clamp Source #

Arguments

:: Ord a 
=> a

lower bound

-> a

upper bound

-> a

value

-> a 

Clamp a value to a specified range.

Returns the value if it's within bounds, otherwise returns the nearest boundary.

clamp2 :: Ord a => a -> a -> Noise2 a -> Noise2 a Source #

Clamp the output of a 2D noise function to the range [lower, upper].

clamp3 :: Ord a => a -> a -> Noise3 a -> Noise3 a Source #

Clamp the output of a 3D noise function to the range [lower, upper].

cubicInterp :: Num a => a -> a -> a -> a -> a -> a Source #

cubic interpolation

hermiteInterp :: Num a => a -> a Source #

hermite interpolation

lerp Source #

Arguments

:: Num a 
=> a

start

-> a

end

-> a

parameter in range [0, 1]

-> a 

Linear interpolation between two values.

Monotonic lerp

quinticInterp :: Num a => a -> a Source #

quintic interpolation