1

I am rather new to tikz, but I have been studying it extensively lately, and I have received great help in this question I asked here. I have written the code below

\begin{tikzpicture} [scale=2]
\coordinate (A) at (0,3);
\coordinate (B) at (0,0);
\coordinate (C) at (3,0);
\coordinate (D) at (3,3);

\coordinate (E) at (0,2); \coordinate (F) at (3,2);

\draw[fill=teal] (E) .. controls (1.5,2.75) and (1.5,2.75) .. (F) -- (C) -- (B) -- (E);

\draw (A) -- (E); \draw (D) -- (F);

\draw[color=blue] (E) .. controls (1.5,2.75) and (1.5,2.75) .. (F) ;

\end{tikzpicture}

which produces the figure on the left, whereas I seek the one on the right in what appears below

curves

I do not care about the colors, nor the length and width of the outer frame/box. What I do care about is the shape of the arc/curve on top. In the left figure, the curve seems to be curved at the beginning and end, whereas in the right figure, the top curve/arc is flatter near the left and right endpoints (I have highlighted the specified areas of concern in red). I have tried modifying my control points but that did not seem to work. Can this be done with tikz using control points, or do I need something else entirely? I thank all helpers and would appreciate any and all help on this.

  • You'll need to draw it as two bezier curves, so you'll need a middle point on the curve, maybe G at (1.5,2.5), then something like (E) .. controls +(1,0) and +(-1,0) .. (G) .. controls +(1,0) and +(-1,0) .. (F). Experiment a bit with the numbers to get what you want. – Andrew Stacey Apr 13 '22 at 19:30

1 Answers1

2

Probably the easiest way to adjust curves like this is to use out= and in= in the to command:

\draw (E) to[out=0, in=180] (G) will make the outgoing angle 0 (to the east) from (E) and the incoming angle 180 (from the west) into (G). So place the coordinate (G) where you want, say at (1.5,2.5).

enter image description here

You can adjust the looseness of the arc by adding looseness=.8 (or whatever factor appeals to you) to the \draw options: \draw[fill=teal, looseness=.8].

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture} [scale=2] \coordinate (A) at (0,3); \coordinate (B) at (0,0); \coordinate (C) at (3,0); \coordinate (D) at (3,3);

\coordinate (E) at (0,2); \coordinate (F) at (3,2); \coordinate (G) at (1.5,2.5);

\draw[fill=teal] (E) to[out=0, in=180] (G) to[out=0, in=180] (F) -- (C) -- (B) -- cycle;

\draw (A) -- (E); \draw (D) -- (F);

\end{tikzpicture}

\end{document}

Sandy G
  • 42,558