RulePerlin

ldtk.rules.RulePerlin (Class)

2D Perlin noise, ported from hxd.Perlin of the Heaps engine (MIT license, Copyright (c) 2013 Nicolas Cannasse). Only the parts used by the LDtk rule engine are kept. The integer index hash uses 32 bit arithmetic so that every target produces the same values; the rest is plain IEEE double arithmetic.

Static Members

forRules(): RulePerlin

The configuration used by LDtk auto-layer rules

Returns
RulePerlin

Instance Members

repeat: Int

normalize: Bool

Keep result in the [-1, 1] range


adjustScale(size: Int, scale: Float): Float
Name Type
size Int
scale Float
Returns
Float

inlineGradient(seed: Int, x: Float, y: Float): Float
Name Type
seed Int
x Float
y Float
Returns
Float

perlin(seed: Int, x: Float, y: Float, octaves: Int, ?persist: Float = 0.5, ?lacunarity: Float = 2.0): Float
Name Type Default
seed Int
x Float
y Float
octaves Int
persist Float 0.5
lacunarity Float 2.0
Returns
Float

new(): Void

Private Members

NGRADS: Int

GRADIENTS: Array<Float>

gradients: Array<Float>

scurve(a: Float): Float
Name Type
a Float
Returns
Float

linear(a: Float, b: Float, k: Float): Float
Name Type
a Float
b Float
k Float
Returns
Float

gradientAt(x: Float, y: Float, ix: Int, iy: Int, seed: Int): Float
Name Type
x Float
y Float
ix Int
iy Int
seed Int
Returns
Float