I am looking for help creating the attached image in Tikz. The exact coloration of the shapes and borders can be changed, but any help with creating this shape would be appreciated.
1 Answers
Each elementary figure is created through the pic element bird; it is based on an equilateral triangle as @Andrew Stacey explained. Then, there are two more pic elements: flock composed of six birds and flocks composed of seven flocks. The drawing consists of seven flocks.
The constants are there to define the points forming a bird, in the trigonometric order.
The code
\documentclass[border=1cm, 11pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{math, calc}
\begin{document}
\tikzmath{
real \r, \a1, \d1, \a2, \d2, \a3, \d3, \a4, \d4, \b, \e;
\r = 1; \b = 5; \e = .75\r;
\a1 = 40; \a2 = 15; \a3 = 17; \a4 = \a1;
\d1 = .4\r; \d2 = .37\r; \d3 = .65\r; \d4 = \d3;
}
\tikzset{
pics/bird/.style 2 args={% color, fill color
code={%
\draw[#1, fill=#2!20]
(0, 0) -- +(-\a1: \d1) -- +(-\a2: \d2)
-- +(-\a3: \d3) -- +(-\a4: \d4) -- +(-30: \r)
{[rounded corners=2pt] -- +(\b: \e) -- +($(0: 1.732\r) -(\b: \e)$)}
-- +(60 -30: \r) -- +(60 -\a4: \d4) -- +(60 -\a3: \d3)
-- +(60 -\a2: \d2) -- +(60 -\a1: \d1) -- cycle;
}
},
pics/flock/.style 2 args={% color, fill color
code={%
\foreach \i in {0, 2, 4}{%
\path (0, 0) pic[rotate={60\i}] {bird={#1}{#1}};
\path (0, 0) pic[rotate={60(\i +1)}] {bird={#1}{#2}};
}
}
},
pics/flocks/.style 2 args={% color, fill color
code={%
\path (0, 0) pic {flock={#1}{#2}};
\foreach \i in {0, 1, ..., 5}{%
\path (\i60: 1.732*\r) pic {flock={#1}{#2}};
}
}
}
}
\begin{tikzpicture}
\path (0, 0) pic {flocks={violet}{white}};
\foreach \i in {0, 2, 4}{%
\path[rotate={\i60}] ($(0: 1.732\r) +(30: 3\r)$) pic {flocks={red}{white}};
}
\foreach \i in {1, 3, 5}{%
\path[rotate={\i60}]
($(0: 1.732\r) +(30: 3\r)$) pic {flocks={green!50!blue}{white}};
}
\end{tikzpicture}
\end{document}
- 5,687
-
-
Hi @Hello_world! I'm glad you like it. Don't forget to accept the answer. I guess you can recover the dark border line from your image. – Daniel N Dec 01 '22 at 15:23


a A 1(soamatches withA, and1with itself). I'm not sure how easy the documentation is to follow, but that's where I'd start. – Andrew Stacey Nov 28 '22 at 21:14