# How to combine Hobby paths with PGF Basic Layer commands?

I need to combine paths that are created via the hobby package with standard pgf path elements, like arcs. Within the Frontend Layer this is easily done, e.g.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{hobby}
\begin{document}

\begin{tikzpicture}[use Hobby shortcut]
\draw (0,0) arc[start angle=180, end angle=90, x radius=1cm, y radius=1cm] .. (0.51, -0.5) .. (0, 0) -- cycle;
\end{tikzpicture}
\end{document}


But I couldn't find a way to construct hobby paths within the pgf Basic Layer, i.e. for use with \pgfusepath, in the documentation of the hobby package. Since there are situations where I prefer path construction via Basic Layer commands I'd like to know: Is there some way of combining hobby paths with pgf Basic Layer paths into one connected (or closed) path? Does the hobby package maybe provide a Basic Layer interface that I haven't found?

• If I remember correctly, the hobby branches off from PGF syntax by .. and not having a succeeding c of controls and accumulates the points in L3 arrays. So it's not a simple low level PGF trickery. Though a low-level branching should also possible, I don't know if Andrew Stacey sees any benefit from that. – percusse Feb 11 '14 at 20:01
• @percusse Thanks for the information. I agree that a low-level usage of hobby paths will only be needed in some niche cases. Usually the Frontend Layer path construction works well enough for me but when it comes to paths containing elliptic arcs I often depend on the \pgfpatharcaxes command. – Philipp Feb 11 '14 at 20:39
• Have you tried defining keys that will give you similar behavior to \pgfpatharcaxes in the Frontend Layer? – Charles Staats Feb 11 '14 at 22:50
• @CharlesStaats Good suggestion. I've not thought about that yet, because till now \pgfpatharcaxes worked well enough for my purposes. I will give it a shot. Nevertheless the question of Basic Layer hobby paths is still interesting, e.g. it might be quite handy for defining new decorations where I can't use Frontend Layer commands. – Philipp Feb 11 '14 at 23:40
• Hi, I only just found this question. What would you like hobby to do? It should be possible to provide a "low level" path generated using Hobby's algorithm. Can you provide an example of what the output should be? That is, can you add an example of the path construction you use that includes an honest bezier curve. I should be able to figure out the syntax for hobby from that. – Loop Space Feb 19 '14 at 21:53

Assuming that a) I've understood the question, and b) I've done the upload correctly, this is now possible with the development version of hobby, which is available from the TeX-SX launchpad page (download hobby.dtx and run tex hobby.dtx to generate the files).

(Update based on comments and clarification)

The new syntax is as follows. Start with \pgfpathhobby and end with \pgfpathhobbyend. The \pgfpathhobby will look to see if it is followed by a \bgroup (or {) and if so consider the following group as key-value options to be passed on to the configuration. Each point is specified by \pgfpathhobbypt{<point specification>} and will also look for a following group which is taken to be key-values for that point. As an example:

\begin{tikzpicture}
\pgfpathmoveto{\pgfpoint{0}{0}}
\pgfpathlineto{\pgfpoint{1cm}{0}}
\pgfpathhobby{closed=true}
\pgfpathhobbypt{\pgfpoint{1cm}{2cm}}{tension in=2}
\pgfpathhobbypt{\pgfpoint{2cm}{1cm}}
\pgfpathhobbypt{\pgfpoint{3cm}{0cm}}
\pgfpathhobbyend
\pgfusepath{stroke}
\end{tikzpicture}


Obviously, this is still very much in flux and so liable to change. I'll try to keep this answer up to date with the latest version.

• Thank you very much for your answer and sorry that my response comes so late. This looks pretty much like what I had in mind. Unfortunately, I haven't been able to get your new code working with my MiKTeX distribution in order to test it. I have edited my question to share my thoughts on the syntax. But I don't know much about the inner workings of pgf and hobby so that my suggestion might not be very practical. But maybe it gives you some ideas that might be helpful. Thanks again for being so quick about implementing a solution to my problem in your package. – Philipp Feb 20 '14 at 22:01
• @Philipp See edit. – Loop Space Feb 21 '14 at 12:22
• Awesome, this syntax is definitely more convenient than what I came up with (I thought there was something preventing the use of keyword arguments in the Basic Layer, that's why my version was so complicated). If I may, I'd like to make some suggestion for the behaviour of those hobby Basic Layer commands, because it does behave the way I would have expected. And I still couldn't manage to combine an arc and a Hobby path to a (combined) closed path. See my edit. – Philipp Feb 22 '14 at 15:28