Module: ko/color

The color SDK offers various useful helper methods to convert color formats.

Members


require("ko/color").scintilla_yellow

Note: Scintilla colors are BGR longs.

Methods


require("ko/color").BGRToLong(blue, green, red)

Convert separate b,g,r values into a long int.

Parameters:
Name Type Description
blue Long
green Long
red Long
Returns:

color value

Type
Long

require("ko/color").BGRToRGB(value [, green] [, blue])

Convert bgr color value (a long, hex string, or separate r,g,b arguments) into a rgb long int.

Parameters:
Name Type Argument Description
value Long | String

hex string, or red component if using r,g,b arguments

green Long <optional>
blue Long <optional>
Returns:

color value

Type
Long

require("ko/color").create_n_distinct_colors(n, rand)

Returns an array of n distinct (and optionally random) colors in integer format: 0x0AF088

The colors generated will be random, if you want the colors to be a consistent order, pass in a 'rand' float between [0..1].

Parameters:
Name Type Description
n int

The number of colors to create.

rand float

The optional starting random number.

Returns:

of integers.

Type
array

require("ko/color").hexToLong(hexstring)

Converts a hexadecimal string color of the form #ffaabb to a long

Parameters:
Name Type Description
hexstring String
Returns:

color value

Type
Long

require("ko/color").isDark(hexstring)

Return whether this is a dark color.

Parameters:
Name Type Description
hexstring string

Hexadecimal string of the color.

Returns:
Type
Boolean

require("ko/color").isLight(hexstring)

Return whether this is a light color.

Parameters:
Name Type Description
hexstring string

Hexadecimal string of the color.

Returns:
Type
Boolean

require("ko/color").longToHex(color)

Converts an integer into hexadecimal string color of the form #ffaabb.

Parameters:
Name Type Description
color Long

value

Returns:

hexstring

Type
String

require("ko/color").RGB(red, green, blue)

WARNING: This actually returns a BGR value which works fine for Scintilla, but won't work for most other targets.

Convert separate r,g,b values into a long int.

Parameters:
Name Type Description
red Long
green Long
blue Long
Deprecated:
  • since Komodo 9
Returns:

color value

Type
Long

require("ko/color").RGBToBGR(color [, green] [, blue])

Convert rgb color value (a long, hex string, or separate r,g,b arguments) into a bgr long int.

Parameters:
Name Type Argument Description
color Long | String

value, hex string, or red component if using r,g,b arguments

green Long <optional>
blue Long <optional>
Returns:

color value

Type
Long

require("ko/color").RGBToLong(red, green, blue)

Convert separate r,g,b values, or a hex string, into a long int.

Parameters:
Name Type Description
red Long
green Long
blue Long
Returns:

color value

Type
Long

require("ko/color").StandardizeHexString(hexstring)

Parses hex string to a consistent format

Parameters:
Name Type Description
hexstring String
Returns:
Type
String