color.ps 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. %
  2. % Color and reverse video support for dpost. A call made to setcolor with two
  3. % arguments implies reverse video printing.
  4. %
  5. /rgb {setrgbcolor} bind def
  6. /hsb {sethsbcolor} bind def
  7. /colordict 50 dict dup begin
  8. /red { 1 0 0 } def
  9. /green { 0 1 0 } def
  10. /blue { 0 0 1 } def
  11. /cyan { 0 1 1 } def
  12. /magenta { 1 0 1 } def
  13. /yellow { 1 1 0 } def
  14. /white { 1 1 1 } def
  15. /black { 0 0 0 } def
  16. end def
  17. /setcolor {
  18. counttomark 1 eq {
  19. dup colordict exch known not {pop /black} if
  20. colordict exch get exec setrgbcolor
  21. } if
  22. counttomark 2 eq {
  23. /backcolor exch def
  24. /textcolor exch def
  25. colordict backcolor known not colordict textcolor known not or {
  26. /backcolor colordict /black get def
  27. /textcolor colordict /white get def
  28. } if
  29. /backcolor colordict backcolor get def
  30. /textcolor colordict textcolor get def
  31. /dY1 0 def
  32. /dY2 0 def
  33. textcolor exec setrgbcolor
  34. } if
  35. } bind def
  36. /drawrvbox {
  37. /x2 exch def
  38. /x1 exch def
  39. currentpoint dup
  40. /y1 exch def
  41. /y2 exch def pop
  42. dY1 0 eq dY2 0 eq and {
  43. currentfont /FontBBox get aload pop
  44. currentfont /FontMatrix get dtransform /dY2 exch def pop
  45. currentfont /FontMatrix get dtransform /dY1 exch def pop
  46. } if
  47. /y1 y1 dY1 add def
  48. /y2 y2 dY2 add def
  49. backcolor exec setrgbcolor
  50. newpath
  51. x1 y1 moveto
  52. x2 y1 lineto
  53. x2 y2 lineto
  54. x1 y2 lineto
  55. closepath fill
  56. textcolor exec setrgbcolor
  57. } bind def