# Creating tiles for an image with comments on each tile of the puzzle

Let's suppose that we have any image in .pdf, in .jpg in .png.

Exist a package to break into the fragments of an image like a classic puzzle?

I would like each piece of the puzzle to also have the possibility, if possible, of noting or writing down a comment with an arrow.

• yes for pieces see the other Sebastian question tex.stackexchange.com/a/446296 but may need some extra modification such as other answers for the zoomed piece effect see tex.stackexchange.com/questions/267714/inset-within-image etc – user170109 May 21 at 20:34
• @KJO Dear, thank you for the link I saw. The image is behind and above it is created a puzzle that can not certainly separate pieces. In other words, I don't want a puzzle drawn over the image. But the image is created by tiles. – Sebastiano May 21 at 20:37
• Off hand I cant see any reason unless someone does not like Einstein or Jigsaws – user170109 May 23 at 21:15
• @KJO I have to change the images or take them off :-):-) – Sebastiano May 23 at 21:22
• Possible duplicate of Moving tiles of the pattern in TikZ – Raaja May 24 at 11:58

The picture can be set with a pgf key.

\documentclass[x11names, svgnames, dvipsnames,tikz,border=3.14mm]{standalone}
\begin{document}
\tikzset{pics/.cd,
image jigsaw/.style args={img at #1 and #2/#3/#4/#5}{
code={%
\draw[path picture={%
\node at #1
{\edef\temp{\noexpand\includegraphics[\pgfkeysvalueof{/tikz/jigsaw/img options}]{\pgfkeysvalueof{/tikz/jigsaw/img}}}
\temp};}] (-2,-0.35) to[out=90,in={90+#2*45}] ({-2+0.5*#2},-0.45)
arc({-135-(#2-1)*45}:{(#2-1)*180+135+(#2-1)*45}:0.6 and
{0.45*sqrt(2)}) to[out=-90-#2*45,in=-90] (-2,0.35) |- (-0.35,2)
to[out=0,in={0+#3*45}] (-0.45,2-0.5*#3) arc(180-#3*45:{(#3+1)*180+#3*45}:{0.45*sqrt(2)} and 0.6)
to[out=-180-#3*45,in=180] (0.35,2) -| (2,0.35)
to[out=-90,in=270+#4*45] (2-#4*0.5,0.45)
arc(90-#4*45:{(#4+1)*180-90+#4*45}:0.6 and {0.45*sqrt(2)})
to[out=90-#4*45,in=90] (2,-0.35) |- (0.35,-2)
to[out=180,in=-180+#5*45] (0.45,-2+#5*0.5) arc(-#5*45:{(#5-1)*180+180+#5*45}:{0.45*sqrt(2)} and 0.6)
to[out=-#5*45,in=0] (-0.35,-2) -| cycle;
}},
/tikz/jigsaw/.cd,img/.initial={example-image-duck},img options/.initial={}
}
% order : left/top/right/bottom and -1 is out, 1 is in, 0 none
\foreach \X in {0,0.1,...,1,0.9,0.8,...,0.1}
{\begin{tikzpicture}
\path[use as bounding box] (-3,-3) rectangle (3,3);
\draw (-1-\X,-1-\X) pic[scale=0.25]{image jigsaw=img at {(4,4)} and 0/-1/1/0}
(0,-1-\X) pic[scale=0.25]{image jigsaw=img at {(0,4)} and -1/-1/1/0}
(1+\X,-1-\X) pic[scale=0.25]{image jigsaw=img at {(-4,4)} and -1/1/0/0}
(-1-\X,0) pic[scale=0.25]{image jigsaw=img at {(4,0)} and 0/1/-1/1}
(0,0) pic[scale=0.25]{image jigsaw=img at {(0,0)} and 1/-1/1/1}
(1+\X,0) pic[scale=0.25]{image jigsaw=img at {(-4,0)} and -1/1/0/-1}
(-1-\X,1+\X) pic[scale=0.25]{image jigsaw=img at {(4,-4)} and 0/0/1/-1}
(0,1+\X) pic[scale=0.25]{image jigsaw=img at {(0,-4)} and -1/0/1/1}
(1+\X,1+\X) pic[scale=0.25]{image jigsaw=img at {(-4,-4)} and -1/0/0/-1};
\end{tikzpicture}}
\end{document}


• Normally I don't upvote do-it-yourself-answers but this one is really nice :) +1 – Marijn May 21 at 21:23
• @Marijn Nice is understatement I think marmot has taken time off chores today and working at double speed. I am "flabbergasted" at how quick he got this working even IF there was any recycling PS Tongue in cheek I see no zoom :-! – user170109 May 21 at 21:29
• @KJO Zoom is hidden in the pgf key /tikz/jigsaw/img options, which you can set e.g. to scale=2. It is not used here. – user121799 May 21 at 21:44

There is a dedicated package for jigsaws, with this its easy to do something like this:

\documentclass{article}

\usepackage{jigsaw}
\usepackage{graphicx}

\newcommand{\clippiece}[5][]{%
\begin{scope}
\clip[#1]
\side{#2} -- (0.5,0.5) [rotate around={90:(0.5,0.5)}] \side{#3} -- (0.5,0.5) [rotate around={180:(0.5,0.5)}] \side{#5} -- (0.5,0.5) [rotate around={270:(0.5,0.5)}] \side{#4} -- (0.5,0.5) -- cycle;
\node[inner sep=0pt] at (1,-0.7) {\includegraphics[width=3cm]{Lauda_at_1982_Dutch_Grand_Prix}};  % image from https://en.wikipedia.org/wiki/Niki_Lauda#/media/File:Lauda_at_1982_Dutch_Grand_Prix.jpg
\end{scope}
\begin{scope}[#1]
\piece{#2}{#3}{#4}{#5}
\end{scope}
}

\begin{document}

\tikz{\clippiece{1}{-1}{-1}{1}}
\tikz{\clippiece[xshift=1cm]{-1}{-1}{1}{1}}

\tikz{\clippiece[yshift=-1cm]{-1}{-1}{-1}{-1}}
\tikz{\clippiece[xshift=1cm,yshift=-1cm]{-1}{-1}{1}{1}}

\bigskip

\begin{tikzpicture}
\clippiece{1}{-1}{-1}{1}
\clippiece[xshift=1cm]{-1}{-1}{1}{1}
\clippiece[yshift=-1cm]{-1}{-1}{-1}{-1}
\clippiece[xshift=1cm,yshift=-1cm]{-1}{-1}{1}{1}
\end{tikzpicture}

\end{document}


• I like it very much with such sincerity. Is it possible to put comments next to the cards? Thank you very much. – Sebastiano May 22 at 8:31