Map a value to another range.
/// map_value(value,from_low,from_high,to_low,to_high,clamp*);
/// @desc Map a value to another range.
/// @arg value
/// @arg from_low
/// @arg from_high
/// @arg to_low
/// @arg to_high
/// @arg clamp*
var _value = argument[0];
_value -= argument[1]; //Subtract lowest-from from the return value
if argument[1] != argument[2] && argument[3] != argument[4] {
//Change return value to the new range
_value = _value/(argument[2]-argument[1])*(argument[4]-argument[3]);
}
_value += argument[3]; //Add lowest-to to the return value
//Clamp the return value if the argument is supplied and set to 1
if argument_count > 5 && argument[5] {
_value = clamp(_value,min(argument[3],argument[4]),max(argument[3],argument[4]));
}
//Return mapped value
return _value;