API:ColorPickerAddColor
From RoR Wiki
UI Lua API · ColorPicker functions
Version: WAR 1.4.8
Adds one colour swatch to a ColorPicker, in the next free grid position.
ColorPickerAddColor(colorPickerName, r, g, b, id)
Arguments
- colorPickerName
string– Name of the ColorPicker.- r, g, b
number– Colour components on a 0–255 scale.- id
number– Your identifier for the colour. It is converted to a whole number and returned by ColorPickerGetColorAtPoint and ColorPickerGetColorById.
Returns
Nothing.
Details
- Colours added this way are placed in a grid, left to right and then top to bottom. The n-th automatically placed colour (counting from 0) goes to column
n % columnsPerRowand rowfloor(n / columnsPerRow). Its position isx = column * (colorWidth + spacingX),y = row * (colorHeight + spacingY), using the values from ColorPickerGetColorSize and ColorPickerGetColorSpacing. - The swatch is drawn fully opaque. There is no alpha argument.
- Several colours may share the same
id. The lookup functions return the first match. - The stock UI never calls this function; it uses ColorPickerCreateWithColorTable.
Errors
Error in function call 'ColorPickerAddColor': Window %s does not existError in function call 'ColorPickerAddColor': Window %s is not a ColorPicker
Example
A minimal example built from the signature:
ColorPickerClear( "MyColorPicker" ) ColorPickerAddColor( "MyColorPicker", 255, 0, 0, 1 ) -- red ColorPickerAddColor( "MyColorPicker", 0, 255, 0, 2 ) -- green
