Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrow tips in animated path not always working #876

Closed
Excentertex opened this issue Jun 16, 2020 · 3 comments
Closed

Arrow tips in animated path not always working #876

Excentertex opened this issue Jun 16, 2020 · 3 comments

Comments

@Excentertex
Copy link

Excentertex commented Jun 16, 2020

While testing out the example of the manual (page 398), I noticed that the arrows only show when the code is at the beginning of the document.
To produce the output of the MWE below, I use

latex minimal.tex && dvisvgm --exact minimal.dvi && chromium minimal.svg
Strangely enough, in the MWE only one of the arrow tips disappears.
To produce the correct arrows, simply swap out the tikzpicture environment for the \tikz statement.

Minimal working example (MWE)

\documentclass[dvisvgm]{article}

\usepackage{tikz}
\usetikzlibrary{animations}

\begin{document}

\tikz \node [fill, text=white, animate={
  myself:fill = {0s= "red", 2s="blue", begin on = click }}] {Click me};

% Move this environment to the beginning to produce the correct result
\begin{tikzpicture}
  \draw[help lines] (-2,-2) grid (2,2);
  \draw :path={
  0s="{(0,0) to[out=90,in=180]  (.5 , 1) to [out=0,in=90] (.5,.5)}" base,
  2s="{(1,0) to[out=180,in=180] (.25,.5) to [out=0,in=180] (1,.5)}",
  arrows = <.<->, repeats};
\end{tikzpicture}

\end{document}
@hmenke
Copy link
Member

hmenke commented Jun 17, 2020

Possible patch, please test.

diff --git a/tex/generic/pgf/systemlayer/pgfsys-common-svg.def b/tex/generic/pgf/systemlayer/pgfsys-common-svg.def
index 6e825f09..f1d27290 100644
--- a/tex/generic/pgf/systemlayer/pgfsys-common-svg.def
+++ b/tex/generic/pgf/systemlayer/pgfsys-common-svg.def
@@ -891,7 +891,7 @@
       \let\pgf@sys@svg@marker@id@start\pgfutil@empty%
     \else%
       \global\advance\pgf@sys@svg@objectcount by1\relax%
-      \edef\pgf@sys@svg@marker@id{pgf\the\pgf@sys@svg@objectcount}%
+      \edef\pgf@sys@svg@marker@id{pgf\the\pgf@sys@svg@objectcount m}%
       \edef\pgf@sys@svg@add@code{%
         \noexpand\pgf@sys@svg@ref@defs{pgfs\pgf@svg@anim@marker@start}%
         \noexpand\pgfsysprotocol@literal{<marker id="\pgf@sys@svg@marker@id" markerUnits="userSpaceOnUse" orient="auto" overflow="visible">
@@ -904,7 +904,7 @@
       \let\pgf@sys@svg@marker@id@end\pgfutil@empty%
     \else%
       \global\advance\pgf@sys@svg@objectcount by1\relax%
-      \edef\pgf@sys@svg@marker@id{pgf\the\pgf@sys@svg@objectcount}%
+      \edef\pgf@sys@svg@marker@id{pgf\the\pgf@sys@svg@objectcount m}%
       \edef\pgf@sys@svg@add@code@{%
         \noexpand\pgf@sys@svg@ref@defs{pgfs\pgf@svg@anim@marker@end}%
         \noexpand\pgfsysprotocol@literal{<marker id="\pgf@sys@svg@marker@id" markerUnits="userSpaceOnUse" orient="auto" overflow="visible">

The underlying problem is that the object ids collide. Both the object and the marker at the start of the path have id='pgf1'.

<g id='pgf1'>
<marker id='pgf1' markerUnits='userSpaceOnUse' orient='auto' overflow='visible'> <use transform='scale(-1,-1)' xlink:href='#pgfs2'/> </marker>
<marker id='pgf2' markerUnits='userSpaceOnUse' orient='auto' overflow='visible'> <use xlink:href='#pgfs3'/> </marker>
<path d='M 0.0 2.27997 C 0.0 12.45241 1.77396 28.45274 14.22636 28.45274 C 19.77419 28.45274 14.22636 19.77419 14.22636 14.68636' fill='none' id='pgf1p' marker-end='url(#pgf2)' marker-start='url(#pgf1)'/>
</g>

The patch works around this collision by just appending the letter m to all marker ids (in the same spirit as paths have the suffix p already).

<g id='pgf1'>
<marker id='pgf1m' markerUnits='userSpaceOnUse' orient='auto' overflow='visible'> <use transform='scale(-1,-1)' xlink:href='#pgfs2'/> </marker>
<marker id='pgf2m' markerUnits='userSpaceOnUse' orient='auto' overflow='visible'> <use xlink:href='#pgfs3'/> </marker>
<path d='M 0.0 2.27997 C 0.0 12.45241 1.77396 28.45274 14.22636 28.45274 C 19.77419 28.45274 14.22636 19.77419 14.22636 14.68636' fill='none' id='pgf1p' marker-end='url(#pgf2m)' marker-start='url(#pgf1m)'/>
</g>

@hmenke hmenke added this to the 3.1.6 milestone Jun 17, 2020
hmenke added a commit to hmenke/pgf that referenced this issue Jun 17, 2020
Hitherto the markers were given simply ids à la `pgf1' but this clashes
with other objects which are also numbered consecutively.  To this end
I'm simply adding a suffix `m' to the id to make is distinct from other
objects.
@hmenke hmenke linked a pull request Jun 17, 2020 that will close this issue
hmenke added a commit to hmenke/pgf that referenced this issue Jun 17, 2020
Hitherto the markers were given simply ids à la `pgf1' but this clashes
with other objects which are also numbered consecutively.  To this end
I'm simply adding a suffix `m' to the id to make is distinct from other
objects.
@Excentertex
Copy link
Author

I can reproduce your solution!
Thank you for your swift reply.

@hmenke
Copy link
Member

hmenke commented Jun 17, 2020

This isn't merged yet.

@hmenke hmenke reopened this Jun 17, 2020
@hmenke hmenke closed this as completed Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants