loopspace / spath3

TikZ/PGF package for manipulating soft paths, includes the knots and calligraphy TikZ libraries.
16 stars 2 forks source link

Another bug in the new version #16

Closed adamny closed 2 years ago

adamny commented 2 years ago

The command `strand' below used to work, but not anymore:

\usetikzlibrary{positioning, decorations, arrows.meta, calc,shapes, math}
\begin{tikzpicture}
 \draw[decoration={markings, mark=at position 0.2 with {\draw[black, fill=black] circle[radius=2pt];}},postaction={decorate}] (0,0) -- (1,1);
% This used to work, but not anymore:
\begin{knot}
\strand[decoration={markings, mark=at position 0.2 with {\draw[black, fill=black] circle[radius=2pt];}},postaction={decorate}] (0,0) -- (1,1);
   \end{knot}
\end{tikzpicture}
loopspace commented 2 years ago

Thanks for reporting this.

I should probably explicitly disable post/pre actions at various points in the processing of knot strands since they probably shouldn't be applied all the time. I can get what I think is the right behaviour by wrapping the postaction in an only when rendering style:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{
  knots,
  positioning,
  decorations.markings,
  arrows.meta,
  calc,
  shapes,
  math,
}

\begin{document}

\begin{tikzpicture}
\draw[
  decoration={
    markings,
    mark=at position 0.2 with {
      \draw[black, fill=black] circle[radius=2pt];
    }
  },
  postaction={
    decorate
  },
] (0,0) -- (1,1);
% This used to work, but not anymore:
\begin{knot}
\strand[
  decoration={
    markings,
    mark=at position 0.2 with {
      \draw[black, fill=black] circle[radius=2pt];
    }
  },
  only when rendering/.style={
    postaction={
      decorate
    }
  }
] (2,0) -- ++(1,1);
\end{knot}
\end{tikzpicture}
\end{document}

The issue is that the path is used several times, and only some of those are when the path is actually drawn. Ideally, I'd figure out what things definitely shouldn't be set when the path is used but not drawn and explicitly disable them. If not that, then better error reporting would be at least a step in the right direction!

loopspace commented 2 years ago

And ... looks like there is a bug revealed here. There would appear to be some extra grouping defined when a postaction is used (that aren't there when a preaction) is used causing issues with how the knot environment saves the path for re-using.

loopspace commented 2 years ago

Should be fixed in https://github.com/loopspace/spath3/commit/e823f2afb3ed17643f841a2e59113db7ccfe05d7

adamny commented 2 years ago

Many thanks!