Pythonperlin
Perlin noise generator | Worley noise generator | Python | N-dimensional | Seamless tiling | Domain warping | Octaves | 2D and 3D surface grids
Install / Use
/learn @timpyrkov/PythonperlinREADME
Perlin noise is a type of gradient noise developed by professor <b>Ken Perlin</b> in 1983 at the Department of Computer Science at New York University (NYU).
He began working on the algorithm while contributing to Disney’s 1982 science fiction film <b>"Tron"</b>, which starred Bruce Boxleitner and Peter Jurasik — both of whom later appeared in the sci-fi TV series <b>"Babylon 5"</b> (1993–1998).
In recognition of his contribution to computer graphics, Ken Perlin received an <b>Academy Award for Technical Achievement</b> in 1997 from the Academy of Motion Picture Arts and Sciences. His technique has since become a foundational tool in the procedural generation of natural-looking textures and environments.
This documentation (https://pythonperlin.readthedocs.io) provides examples and explanation of using Perlin noise for procedural generation of:
- <b>Natural textures</b>: water, clouds, fire, wood, marble
- <b>Triangulated surface grids</b>: terrain, planets
Installation
pip install pythonperlin
Quick start
import pythonperlin as pp
import matplotlib.pylab as plt
# 2D grid shape to seed gradients
shape = (6,4)
# Density to fill space between gradients
dens = 32
# Generate noise
noise = pp.perlin(shape, dens=dens, seed=0)
# Grid size = [s * dens for s in shape]
print(noise.shape)
# Show noise
plt.figure(figsize=(9,6))
plt.imshow(noise.T, cmap=plt.get_cmap("tab20b"))
plt.axis("off")
plt.show()

Tile
import numpy as np
# Tile along x axis
noise = np.concatenate([noise] * 2, axis=0)
# Tile along y axis
noise = np.concatenate([noise] * 2, axis=1)
plt.figure(figsize=(6,4))
plt.imshow(noise.T, cmap=plt.get_cmap("tab20b"))
plt.plot([noise.shape[0] // 2] * 2, [0, noise.shape[1]], "--k", lw=4)
plt.plot([0, noise.shape[0]], [noise.shape[1] // 2] * 2, "--k", lw=4)
plt.axis("off")
plt.show()

Octaves
# Add octaves
noise = pp.perlin(shape, dens=dens, octaves=4, seed=0)
# Show noise
plt.figure(figsize=(6,4))
plt.imshow(noise.T, cmap=plt.get_cmap("tab20b"))
plt.axis("off")
plt.show()

Domain warping
## Add domain warping
noise = pp.perlin(shape, dens=dens, octaves=4, warp=True, seed=0)
# Show noise
plt.figure(figsize=(6,4))
plt.imshow(noise.T, cmap=plt.get_cmap("tab20b"))
plt.axis("off")
plt.show()

N-dimensional
# Shape specifies the number of nodes along each dimension
shape = (6,4,3)
# Density specifies the filling along each dimension if tuple
dens = (32,32,4)
# Generate noise
noise = pp.perlin(shape, dens=dens, seed=0)
# Grid size = [s * d for s, d in zip(shape, dens)]
print(noise.shape)
# Show noise slices along the z axis
fig, ax = plt.subplots(3, 4, figsize=(6,4))
for k in range(noise.shape[2]):
i, j = k // 4, k % 4
ax[i,j].imshow(noise[...,k].T, cmap=plt.get_cmap("tab20b"))
ax[i,j].axis("off")
plt.tight_layout()
plt.show()

Note that the noise tiles seamlessly along the z axis too:
The noise frames transfrom smoothly and the last frame transforms to the first frame.
Documentation
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
