Documentation
¶
Index ¶
- func Float32(seed uint32, x uint64) float32
- func Float64(seed uint32, x uint64) float64
- func Int(seed uint32, x uint64) int
- func Int32(seed uint32, x uint64) int32
- func Int32In(seed uint32, a, b int32, x uint64) int32
- func Int32N(seed uint32, n int32, x uint64) int32
- func Int64(seed uint32, x uint64) int64
- func Int64In(seed uint32, a, b int64, x uint64) int64
- func Int64N(seed uint32, n int64, x uint64) int64
- func IntIn(seed uint32, a, b int, x uint64) int
- func IntN(seed uint32, n, x uint64) int
- func Norm32(seed uint32, x uint64) float32
- func Norm64(seed uint32, x uint64) float64
- func Roll32(seed uint32, probability float32, x uint64) bool
- func Roll64(seed uint32, probability float64, x uint64) bool
- func SSI1(seed uint32, r1 int) iter.Seq[float32]
- func SSI2(seed uint32, r1, r2 int) iter.Seq[[2]float32]
- func Sparse1(seed uint32, w, gap int) iter.Seq[int]
- func Sparse2(seed uint32, w, h, gap int) iter.Seq[[2]int]
- func Uint(seed uint32, x uint64) uint
- func Uint32(seed uint32, x uint64) uint32
- func Uint32In(seed uint32, a, b uint32, x uint64) uint32
- func Uint32N(seed uint32, n uint32, x uint64) uint32
- func Uint64(seed uint32, x uint64) uint64
- func Uint64In(seed uint32, a, b uint64, x uint64) uint64
- func Uint64N(seed uint32, n uint64, x uint64) uint64
- func UintIn(seed uint32, a, b uint, x uint64) uint
- func UintN(seed uint32, n, x uint64) uint
- func White[T Number](seed uint32, coords ...T) float32
- type FBM
- type Number
- type Simplex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SSI1 ¶
SSI1 generates a 1D hard-core pattern as a streaming iterator. Method: Simple Sequential Inhibition on a unit lattice with one jittered candidate per integer cell in [−r1, +r1]. A candidate is accepted only if it is at least 1.0 units from all previously accepted samples. Traversal order: center-out, visiting 0, +1, −1, +2, −2, ... Deterministic for a given seed. Complexity: O(n²) with the global scan used for distance checks.
Notes:
- Up to 3 jitter attempts per cell, at most one accepted sample per cell.
- Produces stratified, well-spaced samples. Not a Poisson-disk generator, and no blue-noise guarantee is implied.
Example:
for x := range SSI1(12345, 128) {
// use x
}
func SSI2 ¶
SSI2 generates a 2D hard-core pattern as a streaming iterator. Method: Simple Sequential Inhibition on a unit lattice with one jittered candidate per integer cell in the rectangle [−r1, +r1] × [−r2, +r2]. A candidate is accepted only if its squared distance to all accepted samples is ≥ 1.0. Cells are visited in expanding square rings, center-out. Deterministic for a given seed. Complexity: O(n²) with the global scan used for distance checks.
Notes:
- Up to 2 jitter attempts per cell, at most one accepted sample per cell.
- Pattern is stratified and well-spaced, not a Poisson-disk generator and no blue-noise guarantee is implied.
- For large radii, replace the global scan with a 3×3 cell-neighborhood check to obtain O(1) acceptance time per sample.
Example:
for p := range SSI2(12345, 128, 128) {
x, y := p[0], p[1]
// use x,y
}
func Sparse1 ¶
Sparse1 emits integer x positions with at least gap units between any two, streamed in a center-out order across [0, w). Method: maps the SSI1 jittered lattice samples to pixel space by scaling by gap and centering to w, then drops out-of-bounds indices. Properties:
- Deterministic for a given seed.
- Minimum integer spacing equals gap.
- Empty sequence if w <= 0 or gap <= 0.
Complexity: inherits SSI1 cost; O(n²) with global checks, O(n) with neighbor map.
Example:
for ix := range Sparse1(12345, 512, 8) {
// use ix
}
func Sparse2 ¶
Sparse2 emits integer (x, y) positions with at least gap units between any two, streamed in a center-out order across the rectangle [0, w) × [0, h). Method: maps the SSI2 jittered lattice samples to pixel space by scaling by gap in both axes and centering to w and h, then drops out-of-bounds indices. Properties:
- Deterministic for a given seed.
- Minimum integer spacing equals gap in Euclidean metric.
- Empty sequence if w <= 0, h <= 0, or gap <= 0.
Complexity: inherits SSI2 cost; O(n²) with global checks, O(n) with neighbor map.
Example:
for p := range Sparse2(12345, 512, 256, 8) {
x, y := p[0], p[1]
// use x, y
}
Types ¶
type FBM ¶
type FBM struct {
// contains filtered or unexported fields
}
FBM represents a fractal Brownian motion generator
type Number ¶
type Number interface {
~float32 | ~float64 | uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | int | ~int8 | ~int16 | ~int32 | ~int64
}
Number constraint for generic noise functions
type Simplex ¶
type Simplex struct {
// contains filtered or unexported fields
}
Simplex represents a simplex noise generator with its own permutation table
func NewSimplex ¶
NewSimplex creates a new Simplex noise generator with the given seed