Skip to content
/ range Public

Functions to convert from and to a specified range

License

Notifications You must be signed in to change notification settings

rojo2/range

Repository files navigation

@rojo2/range

A series of utility functions to work with ranges.

import range from '@rojo2/range'

// Returns values between `min` and +Infinity
range.upper(0, 10) // 10
// Returns values between -Infinity and `max`
range.lower(100, 10) // 10
// Returns values between `min` and `max`
range.clamp(0, 10, 20) // 10
// Returns the linear extrapolation between `min` and `max`
range.from(5, 0, 10) // 0.5
// Returns the linear interpolation between `min` and `max`
range.to(0.5, 0, 10) // 5
// Returns the linear extrapolation between `fromMin` and
// `fromMax` and returns the linear interpolation between
// `toMin` and `toMax`.
// This is the same as calling to(from(value, fromMin, fromMax), toMin, toMax)
range.fromTo(5, 0, 10, 100, 200) // 150

Made with ❤️ by rojo2

About

Functions to convert from and to a specified range

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published