#noise #ffi #c

noise-rs-ffi

An FFI for *noise-rs* to be used by non-Rust code

1 unstable release

Uses old Rust 2015

0.1.0 Jun 22, 2016

#99 in #noise

MIT/Apache

7KB
56 lines

An FFI for noise-rs

A C FFI for noise-rs.

If you just want to generate noise in Rust, use noise-rs directly.

Documentation

See src/*.

Implemented functionality

  • Perlin noise 2 - 4
  • OpenSimplex noise 2 - 3
  • Cell noise (also: Worley noise, Voronoi noise)
    • Value 2 - 4
    • Range 2 - 4
    • Range Inv 2 - 4
  • Cell noise with Manhattan distance
    • Value 2 - 4
    • Range 2 - 4
    • Range Inv 2 - 4

License

This library is dual-licensed as MIT and Apache v2.0, the same as the Rust language itself. You may choose from both depending on your needs.


lib.rs:

Exposes a subset of functions from noise-rs in a C-compatible FFI interface.

Usage

Use this library in a non-Rust setting. If you're programming in rust, just use noise-rs directly.

Creating a Seed object

Create a Seed using the noise_seed_new function. It accepts an unsigned 32-bit integer and returns a new pointer to the Seed object.

Seed *seed = noise_seed_new((uint32_t) 42);

Using the Seed object for generating noise

You can now use that pointer with the noise generation functions. Here's an example using 3D Perlin noise.

double val = noise_perlin3(seed, 0.2, 0.3, 1.5);

Freeing the Seed object

When you're done using the Seed object, you'll need to free it. To do that, use the noise_seed_delete function.

noise_seed_delete(seed);

Dependencies

~0.8–1MB
~17K SLoC