A subcommand of Tk's winfo command.
winfo rgb window color
Returns a list containing three decimal values, which are the red, green, and blue intensities that correspond to color in the window given by window. Color may be specified in any of the forms acceptable for a color option.
According to Jeff Hobbs, the decimal values are always 16 bits [L1 ].
Here's a quick way to parse the return string into three separate variables:
foreach {r g b} [winfo rgb . $some_color] break
...or if you don't like the "break":
foreach {red green blue} [winfo rgb . "AntiqueWhite"] {}
The technique may seem obscure at first, but apparently it's an accepted idiom in TCL [L2 ].
Note that "winfo rgb" is not idempotent (or surjective) over the space of decimal triples. CL believes that the point is that the range space of "winfo rgb" is the display's color palette (is that the right GUI vernacular?), and is thus smaller than the full cartesian product ([0-65535],[0-65535],[0-65535]) one might otherwise expect.
This presented with VNC service for which
winfo rgb . #ffff1fffffff
is
65535 0 65535
rather than the
65535 7967 65535
delivered by a better-endowed display.
A start to a work-around for this is ...
DKF: The result from winfo rgb is a triple that describes the colour that is actually fed into the display hardware. Different display subsystems interpret this in different ways; that VNC server is obviously using a round-down rule on a 15-bit display...