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.3.tar.gz (1.6 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: perlin_noise-1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 4a0bee3269de29d26ae23f11e7c3630013a0b4bf8d0093544e02e80e29bec2c2
MD5 c787d603abfda5476cfc3460fdb1f7e5
BLAKE2b-256 4ec95a1147604404424e10ff7af8aa778639571b0f77dffbf145fd35cfb9406b

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