Debian Codegraph @

texmf-dist/tex/latex/tkz-euclide/tkz-draw-eu-compass.tex

raw
1 % tkz-obj-eu-compass.tex
2 % Copyright 2011-2026 Alain Matthes
3 % SPDX-License-Identifier: LPPL-1.3c
4 % Maintainer: Alain Matthes
5
6 \typeout{2026/01/25 5.13c tkz-obj-eu-compass.tex}
7 \makeatletter
8 %<--------------------------------------------------------------------------–>
9 % Author Alain Matthes
10 % idea from Y. Combe
11 %<--------------------------------------------------------------------------–>
12 %<--------------------------------------------------------------------------–>
13 % Utilisation du Compas : Compass
14 %<--------------------------------------------------------------------------–>
15 % Setup Compass
16 %<--------------------------------------------------------------------------–>
17 \pgfkeys{tkzsucompass/.cd,
18 line width/.store in = \tkz@compass@lw,
19 color/.store in = \tkz@compass@color,
20 style/.store in = \tkz@compass@style,
21 line width = \tkz@euc@compasswidth,
22 color = \tkz@euc@compasscolor,
23 style = \tkz@euc@compassstyle,
24 /tkzsucompass/.search also = {/tikz,/tkzcompass}
25 }
26 %<--------------------------------------------------------------------------–>
27 \def\tkzSetUpCompass{\pgfutil@ifnextchar[{\tkz@SetUpCompass}{\tkz@SetUpCompass[]}}
28 %<--------------------------------------------------------------------------–>
29 \def\tkz@SetUpCompass[#1]{%
30 \pgfqkeys{/tkzsucompass}{#1}
31 \tikzset{compass style/.style={%
32 color = \tkz@compass@color,
33 line width = \tkz@compass@lw,
34 style = \tkz@compass@style
35 }}
36 }
37 %<--------------------------------------------------------------------------–>
38 % \tkzCompass(A, B)
39 %
40 % Marque de compas auto-ajustée en longueur
41 % #2 center #3 le point
42 % Par défaut:
43 % longueur : 1cm, mais avec un maximum d'un angle de 180°
44 % angle calculé pour la longueur
45 % style traits pleins
46
47 %<--------------------------------------------------------------------------–>
48 \pgfkeys{/tkzcompass/.cd,
49 delta/.store in = \tkz@delta,
50 length/.store in = \tkz@length,
51 length = 1,
52 delta = 0,
53 /tkzcompass/.unknown/.code = {\let\searchname=\pgfkeyscurrentname
54 \pgfkeysalso{\searchname/.try=#1, /tikz/\searchname/.retry=#1}}
55 }
56
57 \def\tkzCompass{\pgfutil@ifnextchar[{\tkz@Compass}{\tkz@Compass[]}}
58 \def\tkz@Compass[#1](#2,#3){%
59 \begingroup
60 \pgfkeys{tkzcompass/.cd,#1}
61 \tkz@@CalcLength(#2,#3){tkz@tempLen}
62 \ifnum\tkz@delta=0 %
63 \pgfmathsetmacro{\tkz@delta}{min(deg(\tkz@length cm/ \tkz@tempLen pt),180)/2}
64 \fi
65 \tkzFindSlopeAngle(#2,#3)\tkzGetAngle{tkz@angle}%
66 \draw[shift ={(#2)},compass style,/tkzcompass/.cd,#1]%
67 (\tkz@angle-\tkz@delta:\tkz@tempLen pt)%
68 arc (\tkz@angle-\tkz@delta:\tkz@angle+\tkz@delta:\tkz@tempLen pt);
69 \endgroup}
70 %<--------------------------------------------------------------------------–>
71 \def\tkz@multiCompass#1 #2\@nil{%
72 \protected@edef\tkz@temp{
73 \noexpand \tkzCompass[\tkz@optcompass](#1)}\tkz@temp%
74 \def\tkz@nextArg{#2}%
75 \ifx\tkzutil@empty\tkz@nextArg
76 \let\next\@gobble
77 \fi
78 \next#2\@nil
79 }
80 \def\tkzCompasss{\pgfutil@ifnextchar[{\tkz@Compasss}{\tkz@Compasss[]}}
81
82 \def\tkz@Compasss[#1](#2){%
83 \global\edef\tkz@optcompass{#1}
84 \begingroup
85 \let\next\tkz@multiCompass
86 \next#2 \@nil %
87 \endgroup
88 }%
89
90 \makeatother
91 \endinput