Return to Snippet

Revision: 37100
at December 3, 2010 23:01 by burnandbass


Initial Code
/**
		* takes a number and gives it to bounderies:
		@n --> the number
		@nMin --> minimal value fo the @n number
		@nMax --> the maximal value 
		example: NumberTools.boundrary(10,5,15) returns 10,  NumberTools.boundrary(4,5,15) returns 5(min).  NumberTools.boundrary(20,5,15) returns 15 
		**/
		public static function boundrary(n:Number, nMin:Number=0, nMax:Number=1):Number{
		  return  Math.max(Math.min(n, nMax),nMin);
		}
		
		/**
		*The function centers values
		**/
		public static function center( container:Number, content:Number):int {
			return Math.round((container - content)/2);
		}

Initial URL


Initial Description


Initial Title
Number utils - center, boundery

Initial Tags


Initial Language
ActionScript 3