summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tkz-base/tkz-obj-segments.tex
blob: f8ad21b85b983743aff44337d54f41d8f87a2c04 (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
% Copyright 2011 by Alain Matthes
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.


\def\fileversion{1.16 c}
\def\filedate{2011/06/01}  

%<--------------------------------------------------------------------------–>
%                               Setup   Segment
%<--------------------------------------------------------------------------–>

%<--------------------------------------------------------------------------–>
%                             draw      segment  (s)
%<--------------------------------------------------------------------------–>                              
\def\tkzDrawSegment{\pgfutil@ifnextchar[{\tkz@DrawSegment}{%
                                         \tkz@DrawSegment[]}} 
\def\tkz@DrawSegment[#1](#2,#3){%    
\begingroup
 \draw[line style,add=0 and 0,#1] (#2) to (#3); 
\endgroup   
}%    

\def\tkz@multiDrawSeg#1 #2\@nil{%
 \protected@edef\tkz@temp{
   \noexpand \tkzDrawSegment[\tkz@optseg](#1)}\tkz@temp%   
   \def\tkz@nextArg{#2}%
   \ifx\tkzutil@empty\tkz@nextArg
     \let\next\@gobble
   \fi
   \next#2\@nil
} 
\def\tkzDrawSegments{\pgfutil@ifnextchar[{\tkz@DrawSegments}{%
                                         \tkz@DrawSegments[]}}
\def\tkz@DrawSegments[#1](#2){% 
\global\edef\tkz@optseg{#1} 
\begingroup
   \let\next\tkz@multiDrawSeg
   \next#2 \@nil %    
\endgroup
}
%<-------------------------------------------------------------------------–> 
%<-------------------------------------------------------------------------–> 
\pgfkeys{tkzmarkoptions/.cd,
pos/.code        = {\global\def\tkz@mkpos{#1}},
color/.code      = {\global\def\tkz@mkcolor{#1}},
mark/.code       = {\global\def\tkz@mark{#1}},
size/.code       = {\global\def\tkz@mksize{#1}},
/tkzmarkoptions/.unknown/.code   = {\let\searchname=\pgfkeyscurrentname
                                \pgfkeysalso{\searchname/.try=#1,
                                 /tikz/\searchname/.retry=#1}
                                 } 
}  

\def\tkzMarkSegment{\pgfutil@ifnextchar[{\tkz@MarkSegment}{%
                                        \tkz@MarkSegment[]}}
\def\tkz@MarkSegment[#1](#2,#3){%
\pgfkeys{tkzmarkoptions/.cd,
         size   = 4pt,
         color  = \tkz@mk@color,
         pos    = .5,
         mark   = none}
\pgfqkeys{/tkzmarkoptions}{#1}

\global\def\tkz@mymark{%
  \pgfsetplotmarksize{\tkz@mksize}
  \pgfuseplotmark{\tkz@mark}
}
\begin{scope} [decoration={ markings,mark=at position \tkz@mkpos with \tkz@mymark}] 
\path [\tkz@mkcolor,postaction={decorate}] (#2) -- (#3);
\end{scope}
} 
%<--------------------------------------------------------------------------–>
%<--------------------------------------------------------------------------–>
% multiple
\def\tkz@multiMS#1 #2\@nil{%
 \protected@edef\tkz@temp{
   \noexpand \tkzMarkSegment[\tkz@optsg](#1)}\tkz@temp%
   \def\tkz@nextArg{#2}%
   \ifx\tkzutil@empty\tkz@nextArg
     \let\next\@gobble
   \fi
   \next#2\@nil
}
%<--------------------------------------------------------------------------–>
\def\tkzMarkSegments{\pgfutil@ifnextchar[{\tkz@MarkSegments}{%
                                          \tkz@MarkSegments[]}}
\def\tkz@MarkSegments[#1](#2){% 
\global\edef\tkz@optsg{#1} 
  \begingroup
   \let\next\tkz@multiMS
   \next#2 \@nil %    
\endgroup 
} 
%<--------------------------------------------------------------------------–>
%<------------------------- Label on segment -------------------------------–>
%<--------------------------------------------------------------------------–>
\def\tkzLabelSegment{\pgfutil@ifnextchar[{\tkz@LabelSegment}{%
                                        \tkz@LabelSegment[]}}
\def\tkz@LabelSegment[#1](#2,#3)#4{%
\begingroup    
\path  (#2) to node[above,#1]{#4} (#3) ;  
\endgroup 
} 
%<--------------------------------------------------------------------------–>
%<--------------------------------------------------------------------------–>
% multiple
\def\tkz@multiLS#1 #2\@nil{%
 \protected@edef\tkz@temp{
   \noexpand \tkzLabelSegment[\tkz@optls](#1){\tkz@labelseg}}\tkz@temp%
   \def\tkz@nextArg{#2}%
   \ifx\tkzutil@empty\tkz@nextArg
     \let\next\@gobble
   \fi
   \next#2\@nil
}
%<--------------------------------------------------------------------------–>
\def\tkzLabelSegments{\pgfutil@ifnextchar[{\tkz@LabelSegments}{%
                                           \tkz@LabelSegments[]}}
\def\tkz@LabelSegments[#1](#2)#3{% 
\global\edef\tkz@optls{#1}
\global\def\tkz@labelseg{#3}
  \begingroup
   \let\next\tkz@multiLS
   \next#2 \@nil %    
\endgroup 
} 
%<--------------------------------------------------------------------------–>
%                                 PolySeg
%<--------------------------------------------------------------------------–>
\def\tkzDrawPolySeg{\pgfutil@ifnextchar[{\tkz@DrawPolySeg}{%
                                         \tkz@DrawPolySeg[]}}
\def\tkz@DrawPolySeg[#1](#2,#3){% 
\begingroup
\draw[#1] (#2) 
    \foreach \tkz@pt in {#3}{--(\tkz@pt)};% 
\endgroup
}   
\endinput