aboutsummaryrefslogtreecommitdiff
path: root/postscript/prologues/color.ps
blob: e304cc3a3f3c9b81728192d4db9331888ff1176c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
%
% Color and reverse video support for dpost. A call made to setcolor with two
% arguments implies reverse video printing.
%

/rgb {setrgbcolor} bind def
/hsb {sethsbcolor} bind def

/colordict 50 dict dup begin
	/red			{ 1 0 0 } def
	/green			{ 0 1 0 } def
	/blue			{ 0 0 1 } def
	/cyan			{ 0 1 1 } def
	/magenta		{ 1 0 1 } def
	/yellow			{ 1 1 0 } def
	/white			{ 1 1 1 } def
	/black			{ 0 0 0 } def
end def

/setcolor {
	counttomark 1 eq {
		dup colordict exch known not {pop /black} if
		colordict exch get exec setrgbcolor
	} if
	counttomark 2 eq {
		/backcolor exch def
		/textcolor exch def
		colordict backcolor known not colordict textcolor known not or {
			/backcolor colordict /black get def
			/textcolor colordict /white get def
		} if
		/backcolor colordict backcolor get def
		/textcolor colordict textcolor get def
		/dY1 0 def
		/dY2 0 def
		textcolor exec setrgbcolor
	} if
} bind def

/drawrvbox {
	/x2 exch def
	/x1 exch def

	currentpoint dup
	/y1 exch def
	/y2 exch def pop

	dY1 0 eq dY2 0 eq and {
		currentfont /FontBBox get aload pop
		currentfont /FontMatrix get dtransform /dY2 exch def pop
		currentfont /FontMatrix get dtransform /dY1 exch def pop
	} if

	/y1 y1 dY1 add def
	/y2 y2 dY2 add def

	backcolor exec setrgbcolor
	newpath
	x1 y1 moveto
	x2 y1 lineto
	x2 y2 lineto
	x1 y2 lineto
	closepath fill
	textcolor exec setrgbcolor
} bind def