Code Monkey home page Code Monkey logo

noise.js's Introduction

noise.js

A javascript random-noise generation and sampling utility. It uses a simple implementation of bilinear interpolation to sample a random 3D data array. Generaly in computer graphics its advised to use texture sampling in a shader program but it's sometimes inconivient or impossible: for example, if we wish to modify the geometry based on this noise texture (Geometry shaders are not current supported in WebGL) or if we use 2D context.

Usage

Download the noise.js file and include it in your page. Next, you can create a Noise object::

var n = new Noise( 16, 16, 16 );

This creates a 16x16x16 noise data array with random data. The three constructor arguments are width, height and depth.

Finally, you can sample the noise for a specific point with the value being interpolated with its neighboring points::

n.sample(  0,  0,  0  ); // 0.9284072476439178
n.sample(  0,  0,  1  ); // 0.3728323532268405
n.sample(  0,  0, .5  ); // 0.6506198004353791

See the example that demonstrates how to use this library in practice to generate a 500x500 image of random noise.

noise.js's People

Contributors

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