3

It is easy to use patterns for nice shapes like rectangle. How to fill an area by patterns enclosed by some curves? For example I have trouble with adding pattern to the following between two arcs:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw  (-1,1) node (v1) {} circle (4.5);
\draw  (v1) circle (2.5);
\draw (-5.5,1) arc (180:360:1 and .25);
\draw (1.5,1) arc (180:360:1 and .25);
\end{tikzpicture}
\end{document}
7

You need a closed shape to use patterns or fill. Shapes bounded by curves can be converted or redrawn like this:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\draw[pattern=horizontal lines] (-5.5,1) arc (180:360:1 and .25) arc (180:360:2.5) arc (180:360:1 and .25) arc (0:-180:4.5) -- cycle;
\end{tikzpicture}
\end{document}

Shape with pattern

  • @CarLaTeX I do not understand what you mean!? – hpekristiansen Feb 3 at 10:15
  • @CarLaTeX You meant to say \path[pattern=horizontal lines] ...? (\fill also does what you want it to do but this is in a way an accident.) – marmot Feb 3 at 16:22
  • 1
    @marmot Yes, \path, lapsus! – CarLaTeX Feb 3 at 16:28
  • Thanks @hpekristiansen. Is it possible to increase number of horizontal lines? – C.F.G Feb 4 at 5:30
  • @C.F.G: Yes, but not easily. - see e.g. tex.stackexchange.com/questions/54358/… – hpekristiansen Feb 4 at 7:05
5
\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw  (-1,1) node (v1) {} circle (4.5);
\draw  (v1) circle (2.5);

\fill[red](-5.5,1) arc (180:360:1 and .25)
arc(180:0:2.5)
arc (180:360:1 and .25)
arc (0:180:4.5) ;
\end{tikzpicture}
\end{document}

enter image description here

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.