[Tex/LaTex] Drawing a flag in Tikz!

tikz-pgf

I have some trouble with tikz. I wanted to draw a flag in Tikz – but that with minimal success. Here a sketch:
Sketch

The sketch is not how it should look like: the letters are just there so I am able to tell you what I actually wanted. The black rectangles shouldn't be there either, it should just show you the regions. It should just look like a green rectangle on a red rectangle with a star in the middle.

The letters are coordinates (in px). Here the coordinates:

The flag edges:

  • N=(0, 300)
  • M=(450, 0)

The star edges:

  • A=(200, 180)

  • B=(185, 135)

  • C=(225, 205)

  • D=(265, 135)

  • E=(250, 180)

Here is what I tried:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{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{tikzpicture}
\fill[fill=grun] (0, 0) rectangle (12, 4.5);
\fill[fill=red] (0,4.5) rectangle (12, 9);
\end{tikzpicture}

\end{document}

Problems:
I don't know why definecolor don't work for "rot" and "gelb". I don't know how to define the units for tikz (so instead of using cm I could write the coordinates in px and get an result). I don't know how to draw the star.

Bonus question:
Is it possible to play with the scale of the done tikzpicture (so make it fill the whole page)? I thought of something like minipage? But that is not an important question, I am just curious for next Tikz projects.

Kind regards and thank you in advance!

Best Answer

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}

enter image description here