procedure ScaleGamma: scale with gamma correction procedure Blend: generate sequence of colors procedure Contrast: choose contrasting color procedure Shade: dither shade using pattern procedure RandomColor: choose random color procedure PaletteGrays: grayscale entries from palette procedure RGBKey: return palette key for color procedure HSVKey: nearest key from HSV specification procedure HSV: HSV interpretation of color procedure HSVValue: color value of HSV specification procedure HLS: HLS interpretation of color procedure HLSValue: color value of HLS specification
link color
April 1, 1997; Gregg M. Townsend
Requires: Version 9 graphics
This file is in the public domain.
These procedures deal with colors in various ways. ScaleGamma(v, g) scales a number with gamma correction. Blend(k1, k2, ...) generates a sequence of colors. Contrast(win, k) returns "white" or "black" contrasting with k. Shade(win, k) sets Fg(), with dithering on a bilevel screen. RandomColor(W, p) returns a randomly chosen color from a palette. PaletteGrays(W, p) returns the gray entries of a palette. RGBKey(W, p, r, g, b) returns the palette key closest to (r,g,b). HSVKey(W, p, h, s, v) returns the palette key closest to (h/s/v). HSV(k) returns the h/s/v interpretation of a color. HSVValue(hsv) returns the ColorValue() of an h/s/v string. HLS(k) returns the h:l:s interpretation of a color. HLSValue(hls) returns the ColorValue() of an h:l:s string. ____________________________________________________________ ScaleGamma(v, g) nonlinearly scales the number v (between 0.0 and 1.0) to an integer between 0 and 65535 using a gamma correction factor g. the default value of g is 2.5. Blend(color1, color2, color3,...) generates ColorValue(color1), then some intermediate shades, then ColorValue(color2), then some more intermediate shades, and so on, finally generating the color value of the last argument. An integer argument can be interpolated at any point to set the number of steps (the default is four) from one color to the next. Contrast(win, colr) returns either "white" or "black", depending on which provides the greater contrast with the specified color. Shade(win, colr) sets the foreground for an area filling operation. On a color screen, Shade() sets the foreground color and returns the window. On a bilevel monochrome screen, Shade() sets the foreground to a magic-square dithering pattern approximating the luminance of the color specified. If the environment variable XSHADE is set to "gray" (or "grey") then Shade simulates a multilevel grayscale monitor. If it is set to any other value, Shade simulates a bilevel monitor. RandomColor(win, palette) returns a randomly chosen color from the given image palette, excluding the "extra" grays of the palette, if any. (Colors are selected from a small finite palette, rather than from the entire color space, to avoid running out of colors if a large number of random choices are desired.) The default palette for this procedure is "c6". PaletteGrays([win,] palette) is like PaletteChars but it returns only the characters corresponding to shades of gray. The characters are ordered from black to white, and in all palettes the shades of gray are equally spaced. RGBKey([win,] palette, r, g, b) returns a palette key given the three color components as real number from 0.0 to 1.0. HSVKey([win,] palette, h, s, v) returns a palette key given a hue, saturation, and value as real numbers from 0.0 to 1.0. HSV() and HSVValue() convert between Icon color strings and strings containing slash-separated HSV values with maxima of "360/100/100". HSV(k) returns the h/s/v interpretation of an Icon color specification; HSVValue(hsv) translates an h/s/v value into an Icon r,g,b value. HLS() and HLSValue() convert between Icon color strings and strings containing colon-separated HLS values with maxima of "360:100:100". HLS(k) returns the h:l:s interpretation of an Icon color specification; HLSValue(hls) translates an h:l:s value into an Icon r,g,b value.