Since adequate answers have already been given, I've felt free to do this picture with MetaPost.
For me it was an occasion to use some recent features of the luamplib
package, (which gives an interface to MetaPost in LuaLaTeX). More precisely, I've made use of the px
unit (which I didn't know of) thanks to the \mpdim
command, and of the integration of colors defined by the xcolor
package, via the \mpcolor
command.
The rectangle's dimensions follow the OP's first wishes, except for the star, for which it seems that several points are missing. So I've included a star of my own.
Edit I've made some minor changes, for the flag to be more like Burkina-Faso's official one, the way Paul Gaborit reports in its comment on the OP's question. So the red and green parts are reversed, and the star diameter is exactly one-third of the flag's height.
\documentclass{standalone}
\usepackage{luamplib, xcolor}
\definecolor{grun}{HTML}{239D48}%green - colour of the top rectangle
\definecolor{rot}{HTML}{BF0028}%red - colour of the bottom rectangle
\definecolor{gelb}{HTML}{F6eC0F}%yellow - colour of the star
\begin{document}
\begin{mplibcode}
u := \mpdim{1px}; % Unit length
beginfig(1);
z = u*(450, 300); path rect; rect = unitsquare xscaled x yscaled .5y;
% Star summits (I was not able to use the OP's given coordinates)
pair S[]; S0 = y/6*right rotated 18;
for i = 2 step 2 until 8: S[i] := S[i-2] rotated 72; endfor
for i = 1 step 2 until 9:
S[i] = whatever[S[(i-3) mod 10], S[(i+1) mod 10]] = whatever[S[i-1], S[(i+3) mod 10]];
endfor
% Drawings
fill rect withcolor \mpcolor{grun};
fill rect shifted (0, .5y) withcolor \mpcolor{rot};
fill S0 for i = 1 upto 9: -- S[i] endfor -- cycle shifted .5z withcolor \mpcolor{gelb};
endfig;
\end{mplibcode}
\end{document}
A solution which allows to draw intersection segments
of any two intersections is available as tikz library fillbetween
.
This library works as general purpose tikz
library, but it is shipped with pgfplots
and you need to load pgfplots
in order to make it work:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\draw [name path=red,red] (120:1.06) circle (1.9);
%\draw [name path=yellow,yellow] (0:1.06) circle (2.12);
\draw [name path=green,green!50!black] (0:0.77) circle (2.41);
\draw [name path=blue,blue] (0:0) circle (1.06);
% substitute this temp path by `\path` to make it invisible:
\draw[name path=temp1, intersection segments={of=red and blue,sequence=L1}];
\draw[red,-stealth,ultra thick, intersection segments={of=temp1 and green,sequence=L3}];
\end{tikzpicture}
\end{document}
The key intersection segments
is described in all detail in the pgfplots
reference manual section "5.6.6 Intersection Segment Recombination"; the key idea in this case is to
create a temporary path temp1
which is the first intersection segment of red and blue
, more precisely, it is the first intersection segment in the L
eft argument in red and blue
: red
. This path is drawn as thin black path. Substitute its \draw
statement by \path
to make it invisible.
Compute the desired intersection segment
by intersecting temp1
and green
and use the correct intersection segment. By trial and error I figured that it is the third segment of path temp1
which is written as L3
(L
= left argument in temp1 and green
and 3
means third segment of that path).
The argument involves some trial and error because fillbetween
is unaware of the fact that end and startpoint are connected -- and we as end users do not see start and end point.
Note that you can connect these path segments with other paths. If such an intersection segment
should be the continuation of another path, use --
as before the first argument in sequence. This allows to fill paths segments:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\draw [name path=red,red] (120:1.06) circle (1.9);
%\draw [name path=yellow,yellow] (0:1.06) circle (2.12);
\draw [name path=green,green!50!black] (0:0.77) circle (2.41);
\draw [name path=blue,blue] (0:0) circle (1.06);
% substitute this temp path by `\path` to make it invisible:
\draw[name path=temp1, intersection segments={of=red and blue,sequence=L1}];
\draw[red,fill=blue,-stealth,ultra thick, intersection segments={of=temp1 and green,sequence=L3}]
[intersection segments={of=temp1 and green, sequence={--R2}}]
;
\end{tikzpicture}
\end{document}
Best Answer
Here is a possible way.
I switched to polar coordinates and use a scale factor to be able to use "natural" coordinates for
\rho
.If you use an older versions of TikZ, i.e. before
patterns.meta
was added, useand
pattern=north east lines
.One can also use
\clip
to clip the relevant region.