![]() |
naev 0.12.6
|
Handles colours. More...
#include "nlua_colour.h"#include "nluadef.h"
Go to the source code of this file.
Functions | |
| static int | colL_eq (lua_State *L) |
| Compares two colours to see if they are the same. | |
| static int | colL_tostring (lua_State *L) |
| Converts a colour to a string. | |
| static int | colL_new (lua_State *L) |
| Creates a new colour. Colours are assumed to be in gamma colourspace by default and are converted to linear unless specified. | |
| static int | colL_newHSV (lua_State *L) |
| Creates a new colour from HSV values. Colours are assumed to be in gamma colourspace by default and are converted to linear unless specified. | |
| static int | colL_alpha (lua_State *L) |
| Gets the alpha of a colour. | |
| static int | colL_rgb (lua_State *L) |
| Gets the RGB values of a colour. | |
| static int | colL_rgba (lua_State *L) |
| Gets the RGBA values of a colour. | |
| static int | colL_hsv (lua_State *L) |
| Gets the HSV values of a colour. | |
| static int | colL_setrgb (lua_State *L) |
| Sets the colours values from the RGB colourspace. | |
| static int | colL_sethsv (lua_State *L) |
| Sets the colours values from the HSV colourspace. | |
| static int | colL_setalpha (lua_State *L) |
| Sets the alpha of a colour. | |
| static int | colL_linearToGamma (lua_State *L) |
| Converts a colour from linear to gamma corrected. | |
| static int | colL_gammaToLinear (lua_State *L) |
| Converts a colour from gamma corrected to linear. | |
| int | nlua_loadCol (nlua_env env) |
| Loads the colour library. | |
| glColour * | lua_tocolour (lua_State *L, int ind) |
| Lua bindings to interact with colours. | |
| glColour * | luaL_checkcolour (lua_State *L, int ind) |
| Gets colour at index or raises error if there is no colour at index. | |
| glColour * | lua_pushcolour (lua_State *L, glColour colour) |
| Pushes a colour on the stack. | |
| int | lua_iscolour (lua_State *L, int ind) |
| Checks to see if ind is a colour. | |
Variables | |
| static const luaL_Reg | colL_methods [] |
Handles colours.
Definition in file nlua_colour.c.
|
static |
Gets the alpha of a colour.
Value is from from 0. (transparent) to 1. (opaque).
Lua usage parameter: colour_alpha = col:alpha()
Lua function parameter: Colour col Colour to get alpha of. Lua return parameter: number The alpha of the colour.
| L | Lua State |
Lua function: alpha
Definition at line 285 of file nlua_colour.c.
|
static |
Compares two colours to see if they are the same.
Lua function parameter: Colour c1 Colour 1 to compare. Lua function parameter: Colour c2 Colour 2 to compare. Lua return parameter: boolean true if both colours are the same.
| L | Lua State |
Lua function: __eq
Definition at line 151 of file nlua_colour.c.
|
static |
Converts a colour from gamma corrected to linear.
Lua function parameter: Colour col Colour to change from gamma corrected to linear. Lua return parameter: Colour Modified colour.
Definition at line 477 of file nlua_colour.c.
|
static |
Gets the HSV values of a colour.
Values are from 0 to 1 except hue which is 0 to 360.
Lua usage parameter: h,s,v = col:rgb()
Lua function parameter: Colour col Colour to get HSV values of. Lua function parameter:[opt=false] boolean gamma Whether or not to get the gamma-corrected value or not. Lua return parameter: number The hue of the colour (0-360 value). Lua return parameter: number The saturation of the colour (0-1 value). Lua return parameter: number The value of the colour (0-1 value).
| L | Lua State |
Lua function: hsv
Definition at line 369 of file nlua_colour.c.
|
static |
Converts a colour from linear to gamma corrected.
Lua function parameter: Colour col Colour to change from linear to gamma. Lua return parameter: Colour Modified colour.
Definition at line 459 of file nlua_colour.c.
|
static |
Creates a new colour. Colours are assumed to be in gamma colourspace by default and are converted to linear unless specified.
Lua usage parameter: colour.new( "Red" ) – Gets colour by name Lua usage parameter: colour.new( "Red", 0.5 ) – Gets colour by name with alpha 0.5 Lua usage parameter: colour.new() – Creates a white (blank) colour Lua usage parameter: colour.new( 1., 0., 0. ) – Creates a bright red colour Lua usage parameter: colour.new( 1., 0., 0., 0.5 ) – Creates a bright red colour with alpha 0.5
Lua function parameter: number r Red value of the colour. Lua function parameter: number g Green value of the colour. Lua function parameter: number b Blue value of the colour. Lua function parameter:[opt=1.] number a Alpha value of the colour. Lua function parameter:[opt=false] gamma Whether to load the colour in the gamma colourspace. Lua return parameter: Colour A newly created colour.
| L | Lua State |
Lua function: new
Definition at line 197 of file nlua_colour.c.
|
static |
Creates a new colour from HSV values. Colours are assumed to be in gamma colourspace by default and are converted to linear unless specified.
Lua usage parameter: colour.new( 0., 0.5, 0.5 ) – Creates a colour with 0 hue, 0.5 saturation and 0.5 value.
Lua function parameter: number h Hue of the colour (0-360 value). Lua function parameter: number s Saturation of the colour (0-1 value). Lua function parameter: number v Value of the colour (0-1 value). Lua function parameter:[opt=1.] number a Alpha value of the colour. Lua function parameter:[opt=false] gamma Whether to load the colour in the gamma colourspace. Lua return parameter: Colour A newly created colour.
| L | Lua State |
Lua function: newHSV
Definition at line 251 of file nlua_colour.c.
|
static |
Gets the RGB values of a colour.
Values are from 0. to 1.
Lua usage parameter: r,g,b = col:rgb()
Lua function parameter: Colour col Colour to get RGB values of. Lua function parameter:[opt=false] boolean gamma Whether or not to get the gamma-corrected value or not. Defaults to internal value that is linear. Lua return parameter: number The red value of the colour. Lua return parameter: number The green value of the colour. Lua return parameter: number The blue value of the colour.
| L | Lua State |
Lua function: rgb
Definition at line 307 of file nlua_colour.c.
|
static |
Gets the RGBA values of a colour.
Values are from 0. to 1.
Lua usage parameter: r,g,b,a = col:rgba()
Lua function parameter: Colour col Colour to get RGB values of. Lua function parameter:[opt=false] boolean gamma Whether or not to get the gamma-corrected value or not. Lua return parameter: number The red value of the colour. Lua return parameter: number The green value of the colour. Lua return parameter: number The blue value of the colour. Lua return parameter: number The alpha value of the colour.
| L | Lua State |
Lua function: rgba
Definition at line 338 of file nlua_colour.c.
|
static |
Sets the alpha of a colour.
Value is from 0. (transparent) to 1. (opaque).
Lua usage parameter: col:setAlpha( 0.5 ) – Make colour half transparent
Lua function parameter: Colour col Colour to set alpha of. Lua function parameter: number alpha Alpha value to set.
| L | Lua State |
Lua function: setAlpha
Definition at line 446 of file nlua_colour.c.
|
static |
Sets the colours values from the HSV colourspace.
Values are from 0. to 1.
Lua usage parameter: col:setHSV( h, s, v )
Lua function parameter: Colour col Colour to set HSV values. Lua function parameter: number h Hue value to set. Lua function parameter: number s Saturation value to set. Lua function parameter: number v Value to set.
| L | Lua State |
Lua function: setHSV
Definition at line 424 of file nlua_colour.c.
|
static |
Sets the colours values from the RGB colourspace.
Values are from 0. to 1.
Lua usage parameter: col:setRGB( r, g, b )
Lua function parameter: Colour col Colour to set RGB values. Lua function parameter: number r Red value to set. Lua function parameter: number g Green value to set. Lua function parameter: number b Blue value to set.
| L | Lua State |
Lua function: setRGB
Definition at line 402 of file nlua_colour.c.
|
static |
Converts a colour to a string.
Lua function parameter: Colour col Colour to get string from. Lua return parameter: string A string representing the colour.
| L | Lua State |
Lua function: __tostring
Definition at line 167 of file nlua_colour.c.
| int lua_iscolour | ( | lua_State * | L, |
| int | ind ) |
Checks to see if ind is a colour.
| L | Lua state to check. |
| ind | Index position to check. |
Definition at line 127 of file nlua_colour.c.
| glColour * lua_pushcolour | ( | lua_State * | L, |
| glColour | colour ) |
Pushes a colour on the stack.
| L | Lua state to push colour into. |
| colour | Colour to push. |
Definition at line 112 of file nlua_colour.c.
| glColour * lua_tocolour | ( | lua_State * | L, |
| int | ind ) |
Lua bindings to interact with colours.
An example would be:
Colours are assumed to be given as gamma-corrected values and are stored internally in linear colourspace by default. Most functions have a boolean parameter that allows controlling this behaviour.
Lua module: colour
Gets colour at index.
| L | Lua state to get colour from. |
| ind | Index position to find the colour. |
Definition at line 87 of file nlua_colour.c.
| glColour * luaL_checkcolour | ( | lua_State * | L, |
| int | ind ) |
Gets colour at index or raises error if there is no colour at index.
| L | Lua state to get colour from. |
| ind | Index position to find colour. |
Definition at line 98 of file nlua_colour.c.
| int nlua_loadCol | ( | nlua_env | env | ) |
Loads the colour library.
| env | Environment to load colour library into. |
Definition at line 57 of file nlua_colour.c.
|
static |
Colour metatable methods.
Definition at line 35 of file nlua_colour.c.