2

Using the following code, how can I fill this closed area with a pattern saved in an outside file as the enclosed one.

\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}[scale=.9, transform shape]
\node [thin, black] at (0,0) (i){x};
\draw [very thick, blue] (i.center) node (ii){} to [out=5, in=170] ++(0.:7.cm) -- +(-90:2.2cm)  to [out=130, in=-170, looseness=.6] (ii.center) -- cycle;
\end{tikzpicture}
\end{frame} 
\end{document} 

enter image description here

enter image description here

3

Beamer loading the graphicx package, I use an example image available with this package.

I use the path picture option which is defined in the section Generalized Filling: Using Arbitrary Pictures to Fill a Path of the TikZ manual.

screenshot

\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}[scale=.9, transform shape]
\node [thin, black] at (0,0) (i){};
\draw [very thick, blue] (i.center) node (ii){} to [out=5, in=170] ++(0.:7.cm) -- +(-90:2.2cm)  to [out=130, in=-170, looseness=.6] (ii.center) -- cycle
[path picture={\node at (path picture bounding box.center) {\includegraphics{example-image}};}];
\end{tikzpicture}
\end{frame} 
\end{document} 

Image size

As @zarko rightly points out, it is necessary that the image is larger than the path. Otherwise, there is a hole.

A solution is then to use a magnification factor, here scale=1.4.

image size

\documentclass{article}
\usepackage[margin=10mm]{geometry}
\usepackage{graphicx,mwe,tikz}

\begin{document}

\Huge{SCALE=1}
\smallskip

\newcommand{\facteur}{1}

\begin{tikzpicture}
\node [thin, black] at (0,0) (i){};
\node[] at (i.center){\includegraphics[scale=\facteur]{example-image}};
\draw [very thick, blue,fill=cyan!80,fill opacity=.5] (-2.7,1) node (ii){} to [out=5, in=170] ++(0.:7.cm) -- +(-90:2.2cm)  to [out=130, in=-170, looseness=.6] (ii.center) -- cycle
[path picture={\node at (path picture bounding box.center) {\includegraphics[scale=\facteur]{example-image}};}];

\draw(current bounding box.south east)rectangle(current bounding box.north west);
\end{tikzpicture}


\bigskip
\Huge{SCALE=1}
\smallskip

\begin{tikzpicture}
\node [thin, black] at (0,0) (i){};
\node[] at (i.center){\includegraphics[scale=\facteur]{example-image-duck}};
\draw [very thick, blue,fill=cyan!80,fill opacity=.5] (-2.7,1) node (ii){} to [out=5, in=170] ++(0.:7.cm) -- +(-90:2.2cm)  to [out=130, in=-170, looseness=.6] (ii.center) -- cycle
[path picture={\node at (path picture bounding box.center) {\includegraphics[scale=\facteur]{example-image-duck}};}];

\draw(current bounding box.south east)rectangle(current bounding box.north west);
\end{tikzpicture}

\renewcommand{\facteur}{1.4}
\bigskip
\Huge{SCALE=1.4}
\smallskip

\begin{tikzpicture}
\node [thin, black] at (0,0) (i){};
\node[] at (i.center){\includegraphics[scale=\facteur]{example-image-duck}};
\draw [very thick, blue,fill=cyan!80,fill opacity=.5] (-2.7,1) node (ii){} to [out=5, in=170] ++(0.:7.cm) -- +(-90:2.2cm)  to [out=130, in=-170, looseness=.6] (ii.center) -- cycle
[path picture={\node at (path picture bounding box.center) {\includegraphics[scale=\facteur]{example-image-duck}};}];

\draw(current bounding box.south east)rectangle(current bounding box.north west);
\end{tikzpicture}
\end{document}
6
  • Nice answer (+1), however if I replace example-image with example-image-duck result is not satisfactory (natural image size seems to be too small).
    – Zarko
    Aug 29 '20 at 12:22
  • If the image size is smaller than the path, is there a way to make it repeated to fill the whole path!
    – Hany
    Aug 29 '20 at 13:45
  • How can I upload the file containing the pattern?
    – Hany
    Aug 29 '20 at 13:47
  • The graphicx package allows you to enlarge or deform it by enlarging it horizontally or vertically. It does not require paving. Ask a new question for this new problem.
    – AndréC
    Aug 29 '20 at 13:52
  • (i) to me is simpler to prescribe pattern image width (ii) the OP path construction contain clutter, it can be write shorter, for example as: \begin{tikzpicture} \coordinate (i); \path[preaction={draw=blue!50, ultra thick},clip] (i) to [out= 15, in=165] ++(0:7.cm) -- +(-90:2.4cm) to [out=130, in=195, looseness=.4] (i); \node [minimum width=\linewidth, minimum height=0.5\linewidth, right=-5mm of i] {\includegraphics[width=\linewidth]{example-image}}; \end{tikzpicture}
    – Zarko
    Aug 29 '20 at 14:07
3

Like this?

enter image description here

Since i haven't your pattern file I use example-image-duck defined in the graphicx package.

MWE:

\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{frame}
\frametitle{}
\begin{tikzpicture}[scale=.9, transform shape]
\coordinate (i);
\path[preaction={draw=blue!50, ultra thick},clip] 
    (i) to [out=5, in=170] ++(0.:7.cm) -- +(-90:2.2cm)  
        to [out=130, in=-170, looseness=.6] (i);
\node (j) [minimum width=\linewidth, minimum height=0.5\linewidth, 
           right=-5mm of i] 
    {\includegraphics[width=\linewidth]{example-image-duck}};
\end{tikzpicture}
\end{frame}
\end{document} 
1
  • Thank you for your answer. I am sorry for the delay, I was very busy.
    – Hany
    Sep 19 '20 at 5:10

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.