Skip to main content

Python implementation for Perlin Noise with unlimited coordinates space

Project description

Smooth random noise generator
read more https://en.wikipedia.org/wiki/Perlin_noise

noise = PerlinNoise(n_dims=2, octaves=3.5, seed=777)
    n_dims : positive int, optional, default = 1
        space dimension
    octaves : positive float, optional, default = 1
        positive number of sub rectangles in each [0, 1] range
    seed : positive int, optional, default = None
        specific seed with which you want to initialize random generator

Usage examples:

import matplotlib.pyplot as plt
from perlin_noise import PerlinNoise

noise = PerlinNoise(n_dims=2, octaves=2)
xpix = 100
ypix = 100
pic = []
for i in range(xpix):
    row = []
    for j in range(ypix):
        row.append(noise([i/xpix, j/ypix]))
    pic.append(row)

plt.imshow(arr, cmap='gray')
plt.show()

png

import matplotlib.pyplot as plt
from perlin_noise import PerlinNoise

noise1 = PerlinNoise(n_dims=2, octaves=0.5)
noise2 = PerlinNoise(n_dims=2, octaves=1)
noise3 = PerlinNoise(n_dims=2, octaves=2)
noise4 = PerlinNoise(n_dims=2, octaves=4)

xpix = 100
ypix = 100
pic = []
for i in range(xpix):
    row = []
    for j in range(ypix):
        noise_val =         noise1([i/xpix, j/ypix])
        noise_val += 0.5  * noise2([i/xpix, j/ypix])
        noise_val += 0.25 * noise3([i/xpix, j/ypix])
        noise_val += 0.125* noise4([i/xpix, j/ypix])

        row.append(noise_val)
    pic.append(row)

plt.imshow(pic, cmap='gray')
plt.show()

png

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

perlin_noise-1.4.tar.gz (1.6 kB view details)

Uploaded Source

File details

Details for the file perlin_noise-1.4.tar.gz.

File metadata

  • Download URL: perlin_noise-1.4.tar.gz
  • Upload date:
  • Size: 1.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.2.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.8

File hashes

Hashes for perlin_noise-1.4.tar.gz
Algorithm Hash digest
SHA256 ceb15bafb76393c137c623d863e072c8dd79ca04c8c7a3e99f11665e7201aab7
MD5 458a259e2ed0a35dd90d0089a4274a34
BLAKE2b-256 462910b2d9bf92ec711adba30b57a0d4dffdb9d80e42c1ddf03dfdad3f325b21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page