Skip to content

node module that scales a number from one range to another

Notifications You must be signed in to change notification settings

ashleymarkfletcher/range-map

Repository files navigation

range-map

inspired by the Map function in Processing. This module scales a number from one range to another

NPM

Build Status codecov

Installation

$ npm install range-map

Example Usage

var rangeMap = require("range-map");

var mapped = rangeMap(50, 0, 100, 0, 1000);

//mapped == 500

var clampMapped = rangeMap(500, 0, 100, 0, 1000, true);

//clampMapped == 1000

API

mapped(input, inputLowest, inputHighest, outputLowest, outputHighest, [clamped=false])

returns a number that has been rounded with Math.round() The ranges will also work with negative numbers.

If clamped is truthy then output value will be clamped to the minimum and maximum output values.

About

node module that scales a number from one range to another

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published