## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Filling for a custom Area Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
Bozack
Posts: 115
Joined: Wed Feb 06, 2008 4:21 pm

### Filling for a custom Area

I'm quite new to TikZ, and am trying to make a simple shape and fill it in with a color. As far as I understand, I can simply make a path, draw all the lines and curves, and then fill them as in the example code below:

\documentclass[11pt]{article}\usepackage{tikz} \begin{document}   \begin{tikzpicture}     \path [fill=Red, draw=Black, line width=1mm]       (1.34,-3.95) -- (4.36,-1.51)       arc [radius=3.77, start angle=201.24007, end angle=302.93512]       (9.92,-3.33) -- (8.96,-2.69) -- (12.56,-1.37) -- (12.58,-5.09) -- (11.48,-4.35)       arc [radius=6.57, start angle=318.5605, end angle=217.13745];   \end{tikzpicture}\end{document}

However, this results in a less than satisfactory result (see attachment). There is this weird line from the starting point to somewhere in the "pointy" end of the figure. Can you see what is wrong?
Attachments
result.png (7.82 KiB) Viewed 8078 times
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 7 Professional 64bit, MikTeX 2.9, TeXnicCenter 2.0 beta 1 64bit

Tags:

Klausiber
Posts: 16
Joined: Sun Apr 14, 2013 11:41 pm
Bozack wrote:As far as I understand, I can simply make a path, draw all the lines and curves, and then fill them as in the example code below
[...]
There is this weird line from the starting point to somewhere in the "pointy" end of the figure. Can you see what is wrong?

There are two things that contribute to your problem:

Whenever you tell TikZ to fill a path, this path needs to be closed, i.e. it must end at its starting point. When it does not, TikZ closes the path for you - this is the line you see.

Now you may wonder why your path is not closed and especially why the "closing line" starts after the first arc. The problem is the move-to operation you use there. The arc already ends in a point and yet you tell TikZ to move to another point (9.92,-3.33) - although this happens to be the same physical spot in this case - because you give it no line-to operation. This ends the path and starts a new one. I have no idea why the final filling operation works none the less.

Also note, that in your picture there's an ugly line joint at this very point. Maybe zoom in to see it better. This also indicates that TikZ does not see this a continued path as it would join the lines properly in this case. Have a look at the lower arc for reference.

Here's a corrected version:
\documentclass[11pt]{article}\usepackage{tikz} \begin{document}   \begin{tikzpicture}     \path [draw=black, fill=red, line width=1mm]       (4.36,-1.51) arc [radius=3.77, start angle=201.24007, end angle=302.93512]       -- (8.96,-2.69) -- (12.56,-1.37) -- (12.58,-5.09) -- (11.48,-4.35)       arc [radius=6.57, start angle=318.5605, end angle=217.13745] -- cycle;   \end{tikzpicture}\end{document}

Bozack
Posts: 115
Joined: Wed Feb 06, 2008 4:21 pm
Klausiber wrote:... you may wonder why your path is not closed and espacially why the "closing line" starts after the first arc. The problem is the move-to operation you use there. The arc already ends in a point and yet you tell TikZ to move to another point (9.92,-3.33) - although this happens to be the same physical spot in this case - because you give it no line-to operation. This ends the path and starts a new one.

Thank you so much for that solution, now I understand!
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 7 Professional 64bit, MikTeX 2.9, TeXnicCenter 2.0 beta 1 64bit

### Who is online

Users browsing this forum: No registered users and 4 guests