Skip to main content

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

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

fast_n-0.0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

fast_n-0.0.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file fast_n-0.0.1.tar.gz.

File metadata

  • Download URL: fast_n-0.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for fast_n-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c74ee5e3304975d293ac6567a15db5cd6868146b39798385dabde823fb2cdacf
MD5 67f57ef6283375832b63ccb3943f95db
BLAKE2b-256 a1eb0ac8aba7521b80721211926b9d015c347e7b5c9f2f5771e0c28d73b27f4d

See more details on using hashes here.

File details

Details for the file fast_n-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: fast_n-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for fast_n-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 45c6e34405f9e6c3ad7d19b081549a0be53ec944a1ad37f7c28b32c8bb200226
MD5 eb4781f41c049bf2266190dff7346fb1
BLAKE2b-256 d5da36c5b310bc78352bc08ca5b1538e5836c78a5e2ece7603e8e4127cf192b0

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