jonschz / tikz-nfold

Triple, quadruple, and n-fold paths and arrows with TikZ
LaTeX Project Public License v1.3c
11 stars 1 forks source link

Special rectangle softpath token are not closed when offset #15

Closed Qrrbrbirlbel closed 1 year ago

Qrrbrbirlbel commented 1 year ago

It appears that the special rectangle softpath tokens don't get offset correctly since they're not closed anymore.

The macros \pgfpathrectangle and \pgfpathrectanglecorners don't appear to be used by TikZ but the rectangle shapes' definitions use it. (Amongst others, they're used by patterns or plotmarks for example but I don't think they're going to be nfold-ed soon.)

Compiling this document:

\documentclass[tikz]{standalone}
\usetikzlibrary{nfold}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle (1,1) [save path=\PATH]; \show\PATH
\draw[red]\pgfextra\pgfoffsetpath\PATH{3mm}\endpgfextra;
\end{tikzpicture}
\begin{tikzpicture}
\node[draw, minimum size=1cm, outer sep=+0pt, anchor=south west][save path=\PATH]{};
\show\PATH
\draw[red]\pgfextra\pgfoffsetpath\PATH{3mm}\endpgfextra;
\end{tikzpicture}

\begin{tikzpicture}
\pgfpathrectangle{\pgfpointorigin}{\pgfpointxy{1}{1}}
\pgfgetpath\PATH\show\PATH
\pgfusepath{stroke}
\color{red}\pgfoffsetpath\PATH{3mm}\pgfusepath{stroke}
\end{tikzpicture}
\begin{tikzpicture}
\pgfpathrectanglecorners{\pgfpointorigin}{\pgfpointxy{1}{1}}
\pgfgetpath\PATH\show\PATH
\pgfusepath{stroke}
\color{red}\pgfoffsetpath\PATH{3mm}\pgfusepath{stroke}
\end{tikzpicture}
\end{document}

will give us these four softpaths.


Normal rectangle path operation:

\pgfsyssoftpath@movetotoken {0.0pt}{0.0pt}
\pgfsyssoftpath@movetotoken {0.0pt}{0.0pt}
\pgfsyssoftpath@linetotoken {0.0pt}{28.45274pt}
\pgfsyssoftpath@linetotoken {28.45274pt}{28.45274pt}
\pgfsyssoftpath@linetotoken {28.45274pt}{0.0pt}
\pgfsyssoftpath@closepathtoken {0.0pt}{0.0pt}
\pgfsyssoftpath@movetotoken {28.45274pt}{28.45274pt}.

rectangle node shape (uses \pgfpathrectanglecorners)

\pgfsyssoftpath@rectcornertoken {0.0pt}{0.0pt}
\pgfsyssoftpath@rectsizetoken {28.45273pt}{28.45273pt}.

PGF: \pgfpathrectangle (lower left corner + diagonal vector)

\pgfsyssoftpath@rectcornertoken {0.0pt}{0.0pt}
\pgfsyssoftpath@rectsizetoken {28.45274pt}{28.45274pt}.

PGF: \pgfpathrectanglecorners (lower left corner + upper right corner)

pgfsyssoftpath@rectcornertoken {0.0pt}{0.0pt}
\pgfsyssoftpath@rectsizetoken {28.45274pt}{28.45274pt}.

where all but the first render as nfold-rect-test-1

jonschz commented 1 year ago

Thanks for reporting! I forgot about pgf rectangles in #11.