Skip to content

Instantly share code, notes, and snippets.

@alumican
Created May 21, 2012 16:28
Show Gist options
  • Save alumican/2763139 to your computer and use it in GitHub Desktop.
Save alumican/2763139 to your computer and use it in GitHub Desktop.
MathUtil.map
package net.alumican.as3.utils
{
public class MathUtil
{
static public function map(value:Number, srcMin:Number, srcMax:Number, dstMin:Number, dstMax:Number):Number
{
value = value < srcMin ? srcMin : value > srcMax ? srcMax : value;
return dstMin + (dstMax - dstMin) * (value - srcMin) / (srcMax - srcMin);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment