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

Uploaded Source

File details

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

File metadata

  • Download URL: perlin_noise-1.2.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/49.6.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.8

File hashes

Hashes for perlin_noise-1.2.tar.gz
Algorithm Hash digest
SHA256 f15b875685671ad14ac26fa947c9dc8bd2f48fb1c84c42d5fafea073d987598a
MD5 ed2f4185942d1b83cf2712568a968c7b
BLAKE2b-256 139584d64395114a5d4f5db302abac47b41d2f6147cb8c43faecf8cb274b2e84

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