Skip to main content

noise-algorithms (Python)

A collection of noise generation algorithms in pure Python (no runtime dependencies). Part of the noise-algorithms monorepo.

Preview

Perlin noise rendered from the built wheel (seed=42, frequency=0.03) — these are the snapshots the integration tests verify:

1D (signal graph) 2D (field) 3D (Swiss cheese cube)
1D 2D 3D

Installation

pip install noise-algorithms

Requires Python 3.10 or newer; no runtime dependencies.

Usage

Every generator returns noise in the [-1, 1] interval. Each algorithm offers four entry points per dimension — a class (reuse it for repeated sampling) and a one-shot function (builds a generator per call), in single-octave and fractal flavours:

Class Function
Single octave PerlinNoise2D perlin_2d(x, y, *, seed=0)
Fractal (fBm) FractalPerlinNoise2D fractal_perlin_2d(x, y, *, seed=0, ...)
from noise_algorithms import (
    PerlinNoise2D,
    perlin_2d,
    FractalPerlinNoise2D,
    fractal_perlin_2d,
)

# Single octave
PerlinNoise2D(seed=42).noise(12, 7)
perlin_2d(12, 7, seed=42)

# Fractal (multi-octave)
FractalPerlinNoise2D(seed=42, octaves=6).noise(12, 7)
fractal_perlin_2d(12, 7, seed=42, octaves=6)

A class builds its permutation table once, so reuse an instance across calls when generating many values (e.g. an image).

Fractal layering (fBm) is a technique for stacking octaves, not a noise algorithm in itself. The shared octave-stacking engine lives in the abstract FractalNoiseGenerator base (and the FractalNoiseGenerator{1,2,3}D protocols); FractalPerlinNoise2D is the Perlin implementation. The base is exported as an abstraction — there is no concrete generic wrapper to instantiate with an arbitrary source.

Parameters

A Perlin generator takes only seed (default 0). It may be an int or a str — a string is hashed to an integer, so named seeds like seed="my-world" work too. The same seed produces the same field in both the Python and TypeScript packages. A fractal generator takes the layering options:

Parameter Default Description
octaves 4 Number of noise layers summed together.
lacunarity 2.0 Frequency multiplier between successive octaves.
persistence 0.5 Amplitude multiplier between successive octaves.
frequency 0.01 Base frequency applied to the first octave.
amplitudes None Weight of each octave, on top of persistence; its length sets the number of octaves.
independent_octaves False Give each octave its own permutation and coordinate offset.

Weighted octaves. amplitudes=[1, 1, 2, 2, 2, 1] makes octave i weigh amplitudes[i] * persistence**i, which lets a field favour a band of scales instead of following the persistence curve alone. A zero skips its octave. Its length is the number of octaves, so it is given instead of octaves, never with it.

Independent octaves. By default every octave samples the same source, so the layers share one lattice: they all cross zero at the origin and wherever their lattices line up. With independent_octaves=True, each octave draws its own permutation and a coordinate offset from the seed — the choice for a field you read against thresholds, where those shared zeros would show.

The FractalPerlinNoise{1,2,3}D classes and fractal_perlin_{1,2,3}d functions accept seed plus all of the above.

The noise_algorithms.NoiseGenerator{1,2,3}D protocols describe the noise contract if you want to type against it.

Sampling over a region

Most of the time you want a whole curve, image or volume rather than a single value. The generic sample_line / sample_grid / sample_volume helpers take any generator (single-octave or fractal) and return nested lists:

from noise_algorithms import FractalPerlinNoise2D, sample_grid

gen = FractalPerlinNoise2D(seed=42, frequency=0.03)
image = sample_grid(gen, width=256, height=256)  # image[y][x] in [-1, 1]
  • sample_line(gen, count=…) → list[float]
  • sample_grid(gen, width=…, height=…) → list[list[float]] (grid[y][x])
  • sample_volume(gen, width=…, height=…, depth=…) → list[list[list[float]]] (volume[z][y][x])

Each also accepts an optional origin (start / start_x / start_y / start_z) and step — sample i maps to coordinate start + i * step (defaults: origin 0, step 1).

For the common one-liner, one-shot region helpers build the generator and sample it in a single call — perlin_line / perlin_grid / perlin_volume and their fractal_perlin_… counterparts:

from noise_algorithms import fractal_perlin_grid

image = fractal_perlin_grid(width=256, height=256, seed=42, frequency=0.03)

Output range

Every generator outputs the full [-1, 1] range. Need [0, 1] instead (for a grayscale image or heightmap)? Apply the to_unit_range helper to a value or map it over a sample:

from noise_algorithms import fractal_perlin_grid, to_unit_range

image = fractal_perlin_grid(width=256, height=256, seed=42, frequency=0.03)
grayscale = [[to_unit_range(v) for v in row] for row in image]  # values in [0, 1]

Development

This package uses uv.

uv sync                 # install dev dependencies
uv run pytest           # unit + integration tests
uv run ruff check .     # lint
uv run ruff format .    # format
uv build                # build sdist + wheel

The integration test (tests/integration/) builds the wheel, imports it from an isolated environment, renders a noise image and compares it to the committed snapshot in tests/snapshots/; the rendered image is written to tests/output/. Refresh the snapshot with UPDATE_SNAPSHOTS=1 uv run pytest tests/integration.

Generating a preview image

uv run --extra images python examples/generate_images.py

License

MIT

Release files for noise-algorithms 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for noise-algorithms 1.1.0
File Size Uploaded
noise_algorithms-1.1.0.tar.gz 162.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for noise-algorithms 1.1.0
File Interpreter ABI Platform
noise_algorithms-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 185.8 kB

Release files / noise_algorithms-1.1.0.tar.gz

Download URL noise_algorithms-1.1.0.tar.gz
Size 162.7 kB
Tags Source
SHA-256 checksum
How to use checksums
26566c4b58382c128a63c243e335cc44a73725d55c92d8244724c8b0ccac6fd9
BLAKE2b-256 checksum
How to use checksums
116006372a276327eab892d6af0578d7cb7381bec226d73ac90e424830b04937
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / noise_algorithms-1.1.0-py3-none-any.whl

Download URL noise_algorithms-1.1.0-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21ca679fffec7f99c1c782f217c5fd6d49cd25f04e6026c63f5cb311fe2bd510
BLAKE2b-256 checksum
How to use checksums
d95c2169c0bf87533929d74e3be37e71ac9295bc9dcc194fdfbdb83411eaf156
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page