LiteCAD Colors Home

LiteCAD color can be a true color (24-bit RGB value) or index of a color palette. In objects properties it is represented as a text string. If a text string has 3 digital values (0-255) separated by commas, then color is a true color. If one value (1-255) - index color. On input, index value can be replaced by color name. Litecad recognises the following color names:
"red"   (same as "1")
"yellow"   (same as "2")
"green"   (same as "3")
"cyan"   (same as "4")
"blue"   (same as "5")
"magenta"   (same as "6")
"foreground"   (same as "7")
"gray"   (same as "8")
"ltgray"   (same as "9")
Also, for graphic objects, a special words can be used - "ByLayer" and "ByBlock".
"ByLayer" means the color assigned to a Layer will dictate the color of an object found on that particular Layer.
"ByBlock" means the color assigned to a Block Reference object will dictate the color of an object added to the Block. If the object is not a part of block but has the "ByBlock" color assigned to it, the foreground color will be used to draw the object.
Foreground color is defined by the LC_PROP_G_COLORFOREM and LC_PROP_G_COLORFOREP property.

The following functions help to retrieve color components from the color text string.

Function Meaning
lcColorIsRGB Determines if a color is RGB color or index
lcColorGetRed Returns Red component of a color
lcColorGetGreen Returns Green component of a color
lcColorGetBlue Returns Blue component of a color
lcColorGetIndex Returns color index
lcColorToVal Converts color value from string into integer components

You can see LiteCAD color palette and find RGB color for any index if run Litecad.exe program, and select menu item "Format / Colors..."
Indices 1 - 255 represent RGB colors, 0 and 256 - logical colors "ByBlock" and "ByLayer"

In order to access LiteCAD color palette programmatically use the following functions:

Function Meaning
lcColorSetPalette Sets RGB color for the palette index
lcColorGetPalette Returns palette RGB color for specified index
lcColorSavePalette Saves palette into a file
lcColorLoadPalette Loads palette from a file

In the "Select Color" dialog you can right click in the palette area - popup menu will appear and you can load/save palette (see the picture below).

Color constants, that can be assigned to properties LC_PROP_ENT_COLORI, LC_PROP_ENT_FCOLORI, LC_PROP_DRW_COLORI, LC_PROP_DRW_FCOLORI :

Constant Color
LC_COLOR_RED Red
LC_COLOR_YELLOW Yellow
LC_COLOR_GREEN Green
LC_COLOR_CYAN Cyan
LC_COLOR_BLUE Blue
LC_COLOR_MAGENTA Magenta
LC_COLOR_FOREGROUND Foreground (contrast to background color)
LC_COLOR_GRAY Gray
LC_COLOR_LTGRAY Light gray

Logical colors for entities
LC_COLOR_BYBLOCK By block
LC_COLOR_BYLAYER By layer
LC_COLOR_WIPEOUT Same as window background


Samples:
lcPropPutStr( hLayer, LC_PROP_LAYER_COLOR, L"200,170,255" );
lcPropPutStr( hEnt, LC_PROP_ENT_COLOR, L"ByLayer" );
lcPropPutStr( hEnt, LC_PROP_ENT_COLOR, L"red" );
lcPropPutStr( hEnt, LC_PROP_ENT_COLOR, L"56" );

WCHAR szColor[32];
int   bRGB, Index, R, G, B;
wcscpy( szColor, lcPropGetStr(hEnt,LC_PROP_ENT_COLOR) );
lcColorToVal( szColor, &bRGB, &Index, &R, &G, &B );

Palette popup menu: