Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust port #118

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ nupkg/
[Rr]elease/
[Rr]eleases/
[Pp]ublish/
[Tt]arget/
x64/
x86/
build/
Expand Down
2 changes: 1 addition & 1 deletion C/FastNoiseLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// ....',;;clodxkkOOOkkdolc:;,,,,,,,,'..........,;:clodxkO0KKXKK0Okxdolcc::;;,,,;;:codkO0XXNNNNXKK0OOOOOkkkkxxdoollloodxkO0KKKXXXXX
//
// VERSION: 1.0.1
// https://github.com/Auburn/FastNoise
// https://github.com/Auburn/FastNoiseLite

// In *one* C or C++ file, use #define FNL_IMPL to generate implementation

Expand Down
4 changes: 2 additions & 2 deletions CSharp/FastNoiseLite.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// MIT License
// MIT License
//
// Copyright(c) 2020 Jordan Peck (jordan.me2@gmail.com)
// Copyright(c) 2020 Contributors
Expand Down Expand Up @@ -45,7 +45,7 @@
// ....',;;clodxkkOOOkkdolc:;,,,,,,,,'..........,;:clodxkO0KKXKK0Okxdolcc::;;,,,;;:codkO0XXNNNNXKK0OOOOOkkkkxxdoollloodxkO0KKKXXXXX
//
// VERSION: 1.0.1
// https://github.com/Auburn/FastNoise
// https://github.com/Auburn/FastNoiseLite

using System;
using System.Runtime.CompilerServices;
Expand Down
2 changes: 1 addition & 1 deletion Cpp/FastNoiseLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// ....',;;clodxkkOOOkkdolc:;,,,,,,,,'..........,;:clodxkO0KKXKK0Okxdolcc::;;,,,;;:codkO0XXNNNNXKK0OOOOOkkkkxxdoollloodxkO0KKKXXXXX
//
// VERSION: 1.0.1
// https://github.com/Auburn/FastNoise
// https://github.com/Auburn/FastNoiseLite

#ifndef FASTNOISELITE_H
#define FASTNOISELITE_H
Expand Down
2 changes: 1 addition & 1 deletion GLSL/FastNoiseLite.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// ....',;;clodxkkOOOkkdolc:;,,,,,,,,'..........,;:clodxkO0KKXKK0Okxdolcc::;;,,,;;:codkO0XXNNNNXKK0OOOOOkkkkxxdoollloodxkO0KKKXXXXX
//
// VERSION: 1.0.1
// https://github.com/Auburn/FastNoise
// https://github.com/Auburn/FastNoiseLite

// Switch between using floats or doubles for input position
#define FNLfloat float
Expand Down
2 changes: 1 addition & 1 deletion Go/fastnoise.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// ....',;;clodxkkOOOkkdolc:;,,,,,,,,'..........,;:clodxkO0KKXKK0Okxdolcc::;;,,,;;:codkO0XXNNNNXKK0OOOOOkkkkxxdoollloodxkO0KKKXXXXX
//
// VERSION: 1.0.1
// https://github.com/Auburn/FastNoise
// https://github.com/Auburn/FastNoiseLite

package fastnoise

Expand Down
2 changes: 1 addition & 1 deletion HLSL/FastNoiseLite.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// ....',;;clodxkkOOOkkdolc:;,,,,,,,,'..........,;:clodxkO0KKXKK0Okxdolcc::;;,,,;;:codkO0XXNNNNXKK0OOOOOkkkkxxdoollloodxkO0KKKXXXXX
//
// VERSION: 1.0.1
// https://github.com/Auburn/FastNoise
// https://github.com/Auburn/FastNoiseLite

// Switch between using floats or doubles for input position
typedef float FNLfloat;
Expand Down
2 changes: 1 addition & 1 deletion Java/FastNoiseLite.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// ....',;;clodxkkOOOkkdolc:;,,,,,,,,'..........,;:clodxkO0KKXKK0Okxdolcc::;;,,,;;:codkO0XXNNNNXKK0OOOOOkkkkxxdoollloodxkO0KKKXXXXX
//
// VERSION: 1.0.1
// https://github.com/Auburn/FastNoise
// https://github.com/Auburn/FastNoiseLite

// To switch between using floats or doubles for input position,
// perform a file-wide replace on the following strings (including /*FNLfloat*/)
Expand Down
4 changes: 2 additions & 2 deletions JavaScript/FastNoiseLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
// https://www.npmjs.com/package/fastnoise-lite
// https://discord.gg/SHVaVfV
//
// Ported to Javascript by storm (Patrick U):
// Discord: storm#8888 (prefered) | Email: storm1surge@gmail.com | Github: stormy482 (https://github.com/stormy482)
// Ported to JavaScript by storm (Patrick U):
// Discord: storm#8888 (preferred) | Email: storm1surge@gmail.com | GitHub: stormy482 (https://github.com/stormy482)
//


Expand Down
2 changes: 1 addition & 1 deletion PreviewApp/FastNoiseLiteGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public FastNoiseLiteGUI()
stack.Items.Add(new StackLayoutItem(save));

var github = new Button { Text = "GitHub" };
github.Click += (sender, e) => { Process.Start(new ProcessStartInfo("https://github.com/Auburn/FastNoise") { UseShellExecute = true }); };
github.Click += (sender, e) => { Process.Start(new ProcessStartInfo("https://github.com/Auburn/FastNoiseLite") { UseShellExecute = true }); };
stack.Items.Add(new StackLayoutItem(github));

controlPanel.Items.Add(stack);
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[![discord](https://img.shields.io/discord/703636892901441577?style=flat-square&logo=discord "Discord")](https://discord.gg/SHVaVfV)
[![npm](https://img.shields.io/npm/v/fastnoise-lite)](https://www.npmjs.com/package/fastnoise-lite)
[![discord](https://img.shields.io/discord/703636892901441577?logo=discord "Discord")](https://discord.gg/SHVaVfV)

# FastNoise Lite

FastNoise Lite is an extremely portable open source noise generation library with a large selection of noise algorithms. This library focuses on high performance while avoiding platform/language specific features, allowing for easy ports to as many possible languages.

This project is an evolution of the [original FastNoise](https://github.com/Auburn/FastNoise/tree/FastNoise-Legacy) library and shares the same goal: An easy to use library that can quickly be integrated into a project and provides performant modern noise generation. See a breakdown of changes from the transition to FastNoise Lite [here](https://github.com/Auburn/FastNoise/pull/49)
This project is an evolution of the [original FastNoise](https://github.com/Auburn/FastNoiseLite/tree/FastNoise-Legacy) library and shares the same goal: An easy to use library that can quickly be integrated into a project and provides performant modern noise generation. See a breakdown of changes from the transition to FastNoise Lite [here](https://github.com/Auburn/FastNoiseLite/pull/49)

If you are looking for a more extensive noise generation library consider using [FastNoise2](https://github.com/Auburn/FastNoise2). It provides large performance gains thanks to SIMD and uses a node graph structure to allow complex noise configurations with lots of flexibility.

Expand All @@ -28,11 +27,14 @@ If you are looking for a more extensive noise generation library consider using
- [C#](/CSharp/)
- [C++98](/Cpp/)
- [C99](/C/)
- [Java](/Java/)
- [JavaScript](/JavaScript/)
- [HLSL](/HLSL/)
- [GLSL](/GLSL/)
- [Go](/Go/)
- [Java](/Java/)
- [JavaScript](/JavaScript/)
[![npm](https://img.shields.io/npm/v/fastnoise-lite?logo=npm "npm")](https://www.npmjs.com/package/fastnoise-lite)
- [Rust](/Rust/)
[![crates.io](https://img.shields.io/crates/v/fastnoise-lite?logo=rust "crates.io")](https://crates.io/crates/fastnoise-lite)

### [Getting Started](https://github.com/Auburn/FastNoiseLite/wiki#getting-started)
### [Documentation](https://github.com/Auburn/FastNoiseLite/wiki/Documentation)
Expand Down Expand Up @@ -72,12 +74,13 @@ Million points of noise generated per second (higher = better)
## Credits:

- [OpenSimplex2](https://github.com/KdotJPG/OpenSimplex2) for the OpenSimplex2 noise algorithm
- [@KdotJPG](https://github.com/KdotJPG) for implementing all the OpenSimplex alogrithms and the Java port
- [@KdotJPG](https://github.com/KdotJPG) for implementing all the OpenSimplex algorithms and the Java port
- [CubicNoise](https://github.com/jobtalle/CubicNoise) for the Value (Cubic) noise algorithm
- [@Rover656](https://github.com/Rover656) for creating the preview GUI and porting FastNoise Lite to C and HLSL.
- [@Stormy482](https://github.com/stormy482) for creating the Javascript port.
- [@Stormy482](https://github.com/stormy482) for creating the JavaScript port.
- [@dotlogix](https://github.com/dotlogix) for creating the GLSL port.
- [@ForeverZer0](https://github.com/ForeverZer0) for creating the Go port.
- [@Keavon](https://github.com/stormy482) for creating the Rust port.

# Examples

Expand Down
7 changes: 7 additions & 0 deletions Rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "fastnoise-lite"
version = "1.0.1"
edition = "2021"
license = "MIT"
description = "FastNoiseLite Lite is an extremely portable open source noise generation library with a large selection of noise algorithms"
repository = "https://github.com/Auburn/FastNoiseLite"
readme = "README.md"
authors = ["Jordan Peck", "Keavon Chambers"]

[features]
f64 = []
50 changes: 50 additions & 0 deletions Rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[crates.io](https://crates.io/crates/fastnoise-lite) • [docs.rs](https://docs.rs/fastnoise-lite/latest/bezier_rs/) • [repo](https://github.com/GraphiteEditor/Graphite/tree/master/libraries/fastnoise-lite)

# FastNoise Lite

FastNoise Lite is an extremely portable open source noise generation library with a large selection of noise algorithms. This library focuses on high performance while avoiding platform/language specific features, allowing for easy ports to as many possible languages.

## Features

- 2D & 3D
- OpenSimplex2 Noise
- OpenSimplex2S Noise
- Cellular (Voronoi) Noise
- Perlin Noise
- Value Noise
- Value Cubic Noise
- OpenSimplex2-based Domain Warp
- Basic Grid Gradient Domain Warp
- Multiple fractal options for all of the above
- Supports floats and/or doubles
- Switch from `f32` to `f64` position inputs with the `"f64"` feature flag in your `Cargo.toml`

## Getting Started

Below is an example for creating a 128x128 array of OpenSimplex2 noise.

Additional documentation is available at [docs.rs](https://docs.rs/fastnoise-lite/latest/bezier_rs/) and the project's [Getting Started](https://github.com/Auburn/FastNoiseLite/wiki#getting-started) and [Documentation](https://github.com/Auburn/FastNoiseLite/wiki/Documentation) pages from its GitHub wiki.

```rs
use fastnoise_lite::*;

// Create and configure FastNoise object
let mut noise = FastNoiseLite::new();
noise.SetNoiseType(NoiseType::OpenSimplex2);

// Gather noise data
const WIDTH: usize = 128;
const HEIGHT: usize = 128;

let mut noise_data = [0.; WIDTH * HEIGHT];

for y in 0..HEIGHT {
for x in 0..WIDTH {
// Enable `features = ["f64"]` in Cargo.toml to pass f64 values here instead of f32.
// Use `noise.get_noise_3d(x, y, z)` for 3D noise instead of 2D.
noise_data[WIDTH * y + x] = noise.get_noise_2d(x as f32, y as f32);
}
}

// Do something with this data...
```
Loading