Code Monkey home page Code Monkey logo

perlin.js's Introduction

perlin.js

A javascript 1, 2, and 3-dimensional perlin noise generator. Cobbled together with Sean McCullough's port of Stefan Gustavson's java implementation of perlin noise (https://gist.github.com/304522) and the Alea random number generator (http://baagoe.com/en/RandomMusings/javascript/).

Usage

Create a perlin noise object:

var pn = new Perlin('random seed');

The perlin noise object has one function, noise. It takes 3 arguments: an x, y, and z coordinate. If you fix one or two of these, the function will behave as a two or one-dimensional perlin noise function, respectively. For example:

value = pn.noise(x, 0, 0); // Leave y and z fixed at zero while varying x will give you a 1D perlin noise function.

value = pn.noise(x, y, 0); // Leave z fixed at zero while varying x and y will give you a 2D perlin noise function.

value = pn.noise(x, y, z); // Varying x, y, and z will give you a 3D perlin noise function.

The noise function returns a value between 0 and 1. If the noise varies too rapidly in the interval you are calculating, you can scale the inputs accordingly:

value = pn.noise(x/10, y/10, z/10);

This will slow the variance of the returned value by an order of magnitude.

License

I don't believe in them. Do whatever you want with your bits.

perlin.js's People

Contributors

wwwtyro 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.