Functions

beforeOpacity

Calculates before opacity color value producing color you need after applying opacity.

Returns: string - the hex color before opacity

ParamTypeDefaultDescription
colorstringThe color you want to get after applying opacity.
opacitynumberOpacity

binarySearch

Search sorted list of elements for the nearest item.

Returns: BinarySearchResult - returns an item of the collection, which is nearest to optimal measured by callback function

ParamTypeDefaultDescription
itemsObject[]- The collection of elements.
callbackfuncDistance- A callback function to get distance for the collection item.
startMinimumnumberundefined- The minimum index in the array to start search from
startMaximumnumberundefined- The maximum index in the array to start search from

Callbacks

funcDistance(item, index)

Callback for finding distance for a collection item

Returns: number - returns a distance for the item

ParamTypeDefaultDescription
itemObjectA collection item
indexnumberAn index of the collection item

compareArrays

Compares non-sorted arrays.

Returns: boolean - returns true if the arrays are identical.

ParamTypeDefaultDescription
array1Object[]- The first collection of elements.
array2Object[]- The second collection of elements.
getKeyFuncgetKeyFuncCallback, undefinedIf callback function is defined it is used to get a key for an array element

Callbacks

getKeyFuncCallback(item)

Callback for getting item key for an element of the array

Returns: number - returns key of the item

ParamTypeDefaultDescription
itemObjectA collection item

getBlue

Gets blue value of HEX color string.

Returns: number - returns blue value of the hex color string.

ParamTypeDefaultDescription
colorstringColor

getColorHexValue

Converts color string into HEX color string.

Returns: string - returns color value in form of hex string.

ParamTypeDefaultDescription
colorstringRegular HTML color string.

getColorName

Converts color string into HTML color name string or return hex color string.

Returns: string - returns html color name or hex string.

ParamTypeDefaultDescription
colorstringRegular HTML color string

getCrossingRectangles

Finds pairs of crossing rectangles.

ParamTypeDefaultDescription
thisArgObjectThe callback function invocation context
rectanglesRect[]Collection of rectangles.
onCrossingonCrossingRectanglesItemCallbackCallback function to pass pair of crossing rectangles.

Callbacks

onCrossingRectanglesItemCallback(rect1, rect2)

Callback function to iterate over pairs of crosssing rectangles

ParamTypeDefaultDescription
rect1RectFirst rectangle
rect2RectSecond rectangle

getGreen

Gets green value of HEX color string.

Returns: number - returns green value of the hex color string.

ParamTypeDefaultDescription
colorstringColor

getLiniarBreaks

Breaks collection of values into 3 intervals, so values stay close to each other within interval.

Returns: number[] - returns array conaining 3 indexes. the first 2 break values into 3 intervals, the last index is actuall index of the last element in the values collection.

ParamTypeDefaultDescription
valuesnumber[]Array of values

getMergedRectangles

Merges collection of rectangles into shapes. Calls callback function to pass result sequences of data points.

ParamTypeDefaultDescription
thisArgObjectThe callback function invocation context
itemsRect[]Collection of rectangles.
onItemonMergedRectangleItemCallbackCallback function to pass result sequences of margin data points.

Callbacks

onMergedRectangleItemCallback(points)

Callback function to itterate over result shapes

ParamTypeDefaultDescription
pointsPoint[]Collection of points tracing marging around result area formed via merge of rectangles. The outer shape margin has clock wise sequance of data ponts. Internal holes inside of the shape are formed by counterclock wise sequence of data points.

getMinimumCrossingRows

Finds minimum number of horizontal lines crossing all reactngles

ParamTypeDefaultDescription
thisArgObjectThe callback function invocation context
rectanglesReact[]Collection of rectangles
onItemonRowCallbackCallback function to call for every found row

Callbacks

onRowCallback(row)

Callback for iterating rows

ParamTypeDefaultDescription
rownumberThe y coordinate of the horizontal line

getRed

Gets red value of HEX color string.

Returns: number - returns red value of the hex color string.

ParamTypeDefaultDescription
colorstringColor

highestContrast

Finds contrast between base color and two optional first and second colors and returns the one which has highest contrast.

Returns: string - returns highest contrast color compared to base color.

ParamTypeDefaultDescription
baseColorstringBase color to compare with
firstColorstringFirst color.
secondColorstringSecond color.

indexOf

Searches specified item in the array

Returns: number - returns index of the item in the array or -1 if item is not found

ParamTypeDefaultDescription
vectorobject[]An array through which to search.
itemobjectThe value to search for.
compFunccompFuncCallbackCallback function to compair two objects

Callbacks

compFuncCallback(item1, item2)

Callback for items comparison

Returns: number - returns true if items are equal

ParamTypeDefaultDescription
item1ObjectFirst item to compare
item2ObjectSecond item to compare

luminosity

Calculates luminosity between two HEX string colors.

Returns: number - returns luminosity value

ParamTypeDefaultDescription
firstColorstringFirst color.
secondColorstringSecond color.

mergeSort

Merges array of sorted arrays into one using call back function for comparison.

Returns: object[] - returns merged sorted array.

ParamTypeDefaultDescription
arraysobject[][]Array of sorted arrays of objects.
getItemWeightgetItemWeightCallbackCallback function to measure item weight.
ignoreDuplicatesbooleanIf true returns distinct weight items only.

Callbacks

getItemWeightCallback(item)

Callback function to measure item weights of merged arrays.

Returns: number - returns item's weight.

ParamTypeDefaultDescription
itemobjectThe item to weight
Have questions? Ask for help on Github.