summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikz-ext/doc/tikz-ext-manual-en-library-paths.ortho.tex
blob: a46f6be023445b392b3eb53e2c2d1391cac99ef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
% !TeX root = tikz-ext-manual.tex
% !TeX spellcheck = en_US
% Copyright 2022 by Qrrbrbirlbel
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Free Documentation License.
%

\section{More Horizontal and Vertical Lines}
\label{library:paths.ortho}

\begin{tikzlibrary}{ext.paths.ortho}
  This library adds new path specifications \verb!|-|!, \verb!-|-! as well as
  |r-ud|, |r-du|, |r-lr| and |r-rl|.
\end{tikzlibrary}

\subsection{Zig-Zag}
Similar to the path operations \verb!|-! and \verb!-|! this library adds\indexPathOperationO{\protect\pgfmanualbar-}\indexPathOperationO{-\protect\pgfmanualbar}
the path operations \verb!|-|! and \verb!-|-!.
{\catcode`\|=12
\begin{pathoperation}[noindex]{|-|}{\opt{\oarg{options}}\meta{coordinate or cycle}}
    \index{---1@\protect\texttt{\protect\pgfmanualbar-\protect\pgfmanualbar} path operation}%
    \index{Path operations!---1@\protect\texttt{\protect\pgfmanualbar-\protect\pgfmanualbar}}%
    \pgfmanualpdflabel[\catcode`\|=12 ]{|-|}{}%
    This operation means ``first vertical, then horizontal and then vertical again''.
\end{pathoperation}
\begin{pathoperation}[noindex]{-|-}{\opt{\oarg{options}}\meta{coordinate or cycle}}
    \index{--1@\protect\texttt{-\protect\pgfmanualbar-} path operation}%
    \index{Path operations!--1@\protect\texttt{-\protect\pgfmanualbar-}}%
    \pgfmanualpdflabel[\catcode`\|=12 ]{-|-}{}%
    This operation means ``first horizontal, then vertical and then horizontal again''.
\end{pathoperation}
}
\begin{key}{/tikz/hvvh/ratio=\meta{ratio} (initially 0.5)}
  This sets the ratio for the middle part of the Zig-Zag connection.
  
  For values $\meta{ratio} < 0$ and $\meta{ratio} > 1$ the Zig-Zag lines will
  look more like Zig-Zig lines.
\begin{codeexample}[preamble=\usetikzlibrary{paths.ortho}]
\begin{tikzpicture}[very thick, rounded corners]
\draw[help lines] (-.25, -1.25) grid (2.25, 1.25);
\draw (0, 0) -|-            (2, 1) --
      (2, 0) -|-[ratio=.25] (0,-1) -- cycle;
\end{tikzpicture}
\end{codeexample}
\end{key}
%TODO: hvvh/distance needs fixing, maybe?
\begin{key}{/tikz/hvvh/distance=\meta{distance}}
  This sets the distance between the start point
  and the middle part of the Zig-Zag connection.
  
  For values $\meta{distance} < 0$ the distance will be used for the target coordinate.
\begin{codeexample}[width=8cm,preamble=\usetikzlibrary{ext.paths.ortho}]
\begin{tikzpicture}[very thick,-latex]
\draw[help lines,-] (-.25, -.25) grid (5.25, 3.25);
\draw (0, 0) -|-[distance= .5cm] ++(2, 1);
\draw (0, 2) -|-[distance=-.5cm] ++(2, 1);

\tikzset{xshift=3cm}
\draw (2, 1) -|-[distance= .5cm] ++(-2, -1);
\draw (2, 3) -|-[distance=-.5cm] ++(-2, -1);
\end{tikzpicture}
\end{codeexample}
\end{key}
\begin{key}{/tikz/hvvh/from center=\opt{\meta{true or false}} (default true)}
  When nodes get connected the placement of the middle part of the Zig-Zag
  and the Zig-Zig (see below) connections will be calculated from the border
  of these nodes.
  The middle part of the connections can be calculated from the nodes' center
  if this key is set to |true|.
\end{key}

New timers are setup for both the Zig-Zag and the Zig-Zig connections,
these can be configured through the following keys.
\begin{codeexample}[width=8cm,preamble=\usetikzlibrary{paths.ortho}]
\tikz \draw (0,0) -|- (2,3) 
  foreach \p in {0.0, 0.25, 0.5, 0.75, 1.0}{
    node [pos=\p] {\p}};
\end{codeexample}
\begin{key}{/tikz/hvvh/spacing=\meta{number} (initially 4)}
  Unless $\meta{number} = 0$ is set
  \begin{itemize}
  \item |pos = 0| will be at the start,\indexKeyO{pos}
  \item |pos = 1| will be at the end,
  \item |pos = |$\frac{1}{\meta{number}}$ will be at the first kink,
  \item |pos = |$\frac{\meta{number}-1}{\meta{number}}$ will be at the second kink and
  \item |pos = .5| will be in the middle of the middle part of the connection.
  \end{itemize}
  
  If $\meta{number} = 0$ then
  \begin{itemize}
  \item |pos = -1| will be at the start,
  \item |pos = 2| will be at the end,
  \item |pos = 0| will be at the first kink,
  \item |pos = 1| will be at the second kink and
  \item |pos = .5| will still be in the middle of the middle part of the connection.
  \end{itemize}
\end{key}
\begin{key}{/tikz/hvvh/middle 0 to 1}
  This is an alias for |spacing = 0|.
\end{key}

\subsection{Zig-Zig}
\begin{pathoperation}{r-ud}{\opt{\oarg{options}}\meta{coordinate or cycle}}
  This operation means ``first up, then horizontal and then down''.
  \begin{key}{/tikz/udlr/ud distance=\meta{length} (initially .5cm)}
    This sets the distance between the start and the horizontal line to \meta{length}.
  \end{key}
\end{pathoperation}
\begin{pathoperation}{r-du}{\opt{\oarg{options}}\meta{coordinate or cycle}}
  This operation means ``first down, then horizontal and then up''.
  \begin{key}{/tikz/udlr/du distance=\meta{length} (initially .5cm)}
    This sets the distance between the start and the horizontal line to \meta{length}.
  \end{key}
\end{pathoperation}
\begin{pathoperation}{r-lr}{\opt{\oarg{options}}\meta{coordinate or cycle}}
  This operation means ``left down, then vertical and then right''.
  \begin{key}{/tikz/udlr/lr distance=\meta{length} (initially .5cm)}
    This sets the distance between the start and the vertical line to \meta{length}.
  \end{key}
\end{pathoperation}
\begin{pathoperation}{r-rl}{\opt{\oarg{options}}\meta{coordinate or cycle}}
  This operation means ``first right, then vertical and then down''.
  \begin{key}{/tikz/udlr/rl distance=\meta{length} (initially .5cm)}
    This sets the distance between the start and the vertical line to \meta{length}.
  \end{key}
\end{pathoperation}

All distances can be set with on key.
\begin{key}{/tikz/udlr/distance=\meta{length}}
  Sets all distances in the |/tikz/udlr| namespace.
\end{key}

\begin{key}{/tikz/udlr/from center=\opt{\meta{true or false}} (initially false, default true)}
  This is an alias for |/tikz/hvvh/from center|.
\end{key}

\subsection{Even more Horizontal and Vertical Lines}

The following keys can be used to access vertical and horizontal line path operations.
\begin{stylekey}{/tikz/horizontal vertical}
  This installs  \verb!to path = -| (\tikztotarget) \tikztonodes! that can be used with\indexKeyO{to path}
  the path operations |to| or |edge|.
\end{stylekey}
\begin{stylekey}{/tikz/vertical horizontal}
  This installs \verb!to path = |- (\tikztotarget) \tikztonodes! that can be used with
  the path operations |to| or |edge|.
\end{stylekey}
\begin{stylekey}{/tikz/horizontal vertical horizontal}
  This installs  \verb!to path = -|- (\tikztotarget) \tikztonodes! that can be used with
  the path operations |to| or |edge|.
\end{stylekey}
\begin{stylekey}{/tikz/vertical horizontal vertical}
  This installs  \verb!to path = |-| (\tikztotarget) \tikztonodes! that can be used with
  the path operations |to| or |edge|.
\end{stylekey}

When connecting rectangular nodes, these keys could be useful as well.
They all need to be given to a |to| or |edge| path operation.
\begin{stylekey}{/tikz/only vertical second=\opt{\meta{length}} (default 0pt)}
This draws a vertical line from the start point to the target point so that
it connects to the target point in the center (or at its border in case it is a node).

The optional \meta{length} can be used to shift the line orthogonally to its direction.
\end{stylekey}
\begin{stylekey}{/tikz/only horizontal second=\opt{\meta{length}} (default 0pt)}
This draws a horizontal line from the start point to the target point so that
it connects to the target point in the center (or at its border in case it is a node).

The optional \meta{length} can be used to shift the line orthogonally to its direction.
\end{stylekey}
\begin{stylekey}{/tikz/only vertical first=\opt{\meta{length}} (default 0pt)}
This draws a vertical line from the start point to the target point so that
it connects to the start point in the center (or at its border in case it is a node).

The optional \meta{length} can be used to shift the line orthogonally to its direction.
\end{stylekey}
\begin{stylekey}{/tikz/only horizontal first=\opt{\meta{length}} (default 0pt)}
This draws a horizontal line from the start point to the target point so that
it connects to the start point in the center (or at its border in case it is a node).

The optional \meta{length} can be used to shift the line orthogonally to its direction.
\end{stylekey}