1
0

stcinfo.ps 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. % Copyright (C) 1995 Aladdin Enterprises. All rights reserved
  2. %
  3. % This file is part of AFPL Ghostscript.
  4. %
  5. % AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  6. % distributor accepts any responsibility for the consequences of using it, or
  7. % for whether it serves any particular purpose or works at all, unless he or
  8. % she says so in writing. Refer to the Aladdin Free Public License (the
  9. % "License") for full details.
  10. %
  11. % Every copy of AFPL Ghostscript must include a copy of the License, normally
  12. % in a plain ASCII text file named PUBLIC. The License grants you the right
  13. % to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14. % conditions described in the License. Among other things, the License
  15. % requires that the copyright notice and this notice be preserved on all
  16. % copies.
  17. % $Id: stcinfo.ps,v 1.2 2000/09/19 18:29:11 lpd Exp $
  18. % stcinfo.ps
  19. % Epson Stylus-Color Printer-Driver
  20. % The purpose of this file is to print & show Parameters of the
  21. % stcolor-driver. If not run on ghostscript/stcolor, it prints
  22. % something like a color-chart.
  23. % use either existing STCinfo-dictionary, retrieve new one or create dummy
  24. statusdict begin product end
  25. dup (Ghostscript) eq 1 index (Aladdin Ghostscript) eq or
  26. exch (AFPL Ghostscript) eq or{
  27. currentdevice getdeviceprops .dicttomark
  28. dup /Name get (stcolor) eq /STCi_onstc exch def
  29. /STCinfo where {/STCinfo get exch pop} if
  30. /STCinfo exch def
  31. }{
  32. /STCinfo 10 dict def
  33. STCinfo begin /Name (unknown) def end
  34. /STCi_onstc false def
  35. }ifelse
  36. % Next Block are procedures to generate the color-triangles.
  37. % you may wish to separate them, just look ahead for the name
  38. % given in the next line to achieve that.
  39. % Begin: colortri_procedures
  40. % Plot the CIE-XY-triangle (or something like that)
  41. % /colortri_mat Conversion matrix RGB -> XYZ
  42. % /colortri_bg procedure, that takes X/Y-Values and delivers the
  43. % "background color" as RGB-Values, default is:
  44. % {pop pop 0.85 dup dup}
  45. % The default matrix was taken from:
  46. % Color spaces FAQ - David Bourgin
  47. % Date: 15/6/94 (items 5.3 and 6 updated)
  48. % Last update: 29/6/94
  49. /colortri_mat [ % RGB -> CIE XYZitu601-1 (D65)
  50. 0.4306 0.3415 0.1784
  51. 0.2220 0.7067 0.0713
  52. 0.0202 0.1295 0.9394
  53. ] def
  54. /colortri_bg {pop pop 0.85 dup dup} bind def
  55. % +---------------------------------------------------------------------+
  56. % | Besides from fixing bugs, nothing should be changed below this line |
  57. % +---------------------------------------------------------------------+
  58. % Arbitrary operation on a pair of vectors, *CHANGES* 1st.
  59. % invoke: Vaccu Vop op vop
  60. /vop {
  61. bind 0 1 3 index length 1 sub {
  62. 3 index 1 index get 3 index 2 index get 3 index exec 4 index 3 1 roll put
  63. } for pop pop
  64. } bind def
  65. /vsub { {sub} vop } bind def % subtract two vectors
  66. /vmul { {mul} vop } bind def % multiply two vectors
  67. % Compute sum of vectors elements
  68. /vsum {0.0 exch{add}forall} bind def
  69. % Sum up products of elements
  70. /veqn { [ 3 -1 roll {} forall ] exch vmul vsum } bind def
  71. % Find index of |maximum| in array
  72. /imax {
  73. dup 0 get abs 0 exch % array i v[i]
  74. 1 1 4 index length 1 sub {
  75. 3 index 1 index get abs dup 3 index gt {4 2 roll}if pop pop
  76. } for
  77. 3 -1 roll pop
  78. } bind def
  79. % Procedure to *CHANGE* RGB-Values into XYZ-Values
  80. /rgb2xyz {
  81. 0 3 6 { colortri_mat exch 3 getinterval 1 index veqn exch } for astore
  82. } bind def
  83. % Procedure to *CHANGE* transform rgb->xy
  84. /rgb2xy {
  85. rgb2xyz
  86. dup 0 get 1 index 1 get 2 index vsum % XYZ X Y sum
  87. dup 0 ne {
  88. exch 1 index div 3 1 roll div % XYZ y x
  89. 2 index exch 0 exch put % xYZ y
  90. 1 index exch 1 exch put % xyZ
  91. }{
  92. pop pop pop dup 0 0 put dup 0 1 put
  93. } ifelse
  94. 0 2 getinterval
  95. } bind def
  96. % So here we go with our procedure
  97. /colortri { %Usage: box #pixels
  98. save
  99. 1 index type /arraytype eq {exch 8}{3 1 roll} ifelse % Default scale
  100. /colortri_scale exch def
  101. /colortri_box exch def
  102. % Prepare some useful constants for xy -> RGB conversion
  103. /colsum [ % Array with column-sums
  104. 0 1 2{0 exch 3 1 index 6 add{colortri_mat exch get add}for}for
  105. ] def
  106. /Xrow colortri_mat 0 3 getinterval def % two rows from colortri_mat
  107. /Yrow colortri_mat 3 3 getinterval def
  108. % Avoid allocating new arrays
  109. /xcoeff 3 array def
  110. /ycoeff 3 array def
  111. % Procedure to derive RGB-Values form X,Y
  112. /xy2rgb{ aload pop
  113. dup dup dup ycoeff astore colsum vmul Yrow vsub imax
  114. 3 index dup dup xcoeff astore colsum vmul Xrow vsub imax
  115. 3 -1 roll 1 index 1 index gt{
  116. xcoeff ycoeff /xcoeff exch def /ycoeff exch def pop 3 -1 roll pop
  117. }{
  118. 3 1 roll pop pop
  119. } ifelse
  120. 1e-6 lt { % No Pivot ?
  121. pop colortri_bg xcoeff astore pop
  122. }{ % Have a Pivot
  123. dup ycoeff exch get neg
  124. 0 1 2 { dup ycoeff exch get 2 index div ycoeff 3 1 roll put} for
  125. pop ycoeff 1 index 0 put
  126. xcoeff 1 index get
  127. 0 1 2 {
  128. ycoeff 1 index get 2 index mul xcoeff 2 index get add
  129. xcoeff 3 1 roll put
  130. } for
  131. pop xcoeff 1 index 0 put
  132. xcoeff imax 1e-6 lt { % no Pivot ?
  133. pop pop colortri_bg xcoeff astore pop
  134. }{
  135. dup 2 index or 3 exch sub
  136. xcoeff 1 index get xcoeff 3 index get div neg
  137. xcoeff exch 3 index exch put
  138. xcoeff 1 index 1 put
  139. ycoeff exch get ycoeff 2 index get xcoeff 4 -1 roll get mul add
  140. xcoeff 3 1 roll put
  141. 0 1 2 {
  142. xcoeff exch get dup -0.0015 lt exch 1.0015 gt or {
  143. colortri_bg xcoeff astore dup exit
  144. } if
  145. } for
  146. pop pop xcoeff
  147. } ifelse
  148. } ifelse
  149. } bind def
  150. % Compute the displayed range
  151. [ 1 1 1 ] rgb2xy
  152. dup 0 get /colortri_x0 exch def /colortri_dx colortri_x0 def
  153. 1 get /colortri_y0 exch def /colortri_dy colortri_y0 def
  154. [[0 0 1][0 1 0][0 1 1][1 0 0][1 0 1][1 1 0]] {
  155. rgb2xy
  156. dup 0 get
  157. dup colortri_x0 lt {/colortri_x0 1 index def}if
  158. dup colortri_dx gt {/colortri_dx 1 index def}if
  159. pop 1 get
  160. dup colortri_y0 lt {/colortri_y0 1 index def}if
  161. dup colortri_dy gt {/colortri_dy 1 index def}if
  162. pop
  163. } forall
  164. colortri_dx colortri_x0 sub /colortri_dx exch def
  165. colortri_dy colortri_y0 sub /colortri_dy exch def
  166. %
  167. % determine the scale
  168. colortri_box 2 get colortri_box 0 get sub colortri_dx div % fx
  169. colortri_box 3 get colortri_box 1 get sub colortri_dy div % fx fy
  170. gt { % fy limits
  171. colortri_box 3 get colortri_box 1 get sub
  172. dup colortri_dx mul colortri_dy div exch
  173. }{ % fx limits
  174. colortri_box 2 get colortri_box 0 get sub
  175. dup colortri_dy mul colortri_dx div
  176. } ifelse
  177. dtransform abs colortri_scale div cvi /colortri_ny exch def
  178. abs colortri_scale div cvi /colortri_nx exch def
  179. colortri_nx colortri_scale mul colortri_ny colortri_scale mul
  180. idtransform abs exch abs exch
  181. colortri_box 0 get colortri_box 2 get 1 index sub 3 index sub 2 div add
  182. colortri_box 1 get colortri_box 3 get 1 index sub 3 index sub 2 div add
  183. transform .5 add cvi exch .5 add cvi exch itransform
  184. translate scale
  185. % String & indices
  186. /colortri_tmp colortri_nx 3 mul string def
  187. /colortri_dx colortri_dx colortri_nx 1 sub div def
  188. /colortri_dy colortri_dy colortri_ny 1 sub div def
  189. /colortri_xy [ colortri_x0 colortri_y0 ] def
  190. /colortri_ie colortri_tmp length 3 sub def
  191. colortri_nx colortri_ny 8 [ colortri_nx 0 0 colortri_ny 0 0 ]
  192. {
  193. colortri_xy 0 colortri_x0 put
  194. 0 3 colortri_ie {
  195. colortri_tmp exch % buf ir
  196. colortri_xy xy2rgb % buf ir rgb buf ib
  197. 2 index 2 index 2 add 2 index 2 get 255 mul cvi put
  198. 2 index 2 index 1 add 2 index 1 get 255 mul cvi put
  199. 0 get 255 mul cvi put
  200. colortri_xy dup 0 exch 0 get colortri_dx add put
  201. }for
  202. colortri_xy dup 1 exch 1 get colortri_dy add put
  203. colortri_tmp
  204. } bind
  205. false 3 colorimage
  206. restore
  207. } bind def
  208. % [ newpath clippath pathbbox ] colortri showpage % standalone usage
  209. % End: colortri_procedures
  210. % The next section is a group of procedures, that I for myself
  211. % do no more fully understand, but they do the Job.
  212. % Begin: stcinfo_procedures_1
  213. % fetch a parameter from the dictionary
  214. /STCiget { STCinfo exch get } bind def
  215. % action upon ProcessColorModel
  216. /STCimode {
  217. /ProcessColorModel STCiget dup
  218. /DeviceCMYK eq{pop 2}{/DeviceRGB eq{1}{0}ifelse}ifelse get exec
  219. } bind def
  220. % print given number of blanks
  221. /STCipspace {
  222. dup 0 gt{ 1 exch 1 exch { pop ( ) print}for }{ pop } ifelse
  223. } bind def
  224. % print right or left-justified text
  225. /STCiprint {
  226. dup 0 gt { dup 2 index length sub STCipspace } if
  227. 1 index print
  228. dup 0 lt { neg dup 2 index length sub STCipspace } if
  229. pop pop
  230. } bind def
  231. % floating-point to fixed-length-string conversion
  232. /STCicvs { % number -> string
  233. % Prepare the result
  234. 8 string dup 0 ( ) putinterval
  235. exch
  236. % Make it unsigned
  237. dup 0 lt {neg(-)}{( )}ifelse 0 get exch
  238. dup 1000 lt 1 index 0 eq 2 index 0.001 ge or and { % floating point
  239. (e+) 0
  240. }{ % engineering
  241. 0 {
  242. 1 index 1000.0 ge
  243. {3 add exch 1000 div exch}
  244. {1 index 1 lt {3 sub exch 1000 mul exch}{exit}ifelse}
  245. ifelse
  246. }loop
  247. dup 0 lt {neg(e-)}{(e+)}ifelse exch
  248. }ifelse
  249. % string sign num esig e
  250. % always up to three Integer Digits plus sign
  251. 2 index cvi 3 { % string sign num esig e int ind
  252. 1 index 10 div cvi dup 10 mul 3 index exch sub cvi
  253. (0123456789) exch get 8 index exch 3 index exch put
  254. 3 -2 roll 1 sub exch pop dup 0 eq 2 index 0 eq or {exit} if
  255. } loop exch pop % string sign num esig e ind
  256. 5 index exch 6 -1 roll put % string num esig e
  257. % print either fraction or exponent
  258. dup 0 eq { pop pop dup cvi sub % String fraction
  259. dup 0.0 ne { % Fraction present
  260. 0.0005 add 1 index 4 (.) putinterval
  261. 5 1 7 { % string frac ind
  262. exch 10 mul dup cvi exch 1 index sub % string ind ic nfrac
  263. exch (0123456789) exch get 3 -1 roll % string nfrac chr ind
  264. exch 3 index 3 1 roll put
  265. } for
  266. } if
  267. pop
  268. }{ 3 -1 roll pop % string esig e
  269. exch 2 index exch 4 exch putinterval
  270. 7 -1 6 { % string n i
  271. 1 index 10 div cvi dup 10 mul 3 index exch sub cvi % string n i n/10
  272. (0123456789) exch get 4 index exch 3 index exch put
  273. exch pop exch pop
  274. } for
  275. pop
  276. } ifelse
  277. } bind def
  278. % compute colorvalue-steps from transfer & coding
  279. /STCisteps { % xfer, coding => X-values, Y-Values
  280. % 2^nbits
  281. 2 /BitsPerComponent STCiget dup 11 gt { pop 11 } if exp cvi
  282. % X & Y - Arrays (stack: xv:4 yv:3 xfer:2 coding:1 2^ni:0)
  283. dup 1 add array 1 index array 5 2 roll
  284. % compute GS-Color-Value according to the coding-array
  285. 1 index null eq { % no coding present
  286. 0 1 2 index 1 sub {
  287. dup 6 index exch dup 4 index div put
  288. 4 index exch dup 3 index 1 sub div put
  289. } for
  290. }{ % coding-array given
  291. 1.0 1 index 1 sub div % y step
  292. 0 % current index
  293. 0 1 4 index 1 sub { % over indices
  294. dup 3 index mul
  295. {
  296. dup 3 index 1 add dup 8 index length ge {pop pop exit} if % i y
  297. 7 index exch get le {exit} if
  298. 2 index 1 add 3 1 roll 4 -1 roll pop
  299. } loop
  300. 5 index 3 index get sub
  301. 5 index 3 index 1 add get 6 index 4 index get sub div
  302. 2 index add 5 index length 1 sub div
  303. 2 copy exch dup 0 eq {
  304. 10 index exch 0.0 put pop
  305. }{
  306. dup 10 index exch 1 sub get 3 -1 roll add 2 div
  307. 10 index 3 1 roll put
  308. }ifelse
  309. 7 index 3 1 roll put
  310. } for % over indices
  311. pop pop
  312. } ifelse
  313. 4 index 1 index 1.0 put
  314. % Replace the raw y-values by those computed from the transfer-array
  315. 0 1 2 index 1 sub { % over indices, 2nd
  316. dup 5 index exch get
  317. dup 5 index length 1 sub mul cvi % -> iy
  318. 5 index 1 index get
  319. 1 index 1 add 7 index length lt {
  320. dup 7 index 3 index 1 add get exch sub
  321. 3 index 3 index 9 index length 1 sub div sub mul
  322. 7 index length 1 sub mul add
  323. } if
  324. exch pop exch pop 5 index 3 1 roll put
  325. } for % over indices, 2nd
  326. pop pop pop
  327. } bind def
  328. /STCibar { % Window X-Values proc => Window
  329. 0 1 3 index length 2 sub {
  330. dup 3 index exch get exch
  331. 1 add 3 index exch get
  332. dup 2 index add 2 div 3 index exec % Color to average
  333. 4 index 2 get 5 index 0 get sub exch 1 index mul 5 index 0 get add 3 1 roll
  334. mul 4 index 0 get add 4 index 3 get 5 index 1 get
  335. newpath
  336. 2 index 1 index moveto
  337. 3 index 1 index lineto
  338. 3 index 2 index lineto
  339. 2 index 2 index lineto
  340. closepath fill
  341. pop pop pop pop
  342. } for
  343. pop pop
  344. 0 setgray
  345. newpath
  346. dup 0 get 1 index 1 get moveto
  347. dup 2 get 1 index 1 get lineto
  348. dup 2 get 1 index 3 get lineto
  349. dup 0 get 1 index 3 get lineto
  350. closepath stroke
  351. pop
  352. } bind def
  353. % End: stcinfo_procedures_1
  354. % Begin: stcinfo_preparation
  355. % Compute used area from clippath
  356. /STCi_clip [
  357. newpath clippath pathbbox
  358. 2 sub 4 1 roll 2 sub 4 1 roll 2 add 4 1 roll 2 add 4 1 roll
  359. ] def
  360. %
  361. % Perpare the texual messages, assume no stcolor if this fails
  362. %
  363. {
  364. /STCi_stopped % A Special Mark
  365. % Textual Parameters (an array of pairs of strings)
  366. /STCi_l1 0 def
  367. /STCi_l2 0 def
  368. /STCi_text [
  369. % Driver-Name & Version
  370. (Parameters of)
  371. /Name STCiget length /Version STCiget length add 1 add string
  372. dup 0 /Name STCiget putinterval dup /Name STCiget length (-)putinterval
  373. dup /Name STCiget length 1 add /Version STCiget putinterval
  374. % Dithering-Algorithm
  375. (Dithering)
  376. /Dithering STCiget
  377. [{( \(Monochrome\))}{( \(RGB\))}{( \(CMYK\))}] STCimode
  378. dup length 2 index length add string exch 1 index exch
  379. 3 index length exch putinterval dup 3 1 roll exch 0 exch putinterval
  380. % Flags for the algorithm
  381. (Flag4-0) 5 string
  382. dup 0 /Flag4 STCiget {(T)}{(f)} ifelse putinterval
  383. dup 1 /Flag3 STCiget {(T)}{(f)} ifelse putinterval
  384. dup 2 /Flag2 STCiget {(T)}{(f)} ifelse putinterval
  385. dup 3 /Flag1 STCiget {(T)}{(f)} ifelse putinterval
  386. dup 4 /Flag0 STCiget {(T)}{(f)} ifelse putinterval
  387. % Bits Per Pixel & Bits Per Component
  388. (BitsPerPixel) 10 string % (nn -> nxnn)
  389. /BitsPerPixel STCiget 1 index cvs length % string used
  390. dup 2 index exch ( -> ) putinterval 4 add dup 2 add exch 2 index exch
  391. [{(1x)}{(3x)}{(4x)}] STCimode putinterval % String used
  392. /BitsPerComponent STCiget 2 index 2 index 2 getinterval cvs length add
  393. 0 exch getinterval
  394. () ()
  395. % ColorAdjustMatrix
  396. (ColorAdjustMatrix)
  397. /ColorAdjustMatrix STCiget dup null eq {
  398. pop (default)
  399. }{
  400. { STCicvs } forall
  401. [{ % Monochrome
  402. 26 string
  403. dup 0 6 -1 roll putinterval dup 8 ( ) putinterval
  404. dup 9 5 -1 roll putinterval dup 17 ( ) putinterval
  405. dup 18 4 -1 roll putinterval
  406. }{ % RGB
  407. 26 string
  408. dup 0 12 -1 roll putinterval dup 8 ( ) putinterval
  409. dup 9 11 -1 roll putinterval dup 17 ( ) putinterval
  410. dup 18 10 -1 roll putinterval
  411. () 26 string
  412. dup 0 11 -1 roll putinterval dup 8 ( ) putinterval
  413. dup 9 10 -1 roll putinterval dup 17 ( ) putinterval
  414. dup 18 9 -1 roll putinterval
  415. () 26 string
  416. dup 0 10 -1 roll putinterval dup 8 ( ) putinterval
  417. dup 9 9 -1 roll putinterval dup 17 ( ) putinterval
  418. dup 18 8 -1 roll putinterval
  419. }{
  420. 35 string
  421. dup 0 19 -1 roll putinterval dup 8 ( ) putinterval
  422. dup 9 18 -1 roll putinterval dup 17 ( ) putinterval
  423. dup 18 17 -1 roll putinterval dup 26 ( ) putinterval
  424. dup 27 16 -1 roll putinterval
  425. () 35 string
  426. dup 0 17 -1 roll putinterval dup 8 ( ) putinterval
  427. dup 9 16 -1 roll putinterval dup 17 ( ) putinterval
  428. dup 18 15 -1 roll putinterval dup 26 ( ) putinterval
  429. dup 27 14 -1 roll putinterval
  430. () 35 string
  431. dup 0 15 -1 roll putinterval dup 8 ( ) putinterval
  432. dup 9 14 -1 roll putinterval dup 17 ( ) putinterval
  433. dup 18 13 -1 roll putinterval dup 26 ( ) putinterval
  434. dup 27 12 -1 roll putinterval
  435. () 35 string
  436. dup 0 13 -1 roll putinterval dup 8 ( ) putinterval
  437. dup 9 12 -1 roll putinterval dup 17 ( ) putinterval
  438. dup 18 11 -1 roll putinterval dup 26 ( ) putinterval
  439. dup 27 10 -1 roll putinterval
  440. }
  441. ] STCimode
  442. } ifelse
  443. () ()
  444. % Printer Model
  445. (Printer-Model) /Model STCiget
  446. % Resolution
  447. (Resolution) 15 string % (nnnnnxnnnnn DpI)
  448. /HWResolution STCiget 0 get cvi 1 index cvs length
  449. dup 2 index exch (x) putinterval 1 add dup 2 index exch 5 getinterval
  450. /HWResolution STCiget 1 get cvi exch cvs length add dup 2 index
  451. exch ( DpI) putinterval 4 add 0 exch getinterval
  452. % HWsize holds entire Page in Pixels,
  453. % .HWMargins is [left,bottom,right,top] in Points
  454. (Printed Area) 18 string % (nnnnnxnnnnn Pixel)
  455. /HWSize STCiget 0 get /.HWMargins STCiget dup 0 get exch 2 get add
  456. /HWResolution STCiget 0 get mul 72.0 div sub cvi 1 index cvs length
  457. dup 2 index exch (x) putinterval 1 add dup 2 index exch 5 getinterval
  458. /HWSize STCiget 1 get /.HWMargins STCiget dup 1 get exch 3 get add
  459. /HWResolution STCiget 1 get mul 72.0 div sub cvi exch cvs length add
  460. dup 2 index exch ( Pixel) putinterval 6 add 0 exch getinterval
  461. () ()
  462. % WeaveMode
  463. (Weave-Mode)
  464. /noWeave STCiget {
  465. (noWeave)
  466. }{
  467. /Microweave STCiget {(Microweave)}{(Softweave)}ifelse
  468. }ifelse
  469. % Unidirectional
  470. (Unidirectional) /Unidirectional STCiget {(ON)}{(off)} ifelse
  471. % Output coding
  472. (OutputCode) /OutputCode STCiget
  473. % number of heads
  474. (escp_Band) /escp_Band STCiget 3 string cvs
  475. (escp_Width) /escp_Width STCiget 5 string cvs
  476. (escp_Height) /escp_Height STCiget 5 string cvs
  477. (escp_Top) /escp_Top STCiget 5 string cvs
  478. (escp_Bottom) /escp_Bottom STCiget 5 string cvs
  479. ] def
  480. %
  481. % compute the Proper X & Y-Arrays
  482. %
  483. [{ % Monochrome
  484. /Ktransfer STCiget /Kcoding STCiget STCisteps
  485. /STCi_yv [ 3 -1 roll ] def
  486. /STCi_xv [ 3 -1 roll ] def
  487. /STCi_col [[0 0 0]] def
  488. /STCi_set [{1.0 exch sub setgray}] def
  489. }{ % RGB
  490. /Rtransfer STCiget /Rcoding STCiget STCisteps
  491. /Gtransfer STCiget /Gcoding STCiget STCisteps
  492. /Btransfer STCiget /Bcoding STCiget STCisteps
  493. exch 4 -1 roll 6 -1 roll exch 3 -1 roll
  494. /STCi_xv [ 5 2 roll ] def
  495. /STCi_yv [ 5 2 roll ] def
  496. /STCi_col [[1 0 0] [0 1 0] [0 0 1]] def
  497. /STCi_set [
  498. {1.0 exch sub 1 exch dup setrgbcolor}
  499. {1.0 exch sub dup 1 exch setrgbcolor}
  500. {1.0 exch sub dup 1 setrgbcolor}
  501. ] def
  502. }{ % CMYK
  503. /Ctransfer STCiget /Ccoding STCiget STCisteps
  504. /Mtransfer STCiget /Mcoding STCiget STCisteps exch 3 1 roll
  505. /Ytransfer STCiget /Ycoding STCiget STCisteps exch 4 1 roll
  506. /Ktransfer STCiget /Kcoding STCiget STCisteps exch 5 1 roll
  507. /STCi_yv [ 6 2 roll ] def
  508. /STCi_xv [ 6 2 roll ] def
  509. /STCi_col [[0 1 1] [1 0 1] [1.0 0.5 0.0] [0 0 0]] def
  510. /STCi_set [
  511. { 0 0 0 setcmykcolor }
  512. { 0 exch 0 0 setcmykcolor }
  513. { 0 exch 0 exch 0 setcmykcolor }
  514. { 0 exch 0 exch 0 exch setcmykcolor }
  515. ] def
  516. }
  517. ]STCimode
  518. } stopped
  519. { {/STCi_stopped eq {exit}if}loop true}
  520. { {/STCi_stopped eq {exit}if}loop false} ifelse
  521. % End: stcinfo_preparation
  522. % The Next section does the real job
  523. % Begin: stcinfo_execution
  524. {
  525. (%%[ stcinfo.ps: currentdevice is not supported -> colortri ]%%\n) print
  526. STCi_clip colortri % The default action
  527. }{
  528. %
  529. % Print the text
  530. %
  531. 0 2 STCi_text length 2 sub { dup 1 add exch
  532. STCi_text exch get length dup STCi_l1 gt{/STCi_l1 exch def}{pop}ifelse
  533. STCi_text exch get length dup STCi_l2 gt{/STCi_l2 exch def}{pop}ifelse
  534. } for
  535. /STCi_l2 STCi_l2 neg def
  536. 0 2 STCi_text length 2 sub {
  537. dup 1 add STCi_text exch get exch STCi_text exch get
  538. 1 index length 0 gt {
  539. dup STCi_l1 STCiprint length 0 gt {(: )}{( )}ifelse print print
  540. }{
  541. pop pop
  542. } ifelse
  543. (\n) print
  544. } for
  545. %
  546. % Deactivate a present ColorAdjust Matrix, if any
  547. %
  548. /ColorAdjustMatrix STCiget null ne STCi_onstc and {
  549. mark
  550. /ColorAdjustMatrix null
  551. currentdevice putdeviceprops pop
  552. } if
  553. %
  554. % "Show" the text
  555. %
  556. /Times-Roman findfont 10 scalefont setfont
  557. /STCi_l1 0 def
  558. 0 2 STCi_text length 2 sub {
  559. STCi_text exch get stringwidth pop dup STCi_l1 gt {
  560. /STCi_l1 exch def
  561. }{
  562. pop
  563. } ifelse
  564. } for
  565. STCi_l1 STCi_clip 0 get add /STCi_l1 exch def
  566. STCi_clip 3 get 12 sub
  567. 0 2 STCi_text length 2 sub {
  568. STCi_text exch get dup length 0 gt {
  569. dup stringwidth pop STCi_l1 exch sub 2 index moveto show
  570. }{
  571. pop
  572. } ifelse
  573. 12 sub
  574. } for
  575. pop
  576. /Courier findfont 10 scalefont setfont
  577. /STCi_l2 0 def
  578. 1 2 STCi_text length 1 sub {
  579. STCi_text exch get stringwidth pop dup STCi_l2 gt {
  580. /STCi_l2 exch def
  581. }{
  582. pop
  583. } ifelse
  584. } for
  585. STCi_clip 3 get 12 sub
  586. 1 2 STCi_text length 1 sub {
  587. STCi_text exch get dup length 0 gt {
  588. STCi_l1 12 add 2 index moveto show
  589. }{
  590. pop
  591. } ifelse
  592. 12 sub
  593. } for
  594. pop
  595. %
  596. % compute the space for the graph-window
  597. %
  598. STCi_l1 12 add STCi_l2 add 12 add dup STCi_clip 2 get exch sub % Extend
  599. [ 3 -1 roll dup 3 index add STCi_clip 3 get dup 5 index sub 3 1 roll ]
  600. /STCi_win exch def /STCi_l1 exch def
  601. % The "Axis"
  602. newpath
  603. STCi_win 0 get STCi_win 1 get 14 add moveto
  604. STCi_win 2 get STCi_win 1 get 14 add lineto stroke
  605. STCi_win 0 get 14 add STCi_win 1 get moveto
  606. STCi_win 0 get 14 add STCi_win 3 get lineto stroke
  607. % The Labels
  608. /Times-Roman findfont 10 scalefont setfont
  609. (Postscript-color) dup stringwidth pop
  610. STCi_win 2 get STCi_win 0 get sub 14 sub 1 index sub 2 div exch pop
  611. STCi_win 0 get add 14 add STCi_win 1 get 4 add moveto show
  612. gsave
  613. STCi_win 0 get 10 add STCi_win 1 get 14 add translate 90 rotate
  614. (Device-color) dup stringwidth pop
  615. STCi_win 3 get STCi_win 1 get sub 14 sub 1 index sub 2 div exch pop
  616. 0 moveto show
  617. grestore
  618. % The Graphs
  619. gsave
  620. STCi_win 0 get 14 add STCi_win 1 get 14 add
  621. STCi_win 2 get 2 index sub STCi_win 3 get 2 index sub
  622. 4 2 roll translate
  623. STCi_col 0 1 2 index length 1 sub {
  624. 1 index 1 index get aload pop setrgbcolor
  625. STCi_xv 1 index get STCi_yv 3 -1 roll get
  626. newpath
  627. 1 index 0 get 5 index mul 1 index 0 get 5 index mul moveto
  628. 1 index 1 get 5 index mul 1 index 0 get 5 index mul lineto
  629. 1 1 2 index length 1 sub {
  630. 2 index 1 index get 6 index mul
  631. 2 index 2 index get 6 index mul lineto
  632. 2 index 1 index 1 add get 6 index mul
  633. 2 index 2 index get 6 index mul lineto
  634. pop
  635. } for
  636. stroke pop pop
  637. } for
  638. pop pop pop
  639. grestore
  640. %
  641. % Find lowest Y from Text or graph
  642. %
  643. STCi_win 1 get STCi_clip 3 get STCi_text length 2 div 12 mul sub
  644. dup 2 index gt { pop } { exch pop } ifelse 12 sub
  645. %
  646. % compute the upper bar-window
  647. %
  648. /STCi_win [
  649. STCi_clip 0 get 4 -1 roll 36 sub STCi_clip 2 get 1 index 36 add
  650. ] def
  651. %
  652. % Draw the required number of graphs
  653. %
  654. [{ % Monochrome
  655. STCi_win STCi_xv 0 get {setgray} STCibar
  656. }{ % RGB
  657. STCi_win STCi_xv 0 get {0 0 setrgbcolor} STCibar
  658. STCi_win dup 1 exch 1 get 47 sub put
  659. STCi_win dup 3 exch 3 get 47 sub put
  660. STCi_win STCi_xv 1 get {0 0 3 1 roll setrgbcolor} STCibar
  661. STCi_win dup 1 exch 1 get 47 sub put
  662. STCi_win dup 3 exch 3 get 47 sub put
  663. STCi_win STCi_xv 2 get {0 0 3 2 roll setrgbcolor} STCibar
  664. }{ % CMYK
  665. STCi_win STCi_xv 0 get {0 0 0 setcmykcolor} STCibar
  666. STCi_win dup 1 exch 1 get 47 sub put
  667. STCi_win dup 3 exch 3 get 47 sub put
  668. STCi_win STCi_xv 1 get {0 0 0 4 1 roll setcmykcolor} STCibar
  669. STCi_win dup 1 exch 1 get 47 sub put
  670. STCi_win dup 3 exch 3 get 47 sub put
  671. STCi_win STCi_xv 2 get {0 0 0 4 2 roll setcmykcolor} STCibar
  672. STCi_win dup 1 exch 1 get 47 sub put
  673. STCi_win dup 3 exch 3 get 47 sub put
  674. STCi_win STCi_xv 3 get {0 0 0 4 3 roll setcmykcolor} STCibar
  675. }
  676. ] STCimode
  677. STCi_win 1 STCi_clip 1 get put
  678. STCi_win dup 3 exch 3 get 47 sub put
  679. %
  680. % Plot either one or two Color-Triangles
  681. %
  682. /ColorAdjustMatrix STCiget null ne STCi_onstc and {
  683. STCi_win 0 get STCi_win 2 get add 2 div
  684. [STCi_win 0 get STCi_win 1 get 3 index STCi_win 3 get ] colortri
  685. mark /ColorAdjustMatrix dup STCiget currentdevice putdeviceprops pop
  686. [1 index STCi_win 1 get STCi_win 2 get STCi_win 3 get ] colortri
  687. pop
  688. }{
  689. STCi_win colortri
  690. } ifelse
  691. newpath clippath stroke
  692. } ifelse
  693. showpage