stcinfo.ps 25 KB

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