module:ColorsExtractor

module:ColorsExtractor

Process to extract neighboring colors.

Constructor

new (require("ColorsExtractor"))(optionsopt)

Source:
Parameters:
Name Type Attributes Description
options Object <optional>

Optional data

Properties
Name Type Attributes Description
pixels String <optional>

Total pixel number of the resized picture for calculation

distance String <optional>

From 0 to 1 is the color distance to not have near colors (1 distance is between white and black)

saturationImportance String <optional>

Power of the saturation weight during the process (0 is not used, 1 is only saturation and not area size)

splitPower String <optional>

Approximation power in the first color splitting during process (from 2 to 16)

colorValidator String <optional>

Callback with test to enable only some colors

Methods

extract(data) → {Array.<Object>}

Source:

Extract colors from data.

Parameters:
Name Type Description
data Array.<Number>

List of colors with an array of flat colors by chanels with 0 to 255 per chanel (red, green, blue, alpha)

Returns:

{ hex, red, green, blue, area, saturation }

Type
Array.<Object>

process(data) → {Array.<Color>}

Source:

Run extract process and get list of colors.

Parameters:
Name Type Description
data Array.<Number>

List of colors with an array of flat colors by chanels with 0 to 255 per chanel (red, green, blue, alpha)

Returns:
Type
Array.<Color>

(inner) testFunction(label, val)

Source:

Test if value is a function.

Parameters:
Name Type Description
label String
val function

(inner) testNumber(label, val, min, max)

Source:

Test if value is a number.

Parameters:
Name Type Default Description
label String
val Number
min Number 0
max Number

(inner) testUint(label, val, min, max)

Source:

Test if value is an integer.

Parameters:
Name Type Default Description
label String
val Number
min Number 0
max Number