Skip to main content

A numpy-based noise generator

Project description

Table of Contents

  1. Vectorized value & gradient noise with NumPy
    1. Install with PIP
    2. Install locally
    3. Examples

Vectorized value & gradient noise with NumPy

Rumore is a lightweight Python library for procedural noise. It provides value noise and gradient noise in 1D/2D/3D plus octave summation of these (fractal Brownian motion, fBm).

The library does not implement Ken Perlin’s original algorithm directly, but its gradient noise produces visually similar results.

Install with PIP

pip install rumore

Install locally

Clone the repo, navigate to the directory and from there

pip install -e .

Examples

Import necessary stuff

import matplotlib.pyplot as plt
import numpy as np
import rumore

Generate some 1d gradient noise with different number of octaves

x = np.linspace(-10, 10, 200)
plt.figure(figsize=(5,4))
for i in range(1, 8):
    plt.plot(x, rumore.grad_noise(x, octaves=i))
plt.show()

img

Perturb points along a circle with 2d noise

t = np.linspace(0, np.pi*2, 200)
x = np.cos(t)
y = np.sin(t)
r = rumore.grad_noise(x, y)*0.5+0.5
plt.figure(figsize=(4,4))
plt.plot(x*r, y*r)
plt.show()

img

Generate a grid of 2d noise value (a grayscale image)

x = np.linspace(0, 5, 300)
y = np.linspace(0, 3, 100)
img = rumore.noise_grid(x, y)
plt.imshow(img)
plt.show()

img

Set noise properties. Here we set the octave_map property, defining a function that is applied to the noise of each octave:

from importlib import reload
from rumore import rumore
reload(rumore)
rumore.cfg.lacunarity = 2.0
rumore.cfg.falloff = 0.5 # falloff for each octave (persistence)
rumore.cfg.set_degree(5) # Interpolation degree (3 or 5)
rumore.cfg.shift = 0 #120.321 # Shift between octaves
rumore.cfg.octave_map = lambda x: np.sin(x*np.pi*4)

x = np.linspace(0, 5, 300)
y = np.linspace(0, 3, 100)
img = rumore.noise_grid(x, y)
plt.imshow(img, cmap='gray')
plt.show()

img

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

rumore-0.1.6.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rumore-0.1.6-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file rumore-0.1.6.tar.gz.

File metadata

  • Download URL: rumore-0.1.6.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.8

File hashes

Hashes for rumore-0.1.6.tar.gz
Algorithm Hash digest
SHA256 8f5cfa56561a4b8d2eace5ae35b421bf7067da05973200c73707a835b5b5366f
MD5 f9ef1ee10bd9b3dba9552cdba1f5ba8b
BLAKE2b-256 264a09dcbbde7b682a5ede6fbd6a6624cce20f9ba02f15e731c786c10dac73e3

See more details on using hashes here.

File details

Details for the file rumore-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: rumore-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.8

File hashes

Hashes for rumore-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1f6f40d8ebedf00a6d37fd62b0df4d6057406e62554c3265502df0f2817e6286
MD5 ccf7431f492e305578f4f7943a1dedde
BLAKE2b-256 a58076fad88decb6f8dc3c2f8609b4db9d0493c67757c814a95d6e60e0a45069

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