mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-29 19:15:55 -05:00
0a19c7a8cb
* hx the codec * fix(ci,html5): use haxe.Timer instead of Sys.time * refactor(compat): use haxe.Timer instead of Sys.time(), introduce TimerUtil to reduce code dupe * fix: redundant types * refactor(style): use TimerTools in place of haxe.Timer * refactor: consistent timer code * feat: build timings * refactor(ci): cleanup ci configs * sigh * sigh, 2 * fix: haxelib deleterepo does not silently fail * retrigger ci * verbose output * debug info after haxelib gti * force haxelib git override * more debug info * force bash * at least haxelib is consistent now * fix the runners first, then do that * update ci-haxe * it is time? * deleterepo may fail * finishing touches
24 lines
550 B
Haxe
24 lines
550 B
Haxe
package funkin.util.tools;
|
|
|
|
/**
|
|
* Utilities for performing common math operations.
|
|
*/
|
|
class FloatTools
|
|
{
|
|
/**
|
|
* Constrain a float between a minimum and maximum value.
|
|
*/
|
|
public static function clamp(value:Float, min:Float, max:Float):Float
|
|
{
|
|
return Math.max(min, Math.min(max, value));
|
|
}
|
|
|
|
/**
|
|
Round a float to a certain number of decimal places.
|
|
**/
|
|
public static function round(number:Float, ?precision = 2):Float
|
|
{
|
|
number *= Math.pow(10, precision);
|
|
return Math.round(number) / Math.pow(10, precision);
|
|
}
|
|
}
|