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

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for perlin_noise-1.1.tar.gz
Algorithm Hash digest
SHA256 66fea548e009fd8f7a72be0079884362efaa9790231d4a59f7f04167955e6a28
MD5 8ffc92a313046408ae9f3b31a2d00ae9
BLAKE2b-256 54d94fc1b5ae421d0b4c169adf607fb76e39aab4ff9547d379a211efe639fa2e

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