Gri: color

General Issues 1: Introduction 2: Simple example 3: Fancy example 4: Running Gri 5: Programming Gri 6: General Issues 7: X-Y Plots 8: Contour Plots 9: Image Plots 10: Examples 11: Handling Data 12: Gri Commands 13: Gri Extras 14: Evolution of Gri 15: Installing Gri 16: Gri Bugs 17: System Tools 18: Acknowledgments 19: License 20: Newsgroup 21: Concept Index | ## 6.3: Color Besides color images, Gri permits the use of arbitrary grayscale or color in any drawn item. Graylevel: Controlling the graylevel of the "pen" Colorlevel: Controlling the color of the "pen" ### 6.3.1: Controlling graylevel of the ``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.
### 6.3.2: Controlling color of the ``pen'' 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. #### 6.3.2.1: The ``set color \name`' Command Set the pen color to the indicated name. By default, only a handful of colors are known. You MUST give color names as written here, obeying the capitilization shown. The color mixes are identical to those used in X11. The following lists some of the colors Gri knows by default.
    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 this, 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`'. #### 6.3.2.2: 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. The 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
#### 6.3.2.3: 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. The 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 coloured 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
## 6.4: Interacting with the user Use the ``query`' command to interact with the user see Query. The results can be stored in variables and synonyms.