2 % PostScript prolog file of the BLT graph widget.
4 % Copyright 1989-1992 Regents of the University of California.
5 % Permission to use, copy, modify, and distribute this
6 % software and its documentation for any purpose and without
7 % fee is hereby granted, provided that the above copyright
8 % notice appear in all copies. The University of California
9 % makes no representations about the suitability of this
10 % software for any purpose. It is provided "as is" without
11 % express or implied warranty.
13 % Copyright 1991-1997 Bell Labs Innovations for Lucent Technologies.
15 % Permission to use, copy, modify, and distribute this software and its
16 % documentation for any purpose and without fee is hereby granted, provided
17 % that the above copyright notice appear in all copies and that both that the
18 % copyright notice and warranty disclaimer appear in supporting documentation,
19 % and that the names of Lucent Technologies any of their entities not be used
20 % in advertising or publicity pertaining to distribution of the software
21 % without specific, written prior permission.
23 % Lucent Technologies disclaims all warranties with regard to this software,
24 % including all implied warranties of merchantability and fitness. In no event
25 % shall Lucent Technologies be liable for any special, indirect or
26 % consequential damages or any damages whatsoever resulting from loss of use,
27 % data or profits, whether in an action of contract, negligence or other
28 % tortuous action, arising out of or in connection with the use or performance
34 /BaseRatio 1.3467736870885982 def % Ratio triangle base / symbol size
35 /BgColorProc 0 def % Background color routine (symbols)
36 /DrawSymbolProc 0 def % Routine to draw symbol outline/fill
37 /StippleProc 0 def % Stipple routine (bar segments)
38 /DashesProc 0 def % Dashes routine (line segments)
40 % Define the array ISOLatin1Encoding (which specifies how characters are
41 % encoded for ISO-8859-1 fonts), if it isn't already present (Postscript
42 % level 2 is supposed to define it, but level 1 doesn't).
44 systemdict /ISOLatin1Encoding known not {
46 /space /space /space /space /space /space /space /space
47 /space /space /space /space /space /space /space /space
48 /space /space /space /space /space /space /space /space
49 /space /space /space /space /space /space /space /space
50 /space /exclam /quotedbl /numbersign /dollar /percent /ampersand
52 /parenleft /parenright /asterisk /plus /comma /minus /period /slash
53 /zero /one /two /three /four /five /six /seven
54 /eight /nine /colon /semicolon /less /equal /greater /question
55 /at /A /B /C /D /E /F /G
56 /H /I /J /K /L /M /N /O
57 /P /Q /R /S /T /U /V /W
58 /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
59 /quoteleft /a /b /c /d /e /f /g
60 /h /i /j /k /l /m /n /o
61 /p /q /r /s /t /u /v /w
62 /x /y /z /braceleft /bar /braceright /asciitilde /space
63 /space /space /space /space /space /space /space /space
64 /space /space /space /space /space /space /space /space
65 /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent
66 /dieresis /space /ring /cedilla /space /hungarumlaut /ogonek /caron
67 /space /exclamdown /cent /sterling /currency /yen /brokenbar /section
68 /dieresis /copyright /ordfeminine /guillemotleft /logicalnot /hyphen
70 /degree /plusminus /twosuperior /threesuperior /acute /mu /paragraph
72 /cedillar /onesuperior /ordmasculine /guillemotright /onequarter
73 /onehalf /threequarters /questiondown
74 /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla
75 /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex
77 /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply
78 /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn
80 /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla
81 /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex
83 /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide
84 /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn
90 % This procedure changes the encoding of a font from the default
91 % Postscript encoding to ISOLatin1. It's typically invoked just
92 % before invoking "setfont". The body of this procedure comes from
93 % Section 5.6.1 of the Postscript book.
98 {1 index /FID ne {def} {pop pop} ifelse} forall
99 /Encoding ISOLatin1Encoding def
103 % I'm not sure why it's necessary to use "definefont" on this new
104 % font, but it seems to be important; just use the name "Temporary"
107 /Temporary exch definefont
123 % Stack: pointSize fontName
124 findfont exch scalefont ISOEncode setfont
128 % Stack: x y width height
138 % Stack: red green blue
149 % Stack: red green blue
159 % The next two definitions are taken from "$tk_library/prolog.ps"
161 % desiredSize EvenPixels closestSize
163 % The procedure below is used for stippling. Given the optimal size
164 % of a dot in a stipple pattern in the current user coordinate system,
165 % compute the closest size that is an exact multiple of the device's
166 % pixel size. This allows stipple patterns to be displayed without
170 % Compute exact number of device pixels per stipple dot.
171 dup 0 matrix currentmatrix dtransform
172 dup mul exch dup mul add sqrt
174 % Round to an integer, make sure the number is at least 1, and compute
175 % user coord distance corresponding to this.
176 dup round dup 1 lt {pop 1} if
180 % width height string filled StippleFill --
182 % Given a path and other graphics information already set up, this
183 % procedure will fill the current path in a stippled fashion. "String"
184 % contains a proper image description of the stipple pattern and
185 % "width" and "height" give its dimensions. If "filled" is true then
186 % it means that the area to be stippled is gotten by filling the
187 % current path (e.g. the interior of a polygon); if it's false, the
188 % area is gotten by stroking the current path (e.g. a wide line).
189 % Each stipple dot is assumed to be about one unit across in the
190 % current user coordinate system.
192 % width height string StippleFill --
194 % Given a path already set up and a clipping region generated from
195 % it, this procedure will fill the clipping region with a stipple
196 % pattern. "String" contains a proper image description of the
197 % stipple pattern and "width" and "height" give its dimensions. Each
198 % stipple dot is assumed to be about one unit across in the current
199 % user coordinate system. This procedure trashes the graphics state.
202 % The following code is needed to work around a NeWSprint bug.
206 % Change the scaling so that one user unit in user coordinates
207 % corresponds to the size of one stipple dot.
208 1 EvenPixels dup scale
210 % Compute the bounding box occupied by the path (which is now
211 % the clipping region), and round the lower coordinates down
212 % to the nearest starting point for the stipple pattern. Be
213 % careful about negative numbers, since the rounding works
214 % differently on them.
218 5 index div dup 0 lt {1 sub} if cvi 5 index mul 4 1 roll
219 6 index div dup 0 lt {1 sub} if cvi 6 index mul 3 2 roll
221 % Stack now: width height string y1 y2 x1 x2
222 % Below is a doubly-nested for loop to iterate across this area
223 % in units of the stipple pattern size, going up columns then
224 % across rows, blasting out a stipple-pattern-sized rectangle at
228 2 index 5 index 3 index {
229 % Stack now: width height string y1 y2 x y
232 1 index exch translate
233 5 index 5 index true matrix tmpstip imagemask
242 /LS { % Stack: x1 y1 x2 y2
243 newpath 4 2 roll moveto lineto stroke
252 %Stack : w h theta centerX centerY
254 % Translate the origin to the center of bounding box and rotate
256 % Translate back to the origin of the text region
257 -0.5 mul exch -0.5 mul exch translate
261 %Stack : str strWidth x y
262 moveto % Go to the text position
263 exch dup dup 4 2 roll
265 % Adjust character widths to get desired overall string width
266 % adjust X = (desired width - real width)/#chars
268 stringwidth pop sub exch
272 % Flip back the scale so that the string is not drawn in reverse
281 % Stack: ?bgColorProc? boolean centerX centerY width height theta imageStr
283 6 -2 roll translate % Translate to center of bounding box
284 4 1 roll neg rotate % Rotate by theta
286 % Find upperleft corner of bounding box
288 2 copy -.5 mul exch -.5 mul exch translate
289 2 copy scale % Make pixel unit scale
291 0 0 moveto 0 1 lineto 1 1 lineto 1 0 lineto
294 % Fill rectangle with background color
302 % Paint the image string into the unit rectangle
304 2 copy true 3 -1 roll 0 0 5 -1 roll 0 0 6 array astore 5 -1 roll
313 % Stack: x y symbolSize
315 3 -2 roll translate 45 rotate
322 % Stack: x y symbolSize
327 newpath neg 0 moveto 0 lineto
329 newpath neg 0 exch moveto 0 exch lineto
336 % Stack: x y symbolSize
338 3 -2 roll translate 45 rotate
345 % Stack: x y symbolSize
352 % 2 3 The plus/cross symbol is a
353 % closed polygon of 12 points.
354 % 0 1 4 5 The diagram to the left
355 % x,y represents the positions of
356 % 11 10 7 6 the points which are computed
362 2 copy exch neg exch neg moveto dup neg dup lineto
363 2 copy neg exch neg lineto 2 copy exch neg lineto
364 dup dup neg lineto 2 copy neg lineto 2 copy lineto
365 dup dup lineto 2 copy exch lineto 2 copy neg exch lineto
366 dup dup neg exch lineto exch neg exch lineto
374 % Stack: x y symbolSize
378 closepath DrawSymbolProc
383 % Stack: x y symbolSize
385 6 -1 roll exch sub exch
386 5 -1 roll exch sub 4 -2 roll Box
392 % Stack: x y symbolSize
393 3 1 roll exch 3 -1 roll 2 div 3 copy
395 sub exch moveto add exch lineto
401 % Stack: x y symbolSize
403 3 1 roll translate 45 rotate 0 0 3 -1 roll Sq
409 % Stack: x y symbolSize
412 BaseRatio mul 0.5 mul % Calculate 1/2 base
413 dup 0 exch 30 cos mul % h1 = height above center point
415 newpath moveto % point 1; b2
416 dup 30 sin 30 cos div mul % h2 = height below center point
417 2 copy lineto % point 2; b2 h2
418 exch neg exch lineto %
426 % Stack: x y symbolSize
429 BaseRatio mul 0.5 mul % Calculate 1/2 base
430 dup 0 exch 30 cos mul % h1 = height above center point
432 newpath moveto % point 1; b2
433 dup 30 sin 30 cos div mul % h2 = height below center point
435 2 copy lineto % point 2; b2 h2
436 exch neg exch lineto %
444 % Stack: x y symbolSize
446 3 1 roll translate pop DrawSymbolProc
451 gsave % Save the graphics state
453 % Default line/text style parameters
455 1 setlinewidth % width
458 [] 0 setdash % dashes
460 /CL 0 def % Set color level mode
461 0 0 0 setrgbcolor % color