pgf-tikz / pgf

A Portable Graphic Format for TeX
https://pgf-tikz.github.io/
1.11k stars 106 forks source link

Offsetting Bezier curves (with basic implementation) #1226

Closed jonschz closed 1 year ago

jonschz commented 1 year ago

Brief outline of the proposed feature

Hello everyone,

I have implemented an algorithm based on the one described here to offset Bezier curves. My original / long term motivation is to implement an alternative to tikz' double option due to some issues and possible generalisations to n-fold arrows I discussed on https://github.com/astoff/tikz-cd/issues/14. Example usage:

grafik

The relevant code can be found here. Please tell me if there is interest in integrating this feature into pgf – in that case I would refactor the code a bit and create a pull request.

Usage example

\begin{pgfpicture}
    \pgfpathmoveto{\pgfpoint{0pt}{-1cm}}
    \pgfpathcurveto{\pgfpoint{1cm}{2cm}}{\pgfpoint{2cm}{-1cm}}{\pgfpoint{3cm}{1cm}}
    \pgfusepathqstroke
    \color{red}
    \pgfoffsetcurve{\pgfpoint{0pt}{-1cm}}{\pgfpoint{1cm}{2cm}}{\pgfpoint{2cm}{-1cm}}{\pgfpoint{3cm}{1cm}}{10pt}
    \pgfusepathqstroke
    \color{blue}
    \pgfoffsetcurve{\pgfpoint{0pt}{-1cm}}{\pgfpoint{1cm}{2cm}}{\pgfpoint{2cm}{-1cm}}{\pgfpoint{3cm}{1cm}}{-10pt}
    \pgfusepathqstroke
\end{pgfpicture}
jonschz commented 1 year ago

I have improved and expanded the code into a package, which can be found at https://github.com/jonschz/tikz-nfold. If there is interest, I may submit a pull request to integrate these features into pgf in the future. As this issue is outdated now, I will close it.