opensimplex
raw JSON → 0.4.5.1 verified Mon Apr 27 auth: no python
OpenSimplex is a noise generation function like Perlin or Simplex noise, but better. Current version 0.4.5.1. Released sparingly, with minor fixes.
pip install opensimplex Common errors
error AttributeError: module 'opensimplex' has no attribute 'noise2d' ↓
cause Using old function-based API after upgrading to v0.4+.
fix
Use class-based API:
from opensimplex import OpenSimplex; gen = OpenSimplex(seed=0); gen.noise2d(x, y). error TypeError: 'int' object is not callable ↓
cause Accidentally assigned `opensimplex` to an integer variable or overwritten the import.
fix
Do not reuse the name
opensimplex as a variable. Use a different name for the instance. error ValueError: seed must be an integer ↓
cause Passing a non-integer seed (e.g., float or string) to OpenSimplex constructor.
fix
Ensure seed is an integer:
OpenSimplex(seed=int(seed_value)). Warnings
breaking In v0.4+, API changed from function-based (`opensimplex.noise2d(x, y)`) to class-based (`OpenSimplex` object). Old `opensimplex.noise2d` etc. no longer exist. ↓
fix Use `from opensimplex import OpenSimplex` and create an instance: `gen = OpenSimplex(seed=...)` then call `gen.noise2d(x, y)`.
deprecated Direct module-level functions `opensimplex.noise2d`, `opensimplex.noise3d`, `opensimplex.noise4d` are removed. Use the class-based API. ↓
fix Replace `opensimplex.noise2d(x, y)` with `OpenSimplex(seed).noise2d(x, y)`.
gotcha The `seed` parameter must be an integer. Passing a non-integer (e.g. string) may cause TypeError or unexpected behavior. ↓
fix Always pass an integer seed: `OpenSimplex(seed=42)`.
gotcha OpenSimplex noise output range is approximately [-1, 1], but not guaranteed to hit exactly -1 or 1. Scaling to [0,1] often done via `(noise + 1) / 2`. ↓
fix If you need a [0,1] range, apply: `value = (noise + 1) / 2`.
Imports
- OpenSimplex
from opensimplex import OpenSimplex
Quickstart
from opensimplex import OpenSimplex
import matplotlib.pyplot as plt
seed = 42
gen = OpenSimplex(seed=seed)
size = 10
noise = [[gen.noise2d(x / size, y / size) for x in range(size)] for y in range(size)]
plt.imshow(noise, cmap='gray')
plt.show()