Giter VIP home page Giter VIP logo

squeaker's Introduction

๐Ÿ“ฃ squeaker

logo

npm size-badge Types codecov


A tiny (but advanced) noise generation module

๐Ÿ“ Table of Contents

๐Ÿง About

I was largely unsatisfied with the options for noise generation that I could find. Often they only provided simplex noise, if they did have perlin noise it lack sizing customization, seeding, or types. So, I decided to take it upon myself to make a smooth noise generator that offered a variety of generation methods with customizable sizes and seeded generation. Enjoy!

Install

Package Manager

NPM

npm i squeaker

PNPM

pnpm add squeaker

Yarn

yarn add squeaker

CDN

Skypack

For Web and Deno, no install is required! Just put this line at the top of your file:

import squeaker from 'https://cdn.skypack.dev/squeaker';

If you want type support with skypack, follow the directions here

UNPKG

<script src="https://unpkg.com/squeaker"></script>

And use it like you would any other package from UNPKG

๐ŸŽˆ Usage

Here's the great part: thanks to microbundle, this package supports CJS, UMD, and ESM formats. That means that wherever and however you use this package โ€” in browser or node, with import or require โ€” you should be set, no configuration required.

๐Ÿ“– Example

To create a noise generator, just use one of the named exports!

import {
	perlinNoise1dFactory,
	perlinNoise2dFactory,
	perlinNoise3dFactory,
	valueNoise1dFactory,
	valueNoise2dFactory,
	valueNoise3dFactory,
	randomFactory,
	interpolationQuintic,
} from 'squeaker';

// create a noise generating function
const noise = perlinNoise2dFactory({ seed: 13223412 });
// and get some smooth random noise
console.log(noise(502.8378, 1003.11)); // 0.48293299950320834
console.log(noise(502.9378, 1003.11)); // 0.44430917275215664

// seed the generator with a random function of your choosing
const customRandom = randomFactory('seed value').random;

// also offers value noise
const noise3d = valueNoise3dFactory({ random: customRandom });
console.log(noise3d(67.37, 12.12, 5 / 83)); // 0.6996699510042976
console.log(noise3d(67.37, 12.19, 6 / 83)); // 0.6684093711981097

// use custom interpolation functions
const noiseVerySmooth = valueNoise3dFactory({
	blendFunction: interpolationQuintic,
});

// or start to tile at set intervals
const noiseTiles = perlinNoise2dFactory({
	seed: 'example',
	xSize: 10,
	ySize: 40,
});
console.log(noiseTiles(0.5, 0.5)); // 0.5245568341212135
console.log(noiseTiles(10.5, 40.5)); // 0.5245568341212135

๐Ÿ”ง Running the tests

The basic set of tests are in the test script, the coverage script, and the report script. Just run those using your perferred package manager (npm, yarn, pnpm, etc.) to make sure nothing has broken.

๐Ÿ“ƒ License

Distributed under the MIT License. See LICENSE for more information.

โœ๏ธ Authors

Find me @illumincrotty on github or @illumincrotty on twitter

๐Ÿ”จ Similar Tools

If this tool isn't working for you, try one of these:

squeaker's People

Contributors

illumincrotty avatar

Stargazers

 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.