4

I am totally new to Latex and I am willing to draw the image below. That will be a great support if you can suggest any starting pointers to create this puzzle image including a slice slightly away from the figure. Any library/package that can help in providing some basic support. I want to try it my own but don't know where to start.

TIA!

enter image description here

Maxey
  • 43

1 Answers1

9

This is to give you a start, not to provide an exact reproduction of the screen shot. The idea is to clip a path, such as the boundary of a head, and then add the puzzle pieces which can either be created with the jigsaw package and/or the answers of this question or other posts.

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\tikzset{pics/.cd,
  jigsaw/.style={
    code={
\draw[#1,ultra thin,fill=#1] (-2,-0.25) to[out=90,in=135] (-1.75,-0.225) arc(-135:135:0.3 and
{0.225*sqrt(2)}) to[out=-135,in=-90] (-2,0.25) |- (-0.25,2)
to[out=0,in=-45] (-0.225,2.25) arc(225:-45:{0.25*sqrt(2)} and 0.3)
to[out=-135,in=180] (0.25,2) -| (2,0.25) 
to[out=-90,in=225] (2.25,0.225) arc(135:-135:0.3 and {0.225*sqrt(2)})
to[out=135,in=90] (2,-0.25) |- (0.25,-2)
to[out=180,in=-135] (0.225,-1.75) arc(-45:225:{0.225*sqrt(2)} and 0.3) 
to[out=-45,in=0] (-0.25,-2) -| cycle;
}}}
\begin{tikzpicture}[font=\sffamily\Large\bfseries,text=white]
 \begin{scope}
  \clip[scale=1.1] (-1,-4) to[out=50,in=-90,looseness=1.4] (-1,-3) to[out=-160,in=0]
   (-2,-3.2) to[out=180,in=-120] (-2.7,-2) to[out=120,in=-120] (-2.9,-1.5)
   to[out=120,in=-120] (-2.95,-1.1) to[out=60,in=-30] (-3.2,-0.9)
   to[out=150,in=-120] (-3,0.4) to[out=60,in=-90] (-3,1.2) 
   to[out=90,in=90,looseness=1.8] (3.3,1.2)
   to[out=-90,in=90,looseness=0.8] (2,-2)
   to[out=-90,in=150,looseness=0.8] (3.2,-4) -- cycle;
  \path (-6,4) pic{jigsaw=teal} (-2,4) pic{jigsaw=teal} (2,4) pic{jigsaw=gray}
   (-2,0) pic[rotate=90]{jigsaw=yellow!90!black} (2,0) pic[rotate=90]{jigsaw=orange}
   (-2,-4) pic{jigsaw=green!70!black} (2,-4) pic{jigsaw=green!70!black};
  \clip (-0.4,2) rectangle ++ (2,4);
  \path  (-1.2,4) pic{jigsaw=teal} ;
 \end{scope}
  \path (-1,3.4) node{01} (1.8,3.4) node{02}
  (1.7,0) node{03} (-1.7,0) node{04} (0,-3) node{05};
\end{tikzpicture}
\end{document}

enter image description here

ADDENDUM: Really just to learn some things, and very much taken from the jigsaw package: using a plain TikZ matrix to draw a jigsaw puzzle. It can be made work, at least to some reasonable extent. The syntax is

\pic[<options>] {tile={r,t,l,b};

where the first entry is the flap on the right, with -1 meaning outward, 1 inward and 0 no flap. Then follow top, left and bottom, corresponding to the angles 0, 90, 180 and 270.

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\tikzset{side/.style={insert path={ -- (0,0)% \ifnum#1=0 \else \fi 
-| (0.5-0.1*\pgfkeysvalueof{/tikz/jigsaw/flap scale},#1*0.1*\pgfkeysvalueof{/tikz/jigsaw/flap scale})
 arc({225*#1}:{-45*#1}:{0.1*sqrt(2)*\pgfkeysvalueof{/tikz/jigsaw/flap scale}} and
 {0.1*sqrt(2)*\pgfkeysvalueof{/tikz/jigsaw/flap scale}*\pgfkeysvalueof{/tikz/jigsaw/flap ratio}}) 
 |-  (1,0)}},pics/tile/.style={code={
  \edef\sone{{#1}[0]}   
  \edef\stwo{{#1}[1]}   
  \edef\sthree{{#1}[2]} 
  \edef\sfour{{#1}[3]}  
  \path[every tile,pic actions,opacity=0] (0,0.002) rectangle (0.998,1);
  \path[every tile,pic actions,draw=none,overlay] (0,0)
    [side=\sfour,
    rotate around={90:(0.5,0.5)},side=\sone,
    rotate around={90:(0.5,0.5)},side=\stwo,
    rotate around={90:(0.5,0.5)},side=\sthree,
    ] -- cycle;    
  \path[every tile,pic actions,fill=none,overlay] (0,0)
    [side=\sfour,
    rotate around={90:(0.5,0.5)},side=\sone,
    rotate around={90:(0.5,0.5)},side=\stwo,
    rotate around={90:(0.5,0.5)},side=\sthree,
    ] -- cycle;     
}},pics/tile/.default={-1,1,1,-1},every tile/.style={},tiles/.style={every
tile/.append style={#1}},jigsaw/.cd,flap scale/.initial=1,flap
ratio/.initial=0.8}
\begin{tikzpicture}[font=\sffamily\Large\bfseries,text=white]
 \begin{scope}[tiles={scale=4}]
  \clip[scale=1.1] (-1,-4) to[out=50,in=-90,looseness=1.4] (-1,-3) to[out=-160,in=0]
   (-2,-3.2) to[out=180,in=-120] (-2.7,-2) to[out=120,in=-120] (-2.9,-1.5)
   to[out=120,in=-120] (-2.95,-1.1) to[out=60,in=-30] (-3.2,-0.9)
   to[out=150,in=-120] (-3,0.4) to[out=60,in=-90] (-3,1.2) 
   to[out=90,in=90,looseness=1.8] (3.3,1.2)
   to[out=-90,in=90,looseness=0.8] (2,-2)
   to[out=-90,in=150,looseness=0.8] (3.2,-4) -- cycle;
  \matrix (puzzle)
  {
  \pic[fill=teal]{tile={-1,0,0,1}}; & \pic[fill=gray]{tile={0,0,1,-1}}; \\
  \pic[fill=yellow!90!black]{tile={1,-1,0,-1}}; & \pic[fill=orange]{tile={0,1,-1,1}}; \\
  \pic[fill=green!70!black]{tile={0,1,0,0}}; &  \pic[fill=green!70!black]{tile={0,-1,0,0}};\\
  };
  \clip (-1,2) rectangle ++ (5,4); 
  \path (-3,2) pic[fill=teal]{tile={-1,0,0,0}};
 \end{scope}
 \path (-0.8,3.2) node{01} (2.5,3.2) node{02}
  (1.7,0) node{03} (-1.7,0) node{04} (0,-3) node{05};
\end{tikzpicture}
\end{document}

enter image description here