3

I am trying to recreate the following image

enter image description here

After a bit of fiddling I was able to create the following

enter image description here

Where the code can be found at the bottom. While I am happy with the result, I am not happy with my approach / code.

Is there a cleaner / better way to create the image in question? In particular

  • Is there any way to avoid guessing the semicircles?
  • Could a better result be achieved with polynomials instead?
  • Is there a better way to do the intersection between the rectangle and circles? The whole part with \tkzDrawPolygon[color=dark,fill=dark,line width = 0cm](A,E,F,D) feels wrong and dirty.
  • Can the rectangle be created any easier?
  • Can one use any overlays or something to make sure the tikz solution is accurate? Now I imported the image into Geogebra and fiddled around until I achieved something "sensible". However, except the colors it is not particularly accurate.

enter image description here

Code

\documentclass[tikz,border=1mm]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}

\usepackage{color}

\definecolor{light}{HTML}{c48fcd}
\definecolor{medium}{HTML}{a757b2}
\definecolor{dark}{HTML}{9637a0}

\begin{document}

\begin{tikzpicture}
    \tkzInit[xmax=18.72, ymax=3.2]
    \tkzClip
    \tkzDefPoint(0,0){A} \tkzDefPoint(18.72,0){B}
    \tkzDefPoint(18.72,3.2){C}
    \tkzDefPoint(0,3.2){D}
    \tkzDefPoint(10,0){E}
    \tkzDefPoint(10,3.2){F}

    \tkzDefPoint(6.96, 16.5){S1}
    \tkzDefPoint(8.02, 13.68){S2}

    \tkzDefPoint(14.00028,1.24159){R1}
    \tkzDefPoint(14.76398,1.2677){R2}

    \tkzDrawPolygon[color=medium,fill=medium,line width = 0cm](A,B,C,D)

    \tkzDrawCircle[color=light, fill=light](S2,R2)
    \tkzDrawCircle[color=dark, fill=dark](S1,R1)    

    \tkzDrawPolygon[color=dark,fill=dark,line width = 0cm](A,E,F,D)

\end{tikzpicture}

\end{document}
3

This is a much shorter code that reproduces your screen shot rather well IMHO. I also address your question to fit it precisely in a page. (\usepackage[showframe]{geometry} is used to show that it works.)

\documentclass{article}
\usepackage{tikz}
\usepackage[showframe]{geometry}
\definecolor{light}{HTML}{c48fcd}
\definecolor{medium}{HTML}{a757b2}
\definecolor{dark}{HTML}{9637a0}
\begin{document}
\noindent%
\pgfmathsetmacro{\myscale}{\textwidth/18.85cm}%
\begin{tikzpicture}[nodes={inner sep=0pt,outer sep=0pt},scale=\myscale]
 \fill[dark]  (0,0) rectangle (18.85,3.25);
 \fill[light] (10,0) to[out=14,in=-140] (17.32,3.25)--
  (17.6,3.25) to[out=-140,in=15] (11.7,0) -- cycle;
 \fill[medium] (17.6,3.25) to[out=-140,in=15] (11.7,0) -| (18.85,3.25) -- cycle;
 \node[anchor=south west,text=white,font=\sffamily\bfseries,scale=3*\myscale] at (0.5,0.75){Prove};
 \node[anchor=south east,text=white,font=\sffamily\bfseries,scale=2*\myscale] at (18.3,0.4)
 {24.05.2019};
\end{tikzpicture}
\end{document}

enter image description here

As for your questions:

  • Is there any way to avoid guessing the semicircles? -- You need to have an idea what the path should be. Circles are not a bad choice IMHO.
  • Could a better result be achieved with polynomials instead? -- I do not see how polynomials may help but there are many ways to draw such arcs.
  • Is there a better way to do the intersection between the rectangle and circles? The whole part with \tkzDrawPolygoncolor=dark,fill=dark,line width = 0cm feels wrong and dirty. -- Yes, see my code below. You do not need any of the tkz-euclide stuff and can shorten the code considerably.
  • Can the rectangle be created any easier? -- Yes, there is the rectangle path construction which is used below.
  • Can one use any overlays or something to make sure the tikz solution is accurate? Now I imported the image into Geogebra and fiddled around until I achieved something "sensible". However, except the colors it is not particularly accurate. -- "Accurate" w.r.t. what? If you have a clear prescription for the arcs, you can achieve very good accuracy.

The following contains a much shorter code. Note also that tikz loads xcolor, so there is no need to load color.

\documentclass[tikz,border=1mm]{standalone}
\definecolor{light}{HTML}{c48fcd}
\definecolor{medium}{HTML}{a757b2}
\definecolor{dark}{HTML}{9637a0}

\begin{document}

\begin{tikzpicture}
    \fill[dark] (0,0) rectangle (18.72,3.2);
    \clip (6,0) rectangle (18.72,3.2);
    \pgfmathsetmacro{\rone}{veclen(7.04,15.35)}
    \pgfmathsetmacro{\rtwo}{veclen(6.74,12.41)}
    \fill[light,even odd rule] (6.9, 16.5) circle[radius={\rone*1cm}]
    (8.02, 13.68) circle[radius={\rtwo*1cm}];
    \fill[medium,even odd rule]     (8.02, 13.68) circle[radius={\rtwo*1cm}]
    (8.02, 13.68) circle[radius={2*\rtwo*1cm}];
\end{tikzpicture}

\end{document}

enter image description here

If you give me a hint for the prescription how this image is obtained, it will be possible to make it very accurate.

  • Awesome solution! Is there an easy way to scale this to fit on a standard pagewidth? I am not able to give much context for the image unfortunately as I obtained it from a pdf. It is used for the cover image for the exams at my school. – N3buchadnezzar May 24 at 17:32
  • 1
    @N3buchadnezzar I added a simple way to adjust the size to the text width. If you want to adjust it to another length, replace \textwidth in \pgfmathsetmacro{\myscale}{\textwidth/18.85cm} by this length. – user121799 May 24 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.