forked from Qrrbrbirlbel/TikZ-misc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtikzlibrarypaths.rectangle.code.tex
53 lines (52 loc) · 1.73 KB
/
tikzlibrarypaths.rectangle.code.tex
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
% This is the TikZ library paths.rectangle
% Load with \usetikzlibrary{paths.rectangle}
%
% This small library extends the node placing algorithm (a.k.a. timer)
% so that nodes can be placed on the path of an rectangle.
%
% Styles are:
% - rectangle original timer
% The original placement between position 0 and 1 are not changed.
% The rectangle's path can be accessed by positions between 1 and 2.
% - rectangle new timer
% This style switches the positions between 0 and 1 with those
% between 1 and 2.
\def\qrr@tikz@timer@rect@origline{%
\ifdim\tikz@time pt>1pt
\pgfutil@tempdima\tikz@time pt
\ifdim\pgfutil@tempdima<1.5pt
\advance\pgfutil@tempdima-1pt
\else
\advance\pgfutil@tempdima-1.5pt
\let\pgf@tempa\tikz@timer@start
\let\tikz@timer@start\tikz@timer@end
\let\tikz@timer@end\pgf@tempa
\fi
\multiply\pgfutil@tempdima2
\edef\tikz@time{\strip@pt\pgfutil@tempdima}%
\expandafter\tikz@timer@vhline
\else\expandafter\tikz@timer@line\fi
}
\def\qrr@tikz@timer@rect@lineafterone{%
\pgfutil@tempdima\tikz@time pt
\ifdim\pgfutil@tempdima<1pt
\ifdim\pgfutil@tempdima<.5pt\else
\advance\pgfutil@tempdima-.5pt
\let\pgf@tempa\tikz@timer@start
\let\tikz@timer@start\tikz@timer@end
\let\tikz@timer@end\pgf@tempa
\fi
\multiply\pgfutil@tempdima2
\edef\tikz@time{\strip@pt\pgfutil@tempdima}%
\expandafter\tikz@timer@vhline
\else
\advance\pgfutil@tempdima-1pt
\edef\tikz@time{\strip@pt\pgfutil@tempdima}%
\expandafter\tikz@timer@line
\fi
}
\tikzset{
rectangle original timer/.code=\let\tikz@timer@line\qrr@tikz@timer@rect@origline,
rectangle new timer/.code=\let\tikz@timer@line\qrr@tikz@timer@rect@lineafterone,
rectangle original timer
}