I was hoping to draw something like the following:
And I can by using \draw
twice:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=1mm]
\draw[fill=red](0,0)rectangle(4,4)--(8,8);
\draw[fill=blue](8,8)rectangle(12,12);
\end{tikzpicture}
\end{document}
However I was hoping to do this with a single \draw
. I can do this easily if both of the squares were the same color. à la,
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=1mm,fill=red]
\draw(0,0)rectangle(4,4)--(8,8)rectangle(12,12);
\end{tikzpicture}
\end{document}
But I can't figure out how to get two differently colored shapes with a single draw. Is there a way to change colors partway through a draw?
Best Answer
You could perhaps draw a line from
(0,0)
to(4,4)
and add anode
at each end.