As a developer, it’s annoying to have to dissect NumberRange every time I want to interact with it. I’d like to use it throughout my codebase to represent ranges but it’s unwieldy right now. It would be great if it had some utility functions.
Off the top of my head:
-
NR:isInRange(number) -> boolean
to see if a number is within the range -
NR:clamp(number) -> number
to clamp an input using the NR as a range -
NR.size number
to see how wide the range is -
NR.collapsed boolean
to see if the NR’s min and max are the same value -
NR:getAlpha(number) -> number
to get the alpha of an input number ((x-min)/(max-min)
) -
NR:slide(number) -> NumberRange
to slide the min and max by a certain amount
Just a bunch of stuff like this would be great