You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

794 lines
25 KiB

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