Utility functions. Adapted from https://github.com/Tw1ddle/geometrize-haxe/

Static methods

staticinlineabs (value:Int):Int

Returns the absolute value of the given value.

Parameters:

value

The value to abs.

Returns:

The absolute value of the given value.

staticinlineclamp (value:Int, min:Int, max:Int):Int

Clamps a value within a range.

Parameters:

value

The value to clamp.

min

The lower bound of the range.

max

The upper bound of the range.

Returns:

The clamped value.

staticdist (x:Int, y:Int):Int

staticinlinemax (first:Int, second:Int):Int

Compare two values and returns the larger one.

Parameters:

first

The first value.

second

The second value.

Returns:

The larger value.

staticinlinemin (first:Int, second:Int):Int

Compares two values and returns the smaller one.

Parameters:

first

The first value.

second

The second value.

Returns:

The smaller value.

staticinlineminMaxElements (a:Array<Int>):{min:Int, max:Int}

Returns the smallest and largest items from an array of ints.

Parameters:

a

The array of ints.

Returns:

The smallest and largest items from the array.

staticmultiply (a:Array<Array<Float>>, b:Array<Array<Float>>):Array<Array<Float>>

staticinlineparseIntOrThrow (s:String):Int

Converts a value measured in radians to degrees.

Parameters:

radians

Radians value to convert to degrees.

Returns:

The value converted to degrees.

staticprintRectangle (r:Rectangle):String

staticinlinerandom (lower:Float, upper:Float):Int

Returns a random integer in the range (inclusive).

Parameters:

lower

The lower bound.

upper

The upper bound.

Returns:

A random integer in the range [lower:upper] inclusive.

staticrandomArrayItem<T> (a:Array<T>):T

Returns a random item from an array.

Parameters:

a

The array to pick a random item from.

Returns:

A random item from the array.

@:value({ noRepeat : false })staticinlinerandomIntArray (length:Int, lower:Int, upper:Int, noRepeat:Bool = false):Array<Int>

Returns a random array of integers in the range (inclusive).

Parameters:

lower

The lower bound.

upper

The upper bound.

Returns:

An array of random integers in the range [lower:upper] inclusive.

staticinlinerandomRectangle (r:Rectangle):{y:Int, x:Int, width:Int, height:Int}

staticinlinesgn (value:Int):Int

staticinlinetoDegrees (radians:Float):Float

Converts a value measured in radians to degrees.

Parameters:

radians

Radians value to convert to degrees.

Returns:

The value converted to degrees.

staticinlinetoRadians (degrees:Float):Float

Converts a value measured in degrees to radians.

Parameters:

degrees

Degrees value to convert to radians.

Returns:

The value converted to radians.

staticurlToBase64 (s:String):String