% Title: The ParaTriCube
% Tags: Clipping, Node positioning, Shadings, Macros
% Author: Jacques Duma
% Site: http://math.et.info.free.fr/TikZ/index.html

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc}

\usepackage{verbatim}

\begin{comment}
:Title: The ParaTriCube
:Tags: Paths, Scopes, Clipping, Macros, Decorations
:Author: Jacques Duma
:Site: http://math.et.info.free.fr/TikZ/index.html

Paradoxical triangle made of nine paradoxical cubes.
\end{comment}


% Paradoxical cube
%: \ParaCube[<TikZ options>]{<line color>}{<frame color>}
\newcommand{\ParaCube}[3][scale=1]
{\begin{scope}[#1,scale=.03,shift={(-79,-87)},even odd rule,draw=#2,line join=round]
\draw[fill=#3]
  (94,15.5)--(90,62.9)--(104,59.2)--(107,20.3)--(101,7)--cycle;
\draw (100.4,14.4)--(96.9,61.1);
\draw[fill=#3]
  (64,159.8)--(68,112)--(55,115.1)--(52,154.9)--(59,161)--cycle;
\draw (57.6,159.8)--(61.2,113.6);
\draw[fill=#3] (10,30)--(64,77)--(154,53)--(101,7)--(10,30)--cycle
  (24,33)--(66,69)--(140,50)--(100,14)--(24,33)--cycle;
\draw[fill=#3] (147,145)--(57,168)--(4,121)--(94,99)--(147,145)--cycle
  (17,124)--(59,161)--(134,142)--(94,106)--(17,124)--cycle;
\draw[fill=#3] (56,100.5)--(58,80)--(16,44)--(11,111)--(88,93)--
  (89,77.2)--(95.8,75.4)--(94,99)--(4,121)--(10,30)--
  (64,77)--(62.3,99)--(56,100.5);
\draw[fill=#3] (103,73.6)--(101,94)--(140,129)--(145,63)--
  (70,82)--(69,97.5)--(62.3,99)--(64,77)--(154,53)--
  (147,145)--(94,99)--(95.8,75.4)--(103,73.6);
\end{scope}}

% Paradoxical triangle made of 9 paradoxical cubes
%: \ParaTriCube[<TikZ options>]{<lc1>}{<fc1>}{<lc2>}{<fc2>}{<lc3>}{<fc3>}
% <lci> <fci> line color and frame color of i-th cube of a triangle side
\newcommand{\ParaTriCube}[7][shift={(0,0)}]{\begin{scope}[#1,shift={(-6.8,-4.8)},scale=.95]
% side one
\ParaCube [shift={(8.9,11.6)}]{#2}{#3}
\ParaCube [shift={(6.1,8.6)}]{#4}{#5}
\ParaCube [shift={(3.3,5.6)}]{#6}{#7}
% side two
\ParaCube [shift={(0.5,2.6)}]{#2}{#3}
\ParaCube [shift={(4,1.9)}]{#4}{#5}
\ParaCube [shift={(7.5,1.2)}]{#6}{#7}
% side three
\ParaCube [shift={(11,0.5)}]{#2}{#3}
\ParaCube [shift={(10.3,4.2)}]{#4}{#5}
\ParaCube [shift={(9.6,7.9)}]{#6}{#7}
% clip outline of last cube
\clip [shift={(7.23,5.29)},scale=0.03](9,30)--(101,7)--(154,53)--(147,146)--(57,169)--(3,122)--(9,30);
% redraw the first two cubes
\ParaCube [shift={(8.9,11.6)}]{#2}{#3}
\ParaCube [shift={(6.1,8.6)}]{#4}{#5}
\end{scope}}

\begin{document}

\pagestyle{empty}

\begin{center}
\begin{tikzpicture}
  \ParaCube [shift={(-5,8)},scale=1.5,ultra thick] {black}{yellow!50}
  \ParaTriCube {red}{white} {green!25!black}{white} {blue}{white}
\end{tikzpicture}
\end{center}
 

\end{document}