Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jossmac/interpolate-range
💯 Super simple numeric range interpolation
https://github.com/jossmac/interpolate-range
animation chart curve graph interpolate range
Last synced: 8 days ago
JSON representation
💯 Super simple numeric range interpolation
- Host: GitHub
- URL: https://github.com/jossmac/interpolate-range
- Owner: jossmac
- License: mit
- Created: 2017-11-29T05:15:06.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-30T04:24:58.000Z (almost 7 years ago)
- Last Synced: 2024-11-02T06:23:37.351Z (15 days ago)
- Topics: animation, chart, curve, graph, interpolate, range
- Language: JavaScript
- Homepage:
- Size: 32.2 KB
- Stars: 15
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Interpolate Range
Numeric range interpolation à la ReactNative's `AnimatedValue.interpolate()`. No dependencies, handy for animation or plotting points on a chart.
### Props
Name | Type | Description
--- | --- | ---
`input` | `[number, number]` | Input range _(required)_
`output` | `[number, number]` | Output range _(required)_
`clamp` | `boolean` | Restrict the returned value to the output range
`fn` | `(from, to, x) => number` | Alternative function to call on the value### Usage
```js
import interpolate from 'interpolate-range';function generateCurve({ floor, ceil, total }) {
const data = [];
const int = interpolate({
inputRange: [floor, ceil],
outputRange: [0, 1],
clamp: true,
});for (let k = 0; k < total; k++) {
data.push({ x: k, y: int(k) });
}return data;
}
```