Map values between [0;1] to [X,Y] with various curves.
Check out the Demo website.
$ yarn add tapers
# or
$ npm i tapers
Implements an affine function a * x + b
.
import { LinearTaper } from 'tapers'
const taper = new LinearTaper(3, 5)
taper.map(0) // => 3
taper.map(0.5) // => 4
taper.map(1) // => 5
Given an array of Y values, interpolate linearily between those points.
import { PiecewiseLinearTaper } from 'tapers'
const taper = new PiecewiseLinearTaper([3, 5, 2, 12])
taper.map(0) // => 3
taper.map(0.5) // => 3.5
taper.map(1) // => 12
A [0;1] to [0;1] mapping curve with 3 inflexion points (y === x): 0, 1 and 0.5, with a configurable S-shape bend.
import { SCurveTaper } from 'tapers'
const taper = new SCurveTaper(0.75)
taper.map(0) // => 0
taper.map(0.25) // => 0.1
taper.map(0.5) // => 0.5
taper.map(0.75) // => 0. 9
taper.map(1) // => 1
See this taper in action on Desmos :
MIT - Made with ❤️ by François Best - Donations welcome 🙏