npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simplex-noise-esm

v2.5.0-esm.0

Published

simplex-noise is a fast simplex noise implementation in Javascript. Works in node and in the browser.

Downloads

24

Readme

simplex-noise.js

Build Status

simplex-noise.js is a fast simplex noise implementation in Javascript. It works in the browser and on nodejs.

Demos

Usage

By default simplex-noise.js will use Math.random() to seed the noise.

// initializing a new simplex instance
// do this only once as it is relatively expensive
var simplex = new SimplexNoise(),
    value2d = simplex.noise2D(x, y),
    value3d = simplex.noise3D(x, y, z),
    value4d = simplex.noise4D(x, y, z, w);

You can also pass in a seed string which will then be used to initialize the noise using the built in alea PRNG.

var simplex = new SimplexNoise('seed'),
    value2d = simplex.noise2D(x, y),
    sameSeed = new SimplexNoise('seed'),
    differentSeed = new SimplexNoise('different seed');

sameSeed.noise2D(x, y) === value2d
differentSeed.noise2D(x, y) !== value2d

You can also pass an alternative random function to the constructor that is used to build the permutation table. This can be used with a custom pseudo random number generator:

var random = new Alea(seed),
    simplex = new SimplexNoise(random),
    value2d = simplex.noise2D(x, y);

The ALEA PRNG can be found on in the npm package alea.

node.js

Node.js is also supported, you can install the package using npm.

var SimplexNoise = require('simplex-noise'),
    simplex = new SimplexNoise(Math.random),
    value2d = simplex.noise2D(x, y);

Benchmarks

For development you can open perf/index.html and watch the console or run node perf/benchmark.js in a shell. There is also a rake task for comparing your current changes can also run make compare. The command works using git stash.

Tests

There are some simple unit tests for this library to run them

npm install && npm test

Changelog

2.4.0

  • Included a PRNG based on ALEA to directly allow seeding
  • Included typescript definitions

2.3.0

:warning: This release changes the output of the noise functions. :warning:

In the future such changes will be released as a new major version.

  • Corrected generation of permutation table
  • Moved tests to mocha/chai
  • Cleanup

2.2.0

  • Small performance improvement for 2D noise

2.1.1

  • Increased entropy by fixing a little initialization issue.

2.1.0

  • AMD support

2.0.0

  • Changed node.js api, SimplexNoise is now exported directly.
  • Added unit tests

1.0.0

  • Initial Release

Requirements

It requires typed arrays. If you want to use it in browsers without support you will need to use a polyfill like typedarray.js.

License

Copyright (c) 2015 Jonas Wagner, licensed under the MIT License (enclosed)

Credits

This is mostly a direct javascript port of the Java implementation by Stefan Gustavson and Peter Eastman.

The integrated pseudo random generator is based on code by by Johannes Baagøe.

The typescript definition has been provided by Neonit.