aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/llgcode/ps/samples/3dcolor.ps
blob: 1b31d080c5872535913697e73559e14575492c25 (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
%!PS
/B {bind} bind def
/D {def} def
/Q {bind def} B D
/E {exch def} Q
/S {gsave} Q
/R {grestore} Q
/P 20 D
/N P 1 sub D
/I 1 P div D
initclip clippath pathbbox newpath
72 sub /URy E 72 sub /URx E 72 add /LLy E 72 add /LLx E
/Sq5 5 sqrt D
/F 2 Sq5 add D
/Wx URx LLx sub D /Wy URy LLy sub D
/Xx Wx 4 div D /Xy Wy F div D /X Xx Xy le {Xx}{Xy}ifelse D
Wx X 4 mul sub 2 div LLx add X 2 mul add Wy X F mul sub 2 div LLy add translate
/X X Sq5 mul D
X dup scale
0.1 X div setlinewidth
S
[ 1 .5 0 1 0 0 ] concat
0 1 N {I mul /A E
	0 1 N {I mul /B E
		S A B translate
		newpath 0 0 moveto I 0 rlineto 0 I rlineto I neg 0 rlineto
			closepath
		S I B add 1 1 A sub setrgbcolor fill R stroke % Green
		R
	      } for
      } for
R
S
[ -1 .5 0 1 0 0 ] concat
0 1 N {I mul /A E
	0 1 N {I mul /B E
		S A B translate
		newpath 0 0 moveto I 0 rlineto 0 I rlineto I neg 0 rlineto
			closepath
		S I B add 1 A sub 1 setrgbcolor fill R stroke % Blue
		R
	      } for
      } for
R
S
[ 1 .5 -1 0.5 0 1 ] concat
0 1 N {I mul /A E
	0 1 N {I mul /B E
		S A B translate
		newpath 0 0 moveto I 0 rlineto 0 I rlineto I neg 0 rlineto
			closepath
		S 1 1 B sub 1 A sub setrgbcolor fill R stroke % Red
		R
	      } for
      } for
R
showpage