solid-knobs / rangeFunctions
- toNormalised
- fromNormalised
- fromString
- toString
- snap
- getRandom
- limit
- nudge
- getStart
- getEnd
- limitValue
▸ toNormalised(range
, value
): number
Converts value
to a normalised value (ranging from 0 to 1) and returns it.
Name | Type |
---|---|
range |
Range |
value |
number |
number
▸ fromNormalised(range
, normalisedValue
): number
Converts a normalised value
(ranging from 0 to 1) to it's natural range and returns it.
Name | Type |
---|---|
range |
Range |
normalisedValue |
number |
number
▸ fromString(range
, value
, unit
): number
Parses value
from a value and a unit and returns the value as a number.
Name | Type |
---|---|
range |
Range |
value |
number |
unit |
string |
number
▸ toString(range
, value
): string
Converts an unnormalised value
to a user-friendly string representation.
Name | Type |
---|---|
range |
Range |
value |
number |
string
▸ snap(range
, value
): number
Snaps an unnormalised value
to the closest legal value.
Name | Type |
---|---|
range |
Range |
value |
number |
number
▸ getRandom(range
): number
Returns a random un-normalised value.
Name | Type |
---|---|
range |
Range |
number
▸ limit(range
, value
): number
Limits an un-normalised value to be within the range.
Name | Type |
---|---|
range |
Range |
value |
number |
number
▸ nudge(range
, value
, steps
): number
Nudges the un-normalised value
by steps
.
Name | Type |
---|---|
range |
Range |
value |
number |
steps |
number |
number
▸ getStart(range
): number
Name | Type |
---|---|
range |
Range |
number
▸ getEnd(range
): number
Name | Type |
---|---|
range |
Range |
number
▸ limitValue(value
, min
, max
): number
Clamps value
to at least min
and at most max
.
Name | Type |
---|---|
value |
number |
min |
number |
max |
number |
number