<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%% 
%%  The LaTeX Graphics Companion, 2ed (first printing May 2007)
%% 
%%  Example 6-5-19 on page 396.
%% 
%%  Copyright (C) 2007 Michel Goossens, Frank Mittelbach, Denis Roegel, Sebastian Rahtz, Herbert Vo\ss 
%% 
%%  It may be distributed and/or modified under the conditions
%%  of the LaTeX Project Public License, either version 1.3
%%  of this license or (at your option) any later version.
%% 
%%  See http://www.latex-project.org/lppl.txt for details.
%% 

\documentclass{ttctexa}
\pagestyle{empty}
\setcounter{page}{6}
\setlength\textwidth{348.0pt}
\StartShownPreambleCommands
\usepackage{pstricks,pst-3d}
\StopShownPreambleCommands
\begin{document}
\newcommand\CubeSide[4]{%
  \ThreeDput[normal=#1](#2){
  \psframe*[linecolor=#3](4,4)
  \rput(2,2){\footnotesize#4}}
}
\newcommand\TheCube[2]{%
\begin{pspicture}(-7,-5)(8,7)
  \bfseries
  \ifcase #1 \relax
  \or %1
    \psset{viewpoint=-1 -1 #2}
    \rput[l](-7,-5){{\normalsize \texttt{viewpoint=-1 -1 #2}}}
    \ifnum#2&gt;0\ThreeDput[normal=0 0 1]{\psgrid(-3,-3)(6,6)}\fi
    \CubeSide{-1 0 0}{0,4,0}{yellow}{FRONT}
    \CubeSide{0 -1 0}{0,0,0}{blue}{FRONT}
  \or %2
    \psset{viewpoint=1 -1 #2}
    \rput[l](-7,-5){{\normalsize \texttt{viewpoint=1 -1 #2}}}
    \ifnum#2&gt;0\ThreeDput[normal=0 0 1]{\psgrid(-3,-3)(6,6)}\fi
    \CubeSide{0 -1 0}{0,0,0}{blue}{FRONT}
    \CubeSide{1 0 0}{4,0,0}{white}{BACK}
  \or %3
    \psset{viewpoint=1 1 #2}
    \rput[l](-7,-5.5){{\normalsize \texttt{viewpoint=1 1 #2}}}
    \ifnum#2&gt;0\ThreeDput[normal=0 0 1]{\psgrid(-3,-3)(6,6)}\fi
    \CubeSide{1 0 0}{4,0,0}{white}{BACK}
    \CubeSide{0 1 0}{4,4,0}{green}{BACK}
  \or %4
    \psset{viewpoint=-1 1 #2}
    \rput[l](-7,-5.5){{\normalsize \texttt{viewpoint=-1 1 #2}}}
    \ifnum#2&gt;0\ThreeDput[normal=0 0 1]{\psgrid(-3,-3)(6,6)}\fi
    \CubeSide{0 1 0}{4,4,0}{green}{BACK}
    \CubeSide{-1 0 0}{0,4,0}{yellow}{FRONT}
  \fi
  \ifnum#2&lt;0\CubeSide{0 0 -1}{0,4,0}{magenta}{BOT}
  \else\CubeSide{0 0 1}{0,0,4}{red}{TOP}\fi
\end{pspicture}
}
\psset{unit=.35cm,subgriddiv=0}
\begin{tabular}{cc}
\TheCube{1}{1} &amp; \TheCube{2}{1}\\[-10pt]
\TheCube{3}{1} &amp; \TheCube{4}{1}\\
\end{tabular}
\end{document}
</pre></body></html>