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

Uploaded Source

Supported by

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