summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-02-21 20:53:18 +0000
committerKarl Berry <karl@freefriends.org>2023-02-21 20:53:18 +0000
commit2fe97a2d1607083385fbddba42770750464a9eb6 (patch)
tree7d23684dfc0e78289825c6e0577a988bb5209f0e /Master/texmf-dist/tex
parent307d931f6e784fa18a29b2675473afaa8a25aba1 (diff)
jigsaw (21feb23) (branch)
git-svn-id: svn://tug.org/texlive/branches/branch2022.final@66036 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/jigsaw/jigsaw.sty36
1 files changed, 24 insertions, 12 deletions
diff --git a/Master/texmf-dist/tex/latex/jigsaw/jigsaw.sty b/Master/texmf-dist/tex/latex/jigsaw/jigsaw.sty
index ad8bcc96743..49f2b618bed 100644
--- a/Master/texmf-dist/tex/latex/jigsaw/jigsaw.sty
+++ b/Master/texmf-dist/tex/latex/jigsaw/jigsaw.sty
@@ -12,7 +12,7 @@
% See http://www.latex-project.org/lppl.txt
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ProvidesPackage{jigsaw}[2018/11/09 v0.1 Draw jigsaw pieces in TikZ]
+\ProvidesPackage{jigsaw}[2023/02/21 version v0.4 Draw jigsaw pieces in TikZ]
\RequirePackage{tikz}
@@ -31,37 +31,45 @@
\pgfmathparse{int(random(1,120))}
+% store the current scale factor
+% from https://github.com/samcarter/tikzlings/issues/3#issuecomment-461373494
+\newcommand{\jigsaw@getscaling}{
+ \pgfgettransformentries{\tmpscaleA}{\tmpscaleB}{\tmpscaleC}{\tmpscaleD}{\tmp}{\tmp}%
+ \pgfmathsetmacro{\scalingfactor}{sqrt(abs(\tmpscaleA*\tmpscaleD-\tmpscaleB*\tmpscaleC))*sqrt(abs((\pgf@xx/1cm)*(\pgf@yy/1cm)-(\pgf@xy/1cm)*(\pgf@yx/1cm)))}%
+}
+
\newcommand{\side}[1]{
(0.0,#1*0.00) .. controls (0.0,#1*0.00) and (0.4,#1*-0.04) ..
(0.4,#1*0.04) .. controls (0.4,#1*0.11) and (0.2,#1*0.26) ..
(0.5,#1*0.26) .. controls (0.8,#1*0.26) and (0.6,#1*0.11) ..
(0.6,#1*0.04) .. controls (0.6,#1*-0.04) and (1.0,#1*0.00) ..
-(1.0,#1*0.00) -- ++(.5\pgflinewidth,0)
+(1.0,#1*0.00) -- ++(.5\pgflinewidth/\scalingfactor,0)
}
-\newcommand{\halfpiece}[2]{
+\newcommand{\halfpiece}[2]{%
+ \jigsaw@getscaling%
\draw \side{#1} [rotate around={90:(0.5,0.5)}] \side{#2};
}
-\newcommand{\piece}[5][\@nil]{
- \def\tmp{#1}%
- \ifx\tmp\@nnil
- \else
+\NewDocumentCommand{\piece}{ommmm}{%
+ \jigsaw@getscaling%
+ \IfValueT{#1}{%
\fill[#1]
\side{#2}
[rotate around={90:(0.5,0.5)}] -- \side{#3}
[rotate around={90:(0.5,0.5)}] -- \side{#4}
[rotate around={90:(0.5,0.5)}] -- \side{#5}
-- cycle;
- \fi
+ }%
\draw
\side{#2}
[rotate around={90:(0.5,0.5)}] -- \side{#3}
[rotate around={90:(0.5,0.5)}] -- \side{#4}
- [rotate around={90:(0.5,0.5)}] -- \side{#5};
+ [rotate around={90:(0.5,0.5)}] -- \side{#5}
+ -- cycle;
}
-\newcommand{\tile}[5][\@nil]{%
+\NewDocumentCommand{\tile}{ommmm}{%
\begin{tikzpicture}
\path (0,0) rectangle (1,0.97);
\begin{pgfinterruptboundingbox}
@@ -97,8 +105,10 @@
\tikzset{
pics/piece/.style n args={4}{
- inherit options/.code={\csname tikz@options\endcsname},inherit options,
+ inherit options/.code={\csname tikz@options\endcsname},
+ inherit options,
code = {
+ \jigsaw@getscaling%
\path (0,0) rectangle (1,1);
\begin{pgfinterruptboundingbox}
\path[pic actions]
@@ -107,8 +117,10 @@
[rotate around={90:(0.5,0.5)}] -- \side{#3}
[rotate around={90:(0.5,0.5)}] -- \side{#4}
-- cycle;
+ % expansion trick from https://topanswers.xyz/tex?q=3340#a3677
+ \node[draw=none,fill=none,style/.expand once=\tikzpictextoptions] at (0.5,0.5) {\tikzpictext};
\end{pgfinterruptboundingbox}
}
},
piece/.search also={,/tikz,/pgf},
-} \ No newline at end of file
+}