Python implementation for Perlin Noise with unlimited coordinates space
Project description
Smooth random noise generator
read more https://en.wikipedia.org/wiki/Perlin_noise
source code: https://github.com/salaxieb/perlin_noise
noise = PerlinNoise(octaves=3.5, seed=777)
octaves : number of sub rectangles in each [0, 1] range
seed : specific seed with which you want to initialize random generator
from perlin_noise import PerlinNoise
noise = PerlinNoise()
# accepts as argument float and/or list[float]
noise(0.5) == noise([0.5])
--> True
# noise not limited in space dimension and seamless in any space size
noise([0.5, 0.5]) == noise([0.5, 0.5, 0, 0, 0])
--> True
Usage examples:
import matplotlib.pyplot as plt
from perlin_noise import PerlinNoise
noise = PerlinNoise(octaves=10, seed=1)
xpix, ypix = 100, 100
pic = [[noise([i/xpix, j/ypix]) for j in range(xpix)] for i in range(ypix)]
plt.imshow(pic, cmap='gray')
plt.show()
import matplotlib.pyplot as plt
from perlin_noise import PerlinNoise
noise1 = PerlinNoise(octaves=3)
noise2 = PerlinNoise(octaves=6)
noise3 = PerlinNoise(octaves=12)
noise4 = PerlinNoise(octaves=24)
xpix, ypix = 100, 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()
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.12.tar.gz
(4.3 kB
view hashes)
Built Distribution
Close
Hashes for perlin_noise-1.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c65b6671ce06d93cf467e2b59041878e3d5dc40208a8c089de581d3f9d47701 |
|
MD5 | a612da183eca6ec4cd81e9964fa9067f |
|
BLAKE2b-256 | a1e03319e5911f456ce702d45c23f8a56f56c2d4a3c80308fa68450bf195a183 |