Skip to content

Instantly share code, notes, and snippets.

@Boztown
Created July 5, 2012 16:34
Show Gist options
  • Save Boztown/3054684 to your computer and use it in GitHub Desktop.
Save Boztown/3054684 to your computer and use it in GitHub Desktop.
AS3: Convert Ranges
private function newRange( value:Number, oldMin:Number, oldMax:Number, newMin:Number, newMax:Number):Number
{
value -= oldMin;
value /= (oldMax - oldMin); //returns a value between 0 and 1
return value * (newMax - newMin) + newMin; //place that ratio from previous step into a new range function
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment