Skip to content

FxColor ​

This module contains functions for creating and editing colors.

Load ​

lua
FxColor = require "FxColor";

Functions ​

FunctionDescription
CreateFromHex (Hex)Returns a color created from a hexadecimal string.
CreateFromRGB (R, G, B)Returns a color created from RGB values.
GetR (Color)
GetG (Color)
GetB(Color)
Return the color channel value of a color.
SetR (Color, Value)
SetG(Color, Value)
SetB(Color, Value)
Set the color channel value of a color.

CreateFromHex (Hex) ​

This function returns a color created from a hexadecimal string.

Parameters ​

  • Hex: hexadecimal string with optional leading #

Returns ​

The new color

Since ​

Version 1.0

Example ​

lua
color = FxColor.CreateFromHex("e6482e");

CreateFromRGB (R, G, B) ​

This function returns a color created from RGB values.

Parameters ​

  • R: The red channel value
  • G: The green channel value
  • B: The blue channel value

Returns ​

The new color

Since ​

Version 1.0

Example ​

lua
color = FxColor.CreateFromRGB(230, 72, 46);

GetR (Color)
GetG (Color)
GetB (Color) ​

These functions return the color channel value of the specified color.

Parameters ​

  • Color: The color value

Returns ​

Value of a color channel depending on the function used

Since ​

Version 1.0

Example ​

lua
color = FxColor.CreateFromHex("e6482e");
r = FxColor.GetR(color); -- the value of r is 230

SetR (Color, Value)
SetG (Color, Value)
SetB (Color, Value) ​

These functions set the color channel value of the specified color and return the new color.

Parameters ​

  • Color: The color value
  • Value: The new color channel value

Returns ​

The new color

Since ​

Version 1.0

Example ​

lua
color = FxColor.CreateFromHex("e6482e");
color = FxColor.SetR(color, 200);