When manipulating colors, the output is shown as a textual expression like Hue[1/5]
, RGBColor[2/3, 1, 1/3]
, GrayLevel[3/5]
. It can be hard to visualize what color these represent.
How can you quickly display the color itself on screen?
A simple way is to use a ColorSetter
.
Where color
is the color you want to display, run
DynamicSetting@ColorSetter@color
You can also copy the result and use it as input in a notebook.
Evaluate (Shift+Enter) your code for color. In Mathematica 9 the suggestion bar will appear under the output with suggestion "swatch". Just click it and you'll get a square with that color.
If you just want to know what a particular color looks like and don't have M9 you can set it up with Graphics
in many ways. Here is one. I've added the Listable
attribute so you can see many colors at once.
SetAttributes[swatch, Listable];
swatch[col_] := Graphics[{col, Disk[]}, ImageSize -> 50]
swatch[{Hue[1/5], RGBColor[2/3, 1, 1/3], GrayLevel[3/5]}]