https://github.com/juliareinforcementlearning/fastnoise2.jl
A Julia wrapper for https://github.com/Auburn/FastNoise2
https://github.com/juliareinforcementlearning/fastnoise2.jl
Last synced: 3 months ago
JSON representation
A Julia wrapper for https://github.com/Auburn/FastNoise2
- Host: GitHub
- URL: https://github.com/juliareinforcementlearning/fastnoise2.jl
- Owner: JuliaReinforcementLearning
- License: mit
- Created: 2022-08-07T04:55:26.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-08-08T10:13:39.000Z (almost 3 years ago)
- Last Synced: 2024-04-13T23:15:34.365Z (about 1 year ago)
- Language: Julia
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastNoise2.jl
A Julia wrapper for [Auburn/FastNoise2](https://github.com/Auburn/FastNoise2) through the C API.
## Interactive Example
[](./notebooks/notebook.jl)
## Usage
```julia
julia> using FastNoise2julia> n = Node("OpenSimplex2") # Create a node. List all the supported names with `keys(FastNoise2.NODE_NAMES_TO_ID)`
Node(Ptr{Nothing} @0x0000000002fa72b0, 1946463812)julia> n(4, 3) # Generate one single noise value at specific 2D position
-0.4346525f0julia> n(0.4,0.3,0.2) # 3D
0.5271185f0julia> n(0.4,0.3,0.2,0.1) # 4D
0.5271185f0julia> n((4,4), 4, 3) # Generate a 2D Matrix
4×4 Matrix{Float32}:
-0.434653 0.34371 -0.616628 -0.600485
-0.251613 0.84233 0.700396 -0.0943251
-0.604788 0.202821 0.0345254 0.968949
-0.554117 0.12885 0.70932 0.848869julia> n((2,3,4), 4, 3, 2; frequency=0.1) # Generate a 3D Array. 4D is also similar. Note the frequency parameter
2×3×4 Array{Float32, 3}:
[:, :, 1] =
0.527119 0.488778 0.278744
0.569762 0.488646 0.235996[:, :, 2] =
0.796065 0.644488 0.299173
0.791319 0.598346 0.215275[:, :, 3] =
0.926368 0.690241 0.246656
0.894577 0.616639 0.132056[:, :, 4] =
0.894904 0.616644 0.132056
0.846379 0.528225 0.0ulia> x = zeros(Float32, 4, 4)
4×4 Matrix{Float32}:
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0julia> n(x, 4,3) # the in-place version
julia> x
4×4 Matrix{Float32}:
-0.434653 0.34371 -0.616628 -0.600485
-0.251613 0.84233 0.700396 -0.0943251
-0.604788 0.202821 0.0345254 0.968949
-0.554117 0.12885 0.70932 0.848869
```