# 7 Colors and Styles

 7 Colors and Styles
The Wolfram Language doesn’t just handle things like numbers. It also for example handles things like colors. It lets you refer to common colors by their names.
Red represents the color red:
Red

Make a list of colors:
{Red, Green, Blue, Purple, Orange, Black}

You can do operations on colors. ColorNegate “negates” a color, giving the complementary color. Blend blends a list of colors together.
Negating the color yellow gives blue:
ColorNegate[Yellow]

Here’s the result of blending yellow, pink and green:
Blend[{Yellow, Pink, Green}]

You can specify a color by saying how much red, green and blue it contains. The function RGBColor lets you do that, giving the amount of each color, from 0 to 1.
This gives maximum red, with no green or blue:
RGBColor[1, 0, 0]

Maximum red and green gives yellow:
RGBColor[1, 1, 0]

This gives a table of colors with maximum red and varying levels of green:
Table[RGBColor[1, g, 0], {g, 0, 1, 0.05}]

A hue of 0.5 corresponds to cyan:
Hue[0.5]

Here’s a table of colors with hues from 0 to 1:
Table[Hue[x], {x, 0, 1, 0.05}]

Sometimes you may want to just pick a random color. RandomColor lets you do this. When you say RandomInteger[10], you’re asking to generate a random integer up to 10. But for a random color you don’t have to specify a range, so you can just write not giving any explicit input to the function.
Generate a random color:
RandomColor[]

Make a table of 30 random colors:
Table[RandomColor[], 30]

Blending together lots of random colors usually gives something muddy:
Blend[Table[RandomColor[], 20]]

You can use colors in all sorts of places. For example, you can style output with colors.
This gives the number 1000, styled in red:
Style[1000, Red]

Here are 30 random integers, styled in random colors:
Table[Style[RandomInteger[1000], RandomColor[]], 30]

Show x styled in 30-point type:
Style[x, 30]

This styles the number 100 in a sequence of different sizes:
Table[Style[100, n], {n, 30}]

You can combine color and size styling; here’s x in 25 random colors and sizes:
Table[Style[x, RandomColor[], RandomInteger[30]], 25]

 Red, Green, Blue, Yellow, Orange, Pink, Purple, ... colors RGBColor[0.4,0.7,0.3] red, green, blue color Hue[0.8] color specified by hue RandomColor[ ] randomly chosen color ColorNegate[Red] negate a color (complement) Blend[{Red,Blue}] blend a list of colors Style[x,Red] style with a color Style[x,20] style with a size Style[x,20,Red] style with a size and color
7.1Make a list of red, yellow and green. »
Expected output:
 Out[]=
7.2Make a red, yellow, green column (“traffic light”). »
Expected output:
 Out[]=
7.3Compute the negation of the color orange. »
Expected output:
 Out[]=
Expected output:
 Out[]=
Expected output:
 Out[]=
7.6Blend the colors pink and yellow. »
Expected output:
 Out[]=
7.7Make a list of colors obtained by blending yellow with hues from 0 to 1 in steps of 0.05. »
Expected output:
 Out[]=
7.8Make a list of numbers from 0 to 1 in steps of 0.1, each with a hue equal to its value. »
Expected output:
 Out[]=
7.9Make a purple color swatch of size 100. »
Expected output:
 Out[]=
7.10Make a list of red swatches with sizes from 10 to 100 in steps of 10. »
Expected output:
 Out[]=
7.11Display the number 999 in red at size 100. »
Expected output:
 Out[]=
7.12Make a list of the first 10 squares, in which each value is styled at its size. »
Expected output:
 Out[]=
7.13Use Part and RandomInteger to make a length-100 list in which each element is randomly Red, Yellow or Green»
Sample expected output:
 Out[]=
7.14Use Part to make a list of the first 50 digits of 2^1000, in which each digit has a size equal to 3 times its value. »
Expected output:
 Out[]=
+7.1Create a column of colors with hues varying from 0 to 1 in steps of 0.05. »
Expected output:
 Out[]=
+7.2Make a list of colors varying from red to green with green components x varying from 0 to 1 in steps of 0.05 and with red components 1-x.  »
Expected output:
 Out[]=
+7.3Create a list of colors with no red or blue, and with green varying from 0 to 1 and back down to 0 in increments of 0.1 (the 1 should not be repeated). »
Expected output:
 Out[]=
+7.4Blend the color red and its negation. »
Expected output:
 Out[]=
+7.5Blend a list of colors with hues from 0 to 1 in increments of 0.1. »
Expected output:
 Out[]=
+7.6Blend the color red with white, then blend it again with white.  »
Expected output:
 Out[]=
+7.7Make a list of 100 random colors. »
Sample expected output:
 Out[]=
+7.8Make a column for each number 1 through 10, with the number rendered first in red then in green. »
Expected output:
 Out[]=
+7.9Make columns of the numbers 1 through 10, rendered as plain, bold and italic in each column. »
Expected output:
 Out[]=
What named colors does the Wolfram Language have?
Red, Green, Blue, Black, White, Gray, Yellow, Brown, Orange, Pink, Purple, LightRed, etc. In Section 16 we’ll see how to use ctrl+= to enter any color name in plain English.
Why can colors be specified by red, green, blue values?
Basically because that’s how we humans perceive colors: there are three kinds of cells in our eyes that are roughly sensitive respectively to red, green and blue components of light. (Some other organisms work differently.)
What does color negation do?
It generates complementary colors, defined by computing 1value (one minus the value) for each RGB component. If you negate the “display (emitted light) primaries” red, green, blue, you get the “print (reflected light) primaries” cyan, magenta, yellow.
What is hue?
It’s a way of specifying what are often called pure colors, independent of their tint, shade, saturation or brightness. Colors of different hues are often arranged around a color wheel. The RGB values for a particular hue are determined by a mathematical formula.
Are there other ways to specify colors than RGB?
Yes. A common one (implemented by Hue) is to use the combination of hue, saturation and brightness. LABColor and XYZColor are other examples. GrayLevel represents shades of gray, with GrayLevel[0] being black and GrayLevel[1] being white.