p_header.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. /* This file is part of the GNU plotutils package. Copyright (C) 1995,
  2. 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
  3. The GNU plotutils package is free software. You may redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software foundation; either version 2, or (at your
  6. option) any later version.
  7. The GNU plotutils package is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with the GNU plotutils package; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. /* The following Postscript procset defines a set of macros and constants
  16. that libplot uses when rendering graphics. It is split into several
  17. shorter pieces, because some compilers have difficulty with strings that
  18. are too long. It is #included by p_defplot.c.
  19. The procset was largely written by John Interrante
  20. <interran@uluru.stanford.edu>, formerly of the InterViews team. (Thanks
  21. to John for generously providing it, and for helpful comments.)
  22. For more information see the InterViews distribution at
  23. ftp://interviews.stanford.edu.
  24. The present procset, version 1.1, includes a minor modification.
  25. Originally, FontBBox was assumed always to be an executable array. Many
  26. fonts are designed this way, but it is not required. The assumption
  27. gave problems on some versions of ghostscript. Thanks to Alex
  28. Cherepanov for the bug fix. */
  29. #define PS_PROCSET_NAME "GNU_libplot"
  30. #define PS_PROCSET_VERSION "1.1"
  31. static const char * const _ps_fontproc =
  32. "\
  33. /ISOLatin1Encoding [\n\
  34. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n\
  35. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n\
  36. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n\
  37. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n\
  38. /space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n\
  39. /parenleft/parenright/asterisk/plus/comma/minus/period/slash\n\
  40. /zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n\
  41. /less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n\
  42. /O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n\
  43. /asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n\
  44. /n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde\n\
  45. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n\
  46. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n\
  47. /.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve\n\
  48. /dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut\n\
  49. /ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar\n\
  50. /section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot\n\
  51. /hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior\n\
  52. /acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine\n\
  53. /guillemotright/onequarter/onehalf/threequarters/questiondown\n\
  54. /Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla\n\
  55. /Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex\n\
  56. /Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis\n\
  57. /multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute\n\
  58. /Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis\n\
  59. /aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave\n\
  60. /iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex\n\
  61. /otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis\n\
  62. /yacute/thorn/ydieresis\n\
  63. ] def\n\
  64. /reencodeISO {\n\
  65. dup dup findfont dup length dict begin\n\
  66. { 1 index /FID ne { def }{ pop pop } ifelse } forall\n\
  67. /Encoding ISOLatin1Encoding def\n\
  68. currentdict end definefont\n\
  69. } def\n";
  70. /* The following is split into substrings, because some compilers (e.g.,
  71. MS VC++) can't handle very long strings. */
  72. static const char * const _ps_procset[] =
  73. {"\
  74. /none null def\n\
  75. /numGraphicParameters 17 def\n\
  76. /stringLimit 65535 def\n\
  77. /arrowHeight 8 def\n\
  78. /eoFillRule true def\n\n\
  79. /Begin { save numGraphicParameters dict begin } def\n\
  80. /End { end restore } def\n\
  81. \n\
  82. /SetB {\n\
  83. dup type /nulltype eq {\n\
  84. pop\n\
  85. false /brushRightArrow idef\n\
  86. false /brushLeftArrow idef\n\
  87. true /brushNone idef\n\
  88. } {\n\
  89. /brushDashOffset idef\n\
  90. /brushDashArray idef\n\
  91. 0 ne /brushRightArrow idef\n\
  92. 0 ne /brushLeftArrow idef\n\
  93. /brushWidth idef\n\
  94. false /brushNone idef\n",
  95. "} ifelse\n\
  96. } def\n\
  97. \n\
  98. /SetCFg {\n\
  99. /fgblue idef\n\
  100. /fggreen idef\n\
  101. /fgred idef\n\
  102. } def\n\
  103. \n\
  104. /SetCBg {\n\
  105. /bgblue idef\n\
  106. /bggreen idef\n\
  107. /bgred idef\n\
  108. } def\n\
  109. \n\
  110. /SetF {\n\
  111. /printSize idef\n\
  112. /printFont idef\n\
  113. } def\n\
  114. \n\
  115. /SetP {\n\
  116. dup type /nulltype eq {\n\
  117. pop true /patternNone idef\n\
  118. } {\n\
  119. /patternGrayLevel idef\n\
  120. patternGrayLevel -1 eq {\n\
  121. /patternString idef\n\
  122. } if\n\
  123. false /patternNone idef\n\
  124. } ifelse\n\
  125. } def\n\
  126. \n",
  127. "/BSpl {\n\
  128. 0 begin\n\
  129. storexyn\n\
  130. newpath\n\
  131. n 1 gt {\n\
  132. 0 0 0 0 0 0 1 1 true subspline\n\
  133. n 2 gt {\n\
  134. 0 0 0 0 1 1 2 2 false subspline\n\
  135. 1 1 n 3 sub {\n\
  136. /i exch def\n\
  137. i 1 sub dup i dup i 1 add dup i 2 add dup false subspline\n\
  138. } for\n\
  139. n 3 sub dup n 2 sub dup n 1 sub dup 2 copy false subspline\n\
  140. } if\n\
  141. n 2 sub dup n 1 sub dup 2 copy 2 copy false subspline\n\
  142. patternNone not brushLeftArrow not brushRightArrow not and and { ifill } if\n\
  143. brushNone not { istroke } if\n",
  144. "0 0 1 1 leftarrow\n\
  145. n 2 sub dup 1 sub dup rightarrow\n\
  146. } if\n\
  147. end\n\
  148. } dup 0 4 dict put def\n\
  149. \n\
  150. /Circ {\n\
  151. newpath\n\
  152. 0 360 arc\n\
  153. closepath\n\
  154. patternNone not { ifill } if\n\
  155. brushNone not { istroke } if\n\
  156. } def\n\
  157. \n",
  158. "/CBSpl {\n\
  159. 0 begin\n\
  160. dup 2 gt {\n\
  161. storexyn\n\
  162. newpath\n\
  163. n 1 sub dup 0 0 1 1 2 2 true subspline\n\
  164. 1 1 n 3 sub {\n\
  165. /i exch def\n\
  166. i 1 sub dup i dup i 1 add dup i 2 add dup false subspline\n\
  167. } for\n",
  168. "n 3 sub dup n 2 sub dup n 1 sub dup 0 0 false subspline\n\
  169. n 2 sub dup n 1 sub dup 0 0 1 1 false subspline\n\
  170. patternNone not { ifill } if\n\
  171. brushNone not { istroke } if\n\
  172. } {\n\
  173. Poly\n\
  174. } ifelse\n\
  175. end\n\
  176. } dup 0 4 dict put def\n\
  177. \n\
  178. /Elli {\n\
  179. 0 begin\n\
  180. newpath\n\
  181. 4 2 roll\n\
  182. translate\n\
  183. scale\n\
  184. 0 0 1 0 360 arc\n\
  185. closepath\n\
  186. patternNone not { ifill } if\n\
  187. brushNone not { istroke } if\n\
  188. end\n\
  189. } dup 0 1 dict put def\n\
  190. \n\
  191. /Line {\n\
  192. 0 begin\n\
  193. 2 storexyn\n",
  194. "newpath\n\
  195. x 0 get y 0 get moveto\n\
  196. x 1 get y 1 get lineto\n\
  197. brushNone not { istroke } if\n\
  198. 0 0 1 1 leftarrow\n\
  199. 0 0 1 1 rightarrow\n\
  200. end\n\
  201. } dup 0 4 dict put def\n\
  202. \n\
  203. /MLine {\n\
  204. 0 begin\n\
  205. storexyn\n\
  206. newpath\n\
  207. n 1 gt {\n\
  208. x 0 get y 0 get moveto\n\
  209. 1 1 n 1 sub {\n\
  210. /i exch def\n\
  211. x i get y i get lineto\n\
  212. } for\n\
  213. patternNone not brushLeftArrow not brushRightArrow not and and { ifill } if\n\
  214. brushNone not { istroke } if\n",
  215. "0 0 1 1 leftarrow\n\
  216. n 2 sub dup n 1 sub dup rightarrow\n\
  217. } if\n\
  218. end\n\
  219. } dup 0 4 dict put def\n\
  220. \n\
  221. /Poly {\n\
  222. 3 1 roll\n\
  223. newpath\n\
  224. moveto\n\
  225. -1 add\n\
  226. { lineto } repeat\n\
  227. closepath\n\
  228. patternNone not { ifill } if\n\
  229. brushNone not { istroke } if\n\
  230. } def\n\
  231. \n",
  232. "/Rect {\n\
  233. 0 begin\n\
  234. /t exch def\n\
  235. /r exch def\n\
  236. /b exch def\n\
  237. /l exch def\n\
  238. newpath\n\
  239. l b moveto\n\
  240. l t lineto\n\
  241. r t lineto\n\
  242. r b lineto\n\
  243. closepath\n\
  244. patternNone not { ifill } if\n\
  245. brushNone not { istroke } if\n\
  246. end\n\
  247. } dup 0 4 dict put def\n\
  248. \n\
  249. /Text {\n\
  250. ishow\n\
  251. } def\n\
  252. \n\
  253. /idef {\n\
  254. dup where { pop pop pop } { exch def } ifelse\n\
  255. } def\n\
  256. \n\
  257. /ifill {\n\
  258. 0 begin\n\
  259. gsave\n",
  260. "patternGrayLevel -1 ne {\n\
  261. fgred bgred fgred sub patternGrayLevel mul add\n\
  262. fggreen bggreen fggreen sub patternGrayLevel mul add\n\
  263. fgblue bgblue fgblue sub patternGrayLevel mul add setrgbcolor\n\
  264. eoFillRule { eofill } { fill } ifelse\n\
  265. } {\n\
  266. eoFillRule { eoclip } { clip } ifelse\n\
  267. originalCTM setmatrix\n\
  268. pathbbox /t exch def /r exch def /b exch def /l exch def\n\
  269. /w r l sub ceiling cvi def\n\
  270. /h t b sub ceiling cvi def\n\
  271. /imageByteWidth w 8 div ceiling cvi def\n\
  272. /imageHeight h def\n",
  273. "bgred bggreen bgblue setrgbcolor\n\
  274. eoFillRule { eofill } { fill } ifelse\n\
  275. fgred fggreen fgblue setrgbcolor\n\
  276. w 0 gt h 0 gt and {\n\
  277. l b translate w h scale\n\
  278. w h true [w 0 0 h neg 0 h] { patternproc } imagemask\n\
  279. } if\n\
  280. } ifelse\n\
  281. grestore\n\
  282. end\n\
  283. } dup 0 8 dict put def\n\
  284. \n",
  285. "/istroke {\n\
  286. gsave\n\
  287. brushDashOffset -1 eq {\n\
  288. [] 0 setdash\n\
  289. 1 setgray\n\
  290. } {\n\
  291. brushDashArray brushDashOffset setdash\n\
  292. fgred fggreen fgblue setrgbcolor\n\
  293. } ifelse\n",
  294. "brushWidth setlinewidth\n\
  295. originalCTM setmatrix\n\
  296. stroke\n\
  297. grestore\n\
  298. } def\n\
  299. \n\
  300. /ishow {\n\
  301. 0 begin\n\
  302. gsave\n\
  303. fgred fggreen fgblue setrgbcolor\n\
  304. /fontDict printFont findfont printSize scalefont dup setfont def\n\
  305. /descender fontDict begin 0 /FontBBox load 1 get FontMatrix end\n\
  306. transform exch pop def\n\
  307. /vertoffset 1 printSize sub descender sub def {\n\
  308. 0 vertoffset moveto show\n\
  309. /vertoffset vertoffset printSize sub def\n\
  310. } forall\n\
  311. grestore\n\
  312. end\n\
  313. } dup 0 3 dict put def\n\
  314. \n",
  315. "/patternproc {\n\
  316. 0 begin\n\
  317. /patternByteLength patternString length def\n\
  318. /patternHeight patternByteLength 8 mul sqrt cvi def\n\
  319. /patternWidth patternHeight def\n\
  320. /patternByteWidth patternWidth 8 idiv def\n\
  321. /imageByteMaxLength imageByteWidth imageHeight mul\n\
  322. stringLimit patternByteWidth sub min def\n\
  323. /imageMaxHeight imageByteMaxLength imageByteWidth idiv patternHeight idiv\n\
  324. patternHeight mul patternHeight max def\n",
  325. "/imageHeight imageHeight imageMaxHeight sub store\n\
  326. /imageString imageByteWidth imageMaxHeight mul patternByteWidth add string def\n\
  327. 0 1 imageMaxHeight 1 sub {\n\
  328. /y exch def\n\
  329. /patternRow y patternByteWidth mul patternByteLength mod def\n\
  330. /patternRowString patternString patternRow patternByteWidth getinterval def\n\
  331. /imageRow y imageByteWidth mul def\n\
  332. 0 patternByteWidth imageByteWidth 1 sub {\n\
  333. /x exch def\n\
  334. imageString imageRow x add patternRowString putinterval\n\
  335. } for\n\
  336. } for\n",
  337. "imageString\n\
  338. end\n\
  339. } dup 0 12 dict put def\n\
  340. \n\
  341. /min {\n\
  342. dup 3 2 roll dup 4 3 roll lt { exch } if pop\n\
  343. } def\n\
  344. \n\
  345. /max {\n\
  346. dup 3 2 roll dup 4 3 roll gt { exch } if pop\n\
  347. } def\n\
  348. \n\
  349. /midpoint {\n\
  350. 0 begin\n\
  351. /y1 exch def\n\
  352. /x1 exch def\n\
  353. /y0 exch def\n\
  354. /x0 exch def\n\
  355. x0 x1 add 2 div\n\
  356. y0 y1 add 2 div\n\
  357. end\n\
  358. } dup 0 4 dict put def\n\
  359. \n",
  360. "/thirdpoint {\n\
  361. 0 begin\n\
  362. /y1 exch def\n\
  363. /x1 exch def\n\
  364. /y0 exch def\n\
  365. /x0 exch def\n",
  366. "x0 2 mul x1 add 3 div\n\
  367. y0 2 mul y1 add 3 div\n\
  368. end\n\
  369. } dup 0 4 dict put def\n\
  370. \n\
  371. /subspline {\n\
  372. 0 begin\n\
  373. /movetoNeeded exch def\n\
  374. y exch get /y3 exch def\n\
  375. x exch get /x3 exch def\n\
  376. y exch get /y2 exch def\n\
  377. x exch get /x2 exch def\n\
  378. y exch get /y1 exch def\n\
  379. x exch get /x1 exch def\n\
  380. y exch get /y0 exch def\n\
  381. x exch get /x0 exch def\n\
  382. x1 y1 x2 y2 thirdpoint\n\
  383. /p1y exch def\n\
  384. /p1x exch def\n\
  385. x2 y2 x1 y1 thirdpoint\n\
  386. /p2y exch def\n\
  387. /p2x exch def\n",
  388. "x1 y1 x0 y0 thirdpoint\n\
  389. p1x p1y midpoint\n\
  390. /p0y exch def\n\
  391. /p0x exch def\n\
  392. x2 y2 x3 y3 thirdpoint\n\
  393. p2x p2y midpoint\n\
  394. /p3y exch def\n\
  395. /p3x exch def\n\
  396. movetoNeeded { p0x p0y moveto } if\n\
  397. p1x p1y p2x p2y p3x p3y curveto\n\
  398. end\n\
  399. } dup 0 17 dict put def\n\
  400. \n\
  401. /storexyn {\n\
  402. /n exch def\n\
  403. /y n array def\n\
  404. /x n array def\n\
  405. n 1 sub -1 0 {\n\
  406. /i exch def\n\
  407. y i 3 2 roll put\n\
  408. x i 3 2 roll put\n\
  409. } for\n\
  410. } def\n\
  411. \n",
  412. "/arrowhead {\n\
  413. 0 begin\n\
  414. transform originalCTM itransform\n",
  415. "/taily exch def\n\
  416. /tailx exch def\n\
  417. transform originalCTM itransform\n\
  418. /tipy exch def\n\
  419. /tipx exch def\n\
  420. /dy tipy taily sub def\n\
  421. /dx tipx tailx sub def\n\
  422. /angle dx 0 ne dy 0 ne or { dy dx atan } { 90 } ifelse def\n\
  423. gsave\n\
  424. originalCTM setmatrix\n\
  425. tipx tipy translate\n\
  426. angle rotate\n\
  427. newpath\n\
  428. arrowHeight neg arrowWidth 2 div moveto\n\
  429. 0 0 lineto\n\
  430. arrowHeight neg arrowWidth 2 div neg lineto\n\
  431. patternNone not {\n\
  432. originalCTM setmatrix\n",
  433. "/padtip arrowHeight 2 exp 0.25 arrowWidth 2 exp mul add sqrt brushWidth mul\n\
  434. arrowWidth div def\n\
  435. /padtail brushWidth 2 div def\n\
  436. tipx tipy translate\n\
  437. angle rotate\n\
  438. padtip 0 translate\n\
  439. arrowHeight padtip add padtail add arrowHeight div dup scale\n\
  440. arrowheadpath\n\
  441. ifill\n\
  442. } if\n\
  443. brushNone not {\n\
  444. originalCTM setmatrix\n\
  445. tipx tipy translate\n\
  446. angle rotate\n\
  447. arrowheadpath\n\
  448. istroke\n\
  449. } if\n\
  450. grestore\n\
  451. end\n\
  452. } dup 0 9 dict put def\n\
  453. \n",
  454. "/arrowheadpath {\n\
  455. newpath\n\
  456. arrowHeight neg arrowWidth 2 div moveto\n\
  457. 0 0 lineto\n\
  458. arrowHeight neg arrowWidth 2 div neg lineto\n\
  459. } def\n\
  460. \n\
  461. /leftarrow {\n\
  462. 0 begin\n\
  463. y exch get /taily exch def\n\
  464. x exch get /tailx exch def\n\
  465. y exch get /tipy exch def\n\
  466. x exch get /tipx exch def\n\
  467. brushLeftArrow { tipx tipy tailx taily arrowhead } if\n\
  468. end\n\
  469. } dup 0 4 dict put def\n\
  470. \n",
  471. "/rightarrow {\n\
  472. 0 begin\n\
  473. y exch get /tipy exch def\n\
  474. x exch get /tipx exch def\n\
  475. y exch get /taily exch def\n\
  476. x exch get /tailx exch def\n\
  477. brushRightArrow { tipx tipy tailx taily arrowhead } if\n\
  478. end\n\
  479. } dup 0 4 dict put def\n",
  480. ""};