# TikZ style that shifts a path perpendicular

Is it possible to define a TikZ style that shifts a path perpendicularly? I.e., the resulting path should be obtained from the given path by shifting every point, say, 0.1cm to the right, orthogonal to the direction of the path at this point.

This should work for arbitrary paths (not just straight lines). Also, I do not just want to draw a line along the shifted path, but also do clipping or filling, etc. So using the "raise=..." key together with a decoration as described in "perpendicular shift" for paths won't work I think.

• it would be helpful to have a handrawn sketch of the desired result Commented Jul 16, 2020 at 14:14
• maybe a clearer definition of what I want: Draw a line with line width=0.2cm along the original path. The desired path is the right boundary of that line. Commented Jul 16, 2020 at 14:27
• So the intended use I have in mind is to draw the boundary of some shape (like a rectangle, circle, etc.) and at the same time clip to the "white part inside the shape" which is distinct from the drawn path because the line has a finite width. Commented Jul 16, 2020 at 14:30
• The answers to this question actually define a path that is parallel to the main path, and therefore corresponds to your request. Flexure of a Grid Commented Jul 16, 2020 at 20:17
• Thanks for that link! The second answer therein looks like what I want, however, it just draws many strokes on top of each other, and wouldn't give me the chance to use the "inner edge" of the grid for, e.g., clipping... Commented Jul 16, 2020 at 20:45

If I understood your question correctly, this is natively possible with TikZ's double option which allows you to draw a double line. Here is a slightly modified example from the Graphic Parameters: Double Lines and Bordered Lines section of the 3.1.5b manual.

\documentclass[tikz,border=5mm]{standalone}

\begin{document}
\begin{tikzpicture}
\draw[very thick,double] (0,0) arc (180:90:1cm);
\draw[very thick,double distance=5pt,double=green!50] (1,0) arc (180:90:1cm);
\draw[thin,double distance=.1cm] (2,0) arc (180:90:1cm);
\end{tikzpicture}

\end{document}


Some examples from page 151 of the pgf book maybe point in the right direction

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
\coordinate (a) at (1,0);
\coordinate (b) at (3,1);
\draw (a) -- (b);
\coordinate (c) at ($(a)!.25!(b)$);
\coordinate (d) at ($(c)!1cm!90:(b)$);
\draw [<->] (c) -- (d) node [sloped,midway,above] {1cm};
\end{tikzpicture}
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,2);
\coordinate (a) at (0,1);
\coordinate (b) at (3,2);
\coordinate (c) at (2.5,0);
\draw (a) -- (b) -- (c) -- cycle;
\draw[red] (a) -- ($(b)!(a)!(c)$);
\draw[orange] (b) -- ($(a)!(b)!(c)$);
\draw[blue] (c) -- ($(a)!(c)!(b)$);
\end{tikzpicture}
\end{document}

• No idea how this helps in shifting a whole path (instead of a single point), but thanks though! Commented Jul 16, 2020 at 15:19
• You can apply it to a scope. Commented Jul 17, 2020 at 16:05