Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

Color operations
[Basic Components]


Detailed Description

color operations

Author:
benjamin gerard


Files

file  color.lua
 color type.

file  rgb.lua
 rbg color table name conversion.


Functions

 color_new (var a, var r, var g, var b, var noclip)
 Create a new color object.

 color_copy (var c, var s, var noalpha)
 Copy a color.

 color_clip (var c, var min, var max)
 Clip color components.

 color_lum (var c)
 Get color luminosity.

 color_max (var c)
 Get index of first hightest component.

 color_min (var color)
 Get index of first lowest component.

 color_maximize (var c)
 Scale color to have the highest component equal to 1.

 color_tostring (var c)
 Transform color to string (#AARRBBGG).

 color_tohexa (var c)
 Transform color to string (#AARRBBGG).

 color_concat (var a, var b)
 color "concat" tag method.

 color_index (var c, var i)
 color "index" tag method.

 color_settable (var c, var i, var v)
 color "settable" tag method.

 tostring (var c)
 color_add (var a, var b)
 color "add" tag method; "+" operator.

 color_sub (var a, var b)
 color "sub" tag method; "-" operator.

 color_mul (var a, var b)
 color "mul" tag method; "*" operator.

 color_div (var a, var b)
 color "div" tag method; "/" operator.

 color_minus (var a, var b)
 color "minus" tag method; unary "-" operator.

 color_abs (var c)
 Absolutes color components.

 color_distant (var c, var alt)
 Get a distant color.

 color_sort (var c)
 Descending sort R,G,B components.


Variables

color rgb_color_table [name]
 color name table.


Function Documentation

color_new var  a,
var  r,
var  g,
var  b,
var  noclip
 

Create a new color object.

Creates a new color object from either four numbers or a table of four numbers or a string. Default value is 1 for all components.

table can be any table. rawget() function is used to retrieve color components with index 1,2,3,4 for respectively a,r,g,b components.

string := "COLOR-NAME". Picks the rgb_color_table[COLOR-NAME], if it exists. This conversion is prior to the hexadecimal string conversion which mean it is possible to short circuit an hexadecimal value to another color.

string := "[#][AA]RRGGBB". This is an hexacimal description of the color. It may start by an optional '#' char. Alpha componant is optionnal and its default value is 1.

Warning:
With table or string creation methods the noclip parameter is in 2nd position.
Parameters:
a alpha component or a table or a string.
r red component
g green component
b blue component
noclip prevents [0..1] clipping is not nil.
Returns:
a new color table.

color_copy var  c,
var  s,
var  noalpha
 

Copy a color.

Parameters:
c destination color or nil for a new color.
s source color.
noalpha Prevents alpha component copy if not nil.
Returns:
c or a new color table.

color_clip var  c,
var  min,
var  max
 

Clip color components.

Parameters:
c Color to clip
min Minimum clipping value or nil for no minimum
max Maximum clipping value or nil for no maximum
Returns:
c

color_lum var  c  ) 
 

Get color luminosity.

Parameters:
c Color.
Returns:
number

color_max var  c  ) 
 

Get index of first hightest component.

Parameters:
c Color.
Returns:
index

color_min var  color  ) 
 

Get index of first lowest component.

Parameters:
c Color.
Returns:
index

color_maximize var  c  ) 
 

Scale color to have the highest component equal to 1.

Parameters:
c Color.
Returns:
c

color_tostring var  c  ) 
 

Transform color to string (#AARRBBGG).

Parameters:
c Color.
Returns:
string

color_tohexa var  c  ) 
 

Transform color to string (#AARRBBGG).

This function works kike color_tostring() except it always return a string. The default value is "#00000000".

Parameters:
c Color.
Returns:
string

color_concat var  a,
var  b
 

color "concat" tag method.

Parameters:
a concat left operand
b concat right operand
Returns:
string

color_index var  c,
var  i
 

color "index" tag method.

Parameters:
c color
i an index (valid values are "a","r","g","b")
Returns:
color component

color_settable var  c,
var  i,
var  v
 

color "settable" tag method.

Parameters:
c color
i index [1..4] or ["a","r","g","b"]
v component new value

color_add var  a,
var  b
 

color "add" tag method; "+" operator.

Parameters:
a left operand (color or number)
b right operand (color or number)
Returns:
color
See also:
table_add()

color_sub var  a,
var  b
 

color "sub" tag method; "-" operator.

Parameters:
a left operand (color or number)
b right operand (color or number)
Returns:
color
See also:
table_sub()

color_mul var  a,
var  b
 

color "mul" tag method; "*" operator.

Parameters:
a left operand (color or number)
b right operand (color or number)
Returns:
color
See also:
table_mul()

color_div var  a,
var  b
 

color "div" tag method; "/" operator.

Parameters:
a left operand (color or number)
b right operand (color or number)
Returns:
color
See also:
table_div()

color_minus var  a,
var  b
 

color "minus" tag method; unary "-" operator.

Parameters:
a left operand (color or number)
b right operand (color or number)
Returns:
color
See also:
table_minus()

color_abs var  c  ) 
 

Absolutes color components.

Parameters:
c color
Returns:
c with each component as the absolute value of its former value.

color_distant var  c,
var  alt
 

Get a distant color.

Parameters:
c color
alt alternate color. If nil alt is the one's complement color.
Returns:
color which should be distant from the colorc.

color_sort var  c  ) 
 

Descending sort R,G,B components.

Parameters:
c color
Returns:
a table with the index of the componant at this raw.
e.g { 0.3, 0.1, 0.8, 0.2 } => { 3, 1, 4, 2 }


dcplaya documentation version 2.0 Generated on November 2004 by doxygen 1.3.6