Skip to content

Class Utils

Moderr edited this page Feb 27, 2023 · 2 revisions
class Utils

Used to simplify work.

Method Summary

Static Methods

Method Description
getRandomElementFromArray(arr) Gives random element from any array.
getRandomNumber(min, max) Gives random integer in range.
RgbToHex(r, g, b) Converts RGB to HEX color with hash at the start.
isInRange(a, min, max) Checks if the number a is in range.
createImage(imagePath) Creates new image element.

Method Details

static getRandomElementFromArray(arr)

Gives random element from any array.
Parameters:
*[] arr - The array
Returns:
* The random array element

static getRandomNumber(min, max)

Gives random integer in range.
Parameters:
number min - The range minimum
number max - The range maximum
Returns:
number The random integer in range.

static RgbToHex(r, g, b)

Converts RGB to HEX color with hash at the start.
Parameters:
number r - The red channel
number g - The green channel
number b - The blue channel
Returns:
string #RRGGBB

static isInRange(a, min, max)

Checks if the number a is in range.
Parameters:
number a - The number to check
number min - The range minimum
number max - The range maximum
Returns:
boolean is the number to check in range?

static createImage(imagePath)

Creates new image element.
Parameters:
string imagePath - The image source
Returns:
HTMLImageElement The image element.

Clone this wiki locally