Colors can be specified or returned as AutoCAD color indexes (ACIs) or true colors.
By true colors we mean 24-bit color: three RGB components, 8 bits each, with no alpha component (that is, no transparency value).
ACI Colors
The valid ACI formats are
Color Indexes, integer strings from 0 through 256. For example, "123". Note that indexes 0 and 256 do not specify colors literally, as 1 through 255 do, but logically. See "Logical Colors" below.
Color Names, which correspond to indexes 1 through 7. The color names are red, yellow, green, cyan, blue, magenta, and white. For example, "yellow" (always double-quoted).
Logical Colors, which correspond to indexes 0 and 256. The logical colors are ByBlock and ByLayer. For example, "ByBlock" (always double-quoted). Note that ByBlock and ByLayer can return true colors or ACIs.
For more information about ACI colors, see Color Index Colors.
True Colors
The valid true-color formats are
RGB Triplets, where each component is an integer from 0 through 255. For example, "255,0,0". RGB triplets are wrapped in double quotes except when they are used in query conditions, in which case they must always be wrapped in escaped double quotes ('\"'). See "Color Patterns" below.
Color Book Colors, such as "Pantone, 123 CVC", a composite of two comma-separated names representing a Color Book and a color within it. Color book strings are wrapped in double quotes except when they are used in query conditions, in which case they must always be wrapped in escaped double quotes ('\"'). See "Color Patterns" below. And no matter where they are used, color book strings must always be wrapped in escaped double quotes if they contain certain special characters. If you are unsure if a color book string contains special characters, there is no harm wrapping it in escaped double quotes just to be sure.
Expressions, such as ".COLOR" or ".TRUECOLOR" (always double-quoted). ".COLOR" always returns an ACI color. If the selected object's color is a true color it returns the nearest ACI equivalent. ".TRUECOLOR" returns a true color if the selected object's color is a true color, or an ACI if its color is an ACI. Note that ".TRUECOLOR", and other expressions that can return true colors, return in valid format only if the type argument of (ade_expreval) is "string".
Color Patterns, comma-separated lists of colors in any of the valid formats, including ACI colors, always double-quoted. Color patterns are used to express multiple color conditions in compact format. Consider the color pattern "red, green". The pseudocode expression, color = "red,green", is logically equivalent to (color = "red") OR (color = "green"). Similarly, color <> "red,green" is logically equivalent to (color <> "red") AND (color <> "green"). Because color patterns are comma-separated lists, Color Book colors and RGB colors in query conditions are always bounded by escaped double quotes ('\"') because they are themselves comma-separated. For example, the following color pattern includes six colors: three ACIs, one RGB, and one Color Book color.
"12,34,56,\"12,34,56\",\"Pantone, 123 CVC\""
Note You can use wildcard characters when you specify a match string for Color Book colors (but not for RGB colors). For this reason, any wildcard character in a Color Book string that is meant to be taken literally must be escaped using a backquote, "`". For example, the "." character in the following string, normally a wildcard matching any non-alphanumeric character, is meant as a literal: "My`.Colors, Hot".