texlive[66036] branches/branch2022.final/Master/texmf-dist: jigsaw

commits+karl at tug.org commits+karl at tug.org
Tue Feb 21 21:53:18 CET 2023


Revision: 66036
          http://tug.org/svn/texlive?view=revision&revision=66036
Author:   karl
Date:     2023-02-21 21:53:18 +0100 (Tue, 21 Feb 2023)
Log Message:
-----------
jigsaw (21feb23) (branch)

Modified Paths:
--------------
    branches/branch2022.final/Master/texmf-dist/doc/latex/jigsaw/README.md
    branches/branch2022.final/Master/texmf-dist/doc/latex/jigsaw/jigsaw-doc.pdf
    branches/branch2022.final/Master/texmf-dist/doc/latex/jigsaw/jigsaw-doc.tex
    branches/branch2022.final/Master/texmf-dist/tex/latex/jigsaw/jigsaw.sty

Modified: branches/branch2022.final/Master/texmf-dist/doc/latex/jigsaw/README.md
===================================================================
--- branches/branch2022.final/Master/texmf-dist/doc/latex/jigsaw/README.md	2023-02-21 20:53:00 UTC (rev 66035)
+++ branches/branch2022.final/Master/texmf-dist/doc/latex/jigsaw/README.md	2023-02-21 20:53:18 UTC (rev 66036)
@@ -2,7 +2,7 @@
 
 A small LaTeX package to draw jigsaw pieces with TikZ. It is possible to draw individual pieces and adjust their shape, produce tile patterns or to automatically generate complete jigsaws.
 
-Current version: 2022/07/18 version v0.3
+Current version: 2023/02/21 version v0.4
 
 This project is licensed under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt
 

Modified: branches/branch2022.final/Master/texmf-dist/doc/latex/jigsaw/jigsaw-doc.pdf
===================================================================
(Binary files differ)

Modified: branches/branch2022.final/Master/texmf-dist/doc/latex/jigsaw/jigsaw-doc.tex
===================================================================
--- branches/branch2022.final/Master/texmf-dist/doc/latex/jigsaw/jigsaw-doc.tex	2023-02-21 20:53:00 UTC (rev 66035)
+++ branches/branch2022.final/Master/texmf-dist/doc/latex/jigsaw/jigsaw-doc.tex	2023-02-21 20:53:18 UTC (rev 66036)
@@ -10,9 +10,6 @@
 % Released under the LaTeX Project Public License v1.3c or later
 % See http://www.latex-project.org/lppl.txt
 %
-% Version 0.1a
-% NOv 9, 2018  
-%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \documentclass[parskip=half]{scrartcl}
 
@@ -98,7 +95,7 @@
 		\url{https://github.com/samcarter/jigsaw}\\
 		\url{https://www.ctan.org/pkg/jigsaw}
 	}{samcarter}}
-\date{Version v0.3 \textendash{} 2022/07/18}
+\date{Version v0.4 \textendash{} 2023/02/21}
 
 \begin{document}
 \maketitle
@@ -155,11 +152,15 @@
 \begin{tcblisting}{title={\texttt{pic}}}
 \begin{tikzpicture}
 	\path (2,-3) pic[
-    fill=lightgray,draw=teal,thick
+    fill=lightgray, draw=teal, ultra thick, 
+    scale=2, pic text={Some Text},
+    pic text options={text=violet}
   ]{piece={1}{-1}{1}{0}};
 \end{tikzpicture}
 \end{tcblisting}
 
+Using the \TikZ \verb|pic| allows to apply various \TikZ option like \verb|scale| or add text in the centre of the piece via \verb|pic text={...}|.
+
 The shapes of the jigsaw pieces are designed to seamlessly fit into each other which allows to produce tile patters in various ways:
 
 \begin{tcblisting}{title={Manual tile pattern}}
@@ -187,7 +188,7 @@
   {piece={1}{0}{0}{-1}};  
 \pic at (0,0) [fill=teal]
   {piece={0}{-1}{-1}{0}};  
-\pic at (1,0) [fill=lightgray]
+\pic at (1,0) [fill=lightgray,draw]
   {piece={0}{0}{-1}{1}};     
 \end{tikzpicture}
 \end{tcblisting}
@@ -196,7 +197,7 @@
 % \usetikzlibrary{matrix}
 \begin{tikzpicture}
 \matrix [nodes=draw]{
-\pic [fill=lightgray]{piece={-1}{-1}{0}{0}};&
+\pic [fill=lightgray]{piece={-1}{1}{0}{0}};&
 \pic [fill=teal]{piece={1}{0}{0}{-1}}; \\
 \pic [fill=teal]{piece={0}{-1}{1}{0}}; &
 \pic [fill=lightgray]{piece={0}{0}{-1}{1}};\\

Modified: branches/branch2022.final/Master/texmf-dist/tex/latex/jigsaw/jigsaw.sty
===================================================================
--- branches/branch2022.final/Master/texmf-dist/tex/latex/jigsaw/jigsaw.sty	2023-02-21 20:53:00 UTC (rev 66035)
+++ branches/branch2022.final/Master/texmf-dist/tex/latex/jigsaw/jigsaw.sty	2023-02-21 20:53:18 UTC (rev 66036)
@@ -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,22 +31,29 @@
 
 \pgfmathparse{int(random(1,120))}
 
+% store the current scale factor
+% from https://github.com/samcarter/tikzlings/issues/3#issuecomment-461373494
+\newcommand{\jigsaw at getscaling}{
+  \pgfgettransformentries{\tmpscaleA}{\tmpscaleB}{\tmpscaleC}{\tmpscaleD}{\tmp}{\tmp}%
+  \pgfmathsetmacro{\scalingfactor}{sqrt(abs(\tmpscaleA*\tmpscaleD-\tmpscaleB*\tmpscaleC))*sqrt(abs((\pgf at xx/1cm)*(\pgf at yy/1cm)-(\pgf at xy/1cm)*(\pgf at 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 at 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 at getscaling%
+  \IfValueT{#1}{%
     \fill[#1] 
       \side{#2}
       [rotate around={90:(0.5,0.5)}] -- \side{#3} 
@@ -53,15 +60,16 @@
       [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 at options\endcsname},inherit options,
+    inherit options/.code={\csname tikz at options\endcsname},
+    inherit options,
     code = {
+      \jigsaw at 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
+}



More information about the tex-live-commits mailing list.