Color

Contain various methods to do Color Detection

Constructor
Color(color: number | string | Color)

Construct a color from its number representation, color string or another Color object

Parameters
color The number representation of the color, the color as a string ("#FFRRGGBB" or "#RRGGBB") or another Color object
Constants

CIE76: number = 0

CIE94: number = 1

CIE2000: number = 2

RGBA: number = 3

Static Methods
get
static Color get(point: Point)

Get the color at the coordinate. Return null if the device fail to capture the screen

Parameters
point The coordinate to get the color
Return
Color The color
getAll
static Color[] get(points: Point[] | Region)

Get all the colors at the coordinates or inside the Region. If you need colors at multiple locations, this will be faster than getting the color one by one. Return null if the device fail to capture the screen

Parameters
points The coordinates to get the color. If the input is a Region then all points inside the region will be used
Return
Color[] An array of colors. If use a Region then the array will have the colors of the region row by row
compare
static number compare(color1: Color, color2: Color)

Compare the two color and return the similarity

Parameters
color1 The first color
color2 The second color
Return
number The similarity between the two color. Range 0 to 1.
compareRGB
static number compareRGB(color1: Color, color2: Color)

Compare the two color and return the similarity. This uses the RGB colorspace for comparing

Parameters
color1 The first color
color2 The second color
Return
number The similarity between the two color. Range 0 to 1.
deltaE
static number deltaE(color1: number | string | Color, color2: number | string | Color, method: number = 0)

Returns the deltaE between two colors. Note that CIE94 and CIE2000 are not yet supported

Parameters
color1 The color to compare
color2 The color to compare
method One of the CIE76, CIE94, CIE2000, RGBA
Return
number The detaE
Methods
isSame
bool isSame(color: number | string | Color, method: number = 0)

Check if the current color is the same as the input color. Delta E metric is used with the predicate of dE <= 10. Note that CIE94 and CIE2000 are not yet supported

Parameters
color The color to compare
method One of the CIE76, CIE94, CIE2000, RGBA
Return
bool true if dE <= 10
isExact
bool isExact(color: number | string | Color, method: number = 0)

Check if the current color is exactly the same as the input color. Delta E metric is used with the predicate of dE = 0. Note that CIE94 and CIE2000 are not yet supported

Parameters
color The color to compare
method One of the CIE76, CIE94, CIE2000, RGBA
Return
bool true if dE = 0
value
number value()

Get the number representation of the color

Return
number The number representation of the color
valueString
string valueString()

Get the string representation of the color

Return
string The string representation of the color
red
number red()

Get the red component of the color

Return
number The red component
green
number green()

Get the green component of the color

Return
number The green component
blue
number blue()

Get the blue component of the color

Return
number The blue component
alpha
number alpha()

Get the alpha component of the color

Return
number The alpha component

© 2024 - Macrorify by KoK-CODE