Skip to content

API Reference

MusNik edited this page Nov 12, 2023 · 30 revisions

Constructor

new OKColor()Struct.OKColor

This constructor will return a new instance of the OKColor struct to hold a color data.

Check out How to use section for basics.

Setters

setColor(color)Struct.OKColor

With this method, you can set a color for OKColor struct in GameMaker format.

Parameters:

Name Type Description
color Constant.Color The color definition in GameMaker supported format, can be c_color constant, #rrggbb, $bbggrr or a decimal number.

Returns: Struct.OKColor The same OKColor instance that the method was called on, for method chaining.

setHex(hex)Struct.OKColor

With this method, you can set a color for OKColor struct in a string format.

Parameters:

Name Type Description
hex String The color definition in hex format as a string "#rrggbb".

Returns: Struct.OKColor The same OKColor instance that the method was called on, for method chaining.

setRGB([red], [green], [blue])Struct.OKColor

With this method, you can set a color in sRGB format. Arguments are optional so you can set components separately.

Parameters:

Name Type Description
[red] Real The red component definition of RGB color (in 0-255 range).
[green] Real The green component definition of RGB color (in 0-255 range).
[blue] Real The blue component definition of RGB color (in 0-255 range).

Returns: Struct.OKColor The same OKColor instance that the method was called on, for method chaining.

setLinearRGB([red], [green], [blue])Struct.OKColor

With this method, you can set a color in non-gamma corrected Linear RGB format. Arguments are optional so you can set components separately.

Parameters:

Name Type Description
[red] Real The red component definition of Linear RGB color (in 0-1 range).
[green] Real The green component definition of Linear RGB color (in 0-1 range).
[blue] Real The blue component definition of Linear RGB color (in 0-1 range).

Returns: Struct.OKColor The same OKColor instance that the method was called on, for method chaining.

setHSV([hue], [saturation], [value])Struct.OKColor

With this method, you can set a color in HSV format. Arguments are optional so you can set components separately.

Parameters:

Name Type Description
[hue] Real The hue component definition of HSV color (in 0-360 range).
[saturation] Real The saturation component definition of HSV color (in 0-1 range).
[value] Real The value component definition of HSV color (in 0-1 range).

Returns: Struct.OKColor The same OKColor instance that the method was called on, for method chaining.

setHSL([hue], [saturation], [lightness])Struct.OKColor

With this method, you can set a color in HSL format. Arguments are optional so you can set components separately.

Parameters:

Name Type Description
[hue] Real The hue component definition of HSL color (in 0-360 range).
[saturation] Real The saturation component definition of HSL color (in 0-1 range).
[lightness] Real The lightness component definition of HSL color (in 0-1 range).

Returns: Struct.OKColor The same OKColor instance that the method was called on, for method chaining.

setLab([lightness], [a], [b])Struct.OKColor

With this method, you can set a color in CIELab format. Arguments are optional so you can set components separately.

Parameters:

Name Type Description
[lightness] Real The lightness component definition of CIELab color (in 0-1 range).
[a] Real The a component definition of CIELab color (in -125 to 125 range).
[b] Real The b component definition of CIELab color (in -125 to 125 range).

Returns: Struct.OKColor The same OKColor instance that the method was called on, for method chaining.

setLCH([lightness], [chroma], [hue])Struct.OKColor

With this method, you can set a color in CIELCH format. Arguments are optional so you can set components separately.

Parameters:

Name Type Description
[lightness] Real The lightness component definition of CIELCH color (in 0-1 range).
[chroma] Real The chroma component definition of CIELCH color (in 0-150 range).
[hue] Real The hue component definition of CIELCH color (in 0-360 range).

Returns: Struct.OKColor The same OKColor instance that the method was called on, for method chaining.

setOKLab([lightness], [a], [b])Struct.OKColor

With this method, you can set a color in OKLab format. Arguments are optional so you can set components separately.

Parameters:

Name Type Description
[lightness] Real The lightness component definition of OKLab color (in 0-1 range).
[a] Real The a component definition of OKLab color (in -0.4 to 0.4 range).
[b] Real The b component definition of OKLab color (in -0.4 to 0.4 range).

Returns: Struct.OKColor The same OKColor instance that the method was called on, for method chaining.

setOKLCH([lightness], [chroma], [hue])Struct.OKColor

With this method, you can set a color in OKLCH format. Arguments are optional so you can set components separately.

Parameters:

Name Type Description
[lightness] Real The lightness component definition of OKLCH color (in 0-1 range).
[chroma] Real The chroma component definition of OKLCH color (in 0 to 0.4 range).
[hue] Real The hue component definition of OKLCH color (in 0-360 range).

Returns: Struct.OKColor The same OKColor instance that the method was called on, for method chaining.

setLMS([long], [medium], [short])Struct.OKColor

With this method, you can set a color in LMS format that is mostly used for technical needs. Arguments are optional so you can set components separately.

Parameters:

Name Type Description
[long] Real The long wavelength definition of LMS color.
[medium] Real The medium wavelength definition of LMS color.
[short] Real The short wavelength definition of LMS color.

Returns: Struct.OKColor The same OKColor instance that the method was called on, for method chaining.

setXYZ([x], [y], [z])Struct.OKColor

With this method, you can set a color in CIE XYZ format that is mostly used for technical needs. Arguments are optional so you can set components separately.

Parameters:

Name Type Description
[x] Real The X component definition of CIE XYZ color.
[y] Real The Y component definition of CIE XYZ color.
[z] Real The Z component definition of CIE XYZ color.

Returns: Struct.OKColor The same OKColor instance that the method was called on, for method chaining.

Getters

Color Getters

Gamut Mapping

Mixing

Cloning