https://github.com/jongacnik/linmap
Linear map
https://github.com/jongacnik/linmap
Last synced: about 1 year ago
JSON representation
Linear map
- Host: GitHub
- URL: https://github.com/jongacnik/linmap
- Owner: jongacnik
- Created: 2015-08-22T07:47:35.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-08-22T07:52:29.000Z (almost 11 years ago)
- Last Synced: 2025-03-24T22:03:43.802Z (about 1 year ago)
- Language: JavaScript
- Size: 113 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# linmap
Linear map function for node and browser (browserify or similar)
## Usage
var map = require('linmap')
// map(min1, max1, min2, max2, input)
var result = map(0, 100, 0, 10, 50)
// => 5
## Example
Maps the mouseX position from 0 to 10
window.addEventListener('mousemove', function (e) {
var result = map(0, window.innerWidth, 0, 10, e.pageX)
console.log(result)
})