Giter VIP home page Giter VIP logo

perlinnim's Introduction

PerlinNim

Build License

A noise generation library for Nim, with support for both Perlin noise and Simplex noise.

API Docs

http://nycto.github.io/PerlinNim/perlin.html

A Quick Example

import perlin, random, math

# Call randomize from the 'math' module to ensure the seed is unique
randomize()

let noise = newNoise()

# Output a 20x10 grid of noise
for y in 0..10:
    for x in 0..20:
        let value = noise.simplex(x, y)
        # If you wanted to use Perlin noise, you would swap that line out with:
        # let value = noise.perlin(x, y)

        stdout.write( int(10 * value) )
    stdout.write("\n")

License

This library is released under the MIT License, which is pretty spiffy. You should have received a copy of the MIT License along with this program. If not, see http://www.opensource.org/licenses/mit-license.php

perlinnim's People

Contributors

bitdeli-chef avatar nycto avatar robertrautenbach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

perlinnim's Issues

Perlin noise doesn't work with negative coordinates

Using a slightly modified version of the example:

import perlin, random, math

randomize()
let noise = newNoise()

for y in 0..10:
    for x in 0..20:
        echo noise.perlin(-x, -y)

sample from output:

5.716112000000001
3.282981724160003
11.60813961216002
60.05479239680006
205.2020080716802
-4.865088000000002
-7.199699819840007
-23.70134179840006
-83.59753790208008
-238.8913038540804
-3.896455000000001
0.9298921574400039
11.76152181184003
41.58326589440004
119.6164463395202
-8.679456000000002

Numbers are not in the range 0-1 as expected from the docs. Swapping perlin for simplex works as expected

Installation broken on windows

I get an exception:

Traceback (most recent call last)
nimble.nim(1007)         nimble
nimble.nim(939)          doAction
nimble.nim(581)          install
nimble.nim(536)          downloadPkg
download.nim(200)        doDownload
download.nim(164)        verifyClone
packageparser.nim(239)   getPkgInfo
packageparser.nim(230)   readPackageInfo
Error: unhandled exception: Could not read package info file in C:\Users\rsharan\AppData\Local\Temp\\nimble_19652\githubcom_NyctoPerlinNim\perlin.nimble;
  Reading as ini file failed with:
    Invalid section: .
  Evaluating as NimScript file failed with:
    Cannot find nimscriptapi.nim. [NimbleError]

I believe this is due to the wrong path:
C:\Users\rsharan\AppData\Local\Temp\\nimble_19652\githubcom_NyctoPerlinNim\perlin.nimble;. it has 2 slashes after Temp.

OpenSimplex?

Hi, this is pretty useful to have on hand. Nice and simple to use too! I'm wondering though, did you use the straight up Simplex algorithm? If so, I hate to be one of those pesky people when it comes to patents, but can you implement OpenSimplex instead as an option?

https://en.wikipedia.org/wiki/OpenSimplex_noise

Octave loop range fix

Hello, I noticed that there is an issue with the octave range in the applyOctaves template. It will always run octaves + 1 times. This small change fixes the issue:

-    for i in 0..self.octaves:
+    for i in 0..<self.octaves:

value out of range error?

Hi when compiling on certain systems the randomseed() proc is raising a value out of range error.
I've changed:
uint32(rand(high(int)))
to
uint32(rand(high(int16)))
It seems to have fixed the issue, but I'm not sure why it was happening in the first place. Are you able to shed any light on this?

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.