Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance 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

Contributors 2

AltStyle によって変換されたページ (->オリジナル) /