draw2d/resource/postscript/3dcolor.ps

58 lines
1.2 KiB
PostScript

%!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