Gri: pen color

Chapters: 1: Introduction 2: Simple example 3: Invocation 4: Finer Control 5: X-Y Plots 6: Contour Plots 7: Image Plots 8: Examples 9: Gri Commands 10: Programming 11: Environment 12: Emacs Mode 13: History 14: Installation 15: Gri Bugs 16: Test Suite 17: Gri in Press 18: Acknowledgments 19: License Indices: Concepts Commands Variables | ## 4.9: Colour of ink in pen The darkness of the ``pen'' used in drawing commands (for either lines or for text) is set by ``set graylevel .brightness.`'. A brightness value of 0 corresponds to black ink, and a brightness value of 1 corresponds to white ink. Values outside this range are clipped to the nearer endpoint. Values inside this range choose a proportional graylevel in between; for example, ``set graylevel 0.5`' gives a 50 percent gray tone. The graylevel applies to text as well as lines. Often you'll want to draw a gray line and a black label beside it, or you'll want to set a graylevel temporarily. Here's how to do it:
    # Save old graylevl, set, then reset to old
    .old_gray. = ..graylevel..
    set graylevel 0.5
    draw curve
    set graylevel 0
    draw label for last curve "TEST"
    set graylevel .old_gray.
The color of the "pen" may be set to any value you can describe with an RGB (red, green, blue) or HSB (hue, saturation, brightness) specification, or a color name. This pen color applies to everything, even text. The ``set color \name`' command Set the pen color to the indicated name. There are two types of names: hexadecimal-triplet names and English names. Hexadecimal-triplet names are of a form often used in web-pages. They consist of exactly 6 characters, which are divided by Gri into three sets of two characters, specifying the red component, the green component, and the blue component of the color, respectively. These components are in hexadecimal notation, i.e. ranging from 00 to FF, indicating values from 0 to 255. For example,
    set color ACD4EF
sets a pastel blue color, almost the color of a robin's egg. The English colors are written simply in the form
    set color blue
where the color is from the following list. (Gri requires that you use the exact form shown, including the capitilization.) The color mixes are identical to those used in X11.
    NAME               RED    GREEN  BLUE
    "white"            1.000  1.000  1.000
    "LightGray"        0.827  0.827  0.827
    "darkslategray"    0.184  0.310  0.310
    "black"            0.000  0.000  0.000
    "red"              1.000  0.000  0.000
    "brown"            0.647  0.165  0.165
    "tan"              0.824  0.706  0.549
    "orange"           1.000  0.647  0.000
    "yellow"           1.000  1.000  0.000
    "green"            0.000  1.000  0.000
    "ForestGreen"      0.133  0.545  0.133
    "cyan"             0.000  1.000  1.000
    "blue"             0.000  0.000  1.000
    "skyblue"          0.529  0.808  0.922
    "magenta"          1.000  0.000  1.000
To get more colors than those provided in the above list, use the ``read colornames`' command. You should do a test case for your printer to see which colors you find most to your liking. You'll want to pick colors that look different from each other. In some cases you might want to avoid dithered colors, since they look too broken on really thin lines. For example, on my printer I like the following colors: ``black`', ``red`', ``yellow`', ``green`', ``cyan`', and ``magenta`'. The ``set color rgb .red. .green. .blue.`' command This command sets the color using the red-green-blue color model. If you are familiar with how colors add (e.g. red plus green yields yellow), then you might like this, but most people find it easier to use the ``set color hsb ...`' style described below. Set the individual color components as follows. The numbers ``.red.`', ``.green.`' and ``.blue.`' range from 0 (for no contribution of that color component to the final color) to 1 (for maximal contribution). Values less than 0 are clipped to 0; values greater than 1 are clipped to 1. EXAMPLES:
    set color rgb 0   0   0  # black
    set color rgb 1   1   1  # white
    set color rgb 1   0   0  # bright red
    set color rgb 0.5 0   0  # dark red
    set color rgb 0   1   0  # pure green
    set color rgb 1   1   0  # yellow: red + green
The ``set color hsb .hue. .saturation. .brightness.`' command In this color model, the color ("hue") is specified with a single parameter. Many people find this easier than using the corresponding ``rgb`' command. Set the individual color components as follows. The numbers ``.hue.`', ``.saturation.`' and ``.brightness.`' range from 0 to 1. The color, represented by ``.hue.`', ranges from 0 for pure red, through 1/3 for pure green, and 2/3 for pure blue, and back to 1 again for pure red. (HINT: It is a good idea to limit the total range of hue you use to 2/3, instead of 1; otherwise you'll get confused by (nearly) repeated colors at the crossover. For example, limit the hue to range from 1/3 to 1, or 0 to 2/3.) The purity of the color, represented by ``.saturation.`', ranges from 0 (none of the hue is visible) to 1 (the maximal amount is present). Less saturated colours are like those you would get from mixing black paint into colored paint. The brightness of the color, represented by ``.brightness.`', ranges from 0 (black) to 1 (maximal brightness). Lowering brightness is like decreasing the intensity of the light you shine on a painting. Hue, saturation, and brightness values are all clipped to the range 0 to 1. EXAMPLES:
    set color hsb 0    1   1  # pure, bright red
    set color hsb 0    1 0.5  # half black, half red
    set color hsb .333 1   1  # pure, bright green