xref: /plan9/sys/src/cmd/postscript/postmd/postmd.h (revision 7dd7cddf99dd7472612f1413b4da293630e6b1bc)
1 /*
2  *
3  * An interval list used to map matrix elements into integers in the range 0 to
4  * 254 representing shades of gray on a PostScript printer. The list can be given
5  * using the -i option or can be set in the optional header that can preceed each
6  * matrix. The list should be a comma or space separated list that looks like,
7  *
8  *		num1,num2, ... ,numn
9  *
10  * where each num is a floating point number. The list must be given in increasing
11  * numerical order. The n numbers in the list partion the real line into 2n+1
12  * regions given by,
13  *
14  *		region1		element < num1
15  *		region2		element = num1
16  *		region3		element < num2
17  *		region4		element = num3
18  *		   .		     .
19  *		   .		     .
20  *		   .		     .
21  *		region2n	element = numn
22  *		region2n+1	element > numn
23  *
24  * Every number in a given region is mapped into an integer in the range 0 to 254
25  * and that number, when displayed on a PostScript printer using the image operator,
26  * prints as a square filled with a gray scale that reflects the integer that was
27  * chosen. 0 maps to black and 255 white (that's why 255 is normally omitted).
28  *
29  * The shades of gray chosen by the program are normally generated automatically,
30  * but can be reassigned using the -g option or by including a grayscale line in
31  * the optional header. The grayscale list is comma or space separated list of
32  * integers between 0 and 255 that's used to map individual regions into arbitray
33  * shade of gray, thus overriding the default choice made in the program. The list
34  * should look like,
35  *
36  *		color1,color2, ... ,color2n+1
37  *
38  * where color1 applies to region1 and color2n+1 applies to region2n+1. If less
39  * than 2n+1 numbers are given the default assignments will be used for the missing
40  * regions. Each color must be an integer in the range 0 to 255.
41  *
42  * The default interval list is given below. The default grayscale maps 254 (almost
43  * white) into the first region and 0 (black) into the last.
44  *
45  */
46 
47 #define DFLTILIST	"-1,0,1"
48 
49 /*
50  *
51  * The active interval list is built from an interval string and stored in an array
52  * whose elements are of type Ilist.
53  *
54  */
55 
56 typedef struct  {
57 	double	val;			/* only valid in kind is ENDPOINT */
58 	int	color;			/* gray scale color */
59 	long	count;			/* statistics for each region */
60 } Ilist;
61 
62 /*
63  *
64  * Non-integer function declarations.
65  *
66  */
67 
68 char	*savestring();
69 
70