Color
A color composed of components (R, G, B, A) with floating point precision.
info
Tip: This structure is Open Sourced at https://github.com/nanos-world/nanos-world-lua-lib. Feel free to push merge requests and suggest changes!
tip
Note: This structure supports +
, -
, *
, /
, ==
, and tostring
operations.
Usageβ
local grey_color = Color(0.5, 0.5, 0.5, 1)
Propertiesβ
Value | Name | Description |
---|---|---|
number | R | Red color percentage (0-1) |
number | G | Green color percentage (0-1) |
number | B | Blue color percentage (0-1) |
number | A | Alpha transparency percentage (0-1) |
Static Propertiesβ
Value | Name |
---|---|
Color(1, 1, 1) | Color.WHITE |
Color(0, 0, 0) | Color.BLACK |
Color(0, 0, 0, 0) | Color.TRANSPARENT |
Color(1, 0, 0) | Color.RED |
Color(0, 1, 0) | Color.GREEN |
Color(0, 0, 1) | Color.BLUE |
Color(1, 1, 0) | Color.YELLOW |
Color(0, 1, 1) | Color.CYAN |
Color(1, 0, 1) | Color.MAGENTA |
Color(1, 0.5, 0) | Color.ORANGE |
Color(0.5, 1, 1) | Color.CHARTREUSE |
Color(0, 1, 0.5) | Color.AQUAMARINE |
Color(0, 0.5, 1) | Color.AZURE |
Color(0.5, 0, 1) | Color.VIOLET |
Color(1, 0, 0.5) | Color.ROSE |
Static Functionsβ
Returns | Name | Description |
---|---|---|
Color | Color.RandomPalette() | Returns a random color from Color Palette |
Color | Color.Random() | Returns a random color from all color scope |
Color | Color.FromRGBA(number r, number g, number b, number a) | Returns the color from 0-255 range values |
Color | Color.FromCYMK(number c, number y, number m, number k, number a) | Returns a color from the CYMK format |
Color | Color.FromHSL(number h, number s, number l) | Returns a color from the HSL format |
Color | Color.FromHSV(number h, number s, number v) | Returns a color from the HSV format |
Color | Color.FromHEX(string hex) | Returns a color from the Hexadecimal format |
Functionsβ
Returns | Name | Description |
---|---|---|
string | ToHEX() | Gets the Hexadecimal representation of this Color |