summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-base/doc/latex/TKZdoc-base-BB.tex
blob: 74950a060fdd0cc7b0507d7f83fac9158b6d0937 (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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
\section{Gestion de la bounding box}
La bounding box initiale après usage de la macro \tkzcname{tkzInit} est définie par le rectangle basé sur les points $(0,0)$ et $(10,10)$. La macro \tkzcname{tkzInit} permet de modifier cette bounding box initiale en utilisant les arguments (\tkzname{xmin}, \tkzname{xmax}, \tkzname{ymin}, et \tkzname{ymax}). Bien sûr tout tracé extérieur modifie la bounding box. \TIKZ tient à jour cette bounding box. Il est possible d'influer sur ce comportement soit directement avec des commandes ou des options de \TIKZ comme une commande comme \tkzcname{useasboundingbox} ou l'option \tkzname{use as bounding box}. Une conséquence possible est de réserver une boite pour une figure mais la figure peut déborder de la boite et se repandre au-dessus du texte principal.
La commande suivante \tkzcname{pgfresetboundingbox} permet d'effacer une bounding box et d'en établir une nouvelle.

%Enfin Il est parfois utile de contenir une figure dans une b

%current bounding box or current path bounding box remember picture et overlay

%<--------------------------------------------------------------------------->
%              tkzShowBB
%<--------------------------------------------------------------------------->
\subsection{tkzShowBB}
La macro la plus simple. 
\begin{NewMacroBox}{tkzShowBB}{\oarg{local options}} 
Cette macro permet de visualiser la bounding box. Un cadre rectangulaire entoure celle-ci. Cette macro accepte les options de \TIKZ.
\end{NewMacroBox} 


\subsubsection{Exemple 2 avec \tkzcname{tkzShowBB}}
\begin{tkzexample}[latex=8cm,small]
\begin{tikzpicture}[scale=.5]
  \tkzInit[ymax=5,xmax=8]
  \tkzGrid  
  \tkzDefPoint(3,0){A}
   \begin{scope}
    \tkzClipBB
    \tkzDrawCircle[R](A,5 cm)
     \tkzShowBB
   \end{scope}
\tkzDrawCircle[R,red](A,4 cm)
\end{tikzpicture}
\end{tkzexample}
%<--------------------------------------------------------------------------->
%         tkzClipBB
%<--------------------------------------------------------------------------->
\subsection{tkzClipBB}
\begin{NewMacroBox}{tkzClipBB}{}%
Il s'agit de limiter les futures constructions à la bounding box actuelle.
\end{NewMacroBox} 

\subsubsection{Exemple avec \tkzcname{tkzClipBB} et les bissectrices}

\begin{tkzexample}[latex=6cm,small]
  \begin{tikzpicture}
  \tkzInit[xmin=-3,xmax=6, ymin=-1,ymax=6]
  \tkzDefPoint(0,0){O}\tkzDefPoint(3,1){I}
  \tkzDefPoint(1,4){J}
  \tkzDefLine[bisector](I,O,J) \tkzGetPoint{i}
  \tkzDefLine[bisector out](I,O,J) \tkzGetPoint{j}
  \tkzDrawPoints(O,I,J,i,j) 
  \tkzClipBB
  \tkzDrawLines[add = 1 and 2,color=red](O,I O,J)
  \tkzDrawLines[add = 1 and 2,color=blue](O,i O,j)
  \tkzShowBB
  \end{tikzpicture}
\end{tkzexample}


%<--------------------------------------------------------------------------->
%                 tkzSetBB
%<--------------------------------------------------------------------------->
\subsection{tkzSetBB}
\begin{NewMacroBox}{tkzSetBB}{\parg{$x_A~;~y_A$} \parg{$x_B~;~y_B$} ou bien {\parg{$A$} \parg{$B$}}}
{Cette macro permet de définir le rectangle ayant pour coordonnées  $(x_A~;~y_A$) et $(x_B~;~y_B)$ comme la nouvelle bounding box.}   
\end{NewMacroBox} 

\subsubsection{Exemple avec \tkzcname{tkzShowBB}}
\begin{tkzexample}[latex=8cm,small]
above\\
left
\begin{tikzpicture}
  \tkzDefPoint(0,0){A}
  \tkzDefPoint(3,3){B}
  \tkzDefPoint(1,1){C}
  \tkzSetBB(A)(2,2)
  \tkzDrawSegment(A,B)
  \tkzDrawPoints(A,C)
  \tkzShowBB
\end{tikzpicture}right
\end{tkzexample}
%<--------------------------------------------------------------------------->
%              tkzSaveBB
%<--------------------------------------------------------------------------->
\subsection{tkzSaveBB}{}
\begin{NewMacroBox}{tkzSaveBB}{}
Cette macro permet de sauvegarder la bounding box, autrement dit elle enregistre les coordonnées de deux points qui définissent un rectangle.
\end{NewMacroBox} 

\begin{tkzexample}[latex=7cm,small]
Une figure au-dessus du texte\\
\begin{tikzpicture}
 \begin{scope}
   \tkzSetBB(0,0)(6,2) \tkzShowBB[fill=blue!20]
   \tkzSaveBB
 \end{scope}
  \tkzDefPoint(3,3){A}\tkzShowBB
  \tkzDrawCircle[R,fill=yellow,opacity=.2](A,2cm)
  \tkzRestoreBB
\end{tikzpicture}
\end{tkzexample}




%<--------------------------------------------------------------------------->
%              tkzRestoreBB
%<--------------------------------------------------------------------------->
\subsection{tkzRestoreBB}
\begin{NewMacroBox}{tkzRestoreBB}{} 
Cette macro récupère la sauvegarde  de la bounding box. Comme vous le constater, la figure déborde de la boîte. La bounding box a été réduite.
\end{NewMacroBox} 
\subsubsection{Exemple d'utilisation de \tkzcname{tkzRestoreBB}}
\begin{tkzexample}[latex=8cm,small]
   \vspace{ 2cm}
Start\\  
\begin{tikzpicture}
 \tkzDefPoint(-2,-2){A}
 \tkzDefPoint(2,1){B} 
 \tkzDefPoint(0,0){O}
 \tkzSaveBB
 \tkzShowBB[red,line width=1pt]        
 \tkzRestoreBB
 \tkzDrawCircle(O,B)
 \tkzClipBB
 \tkzFillCircle[gray!20](O,B)
\end{tikzpicture}
End
\end{tkzexample}


%<--------------------------------------------------------------------------->
%                    tkzClip
%<--------------------------------------------------------------------------->
\subsection{tkzClip}
\begin{NewMacroBox}{tkzClip}{\oarg{local options}}
Le rôle de cette macro est de rendre invisible ce qui est hors du rectangle défini par $(xmin~;~ymin)$ et $(xmax~;~ymax)$. 

\medskip
\begin{tabular}{lll}  
\hline
options  & défaut & définition             \\       
\midrule   
\TOline{space} {1} {valeur ajoutée à droite, à gauche, en bas et en haut du background}            
\bottomrule    
\end{tabular}

\medskip 

{Le rôle de l'option \tkzname{space} est d'agrandir la partie visible du dessin. Cette partie devient le rectangle définit par  $(xmin-space~;~ymin-space)$ et $(xmax+space~;~ymax+space)$.  \tkzname{space} peut être négatif!  L'unité est  le cm et ne doit pas être indiquée.  }
\end{NewMacroBox} 

\subsubsection{Premier exemple avec \tkzcname{tkzClip}} \hypertarget{clip}{}   

\begin{tkzexample}[latex=8cm,small]
\begin{tikzpicture}
 \tkzInit[xmax=3, ymax=3]
 \tkzGrid  
 \tkzAxeXY 
 \draw[red] (-1,-1)--(5,5);
\end{tikzpicture}
\end{tkzexample} 

\begin{tkzexample}[latex=8cm,small]
\begin{tikzpicture}
 \tkzInit[xmax=3, ymax=3]
 \tkzGrid  
 \tkzAxeXY 
 \tkzClip
 \draw[red] (-1,-1)--(5,5);
\end{tikzpicture}
\end{tkzexample} 
%<--------------------------------------------------------------------------->
Il est possible d'ajouter un peu d'espace    \tkzcname{tkzClip[space]}  

\subsubsection{\tkzcname{tkzClip} et l'option \tkzname{space}} 
Les dimensions pour définir le rectangle clippé sont \tkzname{xmin-1}, \tkzname{ymin-1}, \tkzname{xmax+1} et \tkzname{ymax+1}.
\begin{tkzexample}[latex=8cm,small]
\begin{tikzpicture}
 \tkzInit[xmax=3, ymax=3]
 \tkzGrid  \tkzAxeXY 
 \draw[red] (-0.5,-0.5)--(3.5,3.5);
\end{tikzpicture}
\end{tkzexample}   

\begin{tkzexample}[latex=8cm,small]
\begin{tikzpicture}
 \tkzInit[xmax=3, ymax=3]
 \tkzGrid  \tkzAxeXY 
 \tkzClip[space=-0.5]
 \draw[red] (-0.5,-0.5)--(3.5,3.5);
\end{tikzpicture}
\end{tkzexample} 

\subsection{style tkzreverseclip}

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[scale=.5]
  \tkzInit[xmin=-5,xmax=5,ymin=-5,ymax=5]
  \pgfinterruptboundingbox
  \tkzDefPoints{-.5/0/P1,.5/0/P2}
  \foreach \i [count=\j from 3] in {2,...,7}{%
      \tkzDefShiftPoint[P\i]({45*(\i-1)}:1 cm){P\j} 
  }
  \endpgfinterruptboundingbox
   \tkzClipOutPolygon(P1,P2,P3,P4,P5,P6,P7,P8)
   \tkzCalcLength[cm](P1,P5)\tkzGetLength{r}
  \begin{scope}[blend group=screen]
     \foreach \i in {1,...,8}{%
       \pgfmathparse{100-5*\i}
       \tkzFillCircle[R,color=blue!%
      \pgfmathresult](P\i,\r)
      }
    \end{scope}
\end{tikzpicture} 
\end{tkzexample}
 

\subsection{option tikz : trim left or right}
voir le \tkzimp{pgfmanual}

\subsection{Commandes de TikZ \tkzcname{pgfinterruptboundingbox} et \tkzcname{endpgfinterruptboundingbox}}
Cette commande interrompt temporairement le calcul de la boîte  et configure une nouvelle boîte

\begin{tkzexample}[latex=8cm,small]
\begin{tikzpicture}
\tkzDefPoint(0,5){A}\tkzDefPoint(5,4){B}
\tkzDefPoint(0,0){C}\tkzDefPoint(5,1){D}
\pgfinterruptboundingbox
   \tkzInterLL(A,B)(C,D)\tkzGetPoint{I}
\endpgfinterruptboundingbox
\tkzClipBB
   \tkzDrawCircle(I,B)
\tkzDrawSegments(A,B C,D A,C)
\end{tikzpicture}
\end{tkzexample} 
\endinput