Programmer Reference : Common Graphics : Specifying colors : Parsing a color-specification string
Parsing a color-specification string
A color-specification string consists either of a color name or a pound character (#) followed by a 3-, 6-, or 12-hex digit specification of the color's red, green, and blue intensities. The following examples specify various approximations of the color magenta: 'magenta', '#F0F', '#FF00FF', '#FFFF0000FFFF'. A color-specification string can be parsed for the RGB values it specifies by sending the parseColor: message to a CgScreen with the color-specification string as the argument. The result is the corresponding CgRGBColor, if the string was successfully parsed, or nil if the string could not be parsed. If the specification string is a color name, the result is the same as using lookupColor:.
| color |
color := CgScreen default parseColor: '#300050008000'.
Transcript cr; show: color printString.
The preceding code prints the string:
aCgRGBColor(16r3000, 16r5000, 16r8000).
Last modified date: 01/29/2015