-
Notifications
You must be signed in to change notification settings - Fork 3
Lua API: Color
The Color structure encompasses information about a given color, as well as providing conveinence functions for constructing common colors.
The Color structure is a fundamental structure within the Kestrel Engine, but doesn't currently serve much purpose within the Lua API. To generate a Color structure you have two choices. Manually construct it, or use a premade common color.
When manually constructing a color, you are specifying the red, green, blue and alpha components of the color, and these values are expected to be values ranging from 0.0 to 1.0. Kestrel will then handle the scaling of this value depending on the context and color space.
local textColor = Color(1.0, 0.0, 0.5, 1.0) -- a purplish colorKestrel provides a number of premade colors for use. Whilst the vast majority of these are unlikely to de used for production purposes, they can serve nicely for debug purposes.
local textColor = Color.orange()The following methods are exposed on the Color class.
| Method Name | Return Type | Lua API Version |
|---|---|---|
whiteColor(Integer, Integer) |
Color |
v0.0.1 |
rgb(Integer, Integer, Integer, Integer) |
Color |
v0.0.1 |
colorValue(Integer) |
Color |
v0.0.1 |
white() |
Color |
v0.0.1 |
lightGrey() |
Color |
v0.0.1 |
grey() |
Color |
v0.0.1 |
darkGrey() |
Color |
v0.0.1 |
black() |
Color |
v0.0.1 |
red() |
Color |
v0.0.1 |
orange() |
Color |
v0.0.1 |
yellow() |
Color |
v0.0.1 |
lime() |
Color |
v0.0.1 |
green() |
Color |
v0.0.1 |
teal() |
Color |
v0.0.1 |
blue() |
Color |
v0.0.1 |
magenta() |
Color |
v0.0.1 |
Returns a new greyscale Color structure using the specified white intensity value (0 to 255) and the alpha value (0 to 255).
Returns a new RGB Color structure using the specified red intensity value (0 to 255), green intensity value (0 to 255), blue intensity value (0 to 255) and the alpha value (0 to 255).
Returns a new RGB Color structure using the specified 32bit color value (format of 0xAARRGGBB) as a basis for each of the component values.
Returns a white color.
Returns a light grey color.
Returns a grey color.
Returns a dark grey color.
Returns a black color.
Returns a red color.
Returns an orange color.
Returns a yellow color.
Returns a lime color.
Returns a green color.
Returns a teal color.
Returns a blue color.
Returns a magenta color.
The following properties are exposed on Color instances.
| Property Name | Type | Access | Lua API Version |
|---|---|---|---|
red |
Integer |
Set, Get | v0.0.1 |
green |
Integer |
Set, Get | v0.0.1 |
blue |
Integer |
Set, Get | v0.0.1 |
alpha |
Integer |
Set, Get | v0.0.1 |
Returns or sets the red component value for the color.
Returns or sets the green component value for the color.
Returns or sets the blue component value for the color.
Returns or sets the alpha component value for the color.