UNPKG

@osbjs/osbjs

Version:

a minimalist osu! storyboarding framework

59 lines (58 loc) 2.33 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.randFloat = exports.randInt = exports.noise4D = exports.noise3D = exports.noise2D = void 0; const simplex_noise_1 = __importDefault(require("simplex-noise")); const simplex = new simplex_noise_1.default('177013'); /** * 2-dimensional noise function. * Returns a number in range from -1 to 1. * The result is not actually random; * it is based on Simplex noise, * which means that the return values for two input values that are near one another tend to be near one another. * This type of noise is useful when you want a sequence of seemingly random numbers that don’t vary wildly from one to the other. */ function noise2D(x, y) { return simplex.noise2D(x, y); } exports.noise2D = noise2D; /** * 3-dimensional noise function. * Returns a number in range from -1 to 1. * The result is not actually random; * it is based on Simplex noise, * which means that the return values for two input values that are near one another tend to be near one another. * This type of noise is useful when you want a sequence of seemingly random numbers that don’t vary wildly from one to the other. */ function noise3D(x, y, z) { return simplex.noise3D(x, y, z); } exports.noise3D = noise3D; /** * 4-dimensional noise function. * Returns a number in range from -1 to 1. * The result is not actually random; * it is based on Simplex noise, * which means that the return values for two input values that are near one another tend to be near one another. * This type of noise is useful when you want a sequence of seemingly random numbers that don’t vary wildly from one to the other. */ function noise4D(x, y, z, w) { return simplex.noise4D(x, y, z, w); } exports.noise4D = noise4D; /** * Random integer in the interval [low, high]. */ function randInt(low, high) { return low + Math.floor(Math.random() * (high - low + 1)); } exports.randInt = randInt; /** * Random float in the interval [low, high]. */ function randFloat(low, high) { return low + Math.random() * (high - low); } exports.randFloat = randFloat;