tapers
v0.1.0
Published
Convert [0;1] values to [X;Y] with various curves
Downloads
4
Maintainers
Readme
tapers
Map values between [0;1] to [X,Y] with various curves.
Featured Tapers
Installation
$ yarn add tapers
# or
$ npm i tapers
Documentation
Linear Taper
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
Piecewise Linear Taper
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
S-Curve Taper
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 :
License
MIT - Made with ❤️ by François Best.