tapers
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

tapers

NPM MIT License Travis CI Build Dependabot Status Average issue resolution time Number of open issues

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 :

S-Curve taper

License

MIT - Made with ❤️ by François Best.

Package Sidebar

Install

npm i tapers

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

132 kB

Total Files

18

Last publish

Collaborators

  • franky47