| Maintainer | Jeremy Nuttall <jeremy@jeremy-nuttall.com> |
|---|---|
| Stability | experimental |
| Safe Haskell | None |
| Language | GHC2021 |
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
- data Noise p v
- type Noise1 v = Noise1' v v
- type Noise1' p v = Noise p v
- type Noise2 v = Noise2' v v
- type Noise2' p v = Noise (p, p) v
- type Noise3 v = Noise3' v v
- type Noise3' p v = Noise (p, p, p) v
- type Seed = Word64
- noise1At :: Noise1 a -> Seed -> a -> a
- noise2At :: Noise2 a -> Seed -> a -> a -> a
- noise3At :: Noise3 a -> Seed -> a -> a -> a -> a
- perlin2 :: RealFrac a => Noise2 a
- perlin3 :: RealFrac a => Noise3 a
- openSimplex2 :: RealFrac a => Noise2 a
- superSimplex2 :: RealFrac a => Noise2 a
- cellular2 :: (RealFrac a, Floating a) => CellularConfig a -> Noise2 a
- data CellularConfig a = CellularConfig {}
- defaultCellularConfig :: RealFrac a => CellularConfig a
- data CellularDistanceFn
- data CellularResult
- value2 :: RealFrac a => Noise2 a
- valueCubic2 :: RealFrac a => Noise2 a
- value3 :: RealFrac a => Noise3 a
- valueCubic3 :: RealFrac a => Noise3 a
- const2 :: a -> Noise2 a
- const3 :: a -> Noise3 a
- remap :: (a -> b) -> Noise p a -> Noise p b
- warp :: (p -> p') -> Noise p' v -> Noise p v
- reseed :: (Seed -> Seed) -> Noise p a -> Noise p a
- next2 :: Noise2 a -> Noise2 a
- next3 :: Noise3 a -> Noise3 a
- sliceX2 :: p -> Noise2' p v -> Noise1' p v
- sliceX3 :: p -> Noise3' p v -> Noise2' p v
- sliceY2 :: p -> Noise2' p v -> Noise1' p v
- sliceY3 :: p -> Noise3' p v -> Noise2' p v
- sliceZ3 :: p -> Noise3' p v -> Noise2' p v
- fractal2 :: RealFrac a => FractalConfig a -> Noise2 a -> Noise2 a
- fractal3 :: RealFrac a => FractalConfig a -> Noise3 a -> Noise3 a
- billow2 :: RealFrac a => FractalConfig a -> Noise2 a -> Noise2 a
- billow3 :: RealFrac a => FractalConfig a -> Noise3 a -> Noise3 a
- ridged2 :: RealFrac a => FractalConfig a -> Noise2 a -> Noise2 a
- ridged3 :: RealFrac a => FractalConfig a -> Noise3 a -> Noise3 a
- pingPong2 :: RealFrac a => FractalConfig a -> PingPongStrength a -> Noise2 a -> Noise2 a
- pingPong3 :: RealFrac a => FractalConfig a -> PingPongStrength a -> Noise3 a -> Noise3 a
- data FractalConfig a = FractalConfig {
- octaves :: Int
- lacunarity :: a
- gain :: a
- weightedStrength :: a
- defaultFractalConfig :: RealFrac a => FractalConfig a
- newtype PingPongStrength a = PingPongStrength a
- defaultPingPongStrength :: RealFrac a => PingPongStrength a
- clamp :: Ord a => a -> a -> a -> a
- clamp2 :: Ord a => a -> a -> Noise2 a -> Noise2 a
- clamp3 :: Ord a => a -> a -> Noise3 a -> Noise3 a
- cubicInterp :: Num a => a -> a -> a -> a -> a -> a
- hermiteInterp :: Num a => a -> a
- lerp :: Num a => a -> a -> a -> a
- quinticInterp :: Num a => a -> a
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.
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
Noise can be composed algebraically:
combined :: Noise (Float, Float) Float combined = (perlin2 + superSimplex2) / 2
Coordinate Transformation
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
| Applicative (Noise p) Source # | Noise admits |
| Functor (Noise p) Source # | Noise admits |
| Monad (Noise p) Source # | Note: The do n1 <- perlin2 n2 <- superSimplex2 return (n1 + n2) is equivalent to: perlin2 + superSimplex2 This is useful for domain warping. |
| Floating a => Floating (Noise p a) Source # | |
Defined in Numeric.Noise.Internal Methods 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 # | |
| Num a => Num (Noise p a) Source # | |
Defined in Numeric.Noise.Internal | |
| Fractional a => Fractional (Noise p a) 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.
Evaluate a 2D noise function at the given coordinates with the given seed.
Evaluate a 3D noise function at the given coordinates with the given seed.
Noise functions
Perlin
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
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 |
| DistManhattan | \( |dx| + |dy| \) - Creates diamond-shaped cells with sharp edges. |
| DistHybrid | Hybrid of Euclidean and Manhattan distances. |
Instances
| Bounded CellularDistanceFn Source # | |||||
Defined in Numeric.Noise.Cellular | |||||
| Enum CellularDistanceFn Source # | |||||
Defined in Numeric.Noise.Cellular Methods succ :: CellularDistanceFn -> CellularDistanceFn # pred :: CellularDistanceFn -> CellularDistanceFn # toEnum :: Int -> CellularDistanceFn # fromEnum :: CellularDistanceFn -> Int # enumFrom :: CellularDistanceFn -> [CellularDistanceFn] # enumFromThen :: CellularDistanceFn -> CellularDistanceFn -> [CellularDistanceFn] # enumFromTo :: CellularDistanceFn -> CellularDistanceFn -> [CellularDistanceFn] # enumFromThenTo :: CellularDistanceFn -> CellularDistanceFn -> CellularDistanceFn -> [CellularDistanceFn] # | |||||
| Generic CellularDistanceFn Source # | |||||
Defined in Numeric.Noise.Cellular Associated Types
Methods from :: CellularDistanceFn -> Rep CellularDistanceFn x # to :: Rep CellularDistanceFn x -> CellularDistanceFn # | |||||
| Read CellularDistanceFn Source # | |||||
Defined in Numeric.Noise.Cellular Methods readsPrec :: Int -> ReadS CellularDistanceFn # readList :: ReadS [CellularDistanceFn] # | |||||
| Show CellularDistanceFn Source # | |||||
Defined in Numeric.Noise.Cellular Methods showsPrec :: Int -> CellularDistanceFn -> ShowS # show :: CellularDistanceFn -> String # showList :: [CellularDistanceFn] -> ShowS # | |||||
| Eq CellularDistanceFn Source # | |||||
Defined in Numeric.Noise.Cellular Methods (==) :: CellularDistanceFn -> CellularDistanceFn -> Bool # (/=) :: CellularDistanceFn -> CellularDistanceFn -> Bool # | |||||
| Ord CellularDistanceFn Source # | |||||
Defined in Numeric.Noise.Cellular Methods compare :: CellularDistanceFn -> CellularDistanceFn -> Ordering # (<) :: CellularDistanceFn -> CellularDistanceFn -> Bool # (<=) :: CellularDistanceFn -> CellularDistanceFn -> Bool # (>) :: CellularDistanceFn -> CellularDistanceFn -> Bool # (>=) :: CellularDistanceFn -> CellularDistanceFn -> Bool # max :: CellularDistanceFn -> CellularDistanceFn -> CellularDistanceFn # min :: CellularDistanceFn -> CellularDistanceFn -> CellularDistanceFn # | |||||
| type Rep CellularDistanceFn Source # | |||||
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
| Bounded CellularResult Source # | |||||
Defined in Numeric.Noise.Cellular | |||||
| Enum CellularResult Source # | |||||
Defined in Numeric.Noise.Cellular Methods succ :: CellularResult -> CellularResult # pred :: CellularResult -> CellularResult # toEnum :: Int -> CellularResult # fromEnum :: CellularResult -> Int # enumFrom :: CellularResult -> [CellularResult] # enumFromThen :: CellularResult -> CellularResult -> [CellularResult] # enumFromTo :: CellularResult -> CellularResult -> [CellularResult] # enumFromThenTo :: CellularResult -> CellularResult -> CellularResult -> [CellularResult] # | |||||
| Generic CellularResult Source # | |||||
Defined in Numeric.Noise.Cellular Associated Types
Methods from :: CellularResult -> Rep CellularResult x # to :: Rep CellularResult x -> CellularResult # | |||||
| Read CellularResult Source # | |||||
Defined in Numeric.Noise.Cellular Methods readsPrec :: Int -> ReadS CellularResult # readList :: ReadS [CellularResult] # | |||||
| Show CellularResult Source # | |||||
Defined in Numeric.Noise.Cellular Methods showsPrec :: Int -> CellularResult -> ShowS # show :: CellularResult -> String # showList :: [CellularResult] -> ShowS # | |||||
| Eq CellularResult Source # | |||||
Defined in Numeric.Noise.Cellular Methods (==) :: CellularResult -> CellularResult -> Bool # (/=) :: CellularResult -> CellularResult -> Bool # | |||||
| Ord CellularResult Source # | |||||
Defined in Numeric.Noise.Cellular Methods compare :: CellularResult -> CellularResult -> Ordering # (<) :: CellularResult -> CellularResult -> Bool # (<=) :: CellularResult -> CellularResult -> Bool # (>) :: CellularResult -> CellularResult -> Bool # (>=) :: CellularResult -> CellularResult -> Bool # max :: CellularResult -> CellularResult -> CellularResult # min :: CellularResult -> CellularResult -> CellularResult # | |||||
| type Rep CellularResult Source # | |||||
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.
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
-- 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
-- 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
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
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
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
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
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
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
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
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
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 #
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
| |
Instances
| Generic (FractalConfig a) Source # | |||||
Defined in Numeric.Noise.Fractal Associated Types
Methods from :: FractalConfig a -> Rep (FractalConfig a) x # to :: Rep (FractalConfig a) x -> FractalConfig a # | |||||
| Read a => Read (FractalConfig a) Source # | |||||
Defined in Numeric.Noise.Fractal Methods readsPrec :: Int -> ReadS (FractalConfig a) # readList :: ReadS [FractalConfig a] # readPrec :: ReadPrec (FractalConfig a) # readListPrec :: ReadPrec [FractalConfig a] # | |||||
| Show a => Show (FractalConfig a) Source # | |||||
Defined in Numeric.Noise.Fractal Methods showsPrec :: Int -> FractalConfig a -> ShowS # show :: FractalConfig a -> String # showList :: [FractalConfig a] -> ShowS # | |||||
| Eq a => Eq (FractalConfig a) Source # | |||||
Defined in Numeric.Noise.Fractal Methods (==) :: FractalConfig a -> FractalConfig a -> Bool # (/=) :: FractalConfig a -> FractalConfig a -> Bool # | |||||
| type Rep (FractalConfig a) Source # | |||||
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
| Generic (PingPongStrength a) Source # | |||||
Defined in Numeric.Noise.Fractal Associated Types
Methods from :: PingPongStrength a -> Rep (PingPongStrength a) x # to :: Rep (PingPongStrength a) x -> PingPongStrength a # | |||||
| type Rep (PingPongStrength a) Source # | |||||
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
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
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