3

How can I color three separate vertical sections in an ellipse? (For example, the French or Italian flags).

4 Answers 4

8

Something like this?

\documentclass[11pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (1.5, 1) ellipse (1.5 and 1);
\clip (1.5, 1) ellipse (1.5 and 1);
\fill[blue] (0,0) rectangle (1, 2);
\fill[white] (1,0) rectangle (2, 2);
\fill[red] (2,0) rectangle (3, 2);
\end{tikzpicture}
\end{document}

This produces the following output: output

3
  • 2
    A french ellipse? ;-)
    – user31729
    Sep 16, 2017 at 18:11
  • Yes, that's exactly what I was looking for. Thank you!
    – learning
    Sep 16, 2017 at 18:11
  • @ChristianHupfer: A Froggie ellipse.
    – Bernard
    Sep 16, 2017 at 18:38
6

Just for fun, an internationalist version with pstricks:

\documentclass[x11names, 12pt, border=6pt]{standalone}
\usepackage{graphicx}
\usepackage{pstricks-add}
\usepackage{auto-pst-pdf}

\begin{document}

\psset{plotstyle=curve, linejoin=1}
\sffamily
\begin{pspicture}(-5,-5)(5,5)
    \psclip{\psellipse[linestyle=none](0,0)(5,4)}
    \rput{90}(0,3){\includegraphics[scale=0.45]{north-korean-flag.eps}}
    \endpsclip
    \rput[l](-5,-5){\sffamily\bfseries In respectful homage to Kim Jong un}
\end{pspicture}

\end{document} 

enter image description here

1
  • nuclear salute!
    – percusse
    Sep 17, 2017 at 15:35
5

You could also use \nodepart.

Just for patriotism:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepgflibrary{shapes.multipart}
\definecolor{verdeb}{RGB}{0,146,70}
\definecolor{biancob}{RGB}{241,242,241}
\definecolor{rossob}{RGB}{206,43,55}
\begin{document}
\begin{tikzpicture}
    \draw[thick] ellipse (1.5 and 1);
    \clip ellipse (1.5 and 1);
    \node [rectangle split, rectangle split parts=3, draw,
        rectangle split horizontal,
        text width=1cm, minimum height=2.5cm, inner sep=0pt,
        rectangle split part fill={verdeb, biancob, rossob}]
        {\nodepart{two}\nodepart{three}};
\end{tikzpicture}
\end{document}

enter image description here

2
  • Isn't this site international?
    – Bernard
    Sep 16, 2017 at 22:51
  • 1
    @Bernard Of course, we are! I'm wondering how many LaTeX friends there are in North Corea... (+1, btw) :):):)
    – CarLaTeX
    Sep 17, 2017 at 2:42
4

Here is another suggestion using path picture:

\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand*\ppverticalfill[3]{
  \path[fill=#1]
    ($(path picture bounding box.south west)!#2!(path picture bounding box.south east)$)
    rectangle
    ($(path picture bounding box.north west)!#3!(path picture bounding box.north east)$)
}
\begin{document}
\begin{tikzpicture}
\draw[
    path picture={
      \ppverticalfill{blue}{0}{1/3};% first third
      \ppverticalfill{yellow}{1/3}{2/3};% second third
      \ppverticalfill{red}{2/3}{1};% last third
    }
  ](1.5, 1) ellipse (1.5 and 1);
\end{tikzpicture}
\end{document}

enter image description here

Other example with

\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand*\ppverticalfill[3]{
  \path[fill=#1]
    ($(path picture bounding box.south west)!#2!(path picture bounding box.south east)$)
    rectangle
    ($(path picture bounding box.north west)!#3!(path picture bounding box.north east)$)
}
\begin{document}
\begin{tikzpicture}
\draw[
    path picture={
      \foreach[count=\j] \i in {100,90,...,10}
        \ppverticalfill{green!\i!blue}{{(\j-1)/10}}{\j/10};
    }
  ](1.5, 1) ellipse (1.5 and 1);
\end{tikzpicture}
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .