Specifying colors by name
Common Graphics provides a selection of predefined named colors. The RGB values of these colors are stored in an internal database and can be referenced by name at any time by an application. A subset of these named colors is listed in the following table:
Table 21. A subset of the predefined named colors
aquamarine | black | blue |
blue violet | brown | cadet blue |
coral | cornflower blue | cyan |
dark green | dark olive green | dark orchid |
dark slate blue | dark slate gray | dark turquoise |
dim gray | firebrick | forest green |
gold | gray0 | gray10 |
gray100 | gray20 | gray30 |
gray40 | gray50 | gray60 |
gray70 | gray80 | gray90 |
green | green yellow | indian red |
khaki | light blue | light steel blue |
lime green | magenta | maroon |
medium aquamarine | medium blue | medium forest green |
medium goldenrod | medium orchid | medium sea green |
medium slate blue | medium spring green | medium turquoise |
medium violet red | navy blue | orange |
orange red | orchid | pale green |
pink | plum | red |
salmon | sandy brown | sea green |
sienna | sky blue | slate blue |
spring green | steel blue | tan |
thistle | turquoise | violet |
violet red | wheat | white |
yellow | | |
The RGB values of a named color can be looked up in the color database by sending the lookupColor: message to a CgScreen. The method is passed the color name to look up. The result is the corresponding CgRGBColor, if the color name was found in the database, or nil if the name was not found.
| color |
color := CgScreen default lookupColor: 'orange'.
Transcript cr; show: color printString.
This code prints a string such as aCgRGBColor(16rFFFF, 16rA5A5, 16r0000) on the Transcript Window. The actual values can differ, depending on the platform.
Last modified date: 05/12/2020