A fast noise library for game dev.
Project description
Fast_n is a fast and easy to use python library to generate noise. (It currently only supports perlin noise.)
Installation
Type pip install fast_n in your command prompt to install fast_n. If you do not have python installed, download it on the official website.
Use cases
Noise is very useful for anything procedural, being especially used for procedural world generation in video games. Fast_n is fast enough for most use cases.
Features
At the moment, only perlin noise is implemented but I'm sure I'll add more at some point, and I already plan on improving the speed of the noise generation by writing it in C rather than pure python.
How to use
Create a noise object, passing in a seed and some noise-dependant parameters, then call its Sample() method with x and y 2D coordinates to access the value at the given position.
This exemple shows how to draw perlin noise using PIL to handle the image stuff:
from fastn import noise
from PIL import Image
perlin = noise.PerlinNoise(23) # creates a PerlinNoise object with a seed of 23
img = Image.new("L", (128, 128)) # creates an image using only a grayscale channel
for y in range(128):
for x in range(128):
# with perlin noise you want to avoid only using integer coordinates
# because they always return the same value
noiseValue = perlin.Sample(x / 32, y / 32)
pixelBrightness = round((noiseValue * 0.5 + 0.5) * 255) # transforms the output from a [-1, 1] range to a [0, 255] range
img.putpixel((x, y), pixelBrightness)
img.show() # opens the image in an image viewer
Credits
- Raouf: My perlin noise implementation is based on this blog post he made.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fast_n-0.0.2.tar.gz.
File metadata
- Download URL: fast_n-0.0.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
864e2dcb6889ee1d8204ab9510f6c14c17ec3eca2a65e638e32d56cc150881d5
|
|
| MD5 |
8067c161443a6b7e340d58441d13ca61
|
|
| BLAKE2b-256 |
b2f6d5aa8b0a54c457deb693a385903980128367898d8f206196d267561a11fc
|
File details
Details for the file fast_n-0.0.2-py3-none-any.whl.
File metadata
- Download URL: fast_n-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6bc1ffac167618fbd7ac5f736b4b83074d856c6613a07037455789a72080c83
|
|
| MD5 |
683528dbc1d6548bce23af72c7f60d72
|
|
| BLAKE2b-256 |
fa578354d7547420e3a4eaa5853aa36623d95229e4444da3b46a8221879141ab
|