Code Monkey home page Code Monkey logo

fuss's Introduction

fuss Build Status Crates.io Maintenance License: MPL 2.0

Fuss - Small, lightweight simplex noise generator for Rust.

This library only provides functionality for generating 2D and 3D simplex noise, as well as the ability to normalize the noise through sum octaves (fractal Brownian motion).

View the Docs.

Getting Started

Prerequisites

Add fuss to your Cargo.toml:

[dependencies]
# Get the current stable
fuss = "0.2.1"

Examples

All fuss interactions happen through the Simplex struct.

Here's how you get one:

extern crate fuss;
use fuss::Simplex;

let sn = Simplex::new();

Simplex lets you generate 2D and 3D noise.

let sn = Simplex::new();
sn.noise_2d(1.0, -1.0);
sn.noise_3d(1.0, -1.0, 0.0);

Which lets you generate noise for large sets of points:

let sn = Simplex::new();

let mut map = Vec::<Vec<Vec<f32>>>::new();
for x in 0..10 {
  map.push(Vec::<Vec<f32>>::new());
  for y in 0..10 {
    map[x as usize].push(Vec::<f32>::new());
    for z in 0..10 {
      map[x as usize][y as usize].push(sn.noise_3d(x as f32, y as f32, z as f32));
    }
  }
}

Simplex generates it's own permutation table based on the rust RNG, however you can apply your own seed to get a Simplex as such:

let sn = Simplex::from_seed(vec![0, 1, 2, 3, 4, 5]);
let other_sn = Simplex::from_seed(vec![0, 1, 2, 3, 4, 5]);

// The two simplexes will generate the same noise for the same points
// if given the same RNG seed
assert_eq!(sn.noise_2d(0.0, 0.0), other_sn.noise_2d(0.0, 0.0));

Simplex uses the same type of seeds that SeedableRng does, being a slice of usizes, however to make this easier Simplex will accept a Vec<usize> instead.

Running the tests

Run

$ cargo test

to run all unit tests and doc tests.

Versioning

fuss follows cargo's rules of Semantic Versioning:

  • Before we reach 1.0.0, anything goes, but if we make breaking changes, we increment the minor version. In Rust, breaking changes include adding fields to structs or variants to enums.
  • After 1.0.0, we only make breaking changes when we increment the major version.
  • After 1.0.0, we don’t add any new public API (no new pub anything) in tiny versions. We always increment the minor version if you add any new pub structs, traits, fields, types, functions, methods or anything else.
  • We use version numbers with three numeric parts such as 1.0.0 rather than 1.0.

License

This project is licensed under the MPPL 2.0 License - See the LICENSE.md file for details

fuss's People

Contributors

surrsurus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.