Rechteck mit benutzerdefinierter Bilddatei füllen

Rechteck mit benutzerdefinierter Bilddatei füllen

Ich habe einen tikzCode zum Zeichnen von Pyramiden aus Rechtecken gefunden, der ausHier. In meinem Dokument muss ich schräge Rechtecke mit einer bestimmten Bilddatei füllen.

Hier ist der Code:

% Using signed distance functions to embed contours in discrete grids
% Author: Josh Chang
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{arrows,shapes,backgrounds}
\begin{document}
\begin{tikzpicture}[scale=2,every node/.style={minimum size=1cm},on grid]

 % slanting: production of a set of n 'laminae' to be piled up.
 % N=number of grids.
\begin{scope}[
        yshift=-100,every node/.append style={
        yslant=0.5,xslant=-1.3},yslant=0.5,xslant=-1.3
        ]
    % opacity to prevent graphical interference
    \fill[white,fill opacity=0.9] (0,0) rectangle (4,4);
    \draw[step=4mm, thin, gray] (0,0) grid (4,4); %defining grids
    \draw[black,very thick] (0,0) rectangle (4,4);%marking borders      
    \draw [ultra thick](0,1) parabola bend (2,2) (4,1)  ; % parabola curve

\coordinate (sphi) at (0.6,3.4);
\node at (sphi) [fill=black,circle,scale=0.1] {$s$};

\pgfkeys{/pgf/number format/.cd, fixed, zerofill, precision =1} 

\foreach \x in {0,...,9} {
\foreach \y in {0,...,9} {
%calculate the signed distance
%
% use newton raphson for 4 iterations to compute the distance
% 
     \pgfmathparse{0.2+0.4*\x}
    \pgfmathresult \let\xpoint\pgfmathresult;
    \pgfmathparse{0.2+0.4*\y}
    \pgfmathresult \global\let\ypoint\pgfmathresult;

    \pgfmathparse{\xpoint}
    \pgfmathresult \global\let\xx\pgfmathresult;
% Run 4 iterations of Newton-Raphson to compute distance
      \foreach \iter in {1,...,4} {
          \pgfmathparse{0.25*(\xx*\xx*\xx-6*\xx*\xx+4*(\xx-2)*\ypoint
           +12*\xx-8*\xpoint+8)}
          \pgfmathresult \let\functionderv\pgfmathresult;
          \pgfmathparse{3*(\xx-2)*(\xx-2)/4+\ypoint}
          \pgfmathresult \let\functiondervv\pgfmathresult;
          \pgfmathparse{\xpoint-\functionderv/(\functiondervv)}
         \pgfmathresult \let\xx\pgfmathresult;
      }

      \pgfmathparse{-\xx*\xx/4+\xx+1}
      \pgfmathresult \global\let\yy\pgfmathresult;
      \pgfmathsetmacro{\dd}{sqrt((\xpoint-\xx)* (\xpoint-\xx)
        + (\ypoint-\yy)*(\ypoint-\yy ))/.4};
      \pgfmathparse{int(\yy*100)}
      \pgfmathresult \let\yyy\pgfmathresult;
      \pgfmathparse{int(\ypoint*100)}
      \pgfmathresult \let\yypoint\pgfmathresult;
      \ifnum \yyy > \yypoint { %% Signed distance
          \pgfmathparse{-\dd} \pgfmathresult \global\let\dd\pgfmathresult;
          }
      \fi   
     \node[scale=0.7,thick] at (\xpoint,\ypoint)
        {$\mathbf{\pgfmathprintnumber{\dd}}$};
    }
 }

\end{scope}

\begin{scope}[
    yshift=-160,every node/.append style={
    yslant=0.5,xslant=-1.3},yslant=0.5,xslant=-1.3
              ]
    %marking border
    \draw[black,very thick] (0,0) rectangle (4,4);


    %draw bottom parabola
    \draw [ultra thick](0,1) parabola bend (2,2) (4,1)  ;
    \draw[-latex,thick](2.8,1)node[right,scale=1.5]{$\partial\Omega$}
             to[out=180,in=270] (2,1.99);

 \node at (2,0.5) [scale=1.5] {$\Omega$};
 \node at (1.2,2.7) [scale=1.5] {$S\setminus\Omega$};
 \coordinate (s) at (0.5,3.5);
 \node at (s) [fill=black,circle,scale=0.1] {$s$};

\end{scope} %end of drawing grids

 % signed distance
 \draw[-latex,thick](4.8,-.2)node[above,scale=1.3]{$\phi_\Omega$}
    to[out=-90,in=0] (4.1,-1.5);

 % s
 \draw[-latex,thick](-4,-.2)node[left,scale=1.3]{$\phi_\Omega(s)$}
    to[out=0,in=90] (sphi);

%s
 \draw[-latex,thick](-4,-3)node[left,scale=1.3]{$s$}
    to[out=0,in=90] (s);    
\end{tikzpicture}
\end{document}

Und hier ist die Ausgabeabbildung:

Ausgabezahl

Meine Frage ist, wie ich diese Rechtecke mit Bildern statt mit vordefinierten Zahlen und Rastern füllen kann. Ich habe \pgfdeclareimagees versucht \pgfuseimage, aber ich glaube, ich verwende es nicht richtig.

Antwort1

So was?

Bildbeschreibung hier eingeben

Ich bin nicht sicher, ob Sie nur die Bilder ausfüllen und alles andere entfernen möchten. Ich habe nur das Raster und die Zahlen weggelassen. Sie können weitere Zeilen auskommentieren, wenn Sie sie nicht benötigen.

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{arrows,shapes,backgrounds}
\begin{document}
\begin{tikzpicture}[scale=2,every node/.style={minimum size=1cm},on grid]

 % slanting: production of a set of n 'laminae' to be piled up.
 % N=number of grids.
\begin{scope}[
        yshift=-100,every node/.append style={
        yslant=0.5,xslant=-1.3},yslant=0.5,xslant=-1.3
        ]
    % opacity to prevent graphical interference
    \fill[white,fill opacity=0.9] (0,0) rectangle (4,4);
    \draw[step=4mm, thin, gray] (0,0) grid (4,4); %defining grids
    \node[inner sep=0pt,outer sep=0pt] at (2,2) {\includegraphics[width=8cm,height=8cm]{example-image-a}};
    \draw[black,very thick,fill=red!20,fill opacity=0.2] (0,0) rectangle (4,4);%marking borders
    \draw [ultra thick](0,1) parabola bend (2,2) (4,1)  ; % parabola curve

\coordinate (sphi) at (0.6,3.4);
\node at (sphi) [fill=black,circle,scale=0.1] {$s$};

%\pgfkeys{/pgf/number format/.cd, fixed, zerofill, precision =1}

%\foreach \x in {0,...,9} {
%\foreach \y in {0,...,9} {
%%calculate the signed distance
%%
%% use newton raphson for 4 iterations to compute the distance
%%
%     \pgfmathparse{0.2+0.4*\x}
%    \pgfmathresult \let\xpoint\pgfmathresult;
%    \pgfmathparse{0.2+0.4*\y}
%    \pgfmathresult \global\let\ypoint\pgfmathresult;
%
%    \pgfmathparse{\xpoint}
%    \pgfmathresult \global\let\xx\pgfmathresult;
%% Run 4 iterations of Newton-Raphson to compute distance
%      \foreach \iter in {1,...,4} {
%          \pgfmathparse{0.25*(\xx*\xx*\xx-6*\xx*\xx+4*(\xx-2)*\ypoint
%           +12*\xx-8*\xpoint+8)}
%          \pgfmathresult \let\functionderv\pgfmathresult;
%          \pgfmathparse{3*(\xx-2)*(\xx-2)/4+\ypoint}
%          \pgfmathresult \let\functiondervv\pgfmathresult;
%          \pgfmathparse{\xpoint-\functionderv/(\functiondervv)}
%         \pgfmathresult \let\xx\pgfmathresult;
%      }
%
%      \pgfmathparse{-\xx*\xx/4+\xx+1}
%      \pgfmathresult \global\let\yy\pgfmathresult;
%      \pgfmathsetmacro{\dd}{sqrt((\xpoint-\xx)* (\xpoint-\xx)
%        + (\ypoint-\yy)*(\ypoint-\yy ))/.4};
%      \pgfmathparse{int(\yy*100)}
%      \pgfmathresult \let\yyy\pgfmathresult;
%      \pgfmathparse{int(\ypoint*100)}
%      \pgfmathresult \let\yypoint\pgfmathresult;
%      \ifnum \yyy > \yypoint { %% Signed distance
%          \pgfmathparse{-\dd} \pgfmathresult \global\let\dd\pgfmathresult;
%          }
%      \fi
%     \node[scale=0.7,thick] at (\xpoint,\ypoint)
%        {$\mathbf{\pgfmathprintnumber{\dd}}$};
%    }
% }

\end{scope}

\begin{scope}[
    yshift=-160,every node/.append style={
    yslant=0.5,xslant=-1.3},yslant=0.5,xslant=-1.3
              ]
    \begin{scope}[on background layer]
    \node[inner sep=0pt,outer sep=0pt] at (2,2) {\includegraphics[width=8cm,height=8cm]{example-image-B}};
    \end{scope}
    %marking border
    \draw[black,very thick,fill=blue!30,fill opacity=0.2] (0,0) rectangle (4,4);


    %draw bottom parabola
    \draw [ultra thick](0,1) parabola bend (2,2) (4,1)  ;
    \draw[-latex,thick](2.8,1)node[right,scale=1.5]{$\partial\Omega$}
             to[out=180,in=270] (2,1.99);

 \node at (2,0.5) [scale=1.5] {$\Omega$};
 \node at (1.2,2.7) [scale=1.5] {$S\setminus\Omega$};
 \coordinate (s) at (0.5,3.5);
 \node at (s) [fill=black,circle,scale=0.1] {$s$};

\end{scope} %end of drawing grids

 % signed distance
 \draw[-latex,thick](4.8,-.2)node[above,scale=1.3]{$\phi_\Omega$}
    to[out=-90,in=0] (4.1,-1.5);

 % s
 \draw[-latex,thick](-4,-.2)node[left,scale=1.3]{$\phi_\Omega(s)$}
    to[out=0,in=90] (sphi);

%s
 \draw[-latex,thick](-4,-3)node[left,scale=1.3]{$s$}
    to[out=0,in=90] (s);
\end{tikzpicture}
\end{document}

verwandte Informationen