ColorPicker

The ColorPicker is a specialized UI element that allows you to add a number of colors to a single UI element.

Summary
ColorPickerThe ColorPicker is a specialized UI element that allows you to add a number of colors to a single UI element.
XML DefinitionThis is the ColorPicker xml definition.
XML Tag
Attributes
textureName of the Ui Texture to display.
columnsPerRowAllows you to specify how many colors you wish to have in a row.
Elements
ColorTexCoordsThe texture coordinates for the top left of the image on the texture.
ColorTexDimsThe texture dimensions of the image to use for colors.
ColorSizeThe width and height of each color.
ColorSpacingThe amount of space (in pixels) in between each color on the x and y.
Window CallbacksThese are the ColorPicker specific callback events.
Callbacks
OnPointMouseOverCalled when the user mouses over a color point.
Functions
ColorPickerGetCoordinatesForColor()Retrieves a color based on a point clicked on the color picker.
ColorPickerGetColorAtPoint()Retrieves a color based on a point clicked on the color picker.
ColorPickerGetColorById()Retrieves a color based on a point clicked on the color picker.
ColorPickerCreateWithColorTable()Creates a color
ColorPickerAddColor()Creates a color
ColorPickerAddColorAtPosition()Creates a color
ColorPickerClear()Clear all the colors from a color picker.
ColorPickerGetColorSpacing()Retrieves the color spacing of a given color picker.
ColorPickerGetTexDims()Retrieves the color size of a given color picker.
ColorPickerGetColorSize()Retrieves the color size of a given color picker.

XML Definition

This is the ColorPicker xml definition.

Summary
XML Tag
Attributes
textureName of the Ui Texture to display.
columnsPerRowAllows you to specify how many colors you wish to have in a row.
Elements
ColorTexCoordsThe texture coordinates for the top left of the image on the texture.
ColorTexDimsThe texture dimensions of the image to use for colors.
ColorSizeThe width and height of each color.
ColorSpacingThe amount of space (in pixels) in between each color on the x and y.

XML Tag

<ColorPicker>
....
</ColorPicker>

Attributes

texture

Name of the Ui Texture to display.

Expects

A string value, which is the name of a valid ui Texture.

Default Value

  • ””

columnsPerRow

Allows you to specify how many colors you wish to have in a row.

Expects

An integer value.

Default Value

  • 1

Elements

ColorTexCoords

The texture coordinates for the top left of the image on the texture.

Syntax

<ColorTexCoords x="100" y="200" />
xThe x pixel coordinate of the top left of the image.
yThe y pixel coordinate of the top left of the image.

Defaults

x0
y0

ColorTexDims

The texture dimensions of the image to use for colors.  If no ColorTexDims are specified and a texture is specified

Syntax

<ColorTexDims x="100" y="100" />
xThe x pixel texture size.
yThe y pixel texture size.

Defaults

x0
y0

ColorSize

The width and height of each color.

Syntax

<ColorSize x="100" y="100" />
xThe x pixel color size.
yThe y pixel color size.

Defaults

x1
y1

ColorSpacing

The amount of space (in pixels) in between each color on the x and y.

Syntax

<TexDims x="100" y="100" />
xThe x amount of space.
yThe y amount of space.

Defaults

x0
y0

Window Callbacks

These are the ColorPicker specific callback events.

Summary
Callbacks
OnPointMouseOverCalled when the user mouses over a color point.
Functions
ColorPickerGetCoordinatesForColor()Retrieves a color based on a point clicked on the color picker.
ColorPickerGetColorAtPoint()Retrieves a color based on a point clicked on the color picker.
ColorPickerGetColorById()Retrieves a color based on a point clicked on the color picker.
ColorPickerCreateWithColorTable()Creates a color
ColorPickerAddColor()Creates a color
ColorPickerAddColorAtPosition()Creates a color
ColorPickerClear()Clear all the colors from a color picker.
ColorPickerGetColorSpacing()Retrieves the color spacing of a given color picker.
ColorPickerGetTexDims()Retrieves the color size of a given color picker.
ColorPickerGetColorSize()Retrieves the color size of a given color picker.

Callbacks

OnPointMouseOver

Called when the user mouses over a color point.

Syntax

SomeMapWindow.OnPointMouseOver(r, g, b, id)

Functions

ColorPickerGetCoordinatesForColor()

Retrieves a color based on a point clicked on the color picker.

Parameters

ColorPickerWindowName(string) The name of the color picker.
r(number) The r value of the color.
g(number) The g value of the color.
b(number) The b value of the color.

Returns

left, top(number) Coordinates x,y position of the topleft point Color Rect on the Color Picker window.

Example

local left, top = ColorPickerGetCoordinatesForColor( “myColorPicker”, r, g, b )

ColorPickerGetColorAtPoint()

Retrieves a color based on a point clicked on the color picker.

Parameters

ColorPickerWindowName(string) The name of the color picker.
x(number) The x position of the mouse click.
y(number) The y position of the mouse click.

Returns

color(table) containing the r, g, and b values of the color, the id and the x, y position of the top left of the color or nil if a color was not picked.

Example

local color = ColorPickerGetColorAtPoint( “myColorPicker”, x, y )

ColorPickerGetColorById()

Retrieves a color based on a point clicked on the color picker.

Parameters

ColorPickerWindowName(string) The name of the color picker.
Id(number) The user specified Id of the color.

Returns

r(number) The red value of the color.
g(number) The green value of the color.
b(number) The blue value of the color.
id(number) The id of the color.
x(number) The x postion of the color.
y(number) The y postion of the color.

Note:Will return nil if no color is found.

Example

local color = ColorPickerGetColorById( “myColorPicker”, colorId )

ColorPickerCreateWithColorTable()

Creates a color

Parameters

ColorPickerWindowName(string) The name of the color picker.
Colors(table) A table of color tables with color information (r, g, b) and their ids.  The id is user defined and has no actually significance to the color picker, but it is a useful way to track colors in lua without having to compare each r, g, b values.  Each color table can also contain optional x, y coordinates of the colors top left corner.  The order with which the colors are placed is dependent upon the order of the table.  Example: Colors = { {r=143, g=57, b=54, id=5 }, {r=50, g=10, b=113, id=17, x=100, y=200}, ...  }
Stride(number) The number of color columns per row.
OffsetX(number) The amount of pixels between each color on the x axis.
OffsetY(number) The amount of pixels between each color on the y axis.

Returns

none

Example

ColorPickerCreateWithColorTable( “myColorPicker”, Colors, 4, 5, 5 )

ColorPickerAddColor()

Creates a color

Parameters

ColorPickerWindowName(string) The name of the color picker.
r(number) the red value of the color (0 to 255).
g(number) the green value of the color (0 to 255).
b(number) the blue value of the color (0 to 255).
id(number) a user defined id that can be specified with the color, these ids do not have to be unique.

Returns

none

Example

ColorPickerAddColor( “myColorPicker”, 115, 40, 213, 1 )

ColorPickerAddColorAtPosition()

Creates a color

Parameters

ColorPickerWindowName(string) The name of the color picker.
r(number) the red value of the color (0 to 255).
g(number) the green value of the color (0 to 255).
b(number) the blue value of the color (0 to 255).
id(number) a user defined id that can be specified with the color, these ids do not have to be unique.
x(number) the left corner of where the color is to be positioned.
y(number) the top corner of where the color is to be positioned.

Returns

none

Example

ColorPickerAddColorAtPosition( “myColorPicker”, 115, 40, 213, 1, 0, 0 )

ColorPickerClear()

Clear all the colors from a color picker.

Parameters

ColorPickerWindowName(string) The name of the color picker.

Returns

none

Example

ColorPickerClear( “myColorPicker” )

ColorPickerGetColorSpacing()

Retrieves the color spacing of a given color picker.

Parameters

ColorPickerWindowName(string) The name of the color picker.

Returns

x(number) The x spacing of a single color in the color picker.
y(number) The y spacing of a single color in the color picker.

Example

local x, y = ColorPickerGetColorSpacing( “myColorPicker” )

ColorPickerGetTexDims()

Retrieves the color size of a given color picker.

Parameters

ColorPickerWindowName(string) The name of the color picker.

Returns

width(number) The width of a single color’s texture in the color picker.
height(number) The height of a single color’s texture in the color picker.

Example

local width, height = ColorPickerGetTexDims( “myColorPicker” )

ColorPickerGetColorSize()

Retrieves the color size of a given color picker.

Parameters

ColorPickerWindowName(string) The name of the color picker.

Returns

width(number) The width of a single color in the color picker.
height(number) The height of a single color in the color picker.

Example

local width, height = ColorPickerGetColorSize( “myColorPicker” )

This element defines a single art texture component.
Name of the Ui Texture to display.