I'd like to draw attention to particular instances of self-similarity in Sierpinski's triangle in LaTeX. Moreover, I would like to do so in a way that is customisable; that is, so that I can focus on different triangles.
I would be happy with something like this:
,
where I can change the red sub-triangle if necessary.
Something like this would be ideal though:
,
with the same ease of changing the red sub-triangle.
EDIT: If I may I'd like to ask even more of your ability. I'd like to do something like this too:
,
where the red and the blue triangles could be changed (by a novice like me).
Here's the code for the picture I've been painting on. It's not mine! See some of the first comments below.
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[
main tri/.style={isosceles triangle,fill,isosceles triangle apex angle=60,
rotate=90,inner sep=0,outer sep=0},
filler tri/.style={isosceles triangle,fill=white,rotate=-90,isosceles triangle apex angle=60,
inner sep=0,outer sep=0}]
\node[minimum height=2cm,main tri] (a) {};
%==================
\node[minimum height=1cm,filler tri] (b) at (a.center){};
%==================
\node[minimum height=0.5cm,filler tri,anchor=right corner] (c1) at (b.left side){};
\node[minimum height=0.5cm,filler tri,anchor=left corner] (c2) at (b.right side){};
\node[minimum height=0.5cm,filler tri,anchor=apex] (c3) at (b.west){};
% ===================
\foreach \x in {1,2,3}{
\node[minimum height=0.25cm,filler tri,anchor=right corner] (d1\x) at (c\x.left side){};
\node[minimum height=0.25cm,filler tri,anchor=left corner] (d2\x) at (c\x.right side){};
\node[minimum height=0.25cm,filler tri,anchor=apex] (d3\x) at (c\x.west){};
}
% ===================
\foreach \x in {1,2,3}{
\foreach \y in {1,2,3}{
\node[minimum height=0.125cm,filler tri,anchor=right corner] (e1\x\y) at (d\x\y.left side){};
\node[minimum height=0.125cm,filler tri,anchor=left corner] (e2\x\y) at (d\x\y.right side){};
\node[minimum height=0.125cm,filler tri,anchor=apex] (e3\x\y) at (d\x\y.west){};
}
}
\end{tikzpicture}
\end{document}
I'm afraid I don't know where to begin.